Re: [Qemu-devel] Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On Mon, Oct 18, 2010 at 2:16 PM, Anthony Liguori wrote: > On 10/18/2010 03:22 AM, Roedel, Joerg wrote: >> >> (Sorry for the late reply) >> >> On Thu, Oct 07, 2010 at 08:48:06AM -0400, Anthony Liguori wrote: >> >>> >>> On 10/07/2010 03:42 AM, Roedel, Joerg wrote: >>> On Wed, Oct 06, 2010 at 03:24:59PM -0400, Anthony Liguori wrote: >>> >>> + qemu_compat_version = machine->compat_version; >>> + >>> if (display_type == DT_NOGRAPHIC) { >>> if (default_parallel) >>> add_device_config(DEV_PARALLEL, "null"); >>> -- >>> 1.7.0.4 >>> >>> >>> >> >> Looks fine to me, given CPUs are not in qdev. Anthony? >> >> >> > > The idea is fine, but why not just add the default CPU to the machine > description? > > If I remember correctly the reason was that the machine description was not accessible in the cpuid initialization path because it is a function local variable. >>> >>> Not tested at all but I think the attached patch addresses it in a >>> pretty nice way. >>> >>> There's a couple ways you could support your patch on top of this. You >>> could add a kvm_cpu_model to the machine structure that gets defaulted >>> too if kvm_enabled(). You could also introduce a new KVM machine type >>> that gets defaulted to if no explicit machine is specified. >>> >> >> I had something similar in mind but then I realized that we need at >> least a cpu_model and a cpu_model_kvm to distinguish between the TCG and >> the KVM case. >> > > I would think that having different default machines for KVM and TCG would > be a better solution. > >> Further the QEMUMachine data structure is used for all architectures in >> QEMU and the model-names only make sense for x86. > > SPARC uses cpu_model too FWIW. I believe Blue Swirl has even discussed > using a feature-format similar to how x86 does it for SPARC CPUs. Actually I copied Sparc feature support from x86. Generic feature support would be nice. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On 10/18/2010 03:22 AM, Roedel, Joerg wrote: (Sorry for the late reply) On Thu, Oct 07, 2010 at 08:48:06AM -0400, Anthony Liguori wrote: On 10/07/2010 03:42 AM, Roedel, Joerg wrote: On Wed, Oct 06, 2010 at 03:24:59PM -0400, Anthony Liguori wrote: +qemu_compat_version = machine->compat_version; + if (display_type == DT_NOGRAPHIC) { if (default_parallel) add_device_config(DEV_PARALLEL, "null"); -- 1.7.0.4 Looks fine to me, given CPUs are not in qdev. Anthony? The idea is fine, but why not just add the default CPU to the machine description? If I remember correctly the reason was that the machine description was not accessible in the cpuid initialization path because it is a function local variable. Not tested at all but I think the attached patch addresses it in a pretty nice way. There's a couple ways you could support your patch on top of this. You could add a kvm_cpu_model to the machine structure that gets defaulted too if kvm_enabled(). You could also introduce a new KVM machine type that gets defaulted to if no explicit machine is specified. I had something similar in mind but then I realized that we need at least a cpu_model and a cpu_model_kvm to distinguish between the TCG and the KVM case. I would think that having different default machines for KVM and TCG would be a better solution. Further the QEMUMachine data structure is used for all architectures in QEMU and the model-names only make sense for x86. SPARC uses cpu_model too FWIW. I believe Blue Swirl has even discussed using a feature-format similar to how x86 does it for SPARC CPUs. Regards, Anthony Liguori So I decided for the comapt-version way (which doesn't mean I object against this one ;-) ) Joerg From d2370c88cef4b07d48ba3c4804e35ae2db8db7c0 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Thu, 7 Oct 2010 07:43:42 -0500 Subject: [PATCH] machine: make default cpu model part of machine structure Signed-off-by: Anthony Liguori diff --git a/hw/boards.h b/hw/boards.h index 6f0f0d7..8c6ef27 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -16,6 +16,7 @@ typedef struct QEMUMachine { const char *name; const char *alias; const char *desc; +const char *cpu_model; QEMUMachineInitFunc *init; int use_scsi; int max_cpus; diff --git a/hw/pc.c b/hw/pc.c index 69b13bf..0826107 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -866,14 +866,6 @@ void pc_cpus_init(const char *cpu_model) int i; /* init CPUs */ -if (cpu_model == NULL) { -#ifdef TARGET_X86_64 -cpu_model = "qemu64"; -#else -cpu_model = "qemu32"; -#endif -} - for(i = 0; i< smp_cpus; i++) { pc_new_cpu(cpu_model); } diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 12359a7..919b4d6 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -204,17 +204,22 @@ static void pc_init_isa(ram_addr_t ram_size, const char *initrd_filename, const char *cpu_model) { -if (cpu_model == NULL) -cpu_model = "486"; pc_init1(ram_size, boot_device, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, 0); } +#ifdef TARGET_X86_64 +#define DEF_CPU_MODEL "qemu64" +#else +#define DEF_CPU_MODEL "qemu32" +#endif + static QEMUMachine pc_machine = { .name = "pc-0.13", .alias = "pc", .desc = "Standard PC", +.cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .is_default = 1, @@ -223,6 +228,7 @@ static QEMUMachine pc_machine = { static QEMUMachine pc_machine_v0_12 = { .name = "pc-0.12", .desc = "Standard PC", +.cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .compat_props = (GlobalProperty[]) { @@ -242,6 +248,7 @@ static QEMUMachine pc_machine_v0_12 = { static QEMUMachine pc_machine_v0_11 = { .name = "pc-0.11", .desc = "Standard PC, qemu 0.11", +.cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .compat_props = (GlobalProperty[]) { @@ -277,6 +284,7 @@ static QEMUMachine pc_machine_v0_11 = { static QEMUMachine pc_machine_v0_10 = { .name = "pc-0.10", .desc = "Standard PC, qemu 0.10", +.cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .compat_props = (GlobalProperty[]) { @@ -324,6 +332,7 @@ static QEMUMachine pc_machine_v0_10 = { static QEMUMachine isapc_machine = { .name = "isapc", .desc = "ISA-only PC", +.cpu_model = "486", .init = pc_init_isa, .max_cpus = 1, }; diff --git a/vl.c b/vl.c index df414ef..3a55cc8 100644 --- a/vl.c +++ b/vl.c @@ -2904,6 +2904,10 @@ int main(int argc, char **argv, char **envp) } qemu_add_globals(); +if (cpu_model == NULL) { +cpu_model = machine->cpu_model; +} + machine->init(r
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
(Sorry for the late reply) On Thu, Oct 07, 2010 at 08:48:06AM -0400, Anthony Liguori wrote: > On 10/07/2010 03:42 AM, Roedel, Joerg wrote: > > On Wed, Oct 06, 2010 at 03:24:59PM -0400, Anthony Liguori wrote: > > > +qemu_compat_version = machine->compat_version; > + > if (display_type == DT_NOGRAPHIC) { > if (default_parallel) > add_device_config(DEV_PARALLEL, "null"); > -- > 1.7.0.4 > > > >>> Looks fine to me, given CPUs are not in qdev. Anthony? > >>> > >>> > >> The idea is fine, but why not just add the default CPU to the machine > >> description? > >> > > If I remember correctly the reason was that the machine description was > > not accessible in the cpuid initialization path because it is a function > > local variable. > > Not tested at all but I think the attached patch addresses it in a > pretty nice way. > > There's a couple ways you could support your patch on top of this. You > could add a kvm_cpu_model to the machine structure that gets defaulted > too if kvm_enabled(). You could also introduce a new KVM machine type > that gets defaulted to if no explicit machine is specified. I had something similar in mind but then I realized that we need at least a cpu_model and a cpu_model_kvm to distinguish between the TCG and the KVM case. Further the QEMUMachine data structure is used for all architectures in QEMU and the model-names only make sense for x86. So I decided for the comapt-version way (which doesn't mean I object against this one ;-) ) Joerg > From d2370c88cef4b07d48ba3c4804e35ae2db8db7c0 Mon Sep 17 00:00:00 2001 > From: Anthony Liguori > Date: Thu, 7 Oct 2010 07:43:42 -0500 > Subject: [PATCH] machine: make default cpu model part of machine structure > > Signed-off-by: Anthony Liguori > > diff --git a/hw/boards.h b/hw/boards.h > index 6f0f0d7..8c6ef27 100644 > --- a/hw/boards.h > +++ b/hw/boards.h > @@ -16,6 +16,7 @@ typedef struct QEMUMachine { > const char *name; > const char *alias; > const char *desc; > +const char *cpu_model; > QEMUMachineInitFunc *init; > int use_scsi; > int max_cpus; > diff --git a/hw/pc.c b/hw/pc.c > index 69b13bf..0826107 100644 > --- a/hw/pc.c > +++ b/hw/pc.c > @@ -866,14 +866,6 @@ void pc_cpus_init(const char *cpu_model) > int i; > > /* init CPUs */ > -if (cpu_model == NULL) { > -#ifdef TARGET_X86_64 > -cpu_model = "qemu64"; > -#else > -cpu_model = "qemu32"; > -#endif > -} > - > for(i = 0; i < smp_cpus; i++) { > pc_new_cpu(cpu_model); > } > diff --git a/hw/pc_piix.c b/hw/pc_piix.c > index 12359a7..919b4d6 100644 > --- a/hw/pc_piix.c > +++ b/hw/pc_piix.c > @@ -204,17 +204,22 @@ static void pc_init_isa(ram_addr_t ram_size, > const char *initrd_filename, > const char *cpu_model) > { > -if (cpu_model == NULL) > -cpu_model = "486"; > pc_init1(ram_size, boot_device, > kernel_filename, kernel_cmdline, > initrd_filename, cpu_model, 0); > } > > +#ifdef TARGET_X86_64 > +#define DEF_CPU_MODEL "qemu64" > +#else > +#define DEF_CPU_MODEL "qemu32" > +#endif > + > static QEMUMachine pc_machine = { > .name = "pc-0.13", > .alias = "pc", > .desc = "Standard PC", > +.cpu_model = DEF_CPU_MODEL, > .init = pc_init_pci, > .max_cpus = 255, > .is_default = 1, > @@ -223,6 +228,7 @@ static QEMUMachine pc_machine = { > static QEMUMachine pc_machine_v0_12 = { > .name = "pc-0.12", > .desc = "Standard PC", > +.cpu_model = DEF_CPU_MODEL, > .init = pc_init_pci, > .max_cpus = 255, > .compat_props = (GlobalProperty[]) { > @@ -242,6 +248,7 @@ static QEMUMachine pc_machine_v0_12 = { > static QEMUMachine pc_machine_v0_11 = { > .name = "pc-0.11", > .desc = "Standard PC, qemu 0.11", > +.cpu_model = DEF_CPU_MODEL, > .init = pc_init_pci, > .max_cpus = 255, > .compat_props = (GlobalProperty[]) { > @@ -277,6 +284,7 @@ static QEMUMachine pc_machine_v0_11 = { > static QEMUMachine pc_machine_v0_10 = { > .name = "pc-0.10", > .desc = "Standard PC, qemu 0.10", > +.cpu_model = DEF_CPU_MODEL, > .init = pc_init_pci, > .max_cpus = 255, > .compat_props = (GlobalProperty[]) { > @@ -324,6 +332,7 @@ static QEMUMachine pc_machine_v0_10 = { > static QEMUMachine isapc_machine = { > .name = "isapc", > .desc = "ISA-only PC", > +.cpu_model = "486", > .init = pc_init_isa, > .max_cpus = 1, > }; > diff --git a/vl.c b/vl.c > index df414ef..3a55cc8 100644 > --- a/vl.c > +++ b/vl.c > @@ -2904,6 +2904,10 @@ int main(int argc, char **argv, char **envp) > } > qemu_add_globals(); > > +if (cpu_model == NULL) { > +cpu_model = machine->cpu_model; > +} > + > machine->init(ram_size, boot_devices, >kernel_filename, kernel_cmdl
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On 10/07/2010 03:42 AM, Roedel, Joerg wrote: On Wed, Oct 06, 2010 at 03:24:59PM -0400, Anthony Liguori wrote: +qemu_compat_version = machine->compat_version; + if (display_type == DT_NOGRAPHIC) { if (default_parallel) add_device_config(DEV_PARALLEL, "null"); -- 1.7.0.4 Looks fine to me, given CPUs are not in qdev. Anthony? The idea is fine, but why not just add the default CPU to the machine description? If I remember correctly the reason was that the machine description was not accessible in the cpuid initialization path because it is a function local variable. Not tested at all but I think the attached patch addresses it in a pretty nice way. There's a couple ways you could support your patch on top of this. You could add a kvm_cpu_model to the machine structure that gets defaulted too if kvm_enabled(). You could also introduce a new KVM machine type that gets defaulted to if no explicit machine is specified. I could have made it a global variable but considered the compat_version approach simpler. The qemu_compat_version might also be useful at other places. The reason we've avoided having a builtin notion of versions is that we have many downstreams where versioning would get very complicated. If we stick to features it makes it much easier for downstreams. Regards, Anthony Liguori Joerg >From d2370c88cef4b07d48ba3c4804e35ae2db8db7c0 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Thu, 7 Oct 2010 07:43:42 -0500 Subject: [PATCH] machine: make default cpu model part of machine structure Signed-off-by: Anthony Liguori diff --git a/hw/boards.h b/hw/boards.h index 6f0f0d7..8c6ef27 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -16,6 +16,7 @@ typedef struct QEMUMachine { const char *name; const char *alias; const char *desc; +const char *cpu_model; QEMUMachineInitFunc *init; int use_scsi; int max_cpus; diff --git a/hw/pc.c b/hw/pc.c index 69b13bf..0826107 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -866,14 +866,6 @@ void pc_cpus_init(const char *cpu_model) int i; /* init CPUs */ -if (cpu_model == NULL) { -#ifdef TARGET_X86_64 -cpu_model = "qemu64"; -#else -cpu_model = "qemu32"; -#endif -} - for(i = 0; i < smp_cpus; i++) { pc_new_cpu(cpu_model); } diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 12359a7..919b4d6 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -204,17 +204,22 @@ static void pc_init_isa(ram_addr_t ram_size, const char *initrd_filename, const char *cpu_model) { -if (cpu_model == NULL) -cpu_model = "486"; pc_init1(ram_size, boot_device, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, 0); } +#ifdef TARGET_X86_64 +#define DEF_CPU_MODEL "qemu64" +#else +#define DEF_CPU_MODEL "qemu32" +#endif + static QEMUMachine pc_machine = { .name = "pc-0.13", .alias = "pc", .desc = "Standard PC", +.cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .is_default = 1, @@ -223,6 +228,7 @@ static QEMUMachine pc_machine = { static QEMUMachine pc_machine_v0_12 = { .name = "pc-0.12", .desc = "Standard PC", +.cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .compat_props = (GlobalProperty[]) { @@ -242,6 +248,7 @@ static QEMUMachine pc_machine_v0_12 = { static QEMUMachine pc_machine_v0_11 = { .name = "pc-0.11", .desc = "Standard PC, qemu 0.11", +.cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .compat_props = (GlobalProperty[]) { @@ -277,6 +284,7 @@ static QEMUMachine pc_machine_v0_11 = { static QEMUMachine pc_machine_v0_10 = { .name = "pc-0.10", .desc = "Standard PC, qemu 0.10", +.cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .compat_props = (GlobalProperty[]) { @@ -324,6 +332,7 @@ static QEMUMachine pc_machine_v0_10 = { static QEMUMachine isapc_machine = { .name = "isapc", .desc = "ISA-only PC", +.cpu_model = "486", .init = pc_init_isa, .max_cpus = 1, }; diff --git a/vl.c b/vl.c index df414ef..3a55cc8 100644 --- a/vl.c +++ b/vl.c @@ -2904,6 +2904,10 @@ int main(int argc, char **argv, char **envp) } qemu_add_globals(); +if (cpu_model == NULL) { +cpu_model = machine->cpu_model; +} + machine->init(ram_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model); -- 1.7.0.4
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On Wed, Oct 06, 2010 at 03:24:59PM -0400, Anthony Liguori wrote: > >> +qemu_compat_version = machine->compat_version; > >> + > >> if (display_type == DT_NOGRAPHIC) { > >> if (default_parallel) > >> add_device_config(DEV_PARALLEL, "null"); > >> -- > >> 1.7.0.4 > >> > > Looks fine to me, given CPUs are not in qdev. Anthony? > > > > The idea is fine, but why not just add the default CPU to the machine > description? If I remember correctly the reason was that the machine description was not accessible in the cpuid initialization path because it is a function local variable. I could have made it a global variable but considered the compat_version approach simpler. The qemu_compat_version might also be useful at other places. Joerg -- AMD Operating System Research Center Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On 10/06/2010 01:53 PM, Marcelo Tosatti wrote: On Mon, Sep 27, 2010 at 03:16:15PM +0200, Joerg Roedel wrote: As requested by Alex this patch makes kvm64 the default CPU model when qemu is started with -enable-kvm. This takes only effect for qemu-versions newer or equal to 0.14.0. Signed-off-by: Joerg Roedel --- hw/boards.h|1 + hw/pc.c| 21 - hw/pc_piix.c |6 ++ qemu-version.h | 35 +++ vl.c |4 5 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 qemu-version.h diff --git a/hw/boards.h b/hw/boards.h index 6f0f0d7..2d41b2d 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -19,6 +19,7 @@ typedef struct QEMUMachine { QEMUMachineInitFunc *init; int use_scsi; int max_cpus; +unsigned int compat_version; unsigned int no_serial:1, no_parallel:1, use_virtcon:1, diff --git a/hw/pc.c b/hw/pc.c index 69b13bf..372ec4c 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -40,6 +40,16 @@ #include "sysbus.h" #include "sysemu.h" #include "blockdev.h" +#include "kvm.h" +#include "qemu-version.h" + +#ifdef TARGET_X86_64 +#define DEFAULT_KVM_CPU_MODEL "kvm64" +#define DEFAULT_QEMU_CPU_MODEL "qemu64" +#else +#define DEFAULT_KVM_CPU_MODEL "kvm32" +#define DEFAULT_QEMU_CPU_MODEL "qemu32" +#endif /* output Bochs bios info messages */ //#define DEBUG_BIOS @@ -867,11 +877,12 @@ void pc_cpus_init(const char *cpu_model) /* init CPUs */ if (cpu_model == NULL) { -#ifdef TARGET_X86_64 -cpu_model = "qemu64"; -#else -cpu_model = "qemu32"; -#endif +if (kvm_enabled()&& +qemu_compat_version>= QEMU_COMPAT_VERSION(0, 14, 0)) { +cpu_model = DEFAULT_KVM_CPU_MODEL; +} else { +cpu_model = DEFAULT_QEMU_CPU_MODEL; +} } for(i = 0; i< smp_cpus; i++) { diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 12359a7..9e46b71 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -35,6 +35,7 @@ #include "sysemu.h" #include "sysbus.h" #include "blockdev.h" +#include "qemu-version.h" #define MAX_IDE_BUS 2 @@ -217,6 +218,7 @@ static QEMUMachine pc_machine = { .desc = "Standard PC", .init = pc_init_pci, .max_cpus = 255, +.compat_version = QEMU_COMPAT_VERSION(0, 13, 0), .is_default = 1, }; @@ -225,6 +227,7 @@ static QEMUMachine pc_machine_v0_12 = { .desc = "Standard PC", .init = pc_init_pci, .max_cpus = 255, +.compat_version = QEMU_COMPAT_VERSION(0, 12, 0), .compat_props = (GlobalProperty[]) { { .driver = "virtio-serial-pci", @@ -244,6 +247,7 @@ static QEMUMachine pc_machine_v0_11 = { .desc = "Standard PC, qemu 0.11", .init = pc_init_pci, .max_cpus = 255, +.compat_version = QEMU_COMPAT_VERSION(0, 11, 0), .compat_props = (GlobalProperty[]) { { .driver = "virtio-blk-pci", @@ -279,6 +283,7 @@ static QEMUMachine pc_machine_v0_10 = { .desc = "Standard PC, qemu 0.10", .init = pc_init_pci, .max_cpus = 255, +.compat_version = QEMU_COMPAT_VERSION(0, 10, 0), .compat_props = (GlobalProperty[]) { { .driver = "virtio-blk-pci", @@ -325,6 +330,7 @@ static QEMUMachine isapc_machine = { .name = "isapc", .desc = "ISA-only PC", .init = pc_init_isa, +.compat_version = QEMU_COMPAT_VERSION(0, 10, 0), .max_cpus = 1, }; diff --git a/qemu-version.h b/qemu-version.h new file mode 100644 index 000..b4bfe48 --- /dev/null +++ b/qemu-version.h @@ -0,0 +1,35 @@ +/* + * qemu-version.h + * + * Defines needed for handling QEMU version compatibility + * + * Copyright (c) 2010 Joerg Roedel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _QEMU_VERSION_H_ +#define _QEMU_VERSION_H_ + +extern unsigned int qemu_compat_version; + +#define QEMU_COMPAT_VERSION(major, m
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On Mon, Sep 27, 2010 at 03:16:15PM +0200, Joerg Roedel wrote: > As requested by Alex this patch makes kvm64 the default CPU > model when qemu is started with -enable-kvm. This takes only > effect for qemu-versions newer or equal to 0.14.0. > > Signed-off-by: Joerg Roedel > --- > hw/boards.h|1 + > hw/pc.c| 21 - > hw/pc_piix.c |6 ++ > qemu-version.h | 35 +++ > vl.c |4 > 5 files changed, 62 insertions(+), 5 deletions(-) > create mode 100644 qemu-version.h > > diff --git a/hw/boards.h b/hw/boards.h > index 6f0f0d7..2d41b2d 100644 > --- a/hw/boards.h > +++ b/hw/boards.h > @@ -19,6 +19,7 @@ typedef struct QEMUMachine { > QEMUMachineInitFunc *init; > int use_scsi; > int max_cpus; > +unsigned int compat_version; > unsigned int no_serial:1, > no_parallel:1, > use_virtcon:1, > diff --git a/hw/pc.c b/hw/pc.c > index 69b13bf..372ec4c 100644 > --- a/hw/pc.c > +++ b/hw/pc.c > @@ -40,6 +40,16 @@ > #include "sysbus.h" > #include "sysemu.h" > #include "blockdev.h" > +#include "kvm.h" > +#include "qemu-version.h" > + > +#ifdef TARGET_X86_64 > +#define DEFAULT_KVM_CPU_MODEL "kvm64" > +#define DEFAULT_QEMU_CPU_MODEL "qemu64" > +#else > +#define DEFAULT_KVM_CPU_MODEL "kvm32" > +#define DEFAULT_QEMU_CPU_MODEL "qemu32" > +#endif > > /* output Bochs bios info messages */ > //#define DEBUG_BIOS > @@ -867,11 +877,12 @@ void pc_cpus_init(const char *cpu_model) > > /* init CPUs */ > if (cpu_model == NULL) { > -#ifdef TARGET_X86_64 > -cpu_model = "qemu64"; > -#else > -cpu_model = "qemu32"; > -#endif > +if (kvm_enabled() && > +qemu_compat_version >= QEMU_COMPAT_VERSION(0, 14, 0)) { > +cpu_model = DEFAULT_KVM_CPU_MODEL; > +} else { > +cpu_model = DEFAULT_QEMU_CPU_MODEL; > +} > } > > for(i = 0; i < smp_cpus; i++) { > diff --git a/hw/pc_piix.c b/hw/pc_piix.c > index 12359a7..9e46b71 100644 > --- a/hw/pc_piix.c > +++ b/hw/pc_piix.c > @@ -35,6 +35,7 @@ > #include "sysemu.h" > #include "sysbus.h" > #include "blockdev.h" > +#include "qemu-version.h" > > #define MAX_IDE_BUS 2 > > @@ -217,6 +218,7 @@ static QEMUMachine pc_machine = { > .desc = "Standard PC", > .init = pc_init_pci, > .max_cpus = 255, > +.compat_version = QEMU_COMPAT_VERSION(0, 13, 0), > .is_default = 1, > }; > > @@ -225,6 +227,7 @@ static QEMUMachine pc_machine_v0_12 = { > .desc = "Standard PC", > .init = pc_init_pci, > .max_cpus = 255, > +.compat_version = QEMU_COMPAT_VERSION(0, 12, 0), > .compat_props = (GlobalProperty[]) { > { > .driver = "virtio-serial-pci", > @@ -244,6 +247,7 @@ static QEMUMachine pc_machine_v0_11 = { > .desc = "Standard PC, qemu 0.11", > .init = pc_init_pci, > .max_cpus = 255, > +.compat_version = QEMU_COMPAT_VERSION(0, 11, 0), > .compat_props = (GlobalProperty[]) { > { > .driver = "virtio-blk-pci", > @@ -279,6 +283,7 @@ static QEMUMachine pc_machine_v0_10 = { > .desc = "Standard PC, qemu 0.10", > .init = pc_init_pci, > .max_cpus = 255, > +.compat_version = QEMU_COMPAT_VERSION(0, 10, 0), > .compat_props = (GlobalProperty[]) { > { > .driver = "virtio-blk-pci", > @@ -325,6 +330,7 @@ static QEMUMachine isapc_machine = { > .name = "isapc", > .desc = "ISA-only PC", > .init = pc_init_isa, > +.compat_version = QEMU_COMPAT_VERSION(0, 10, 0), > .max_cpus = 1, > }; > > diff --git a/qemu-version.h b/qemu-version.h > new file mode 100644 > index 000..b4bfe48 > --- /dev/null > +++ b/qemu-version.h > @@ -0,0 +1,35 @@ > +/* > + * qemu-version.h > + * > + * Defines needed for handling QEMU version compatibility > + * > + * Copyright (c) 2010 Joerg Roedel > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > copy > + * of this software and associated documentation files (the "Software"), to > deal > + * in the Software without restriction, including without limitation the > rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, > + * OUT OF OR IN CONNECTION WITH
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On 09/16/2010 04:21 PM, Roedel, Joerg wrote: On Thu, Sep 16, 2010 at 10:03:19AM -0400, Avi Kivity wrote: >On 09/14/2010 05:52 PM, Joerg Roedel wrote: > > As requested by Alex this patch makes kvm64 the default CPU > > model when qemu is started with -enable-kvm. > > > > > > This breaks compatiblity; if started with -M 0.13 or prior we should > default to qemu64. Ok, I can change that. But its ok to make kvm64 the default for anything> 0.13? Sure. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On Thu, Sep 16, 2010 at 10:03:19AM -0400, Avi Kivity wrote: > On 09/14/2010 05:52 PM, Joerg Roedel wrote: > > As requested by Alex this patch makes kvm64 the default CPU > > model when qemu is started with -enable-kvm. > > > > > > This breaks compatiblity; if started with -M 0.13 or prior we should > default to qemu64. Ok, I can change that. But its ok to make kvm64 the default for anything > 0.13? Joerg -- AMD Operating System Research Center Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On 09/14/2010 05:52 PM, Joerg Roedel wrote: As requested by Alex this patch makes kvm64 the default CPU model when qemu is started with -enable-kvm. This breaks compatiblity; if started with -M 0.13 or prior we should default to qemu64. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
On Tue, Sep 14, 2010 at 11:58:03AM -0400, Alexander Graf wrote: > > +if (kvm_enabled()) > > +cpu_model = DEFAULT_KVM_CPU_MODEL; > > +else > > +cpu_model = DEFAULT_QEMU_CPU_MODEL; > > > > Braces :(. Okay, here is the new patch: >From f49e78edbd4143d05128228d9cc24bd5abc3abf1 Mon Sep 17 00:00:00 2001 From: Joerg Roedel Date: Tue, 14 Sep 2010 16:52:11 +0200 Subject: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled() As requested by Alex this patch makes kvm64 the default CPU model when qemu is started with -enable-kvm. Signed-off-by: Joerg Roedel --- hw/pc.c | 20 +++- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 69b13bf..a6355f3 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -40,6 +40,16 @@ #include "sysbus.h" #include "sysemu.h" #include "blockdev.h" +#include "kvm.h" + + +#ifdef TARGET_X86_64 +#define DEFAULT_KVM_CPU_MODEL "kvm64" +#define DEFAULT_QEMU_CPU_MODEL "qemu64" +#else +#define DEFAULT_KVM_CPU_MODEL "kvm32" +#define DEFAULT_QEMU_CPU_MODEL "qemu32" +#endif /* output Bochs bios info messages */ //#define DEBUG_BIOS @@ -867,11 +877,11 @@ void pc_cpus_init(const char *cpu_model) /* init CPUs */ if (cpu_model == NULL) { -#ifdef TARGET_X86_64 -cpu_model = "qemu64"; -#else -cpu_model = "qemu32"; -#endif +if (kvm_enabled()) { +cpu_model = DEFAULT_KVM_CPU_MODEL; +} else { +cpu_model = DEFAULT_QEMU_CPU_MODEL; +} } for(i = 0; i < smp_cpus; i++) { -- 1.7.0.4 -- AMD Operating System Research Center Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled()
Joerg Roedel wrote: > As requested by Alex this patch makes kvm64 the default CPU > model when qemu is started with -enable-kvm. > > Signed-off-by: Joerg Roedel > --- > hw/pc.c | 19 ++- > 1 files changed, 14 insertions(+), 5 deletions(-) > > diff --git a/hw/pc.c b/hw/pc.c > index 69b13bf..f531d0d 100644 > --- a/hw/pc.c > +++ b/hw/pc.c > @@ -40,6 +40,16 @@ > #include "sysbus.h" > #include "sysemu.h" > #include "blockdev.h" > +#include "kvm.h" > + > + > +#ifdef TARGET_X86_64 > +#define DEFAULT_KVM_CPU_MODEL "kvm64" > +#define DEFAULT_QEMU_CPU_MODEL "qemu64" > +#else > +#define DEFAULT_KVM_CPU_MODEL "kvm32" > +#define DEFAULT_QEMU_CPU_MODEL "qemu32" > +#endif > > /* output Bochs bios info messages */ > //#define DEBUG_BIOS > @@ -867,11 +877,10 @@ void pc_cpus_init(const char *cpu_model) > > /* init CPUs */ > if (cpu_model == NULL) { > -#ifdef TARGET_X86_64 > -cpu_model = "qemu64"; > -#else > -cpu_model = "qemu32"; > -#endif > +if (kvm_enabled()) > +cpu_model = DEFAULT_KVM_CPU_MODEL; > +else > +cpu_model = DEFAULT_QEMU_CPU_MODEL; > Braces :(. Alex -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html