From patchwork Sat Mar 10 12:42:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 145855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4A945B6FAA for ; Sat, 10 Mar 2012 23:43:24 +1100 (EST) Received: from localhost ([::1]:33382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6Ldp-0007ks-O4 for incoming@patchwork.ozlabs.org; Sat, 10 Mar 2012 07:43:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6Ldd-0007kn-7e for qemu-devel@nongnu.org; Sat, 10 Mar 2012 07:43:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S6LdZ-0004rU-Gi for qemu-devel@nongnu.org; Sat, 10 Mar 2012 07:43:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S6LdZ-0004rG-4v for qemu-devel@nongnu.org; Sat, 10 Mar 2012 07:43:05 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2ACh23I015486 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 10 Mar 2012 07:43:02 -0500 Received: from redhat.com (vpn1-5-65.ams2.redhat.com [10.36.5.65]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2ACgkib008877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Sat, 10 Mar 2012 07:42:49 -0500 Date: Sat, 10 Mar 2012 12:42:46 +0000 From: "Daniel P. Berrange" To: libvir-list@redhat.com, qemu-devel@nongnu.org, Gleb Natapov , Anthony Liguori , Jiri Denemark , Avi Kivity Message-ID: <20120310124246.GA4408@redhat.com> References: <20111218095816.GG21664@redhat.com> <20120309205652.GA6807@otherpad.lan.raisama.net> <20120309210403.GA2319@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120309210403.GA2319@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [libvirt] Modern CPU models cannot be used with libvirt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On Fri, Mar 09, 2012 at 09:04:03PM +0000, Daniel P. Berrange wrote: > On Fri, Mar 09, 2012 at 05:56:52PM -0300, Eduardo Habkost wrote: > > Resurrecting an old thread: > > > > I didn't see any clear conclusion in this thread (this is why I am > > resurrecting it), except that many were arguing that libvirt should > > simply copy and/or generate the CPU model definitions from Qemu. I > > really don't think it's reasonable to expect that. > > > > On Thu, Dec 15, 2011 at 03:54:15PM +0100, Jiri Denemark wrote: > > > Hi, > > > > > > Recently I realized that all modern CPU models defined in > > > /etc/qemu/target-x86_64.conf are useless when qemu is used through libvirt. > > > That's because we start qemu with -nodefconfig which results in qemu ignoring > > > that file with CPU model definitions. We have a very good reason for using > > > -nodefconfig because we need to control the ABI presented to a guest OS and we > > > don't want any configuration file that can contain lots of things including > > > device definitions to be read by qemu. However, we would really like the new > > > CPU models to be understood by qemu even if used through libvirt. What would > > > be the best way to solve this? > > > > > > I suspect this could have been already discussed in the past but obviously a > > > workable solution was either not found or just not implemented. > > > > So, our problem today is basically: > > > > A) libvirt uses -nodefconfig; > > B) -nodefconfig makes Qemu not load the config file containing the CPU > > model definitions; and > > C) libvirt expects the full CPU model list from Qemu to be available. > > I could have sworn we had this discussion a year ago or so, and had decided > that the default CPU models would be in something like /usr/share/qemu/cpu-x86_64.conf > and loaded regardless of the -nodefconfig setting. /etc/qemu/target-x86_64.conf > would be solely for end user configuration changes, not for QEMU builtin > defaults. > > But looking at the code in QEMU, it doesn't seem we ever implemented this ? Arrrgggh. It seems this was implemented as a patch in RHEL-6 qemu RPMs but, contrary to our normal RHEL development practice, it was not based on a cherry-pick of an upstream patch :-( For sake of reference, I'm attaching the two patches from the RHEL6 source RPM that do what I'm describing NB, I'm not neccessarily advocating these patches for upstream. I still maintain that libvirt should write out a config file containing the exact CPU model description it desires and specify that with -readconfig. The end result would be identical from QEMU's POV and it would avoid playing games with QEMU's config loading code. Regards, Daniel diff --git a/Makefile b/Makefile index c1dadd0..d147632 100644 --- a/Makefile +++ b/Makefile @@ -319,11 +319,11 @@ ifdef CONFIG_POSIX $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8" endif -install-sysconfig: - $(INSTALL_DIR) "$(sysconfdir)/qemu" - $(INSTALL_DATA) sysconfigs/target/target-x86_64.conf "$(sysconfdir)/qemu" +install-cpuconfig: + $(INSTALL_DIR) "$(DESTDIR)$(cpuconfdir)" + $(INSTALL_DATA) sysconfigs/target/cpu-x86_64.conf "$(DESTDIR)$(cpuconfdir)" -install: all $(if $(BUILD_DOCS),install-doc) install-sysconfig +install: all $(if $(BUILD_DOCS),install-doc) install-cpuconfig $(INSTALL_DIR) "$(DESTDIR)$(bindir)" ifneq ($(TOOLS),) $(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) "$(DESTDIR)$(bindir)" diff --git a/configure b/configure index 9e62b0d..be78a0c 100755 --- a/configure +++ b/configure @@ -33,6 +33,7 @@ prefix="" interp_prefix="/usr/gnemul/qemu-%M" static="no" sysconfdir="" +cpuconfdir="" sparc_cpu="" cross_prefix="" cc="gcc" @@ -480,6 +481,8 @@ for opt do ;; --sysconfdir=*) sysconfdir="$optarg" ;; + --cpuconfdir=*) cpuconfdir="$optarg" + ;; --disable-sdl) sdl="no" ;; --enable-sdl) sdl="yes" @@ -739,6 +742,7 @@ echo " --make=MAKE use specified make [$make]" echo " --install=INSTALL use specified install [$install]" echo " --static enable static build [$static]" echo " --sysconfdir=PATH install config in PATH" +echo " --cpuconfdir=PATH install cpu model config in PATH" echo " --enable-debug-tcg enable TCG debugging" echo " --disable-debug-tcg disable TCG debugging (default)" echo " --enable-debug enable common debug build options" @@ -2058,6 +2062,9 @@ else if test -z "$sysconfdir" ; then sysconfdir="${prefix}/etc" fi + if test -z "$cpuconfdir" ; then + cpuconfdir="$sysconfdir/qemu" + fi fi if test -f kvm/kernel/configure; then @@ -2159,6 +2166,7 @@ if test "$mingw32" = "yes" ; then echo "CONFIG_QEMU_CONFDIR=\"$sysconfdir\"" >> $config_host_mak else echo "CONFIG_QEMU_CONFDIR=\"${sysconfdir}/qemu\"" >> $config_host_mak + echo "CONFIG_QEMU_CPUCONFDIR=\"${cpuconfdir}\"" >> $config_host_mak fi case "$cpu" in @@ -2426,6 +2434,7 @@ echo "bindir=\${prefix}$binsuffix" >> $config_host_mak echo "mandir=\${prefix}$mansuffix" >> $config_host_mak echo "datadir=\${prefix}$datasuffix" >> $config_host_mak echo "sysconfdir=$sysconfdir" >> $config_host_mak +echo "cpuconfdir=$cpuconfdir" >> $config_host_mak echo "docdir=\${prefix}$docsuffix" >> $config_host_mak echo "MAKE=$make" >> $config_host_mak echo "INSTALL=$install" >> $config_host_mak diff --git a/sysconfigs/target/cpu-x86_64.conf b/sysconfigs/target/cpu-x86_64.conf new file mode 100644 index 0000000..ca07088 --- /dev/null +++ b/sysconfigs/target/cpu-x86_64.conf @@ -0,0 +1,85 @@ +# x86 CPU MODELS + +[cpudef] + name = "Conroe" + level = "2" + vendor = "GenuineIntel" + family = "6" + model = "2" + stepping = "3" + feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" + feature_ecx = "sse3 ssse3 x2apic" + extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx" + extfeature_ecx = "lahf_lm" + xlevel = "0x8000000A" + model_id = "Intel Celeron_4x0 (Conroe/Merom Class Core 2)" + +[cpudef] + name = "Penryn" + level = "2" + vendor = "GenuineIntel" + family = "6" + model = "2" + stepping = "3" + feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" + feature_ecx = "sse3 cx16 ssse3 sse4.1 x2apic" + extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx" + extfeature_ecx = "lahf_lm" + xlevel = "0x8000000A" + model_id = "Intel Core 2 Duo P9xxx (Penryn Class Core 2)" + +[cpudef] + name = "Nehalem" + level = "2" + vendor = "GenuineIntel" + family = "6" + model = "2" + stepping = "3" + feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" + feature_ecx = "sse3 cx16 ssse3 sse4.1 sse4.2 x2apic popcnt" + extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx" + extfeature_ecx = "lahf_lm" + xlevel = "0x8000000A" + model_id = "Intel Core i7 9xx (Nehalem Class Core i7)" + +[cpudef] + name = "Opteron_G1" + level = "5" + vendor = "AuthenticAMD" + family = "15" + model = "6" + stepping = "1" + feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" + feature_ecx = "sse3" + extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx" +# extfeature_ecx = "" + xlevel = "0x80000008" + model_id = "AMD Opteron 240 (Gen 1 Class Opteron)" + +[cpudef] + name = "Opteron_G2" + level = "5" + vendor = "AuthenticAMD" + family = "15" + model = "6" + stepping = "1" + feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" + feature_ecx = "sse3 cx16" + extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx rdtscp" + extfeature_ecx = "svm lahf_lm" + xlevel = "0x80000008" + model_id = "AMD Opteron 22xx (Gen 2 Class Opteron)" + +[cpudef] + name = "Opteron_G3" + level = "5" + vendor = "AuthenticAMD" + family = "15" + model = "6" + stepping = "1" + feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" + feature_ecx = "sse3 cx16 monitor popcnt" + extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx rdtscp" + extfeature_ecx = "svm sse4a abm misalignsse lahf_lm" + xlevel = "0x80000008" + model_id = "AMD Opteron 23xx (Gen 3 Class Opteron)" diff --git a/sysconfigs/target/target-x86_64.conf b/sysconfigs/target/target-x86_64.conf deleted file mode 100644 index ca07088..0000000 --- a/sysconfigs/target/target-x86_64.conf +++ /dev/null @@ -1,85 +0,0 @@ -# x86 CPU MODELS - -[cpudef] - name = "Conroe" - level = "2" - vendor = "GenuineIntel" - family = "6" - model = "2" - stepping = "3" - feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" - feature_ecx = "sse3 ssse3 x2apic" - extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx" - extfeature_ecx = "lahf_lm" - xlevel = "0x8000000A" - model_id = "Intel Celeron_4x0 (Conroe/Merom Class Core 2)" - -[cpudef] - name = "Penryn" - level = "2" - vendor = "GenuineIntel" - family = "6" - model = "2" - stepping = "3" - feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" - feature_ecx = "sse3 cx16 ssse3 sse4.1 x2apic" - extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx" - extfeature_ecx = "lahf_lm" - xlevel = "0x8000000A" - model_id = "Intel Core 2 Duo P9xxx (Penryn Class Core 2)" - -[cpudef] - name = "Nehalem" - level = "2" - vendor = "GenuineIntel" - family = "6" - model = "2" - stepping = "3" - feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" - feature_ecx = "sse3 cx16 ssse3 sse4.1 sse4.2 x2apic popcnt" - extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx" - extfeature_ecx = "lahf_lm" - xlevel = "0x8000000A" - model_id = "Intel Core i7 9xx (Nehalem Class Core i7)" - -[cpudef] - name = "Opteron_G1" - level = "5" - vendor = "AuthenticAMD" - family = "15" - model = "6" - stepping = "1" - feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" - feature_ecx = "sse3" - extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx" -# extfeature_ecx = "" - xlevel = "0x80000008" - model_id = "AMD Opteron 240 (Gen 1 Class Opteron)" - -[cpudef] - name = "Opteron_G2" - level = "5" - vendor = "AuthenticAMD" - family = "15" - model = "6" - stepping = "1" - feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" - feature_ecx = "sse3 cx16" - extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx rdtscp" - extfeature_ecx = "svm lahf_lm" - xlevel = "0x80000008" - model_id = "AMD Opteron 22xx (Gen 2 Class Opteron)" - -[cpudef] - name = "Opteron_G3" - level = "5" - vendor = "AuthenticAMD" - family = "15" - model = "6" - stepping = "1" - feature_edx = "sse2 sse fxsr mmx pat cmov pge sep apic cx8 mce pae msr tsc pse de fpu mtrr clflush mca pse36" - feature_ecx = "sse3 cx16 monitor popcnt" - extfeature_edx = "fxsr mmx pat cmov pge apic cx8 mce pae msr tsc pse de fpu lm syscall nx rdtscp" - extfeature_ecx = "svm sse4a abm misalignsse lahf_lm" - xlevel = "0x80000008" - model_id = "AMD Opteron 23xx (Gen 3 Class Opteron)" diff --git a/vl.c b/vl.c index a3b682d..eb993d6 100644 --- a/vl.c +++ b/vl.c @@ -5141,6 +5141,13 @@ int main(int argc, char **argv, char **envp) } } + /* load local cpu config, NB: may possibly be overridden by defconfigs + */ + if (qemu_read_config_file( + CONFIG_QEMU_CPUCONFDIR "/cpu-" TARGET_ARCH ".conf", + defconfig_verbose) == -EINVAL) { + exit(1); + } if (defconfig) { int ret;