[libvirt] [PATCH] qemu conf: Use host-model for cpu mode by default

Now, qemu guest's default cpu model is qemu32/64 and it can be configured per domain. In some case, host-model mode is suitable for getting enough performance in the guest because of features from cpu spec. This patch adds a config option to qemu.conf to use 'host-model' mode as default and allow users to use host-model mode in domains on a host. This is useful because - Guest owners don't need to touch their domain's config. - An administrator can reduce an item in their checklist for VM performance and guarantee all guests should run in the best performance. Signed-off-by: Ken ICHIKAWA <ichikawa.ken@jp.fujitsu.com> --- src/qemu/qemu.conf | 7 +++++++ src/qemu/qemu_command.c | 6 ++++++ src/qemu/qemu_conf.c | 4 ++++ src/qemu/qemu_conf.h | 1 + 4 files changed, 18 insertions(+) diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index dd853c8..5f60237 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -401,3 +401,10 @@ # Defaults to -1. # #seccomp_sandbox = 1 + + +# Use 'host-model' for cpu mode when cpu is not defined in +# domain xml file. +# 1 = on, 0 = off(default). +# +#make_default_cpu_host_model = 1 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1e96982..8fdac2d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4111,6 +4111,12 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, else default_model = "qemu64"; + if (def->cpu == NULL && driver->makeDefaultCPUHostModel){ + if (VIR_ALLOC(def->cpu) < 0) + goto no_memory; + def->cpu->mode = VIR_CPU_MODE_HOST_MODEL; + } + if (def->cpu && (def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) { virCPUCompareResult cmp; diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index dc4d680..92b9c38 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -575,6 +575,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, CHECK_TYPE("seccomp_sandbox", VIR_CONF_LONG); if (p) driver->seccompSandbox = p->l; + p = virConfGetValue(conf, "make_default_cpu_host_model"); + CHECK_TYPE("make_default_cpu_host_model", VIR_CONF_LONG); + if (p) driver->makeDefaultCPUHostModel = p->l; + virConfFree(conf); return 0; } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 2c7f70c..b0a76f4 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -156,6 +156,7 @@ struct qemud_driver { int keepAliveInterval; unsigned int keepAliveCount; int seccompSandbox; + unsigned int makeDefaultCPUHostModel; }; typedef struct _qemuDomainCmdlineDef qemuDomainCmdlineDef; -- 1.7.11.7

On Wed, Nov 14, 2012 at 03:10:48AM +0000, Ichikawa, Ken wrote:
Now, qemu guest's default cpu model is qemu32/64 and it can be configured per domain. In some case, host-model mode is suitable for getting enough performance in the guest because of features from cpu spec.
This patch adds a config option to qemu.conf to use 'host-model' mode as default and allow users to use host-model mode in domains on a host. This is useful because - Guest owners don't need to touch their domain's config. - An administrator can reduce an item in their checklist for VM performance and guarantee all guests should run in the best performance.
While I understand the benefits, I'm afraid I have to NACK this at this time because using host-model doesn't really work when trying to use nested-KVM. Until we have a solution for that, we neeed to stick with a CPU model that works everywhere, since users like OpenStack do actually use nested-KVM for testing work and already complained about this when I made OpenStack set the host-model by default. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

(2012/11/14 18:44:44), Daniel P. Berrange wrote:
Now, qemu guest's default cpu model is qemu32/64 and it can be configured per domain. In some case, host-model mode is suitable for getting enough performance in the guest because of features from cpu spec.
This patch adds a config option to qemu.conf to use 'host-model' mode as default and allow users to use host-model mode in domains on a host. This is useful because - Guest owners don't need to touch their domain's config. - An administrator can reduce an item in their checklist for VM performance and guarantee all guests should run in the best
On Wed, Nov 14, 2012 at 03:10:48AM +0000, Ichikawa, Ken wrote: performance.
While I understand the benefits, I'm afraid I have to NACK this at this time because using host-model doesn't really work when trying to use nested-KVM. Until we have a solution for that, we neeed to stick with a CPU model that works everywhere, since users like OpenStack do actually use nested-KVM for testing work and already complained about this when I made OpenStack set the host-model by default.
Thank you for noticing the nested-KVM problem. However, to enable this patch's function, users need to edit qemu.conf. So, if users use nested-KVM, they just don't edit the conf file. Is there still any problem? Ken ICHIKAWA

-----Original Message----- From: Daniel P. Berrange [mailto:berrange@redhat.com] Sent: Wednesday, November 14, 2012 6:45 PM To: Ichikawa, Ken/市川 顕 Cc: libvir-list@redhat.com; eblake@redhat.com; gaofeng@cn.fujitsu.com; Kaneshige, Kenji/金重 憲治 Subject: Re: [PATCH] qemu conf: Use host-model for cpu mode by default
On Wed, Nov 14, 2012 at 03:10:48AM +0000, Ichikawa, Ken wrote:
Now, qemu guest's default cpu model is qemu32/64 and it can be configured per domain. In some case, host-model mode is suitable for getting enough performance in the guest because of features from cpu spec.
This patch adds a config option to qemu.conf to use 'host-model' mode as default and allow users to use host-model mode in domains on a host. This is useful because - Guest owners don't need to touch their domain's config. - An administrator can reduce an item in their checklist for VM performance and guarantee all guests should run in the best performance.
While I understand the benefits, I'm afraid I have to NACK this at this time because using host-model doesn't really work when trying to use nested-KVM. Until we have a solution for that, we neeed to stick with a CPU model that works everywhere, since users like OpenStack do actually use nested-KVM for testing work and already complained about this when I made OpenStack set the host-model by default.
Ken's patch is not just to change the default cpu mode to host-model. Cpu mode is set to host-model only when user specifies "make_default_cpu_host_model = 1" in qemu.conf. So I don't think it cause the problem. Regards, Kenji Kaneshige
Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Thu, Nov 15, 2012 at 02:55:00 +0000, Kaneshige, Kenji wrote:
-----Original Message----- From: Daniel P. Berrange [mailto:berrange@redhat.com] Sent: Wednesday, November 14, 2012 6:45 PM To: Ichikawa, Ken/市川 顕 Cc: libvir-list@redhat.com; eblake@redhat.com; gaofeng@cn.fujitsu.com; Kaneshige, Kenji/金重 憲治 Subject: Re: [PATCH] qemu conf: Use host-model for cpu mode by default
On Wed, Nov 14, 2012 at 03:10:48AM +0000, Ichikawa, Ken wrote:
Now, qemu guest's default cpu model is qemu32/64 and it can be configured per domain. In some case, host-model mode is suitable for getting enough performance in the guest because of features from cpu spec.
This patch adds a config option to qemu.conf to use 'host-model' mode as default and allow users to use host-model mode in domains on a host. This is useful because - Guest owners don't need to touch their domain's config. - An administrator can reduce an item in their checklist for VM performance and guarantee all guests should run in the best performance.
While I understand the benefits, I'm afraid I have to NACK this at this time because using host-model doesn't really work when trying to use nested-KVM. Until we have a solution for that, we neeed to stick with a CPU model that works everywhere, since users like OpenStack do actually use nested-KVM for testing work and already complained about this when I made OpenStack set the host-model by default.
Ken's patch is not just to change the default cpu mode to host-model. Cpu mode is set to host-model only when user specifies "make_default_cpu_host_model = 1" in qemu.conf. So I don't think it cause the problem.
In current state of CPU probing, host-model is quite likely to request something that QEMU will not be able to provide (but we wouldn't notice it happened) or something that won't even work. I think we should not encourage people to use host-model until we make it better in cooperation with QEMU folks. Not to mention that having this kind of default configuration in libvirt seems pretty strange. This option cannot affect existing domains as it would change their ABI and libvirt cannot guess if this is acceptable or not. And applying such default when creating new domains looks like something that should rather be done by clients. Jirka
participants (4)
-
Daniel P. Berrange
-
Ichikawa, Ken
-
Jiri Denemark
-
Kaneshige, Kenji