From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1489510891515639.1153031596541; Tue, 14 Mar 2017 10:01:31 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGwPjE011298; Tue, 14 Mar 2017 12:58:25 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvtt5002598 for ; Tue, 14 Mar 2017 12:57:55 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvriY011778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:54 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7BE22100234; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:40 +0100 Message-Id: <563f8d62dcf72003fc80db9cd88130d186ce7aac.1489510598.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/12] tests: Switch to sparse initialization of virCPUDef X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- tests/domaincapstest.c | 38 ++++++++++++++++++++++++-------------- tests/testutilsqemu.c | 48 ++++++++++++++++++++--------------------------= -- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index a4bc8d6d0..462f86801 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -66,10 +66,10 @@ fillAllCaps(virDomainCapsPtr domCaps) virDomainCapsDeviceVideoPtr video =3D &domCaps->video; virDomainCapsDeviceHostdevPtr hostdev =3D &domCaps->hostdev; virCPUDef host =3D { - VIR_CPU_TYPE_HOST, 0, 0, - VIR_ARCH_X86_64, (char *) "host", - NULL, 0, (char *) "CPU Vendorrr", - 0, 0, 0, 0, 0, NULL, + .type =3D VIR_CPU_TYPE_HOST, + .arch =3D VIR_ARCH_X86_64, + .model =3D (char *) "host", + .vendor =3D (char *) "CPU Vendorrr", }; =20 domCaps->maxvcpus =3D 255; @@ -119,25 +119,35 @@ fillAllCaps(virDomainCapsPtr domCaps) # include "testutilsqemu.h" =20 static virCPUDef aarch64Cpu =3D { - 0, 0, 0, 0, NULL, NULL, 0, NULL, 1, 1, 1, 0, 0, NULL, + .sockets =3D 1, + .cores =3D 1, + .threads =3D 1, }; =20 static virCPUDef ppc64leCpu =3D { - VIR_CPU_TYPE_HOST, 0, 0, - VIR_ARCH_PPC64LE, (char *) "POWER8", - NULL, 0, NULL, 1, 1, 1, 0, 0, NULL, + .type =3D VIR_CPU_TYPE_HOST, + .arch =3D VIR_ARCH_PPC64LE, + .model =3D (char *) "POWER8", + .sockets =3D 1, + .cores =3D 1, + .threads =3D 1, }; =20 static virCPUDef x86Cpu =3D { - VIR_CPU_TYPE_HOST, 0, 0, - VIR_ARCH_X86_64, (char *) "Broadwell", - NULL, 0, NULL, 1, 1, 1, 0, 0, NULL, + .type =3D VIR_CPU_TYPE_HOST, + .arch =3D VIR_ARCH_X86_64, + .model =3D (char *) "Broadwell", + .sockets =3D 1, + .cores =3D 1, + .threads =3D 1, }; =20 static virCPUDef s390Cpu =3D { - VIR_CPU_TYPE_HOST, 0, 0, - VIR_ARCH_S390X, NULL, - NULL, 0, NULL, 1, 1, 1, 0, 0, NULL, + .type =3D VIR_CPU_TYPE_HOST, + .arch =3D VIR_ARCH_S390X, + .sockets =3D 1, + .cores =3D 1, + .threads =3D 1, }; =20 static int diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 0726cd317..026b73e9b 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -34,20 +34,16 @@ static virCPUFeatureDef cpuDefaultFeatures[] =3D { { (char *) "lahf_lm", -1 }, }; static virCPUDef cpuDefaultData =3D { - VIR_CPU_TYPE_HOST, /* type */ - 0, /* mode */ - 0, /* match */ - VIR_ARCH_X86_64, /* arch */ - (char *) "core2duo", /* model */ - NULL, /* vendor_id */ - 0, /* fallback */ - (char *) "Intel", /* vendor */ - 1, /* sockets */ - 2, /* cores */ - 1, /* threads */ - ARRAY_CARDINALITY(cpuDefaultFeatures), /* nfeatures */ - ARRAY_CARDINALITY(cpuDefaultFeatures), /* nfeatures_max */ - cpuDefaultFeatures, /* features */ + .type =3D VIR_CPU_TYPE_HOST, + .arch =3D VIR_ARCH_X86_64, + .model =3D (char *) "core2duo", + .vendor =3D (char *) "Intel", + .sockets =3D 1, + .cores =3D 2, + .threads =3D 1, + .nfeatures =3D ARRAY_CARDINALITY(cpuDefaultFeatures), + .nfeatures_max =3D ARRAY_CARDINALITY(cpuDefaultFeatures), + .features =3D cpuDefaultFeatures, }; =20 static virCPUFeatureDef cpuHaswellFeatures[] =3D { @@ -77,20 +73,16 @@ static virCPUFeatureDef cpuHaswellFeatures[] =3D { { (char *) "lahf_lm", -1 }, }; static virCPUDef cpuHaswellData =3D { - VIR_CPU_TYPE_HOST, /* type */ - 0, /* mode */ - 0, /* match */ - VIR_ARCH_X86_64, /* arch */ - (char *) "Haswell", /* model */ - NULL, /* vendor_id */ - 0, /* fallback */ - (char *) "Intel", /* vendor */ - 1, /* sockets */ - 2, /* cores */ - 2, /* threads */ - ARRAY_CARDINALITY(cpuHaswellFeatures), /* nfeatures */ - ARRAY_CARDINALITY(cpuHaswellFeatures), /* nfeatures_max */ - cpuHaswellFeatures, /* features */ + .type =3D VIR_CPU_TYPE_HOST, + .arch =3D VIR_ARCH_X86_64, + .model =3D (char *) "Haswell", + .vendor =3D (char *) "Intel", + .sockets =3D 1, + .cores =3D 2, + .threads =3D 2, + .nfeatures =3D ARRAY_CARDINALITY(cpuHaswellFeatures), + .nfeatures_max =3D ARRAY_CARDINALITY(cpuHaswellFeatures), + .features =3D cpuHaswellFeatures, }; =20 static virCPUDef cpuPower8Data =3D { --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1489510889742547.3724573550895; Tue, 14 Mar 2017 10:01:29 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvtVC022219; Tue, 14 Mar 2017 12:57:56 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvtnT002591 for ; Tue, 14 Mar 2017 12:57:55 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvrNP008592 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:54 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7DAD21062CF; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:41 +0100 Message-Id: <885966add99618df3a9ed730b346510a018bf9b1.1489510598.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/12] docs: Clarify /domain/cpu/@match description X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- docs/formatdomain.html.in | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 9a204f845..75367d6dd 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1217,8 +1217,8 @@
cpu
The cpu element is the main container for describing - guest CPU requirements. Its match attribute specified= how - strictly has the virtual CPU provided to the guest match these + guest CPU requirements. Its match attribute specifies= how + strictly the virtual CPU provided to the guest matches these requirements. Since 0.7.6 the match attribute can be omitted if topology is the only element within cpu. Possible values for t= he @@ -1227,13 +1227,21 @@
minimum
The specified CPU model and features describes the minimum - requested CPU.
+ requested CPU. A better CPU will be provided to the guest if it + is possible with the requested hypervisor on the current host. + This is a constrained host-model mode; the domain + will not be created if the provided virtual CPU does not meet + the requirements.
+
exact
-
The virtual CPU provided to the guest will exactly match the - specification
+
The virtual CPU provided to the guest should exactly match t= he + specification. If such CPU is not supported, libvirt will refu= se + to start the domain.
+
strict
-
The guest will not be created unless the host CPU does exact= ly - match the specification.
+
The domain will not be created unless the host CPU exactly + matches the specification. This is not very useful in practice + and should only be used if there is a real reason.
=20 Since 0.8.5 the match --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1489510893519961.9571711496806; Tue, 14 Mar 2017 10:01:33 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvuuE011269; Tue, 14 Mar 2017 12:57:56 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvtlH002599 for ; Tue, 14 Mar 2017 12:57:55 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvr5w020461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:54 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 7F7561062D0; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:42 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/12] Introduce /domain/cpu/@check XML attribute X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The attribute can be used to request a specific way of checking whether the virtual CPU matches created by the hypervisor matches the specification in domain XML. Signed-off-by: Jiri Denemark --- docs/formatdomain.html.in | 30 ++++++++++++++++++++++++++++++ docs/schemas/cputypes.rng | 10 ++++++++++ docs/schemas/domaincommon.rng | 3 +++ src/conf/cpu_conf.c | 30 ++++++++++++++++++++++++++++++ src/conf/cpu_conf.h | 12 ++++++++++++ src/conf/domain_conf.c | 21 +++++++++++++++++++++ 6 files changed, 106 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 75367d6dd..3bea3c75a 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1247,6 +1247,36 @@ Since 0.8.5 the match attribute can be omitted and will default to exact. =20 + Sometimes the hypervisor is not able to create a virtual CPU exact= ly + matching the specification passed by libvirt. + Since 3.2.0, an optional check<= /code> + attribute can be used to request a specific way of checking whether + the virtual CPU matches the specification. It is usually safe to o= mit + this attribute when starting a domain and stick with the default + value. Once the domain starts, libvirt will automatically change t= he + check attribute to the best supported value to ensure= the + virtual CPU does not change when the domain is migrated to another + host. The following values can be used: + +
+
none
+
Libvirt does no checking and it is up to the hypervisor to + refuse to start the domain if it cannot provide the requested = CPU. + With QEMU this means no checking is done at all since the defa= ult + behavior of QEMU is to emit warnings, but start the domain any= way. +
+ +
partial
+
Libvirt will check the guest CPU specification before starti= ng + a domain, but the rest is left on the hypervisor. It can still + provide a different virtual CPU.
+ +
full
+
The virtual CPU created by the hypervisor will be checked + against the CPU specification and the domain will not be start= ed + unless the two CPUs match.
+
+ Since 0.9.10, an optional mode<= /code> attribute may be used to make it easier to configure a guest CPU t= o be as close to host CPU as possible. Possible values for the diff --git a/docs/schemas/cputypes.rng b/docs/schemas/cputypes.rng index 7cc9dd3d8..8189114e3 100644 --- a/docs/schemas/cputypes.rng +++ b/docs/schemas/cputypes.rng @@ -23,6 +23,16 @@ =20 + + + + none + partial + full + + + + diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 5e593285e..767d6979c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4503,6 +4503,9 @@ + + + diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 2724fa30a..90accaea7 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -45,6 +45,12 @@ VIR_ENUM_IMPL(virCPUMatch, VIR_CPU_MATCH_LAST, "exact", "strict") =20 +VIR_ENUM_IMPL(virCPUCheck, VIR_CPU_CHECK_LAST, + "default", + "none", + "partial", + "full") + VIR_ENUM_IMPL(virCPUFallback, VIR_CPU_FALLBACK_LAST, "allow", "forbid") @@ -182,6 +188,7 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu) copy->type =3D cpu->type; copy->mode =3D cpu->mode; copy->match =3D cpu->match; + copy->check =3D cpu->check; copy->fallback =3D cpu->fallback; copy->sockets =3D cpu->sockets; copy->cores =3D cpu->cores; @@ -277,6 +284,7 @@ virCPUDefParseXML(xmlNodePtr node, =20 if (def->type =3D=3D VIR_CPU_TYPE_GUEST) { char *match =3D virXMLPropString(node, "match"); + char *check; =20 if (!match) { if (virXPathBoolean("boolean(./model)", ctxt)) @@ -294,6 +302,18 @@ virCPUDefParseXML(xmlNodePtr node, goto error; } } + + if ((check =3D virXMLPropString(node, "check"))) { + def->check =3D virCPUCheckTypeFromString(check); + VIR_FREE(check); + + if (def->check < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid check attribute for CPU " + "specification")); + goto error; + } + } } =20 if (def->type =3D=3D VIR_CPU_TYPE_HOST) { @@ -532,6 +552,16 @@ virCPUDefFormatBufFull(virBufferPtr buf, } virBufferAsprintf(&attributeBuf, " match=3D'%s'", tmp); } + + if (def->check) { + if (!(tmp =3D virCPUCheckTypeToString(def->check))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected CPU check policy %d"), + def->check); + goto cleanup; + } + virBufferAsprintf(&attributeBuf, " check=3D'%s'", tmp); + } } =20 /* Format children */ diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index cc3fbf0a4..507f630dc 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -64,6 +64,17 @@ typedef enum { VIR_ENUM_DECL(virCPUMatch) =20 typedef enum { + VIR_CPU_CHECK_DEFAULT, + VIR_CPU_CHECK_NONE, + VIR_CPU_CHECK_PARTIAL, + VIR_CPU_CHECK_FULL, + + VIR_CPU_CHECK_LAST +} virCPUCheck; + +VIR_ENUM_DECL(virCPUCheck) + +typedef enum { VIR_CPU_FALLBACK_ALLOW, VIR_CPU_FALLBACK_FORBID, =20 @@ -98,6 +109,7 @@ struct _virCPUDef { int type; /* enum virCPUType */ int mode; /* enum virCPUMode */ int match; /* enum virCPUMatch */ + int check; /* virCPUCheck */ virArch arch; char *model; char *vendor_id; /* vendor id returned by CPUID in the guest */ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 88d419e27..a2cdb260a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4587,6 +4587,24 @@ virDomainVcpuDefPostParse(virDomainDefPtr def) =20 =20 static int +virDomainDefPostParseCPU(virDomainDefPtr def) +{ + if (!def->cpu) + return 0; + + if (def->cpu->mode =3D=3D VIR_CPU_MODE_CUSTOM && + !def->cpu->model && + def->cpu->check !=3D VIR_CPU_CHECK_DEFAULT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("check attribute specified for CPU with no model"= )); + return -1; + } + + return 0; +} + + +static int virDomainDefPostParseInternal(virDomainDefPtr def, struct virDomainDefPostParseDeviceIteratorDa= ta *data) { @@ -4636,6 +4654,9 @@ virDomainDefPostParseInternal(virDomainDefPtr def, =20 virDomainDefPostParseGraphics(def); =20 + if (virDomainDefPostParseCPU(def) < 0) + return -1; + return 0; } =20 --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 148951095782826.89693221419634; Tue, 14 Mar 2017 10:02:37 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGwSfg017498; Tue, 14 Mar 2017 12:58:28 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvt5l002612 for ; Tue, 14 Mar 2017 12:57:55 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvrhL020462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:54 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8193A1062D1; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:43 +0100 Message-Id: <39b6be4e29fade110ba0f0ac510e210847b55128.1489510598.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/12] qemu: Set default values for CPU check attribute X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- src/qemu/qemu_domain.c | 42 ++++++++++++++++++= ++++ src/qemu/qemu_process.c | 13 +++---- .../qemuxml2argv-aarch64-gic-host.xml | 2 +- .../qemuxml2argv-aarch64-gic-v2.xml | 2 +- .../qemuxml2argv-aarch64-gic-v3.xml | 2 +- .../qemuxml2argv-cpu-check-default-none.args | 21 +++++++++++ .../qemuxml2argv-cpu-check-default-none.xml | 19 ++++++++++ .../qemuxml2argv-cpu-check-default-none2.args | 21 +++++++++++ .../qemuxml2argv-cpu-check-default-none2.xml | 21 +++++++++++ .../qemuxml2argv-cpu-check-default-partial.args | 22 ++++++++++++ .../qemuxml2argv-cpu-check-default-partial.xml | 19 ++++++++++ .../qemuxml2argv-cpu-check-default-partial2.args | 21 +++++++++++ .../qemuxml2argv-cpu-check-default-partial2.xml | 21 +++++++++++ .../qemuxml2argv-cpu-check-full.args | 1 + .../qemuxml2argv-cpu-check-full.xml | 21 +++++++++++ .../qemuxml2argv-cpu-check-none.args | 21 +++++++++++ .../qemuxml2argv-cpu-check-none.xml | 21 +++++++++++ .../qemuxml2argv-cpu-check-partial.args | 1 + .../qemuxml2argv-cpu-check-partial.xml | 21 +++++++++++ tests/qemuxml2argvtest.c | 8 +++++ .../qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml | 2 +- ...qemuxml2xmlout-aarch64-video-virtio-gpu-pci.xml | 2 +- .../qemuxml2xmlout-aarch64-virtio-pci-default.xml | 2 +- ...2xmlout-aarch64-virtio-pci-manual-addresses.xml | 2 +- .../qemuxml2xmlout-cpu-check-default-none.xml | 28 +++++++++++++++ .../qemuxml2xmlout-cpu-check-default-none2.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-default-partial.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-default-partial2.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-full.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-none.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-check-partial.xml | 30 ++++++++++++++++ .../qemuxml2xmlout-cpu-eoi-disabled.xml | 2 +- .../qemuxml2xmlout-cpu-eoi-enabled.xml | 2 +- .../qemuxml2xmlout-cpu-host-kvmclock.xml | 2 +- .../qemuxml2xmlout-cpu-host-model-features.xml | 2 +- ...emuxml2xmlout-cpu-host-passthrough-features.xml | 2 +- .../qemuxml2xmlout-cpu-kvmclock.xml | 2 +- .../qemuxml2xmlout-graphics-spice-timeout.xml | 2 +- tests/qemuxml2xmltest.c | 8 +++++ 39 files changed, 536 insertions(+), 22 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-n= one.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-n= one.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-n= one2.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-n= one2.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-p= artial.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-p= artial.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-p= artial2.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-p= artial2.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.xml create mode 120000 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.a= rgs create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.x= ml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-defau= lt-none.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-defau= lt-none2.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-defau= lt-partial.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-defau= lt-partial2.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-full.= xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-none.= xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-parti= al.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 07ce22417..8ebc92479 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2675,6 +2675,45 @@ qemuDomainDefVcpusPostParse(virDomainDefPtr def) =20 =20 static int +qemuDomainDefCPUPostParse(virDomainDefPtr def) +{ + if (!def->cpu) + return 0; + + /* Nothing to be done if only CPU topology is specified. */ + if (def->cpu->mode =3D=3D VIR_CPU_MODE_CUSTOM && + !def->cpu->model) + return 0; + + if (def->cpu->check !=3D VIR_CPU_CHECK_DEFAULT) + return 0; + + switch ((virCPUMode) def->cpu->mode) { + case VIR_CPU_MODE_HOST_PASSTHROUGH: + def->cpu->check =3D VIR_CPU_CHECK_NONE; + break; + + case VIR_CPU_MODE_HOST_MODEL: + def->cpu->check =3D VIR_CPU_CHECK_PARTIAL; + break; + + case VIR_CPU_MODE_CUSTOM: + /* Custom CPUs in TCG mode are not compared to host CPU by default= . */ + if (def->virtType =3D=3D VIR_DOMAIN_VIRT_QEMU) + def->cpu->check =3D VIR_CPU_CHECK_NONE; + else + def->cpu->check =3D VIR_CPU_CHECK_PARTIAL; + break; + + case VIR_CPU_MODE_LAST: + break; + } + + return 0; +} + + +static int qemuDomainDefPostParse(virDomainDefPtr def, virCapsPtr caps, unsigned int parseFlags, @@ -2738,6 +2777,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, if (qemuDomainDefVcpusPostParse(def) < 0) goto cleanup; =20 + if (qemuDomainDefCPUPostParse(def) < 0) + goto cleanup; + ret =3D 0; cleanup: virObjectUnref(qemuCaps); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b9c1847bb..e9631c111 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5184,14 +5184,11 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, if (def->cpu->mode =3D=3D VIR_CPU_MODE_HOST_PASSTHROUGH) return 0; =20 - /* custom CPUs in TCG mode don't need to be compared to host CPU */ - if (def->virtType !=3D VIR_DOMAIN_VIRT_QEMU || - def->cpu->mode !=3D VIR_CPU_MODE_CUSTOM) { - if (virCPUCompare(caps->host.arch, - virQEMUCapsGetHostModel(qemuCaps, def->virtType), - def->cpu, true) < 0) - return -1; - } + if (def->cpu->check =3D=3D VIR_CPU_CHECK_PARTIAL && + virCPUCompare(caps->host.arch, + virQEMUCapsGetHostModel(qemuCaps, def->virtType), + def->cpu, true) < 0) + return -1; =20 if (virCPUUpdate(def->os.arch, def->cpu, virQEMUCapsGetHostModel(qemuCaps, def->virtType)) < 0) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.xml b/tes= ts/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.xml index 445b35857..b14d14281 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.xml @@ -11,7 +11,7 @@ - + destroy restart diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.xml b/tests= /qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.xml index 9ccba9904..8b9983752 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.xml @@ -11,7 +11,7 @@ - + destroy restart diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml b/tests= /qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml index 7c9ee92b3..bde94e16c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.xml @@ -11,7 +11,7 @@ - + destroy restart diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.arg= s b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.args new file mode 100644 index 000000000..24d9f5306 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.args @@ -0,0 +1,21 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-kvm \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu host \ +-m 214 \ +-smp 6,sockets=3D6,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.xml= b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.xml new file mode 100644 index 000000000..314cdf52a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none.xml @@ -0,0 +1,19 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.ar= gs b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.args new file mode 100644 index 000000000..b6a5d4dd4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.args @@ -0,0 +1,21 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu core2duo \ +-m 214 \ +-smp 6,sockets=3D6,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.xm= l b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.xml new file mode 100644 index 000000000..286d2d5d7 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-none2.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.= args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.args new file mode 100644 index 000000000..decf7fdd4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.args @@ -0,0 +1,22 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-kvm \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu core2duo,+ds,+acpi,+ss,+ht,+tm,+pbe,+ds_cpl,+vmx,+est,+tm2,+cx16,+xtp= r,\ ++lahf_lm \ +-m 214 \ +-smp 6,sockets=3D6,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.= xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.xml new file mode 100644 index 000000000..3dd45a704 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial.xml @@ -0,0 +1,19 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2= .args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.args new file mode 100644 index 000000000..bd4cefaeb --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.args @@ -0,0 +1,21 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-kvm \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu core2duo \ +-m 214 \ +-smp 6,sockets=3D6,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2= .xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.xml new file mode 100644 index 000000000..6c7690a95 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-default-partial2.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.args b/test= s/qemuxml2argvdata/qemuxml2argv-cpu-check-full.args new file mode 120000 index 000000000..dd946106e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.args @@ -0,0 +1 @@ +qemuxml2argv-cpu-check-none.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.xml b/tests= /qemuxml2argvdata/qemuxml2argv-cpu-check-full.xml new file mode 100644 index 000000000..653c2aaad --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-full.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.args b/test= s/qemuxml2argvdata/qemuxml2argv-cpu-check-none.args new file mode 100644 index 000000000..bd4cefaeb --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.args @@ -0,0 +1,21 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-kvm \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-cpu core2duo \ +-m 214 \ +-smp 6,sockets=3D6,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot n \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.xml b/tests= /qemuxml2argvdata/qemuxml2argv-cpu-check-none.xml new file mode 100644 index 000000000..632074626 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-none.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.args b/t= ests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.args new file mode 120000 index 000000000..dd946106e --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.args @@ -0,0 +1 @@ +qemuxml2argv-cpu-check-none.args \ No newline at end of file diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.xml b/te= sts/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.xml new file mode 100644 index 000000000..8e7850df8 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-check-partial.xml @@ -0,0 +1,21 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6bd746599..db21edbbf 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2468,6 +2468,14 @@ mymain(void) DO_TEST("fd-memory-no-numa-topology", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OB= JECT_MEMORY_FILE, QEMU_CAPS_KVM); =20 + DO_TEST("cpu-check-none", QEMU_CAPS_KVM); + DO_TEST("cpu-check-partial", QEMU_CAPS_KVM); + DO_TEST("cpu-check-full", QEMU_CAPS_KVM); + DO_TEST("cpu-check-default-none", QEMU_CAPS_KVM); + DO_TEST("cpu-check-default-none2", NONE); + DO_TEST("cpu-check-default-partial", QEMU_CAPS_KVM); + DO_TEST("cpu-check-default-partial2", QEMU_CAPS_KVM); + qemuTestDriverFree(&driver); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-m= mio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio= .xml index 2f1f8dd3d..bea65990e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-aavmf-virtio-mmio.xml @@ -18,7 +18,7 @@ - + cortex-a53 diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-g= pu-pci.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-g= pu-pci.xml index 26f6a5162..2c765e7c3 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.= xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-video-virtio-gpu-pci.= xml @@ -11,7 +11,7 @@ - + cortex-a57 diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-def= ault.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-defau= lt.xml index f7fbdc7a9..88a6a6a0c 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-default.xml @@ -18,7 +18,7 @@ - + cortex-a53 diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-man= ual-addresses.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-= pci-manual-addresses.xml index 1b50f75f0..83cf0d1f5 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-add= resses.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-aarch64-virtio-pci-manual-add= resses.xml @@ -18,7 +18,7 @@ - + cortex-a53 diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none= .xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none.xml new file mode 100644 index 000000000..b25cdd599 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none.xml @@ -0,0 +1,28 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none= 2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none2.xml new file mode 100644 index 000000000..310b95e58 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-none2.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-part= ial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial= .xml new file mode 100644 index 000000000..f4bfe54ee --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-part= ial2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partia= l2.xml new file mode 100644 index 000000000..8619f009c --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-default-partial2.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-full.xml b/t= ests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-full.xml new file mode 100644 index 000000000..3fd13f27e --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-full.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-none.xml b/t= ests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-none.xml new file mode 100644 index 000000000..d71ad5fde --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-none.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-partial.xml = b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-partial.xml new file mode 100644 index 000000000..8619f009c --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-check-partial.xml @@ -0,0 +1,30 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 6 + + hvm + + + + core2duo + + + destroy + restart + destroy + + /usr/bin/qemu-kvm + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-disabled.xml b= /tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-disabled.xml index 7a51e3ddf..b29a24e52 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-disabled.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-disabled.xml @@ -13,7 +13,7 @@ - + qemu32 diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-enabled.xml b/= tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-enabled.xml index ae8ab6aee..efba9e5db 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-enabled.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-eoi-enabled.xml @@ -13,7 +13,7 @@ - + qemu32 diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-kvmclock.xml = b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-kvmclock.xml index c2bdad91f..df0aecb3e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-kvmclock.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-kvmclock.xml @@ -8,7 +8,7 @@ hvm - + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-model-feature= s.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-model-features.xml index 161fcfe39..b1e194910 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-model-features.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-model-features.xml @@ -13,7 +13,7 @@ hvm - + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-passthrough-f= eatures.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-passthrough-= features.xml index 935f8cd39..98189c43f 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-passthrough-features= .xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-host-passthrough-features= .xml @@ -13,7 +13,7 @@ hvm - + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-kvmclock.xml b/tes= ts/qemuxml2xmloutdata/qemuxml2xmlout-cpu-kvmclock.xml index 4d222de4a..a483025a0 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-kvmclock.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cpu-kvmclock.xml @@ -8,7 +8,7 @@ hvm - + core2duo diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout= .xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml index 5f881f1fb..b807ac31b 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml @@ -15,7 +15,7 @@ - + core2duo Intel diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 4353ad245..af56dd4e5 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1108,6 +1108,14 @@ mymain(void) QEMU_CAPS_MACHINE_OPT, QEMU_CAPS_MACHINE_IOMMU); =20 + DO_TEST("cpu-check-none", NONE); + DO_TEST("cpu-check-partial", NONE); + DO_TEST("cpu-check-full", NONE); + DO_TEST("cpu-check-default-none", NONE); + DO_TEST("cpu-check-default-none2", NONE); + DO_TEST("cpu-check-default-partial", NONE); + DO_TEST("cpu-check-default-partial2", NONE); + qemuTestDriverFree(&driver); =20 return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1489510913068435.6511624202084; Tue, 14 Mar 2017 10:01:53 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGwZio022265; Tue, 14 Mar 2017 12:58:35 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvuQF002626 for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvtOi011790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 83CA01062D2; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:44 +0100 Message-Id: <8f5c7d0a1653e264f4988d3977d44f2357828d41.1489510598.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/12] qemu: Refactor Hyper-V features check X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The checks are now in a dedicated qemuProcessVerifyHypervFeatures function. Signed-off-by: Jiri Denemark --- src/qemu/qemu_process.c | 88 ++++++++++++++++++++++++++++++---------------= ---- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e9631c111..48820a204 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3726,6 +3726,59 @@ qemuValidateCpuCount(virDomainDefPtr def, } =20 =20 +static int +qemuProcessVerifyHypervFeatures(virDomainDefPtr def, + virCPUDataPtr cpu) +{ + char *cpuFeature; + size_t i; + int rc; + + for (i =3D 0; i < VIR_DOMAIN_HYPERV_LAST; i++) { + if (def->hyperv_features[i] !=3D VIR_TRISTATE_SWITCH_ON) + continue; + + if (virAsprintf(&cpuFeature, "__kvm_hv_%s", + virDomainHypervTypeToString(i)) < 0) + return -1; + + rc =3D virCPUDataCheckFeature(cpu, cpuFeature); + VIR_FREE(cpuFeature); + + if (rc < 0) + return -1; + else if (rc =3D=3D 1) + continue; + + switch ((virDomainHyperv) i) { + case VIR_DOMAIN_HYPERV_RELAXED: + case VIR_DOMAIN_HYPERV_VAPIC: + case VIR_DOMAIN_HYPERV_SPINLOCKS: + VIR_WARN("host doesn't support hyperv '%s' feature", + virDomainHypervTypeToString(i)); + break; + + case VIR_DOMAIN_HYPERV_VPINDEX: + case VIR_DOMAIN_HYPERV_RUNTIME: + case VIR_DOMAIN_HYPERV_SYNIC: + case VIR_DOMAIN_HYPERV_STIMER: + case VIR_DOMAIN_HYPERV_RESET: + case VIR_DOMAIN_HYPERV_VENDOR_ID: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("host doesn't support hyperv '%s' feature"), + virDomainHypervTypeToString(i)); + return -1; + + /* coverity[dead_error_begin] */ + case VIR_DOMAIN_HYPERV_LAST: + break; + } + } + + return 0; +} + + static bool qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3763,39 +3816,8 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, } } =20 - for (i =3D 0; i < VIR_DOMAIN_HYPERV_LAST; i++) { - if (def->hyperv_features[i] =3D=3D VIR_TRISTATE_SWITCH_ON) { - char *cpuFeature; - if (virAsprintf(&cpuFeature, "__kvm_hv_%s", - virDomainHypervTypeToString(i)) < 0) - goto cleanup; - if (!virCPUDataCheckFeature(guestcpu, cpuFeature)) { - switch ((virDomainHyperv) i) { - case VIR_DOMAIN_HYPERV_RELAXED: - case VIR_DOMAIN_HYPERV_VAPIC: - case VIR_DOMAIN_HYPERV_SPINLOCKS: - VIR_WARN("host doesn't support hyperv '%s' feature= ", - virDomainHypervTypeToString(i)); - break; - case VIR_DOMAIN_HYPERV_VPINDEX: - case VIR_DOMAIN_HYPERV_RUNTIME: - case VIR_DOMAIN_HYPERV_SYNIC: - case VIR_DOMAIN_HYPERV_STIMER: - case VIR_DOMAIN_HYPERV_RESET: - case VIR_DOMAIN_HYPERV_VENDOR_ID: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("host doesn't support hyperv '%s'= feature"), - virDomainHypervTypeToString(i)); - goto cleanup; - break; - - /* coverity[dead_error_begin] */ - case VIR_DOMAIN_HYPERV_LAST: - break; - } - } - } - } + if (qemuProcessVerifyHypervFeatures(def, guestcpu) < 0) + goto cleanup; =20 if (def->cpu) { for (i =3D 0; i < def->cpu->nfeatures; i++) { --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1489510910288245.07269288735813; Tue, 14 Mar 2017 10:01:50 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGwUae011328; Tue, 14 Mar 2017 12:58:30 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvuZv002621 for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvtk5018330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 85ABC1062D3; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:45 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/12] qemu: Refactor KVM features check X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The checks are now in a dedicated qemuProcessVerifyKVMFeatures function. Signed-off-by: Jiri Denemark --- src/qemu/qemu_process.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 48820a204..df9489f3e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3779,6 +3779,28 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def, } =20 =20 +static int +qemuProcessVerifyKVMFeatures(virDomainDefPtr def, + virCPUDataPtr cpu) +{ + int rc =3D 0; + + if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] !=3D VIR_TRISTATE_SWI= TCH_ON) + return 0; + + rc =3D virCPUDataCheckFeature(cpu, VIR_CPU_x86_KVM_PV_UNHALT); + + if (rc <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("host doesn't support paravirtual spinlocks")= ); + return -1; + } + + return 0; +} + + static bool qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3808,15 +3830,8 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, goto cleanup; } =20 - if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] =3D=3D VIR_TRISTA= TE_SWITCH_ON) { - if (!virCPUDataCheckFeature(guestcpu, VIR_CPU_x86_KVM_PV_UNHAL= T)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("host doesn't support paravirtual spinloc= ks")); - goto cleanup; - } - } - - if (qemuProcessVerifyHypervFeatures(def, guestcpu) < 0) + if (qemuProcessVerifyKVMFeatures(def, guestcpu) < 0 || + qemuProcessVerifyHypervFeatures(def, guestcpu) < 0) goto cleanup; =20 if (def->cpu) { --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1489510885348252.82617658159518; Tue, 14 Mar 2017 10:01:25 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGw0QA022222; Tue, 14 Mar 2017 12:58:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvuUG002628 for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvtlj027835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 87A081062D4; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:46 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/12] qemu: Refactor CPU features check X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The checks are now in a dedicated qemuProcessVerifyCPUFeatures function. Signed-off-by: Jiri Denemark --- src/qemu/qemu_process.c | 48 ++++++++++++++++++++++++++++++++-------------= --- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index df9489f3e..25371b93d 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3801,6 +3801,36 @@ qemuProcessVerifyKVMFeatures(virDomainDefPtr def, } =20 =20 +static int +qemuProcessVerifyCPUFeatures(virDomainDefPtr def, + virCPUDataPtr cpu) +{ + int rc; + + if (!def->cpu || + (def->cpu->mode =3D=3D VIR_CPU_MODE_CUSTOM && + !def->cpu->model)) + return 0; + + rc =3D virCPUCheckFeature(def->os.arch, def->cpu, "invtsc"); + + if (rc < 0) { + return -1; + } else if (rc =3D=3D 1) { + rc =3D virCPUDataCheckFeature(cpu, "invtsc"); + if (rc <=3D 0) { + if (rc =3D=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("host doesn't support invariant TSC")); + } + return -1; + } + } + + return 0; +} + + static bool qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -3812,7 +3842,6 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv =3D vm->privateData; int rc; bool ret =3D false; - size_t i; =20 switch (arch) { case VIR_ARCH_I686: @@ -3834,21 +3863,8 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, qemuProcessVerifyHypervFeatures(def, guestcpu) < 0) goto cleanup; =20 - if (def->cpu) { - for (i =3D 0; i < def->cpu->nfeatures; i++) { - virCPUFeatureDefPtr feature =3D &def->cpu->features[i]; - - if (feature->policy !=3D VIR_CPU_FEATURE_REQUIRE) - continue; - - if (STREQ(feature->name, "invtsc") && - !virCPUDataCheckFeature(guestcpu, feature->name)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("host doesn't support invariant TSC")= ); - goto cleanup; - } - } - } + if (qemuProcessVerifyCPUFeatures(def, guestcpu) < 0) + goto cleanup; break; =20 default: --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489510944450296.11471486718574; Tue, 14 Mar 2017 10:02:24 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGwSnM017499; Tue, 14 Mar 2017 12:58:28 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvuT2002629 for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvtHg027836 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8958D1062D5; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:47 +0100 Message-Id: <3756fc97dcc4f2ecbdafd909f44270ee564e0322.1489510598.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/12] qemu: Refactor qemuProcessVerifyGuestCPU X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- src/qemu/qemu_process.c | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 25371b93d..894679373 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3831,50 +3831,44 @@ qemuProcessVerifyCPUFeatures(virDomainDefPtr def, } =20 =20 -static bool +static int qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm, - int asyncJob) + qemuDomainAsyncJob asyncJob) { virDomainDefPtr def =3D vm->def; - virArch arch =3D def->os.arch; - virCPUDataPtr guestcpu =3D NULL; + virCPUDataPtr cpu =3D NULL; qemuDomainObjPrivatePtr priv =3D vm->privateData; int rc; - bool ret =3D false; + int ret =3D -1; =20 - switch (arch) { - case VIR_ARCH_I686: - case VIR_ARCH_X86_64: + if (ARCH_IS_X86(def->os.arch)) { if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) - return false; - rc =3D qemuMonitorGetGuestCPU(priv->mon, arch, &guestcpu); + goto cleanup; + + rc =3D qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu); + if (qemuDomainObjExitMonitor(driver, vm) < 0) - return false; + goto cleanup; =20 if (rc < 0) { if (rc =3D=3D -2) - break; - + ret =3D 0; goto cleanup; } =20 - if (qemuProcessVerifyKVMFeatures(def, guestcpu) < 0 || - qemuProcessVerifyHypervFeatures(def, guestcpu) < 0) + if (qemuProcessVerifyKVMFeatures(def, cpu) < 0 || + qemuProcessVerifyHypervFeatures(def, cpu) < 0) goto cleanup; =20 - if (qemuProcessVerifyCPUFeatures(def, guestcpu) < 0) + if (qemuProcessVerifyCPUFeatures(def, cpu) < 0) goto cleanup; - break; - - default: - break; } =20 - ret =3D true; + ret =3D 0; =20 cleanup: - virCPUDataFree(guestcpu); + virCPUDataFree(cpu); return ret; } =20 @@ -5719,7 +5713,7 @@ qemuProcessLaunch(virConnectPtr conn, goto cleanup; =20 VIR_DEBUG("Detecting if required emulator features are present"); - if (!qemuProcessVerifyGuestCPU(driver, vm, asyncJob)) + if (qemuProcessVerifyGuestCPU(driver, vm, asyncJob) < 0) goto cleanup; =20 VIR_DEBUG("Setting up post-init cgroup restrictions"); --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489510942499884.4199297271177; Tue, 14 Mar 2017 10:02:22 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGwWJS017535; Tue, 14 Mar 2017 12:58:32 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvuEh002627 for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvtnx008609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8BB581062D6; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:48 +0100 Message-Id: <16b8c40cea70ef2d5649524be60c2be5d112ba91.1489510598.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/12] qemu: Use ARCH_IS_X86 in qemuMonitorJSONGetGuestCPU X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- src/qemu/qemu_monitor_json.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3a29f1aa7..733daf096 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6741,22 +6741,19 @@ qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, { int rc; =20 - switch (arch) { - case VIR_ARCH_X86_64: - case VIR_ARCH_I686: + if (ARCH_IS_X86(arch)) { if ((rc =3D qemuMonitorJSONCheckCPUx86(mon)) < 0) return -1; else if (!rc) return -2; =20 return qemuMonitorJSONGetCPUx86Data(mon, "feature-words", data); - - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("CPU definition retrieval isn't supported for '%s= '"), - virArchToString(arch)); - return -1; } + + virReportError(VIR_ERR_INTERNAL_ERROR, + _("CPU definition retrieval isn't supported for '%s'"), + virArchToString(arch)); + return -1; } =20 int --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489510942092875.0358604274461; Tue, 14 Mar 2017 10:02:22 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGwWpC017532; Tue, 14 Mar 2017 12:58:32 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvuqq002646 for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvt90008610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8DAC71062D7; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:49 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/12] qemu: Ask QEMU for filtered CPU features X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" qemuMonitorGetGuestCPU can now optionally create CPU data from filtered-features in addition to feature-words. Signed-off-by: Jiri Denemark --- src/qemu/qemu_monitor.c | 11 ++++++++--- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 25 +++++++++++++++++++++++-- src/qemu/qemu_monitor_json.h | 3 ++- src/qemu/qemu_process.c | 2 +- tests/qemumonitorjsontest.c | 4 ++-- 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index d71f84c80..70e9724c5 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4000,6 +4000,7 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon, * @mon: Pointer to the monitor * @arch: arch of the guest * @data: returns the cpu data + * @disabled: returns the CPU data for features which were disabled by QEMU * * Retrieve the definition of the guest CPU from a running qemu instance. * @@ -4009,15 +4010,19 @@ qemuMonitorSetDomainLog(qemuMonitorPtr mon, int qemuMonitorGetGuestCPU(qemuMonitorPtr mon, virArch arch, - virCPUDataPtr *data) + virCPUDataPtr *data, + virCPUDataPtr *disabled) { - VIR_DEBUG("arch=3D'%s' data=3D'%p'", virArchToString(arch), data); + VIR_DEBUG("arch=3D%s data=3D%p disabled=3D%p", + virArchToString(arch), data, disabled); =20 QEMU_CHECK_MONITOR_JSON(mon); =20 *data =3D NULL; + if (disabled) + *disabled =3D NULL; =20 - return qemuMonitorJSONGetGuestCPU(mon, arch, data); + return qemuMonitorJSONGetGuestCPU(mon, arch, data, disabled); } =20 =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 847e9458a..575d72edd 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1020,7 +1020,8 @@ void qemuMonitorSetDomainLog(qemuMonitorPtr mon, =20 int qemuMonitorGetGuestCPU(qemuMonitorPtr mon, virArch arch, - virCPUDataPtr *data); + virCPUDataPtr *data, + virCPUDataPtr *disabled); =20 int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon); =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 733daf096..553544aea 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6728,6 +6728,7 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon) * @mon: Pointer to the monitor * @arch: arch of the guest * @data: returns the cpu data of the guest + * @disabled: returns the CPU data for features which were disabled by QEMU * * Retrieve the definition of the guest CPU from a running qemu instance. * @@ -6737,8 +6738,11 @@ qemuMonitorJSONCheckCPUx86(qemuMonitorPtr mon) int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, virArch arch, - virCPUDataPtr *data) + virCPUDataPtr *data, + virCPUDataPtr *disabled) { + virCPUDataPtr cpuEnabled =3D NULL; + virCPUDataPtr cpuDisabled =3D NULL; int rc; =20 if (ARCH_IS_X86(arch)) { @@ -6747,13 +6751,30 @@ qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, else if (!rc) return -2; =20 - return qemuMonitorJSONGetCPUx86Data(mon, "feature-words", data); + if (qemuMonitorJSONGetCPUx86Data(mon, "feature-words", + &cpuEnabled) < 0) + goto error; + + if (disabled && + qemuMonitorJSONGetCPUx86Data(mon, "filtered-features", + &cpuDisabled) < 0) + goto error; + + *data =3D cpuEnabled; + if (disabled) + *disabled =3D cpuDisabled; + return 0; } =20 virReportError(VIR_ERR_INTERNAL_ERROR, _("CPU definition retrieval isn't supported for '%s'"), virArchToString(arch)); return -1; + + error: + virCPUDataFree(cpuEnabled); + virCPUDataFree(cpuDisabled); + return -1; } =20 int diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 59d9f098c..2bc2d6ea8 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -475,7 +475,8 @@ int qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon, =20 int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon, virArch arch, - virCPUDataPtr *data); + virCPUDataPtr *data, + virCPUDataPtr *disabled); =20 int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon); =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 894679373..f2aa134d4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3846,7 +3846,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; =20 - rc =3D qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu); + rc =3D qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu, NULL); =20 if (qemuDomainObjExitMonitor(driver, vm) < 0) goto cleanup; diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 402c87d45..d0f9381b3 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -2395,7 +2395,7 @@ testQemuMonitorJSONGetCPUData(const void *opaque) =20 if (qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test), VIR_ARCH_X86_64, - &cpuData) < 0) + &cpuData, NULL) < 0) goto cleanup; =20 if (!(actual =3D virCPUDataFormat(cpuData))) @@ -2438,7 +2438,7 @@ testQemuMonitorJSONGetNonExistingCPUData(const void *= opaque) =20 rv =3D qemuMonitorJSONGetGuestCPU(qemuMonitorTestGetMonitor(test), VIR_ARCH_X86_64, - &cpuData); + &cpuData, NULL); if (rv !=3D -2) { virReportError(VIR_ERR_INTERNAL_ERROR, "Unexpected return value %d, expecting -2", rv); --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1489510953986944.8690703821484; Tue, 14 Mar 2017 10:02:33 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGwb70022287; Tue, 14 Mar 2017 12:58:37 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvupt002648 for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvtAb020477 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8FCCD1062D8; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:50 +0100 Message-Id: <927609b98fa5c475979396e0a9d956ce011508d6.1489510598.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/12] qemu: Update CPU definition according to QEMU X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When starting a domain with custom guest CPU specification QEMU may add or remove some CPU features. There are several reasons for this, e.g., QEMU/KVM does not support some requested features or the definition of the requested CPU model in libvirt's cpu_map.xml differs from the one QEMU is using. We can't really avoid this because CPU models are allowed to change with machine types and libvirt doesn't know (and probably doesn't even want to know) about such changes. Thus when we want to make sure guest ABI doesn't change when a domain gets migrated to another host, we need to update our live CPU definition according to the CPU QEMU created. Once updated, we will change CPU checking to VIR_CPU_CHECK_FULL to make sure the virtual CPU created after migration exactly matches the one on the source. https://bugzilla.redhat.com/show_bug.cgi?id=3D822148 https://bugzilla.redhat.com/show_bug.cgi?id=3D824989 Signed-off-by: Jiri Denemark --- src/cpu/cpu.c | 44 ++++++++++++++++++++++++++++++++++++ src/cpu/cpu.h | 12 ++++++++++ src/cpu/cpu_x86.c | 59 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/libvirt_private.syms | 1 + src/qemu/qemu_process.c | 19 +++++++++++----- 5 files changed, 129 insertions(+), 6 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 5b1940b47..992a0339c 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -713,6 +713,50 @@ virCPUUpdate(virArch arch, =20 =20 /** + * virCPUUpdateLive: + * + * @arch: CPU architecture + * @cpu: guest CPU definition to be updated + * @dataEnabled: CPU data of the virtual CPU + * @dataDisabled: CPU data with features requested by @cpu but disabled by= the + * hypervisor + * + * Update custom mode CPU according to the virtual CPU created by the + * hypervisor. + * + * Returns -1 on error, + * 0 when the CPU was successfully updated, + * 1 when the operation does not make sense on the CPU or it is n= ot + * supported for the given architecture. + */ +int +virCPUUpdateLive(virArch arch, + virCPUDefPtr cpu, + virCPUDataPtr dataEnabled, + virCPUDataPtr dataDisabled) +{ + struct cpuArchDriver *driver; + + VIR_DEBUG("arch=3D%s, cpu=3D%p, dataEnabled=3D%p, dataDisabled=3D%p", + virArchToString(arch), cpu, dataEnabled, dataDisabled); + + if (!(driver =3D cpuGetSubDriver(arch))) + return -1; + + if (!driver->updateLive) + return 1; + + if (cpu->mode !=3D VIR_CPU_MODE_CUSTOM) + return 1; + + if (driver->updateLive(cpu, dataEnabled, dataDisabled) < 0) + return -1; + + return 0; +} + + +/** * virCPUCheckFeature: * * @arch: CPU architecture diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index c329eb134..7d6d3e921 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -87,6 +87,11 @@ typedef int const virCPUDef *host); =20 typedef int +(*virCPUArchUpdateLive)(virCPUDefPtr cpu, + virCPUDataPtr dataEnabled, + virCPUDataPtr dataDisabled); + +typedef int (*virCPUArchCheckFeature)(const virCPUDef *cpu, const char *feature); =20 @@ -122,6 +127,7 @@ struct cpuArchDriver { virCPUArchGetHost getHost; cpuArchBaseline baseline; virCPUArchUpdate update; + virCPUArchUpdateLive updateLive; virCPUArchCheckFeature checkFeature; virCPUArchDataCheckFeature dataCheckFeature; virCPUArchDataFormat dataFormat; @@ -198,6 +204,12 @@ virCPUUpdate(virArch arch, const virCPUDef *host) ATTRIBUTE_NONNULL(2); =20 +int +virCPUUpdateLive(virArch arch, + virCPUDefPtr cpu, + virCPUDataPtr dataEnabled, + virCPUDataPtr dataDisabled) + ATTRIBUTE_NONNULL(2); =20 int virCPUCheckFeature(virArch arch, diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 6719acee2..a43bb2bdf 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2678,6 +2678,64 @@ virCPUx86Update(virCPUDefPtr guest, =20 =20 static int +virCPUx86UpdateLive(virCPUDefPtr cpu, + virCPUDataPtr dataEnabled, + virCPUDataPtr dataDisabled) +{ + virCPUx86MapPtr map; + virCPUx86ModelPtr model =3D NULL; + virCPUx86Data enabled =3D VIR_CPU_X86_DATA_INIT; + virCPUx86Data disabled =3D VIR_CPU_X86_DATA_INIT; + size_t i; + int ret =3D -1; + + if (!(map =3D virCPUx86GetMap())) + return -1; + + if (!(model =3D x86ModelFromCPU(cpu, map, -1))) + goto cleanup; + + if (dataEnabled && + x86DataCopy(&enabled, &dataEnabled->data.x86) < 0) + goto cleanup; + + if (dataDisabled && + x86DataCopy(&disabled, &dataDisabled->data.x86) < 0) + goto cleanup; + + x86DataSubtract(&enabled, &model->data); + + for (i =3D 0; i < map->nfeatures; i++) { + virCPUx86FeaturePtr feature =3D map->features[i]; + + if (x86DataIsSubset(&enabled, &feature->data)) { + VIR_DEBUG("Adding feature '%s' enabled by the hypervisor", + feature->name); + if (virCPUDefUpdateFeature(cpu, feature->name, + VIR_CPU_FEATURE_REQUIRE) < 0) + goto cleanup; + } + + if (x86DataIsSubset(&disabled, &feature->data)) { + VIR_DEBUG("Removing feature '%s' disabled by the hypervisor", + feature->name); + if (virCPUDefUpdateFeature(cpu, feature->name, + VIR_CPU_FEATURE_DISABLE) < 0) + goto cleanup; + } + } + + ret =3D 0; + + cleanup: + x86ModelFree(model); + virCPUx86DataClear(&enabled); + virCPUx86DataClear(&disabled); + return ret; +} + + +static int virCPUx86CheckFeature(const virCPUDef *cpu, const char *name) { @@ -2854,6 +2912,7 @@ struct cpuArchDriver cpuDriverX86 =3D { #endif .baseline =3D x86Baseline, .update =3D virCPUx86Update, + .updateLive =3D virCPUx86UpdateLive, .checkFeature =3D virCPUx86CheckFeature, .dataCheckFeature =3D virCPUx86DataCheckFeature, .dataFormat =3D virCPUx86DataFormat, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4efea0098..0fbbe257f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1009,6 +1009,7 @@ virCPUGetHost; virCPUGetModels; virCPUTranslate; virCPUUpdate; +virCPUUpdateLive; =20 =20 # cpu/cpu_x86.h diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f2aa134d4..3d9ab0cdc 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3832,12 +3832,13 @@ qemuProcessVerifyCPUFeatures(virDomainDefPtr def, =20 =20 static int -qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, - virDomainObjPtr vm, - qemuDomainAsyncJob asyncJob) +qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) { virDomainDefPtr def =3D vm->def; virCPUDataPtr cpu =3D NULL; + virCPUDataPtr disabled =3D NULL; qemuDomainObjPrivatePtr priv =3D vm->privateData; int rc; int ret =3D -1; @@ -3846,7 +3847,7 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) goto cleanup; =20 - rc =3D qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu, NULL); + rc =3D qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu, &disa= bled); =20 if (qemuDomainObjExitMonitor(driver, vm) < 0) goto cleanup; @@ -3863,12 +3864,18 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, =20 if (qemuProcessVerifyCPUFeatures(def, cpu) < 0) goto cleanup; + + if ((rc =3D virCPUUpdateLive(def->os.arch, def->cpu, cpu, disabled= )) < 0) + goto cleanup; + else if (rc =3D=3D 0) + def->cpu->check =3D VIR_CPU_CHECK_FULL; } =20 ret =3D 0; =20 cleanup: virCPUDataFree(cpu); + virCPUDataFree(disabled); return ret; } =20 @@ -5712,8 +5719,8 @@ qemuProcessLaunch(virConnectPtr conn, if (qemuConnectAgent(driver, vm) < 0) goto cleanup; =20 - VIR_DEBUG("Detecting if required emulator features are present"); - if (qemuProcessVerifyGuestCPU(driver, vm, asyncJob) < 0) + VIR_DEBUG("Verifying and updating provided guest CPU"); + if (qemuProcessUpdateLiveGuestCPU(driver, vm, asyncJob) < 0) goto cleanup; =20 VIR_DEBUG("Setting up post-init cgroup restrictions"); --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 12:14:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489510948070866.1963176129105; Tue, 14 Mar 2017 10:02:28 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGwUoc017521; Tue, 14 Mar 2017 12:58:30 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2EGvup2002647 for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2EGvtiY018332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Mar 2017 12:57:56 -0400 Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 91E551062D9; Tue, 14 Mar 2017 17:57:53 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 14 Mar 2017 17:57:51 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/12] qemu: Enforce guest CPU specification X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When guest CPU definition uses VIR_CPU_CHECK_FULL checks, we need to make sure QEMU does not add or remove any features. https://bugzilla.redhat.com/show_bug.cgi?id=3D822148 https://bugzilla.redhat.com/show_bug.cgi?id=3D824989 Signed-off-by: Jiri Denemark --- src/cpu/cpu.c | 3 ++- src/cpu/cpu_x86.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++---= ---- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 992a0339c..1461190ba 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -722,7 +722,8 @@ virCPUUpdate(virArch arch, * hypervisor * * Update custom mode CPU according to the virtual CPU created by the - * hypervisor. + * hypervisor. The function refuses to update the CPU in case cpu->check i= s set + * to VIR_CPU_CHECK_FULL. * * Returns -1 on error, * 0 when the CPU was successfully updated, diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index a43bb2bdf..9e208b094 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2686,6 +2686,10 @@ virCPUx86UpdateLive(virCPUDefPtr cpu, virCPUx86ModelPtr model =3D NULL; virCPUx86Data enabled =3D VIR_CPU_X86_DATA_INIT; virCPUx86Data disabled =3D VIR_CPU_X86_DATA_INIT; + virBuffer bufAdded =3D VIR_BUFFER_INITIALIZER; + virBuffer bufRemoved =3D VIR_BUFFER_INITIALIZER; + char *added =3D NULL; + char *removed =3D NULL; size_t i; int ret =3D -1; =20 @@ -2709,28 +2713,70 @@ virCPUx86UpdateLive(virCPUDefPtr cpu, virCPUx86FeaturePtr feature =3D map->features[i]; =20 if (x86DataIsSubset(&enabled, &feature->data)) { - VIR_DEBUG("Adding feature '%s' enabled by the hypervisor", - feature->name); - if (virCPUDefUpdateFeature(cpu, feature->name, - VIR_CPU_FEATURE_REQUIRE) < 0) + VIR_DEBUG("Feature '%s' enabled by the hypervisor", feature->n= ame); + if (cpu->check =3D=3D VIR_CPU_CHECK_FULL) + virBufferAsprintf(&bufAdded, "%s,", feature->name); + else if (virCPUDefUpdateFeature(cpu, feature->name, + VIR_CPU_FEATURE_REQUIRE) < 0) goto cleanup; } =20 if (x86DataIsSubset(&disabled, &feature->data)) { - VIR_DEBUG("Removing feature '%s' disabled by the hypervisor", - feature->name); - if (virCPUDefUpdateFeature(cpu, feature->name, - VIR_CPU_FEATURE_DISABLE) < 0) + VIR_DEBUG("Feature '%s' disabled by the hypervisor", feature->= name); + if (cpu->check =3D=3D VIR_CPU_CHECK_FULL) + virBufferAsprintf(&bufRemoved, "%s,", feature->name); + else if (virCPUDefUpdateFeature(cpu, feature->name, + VIR_CPU_FEATURE_DISABLE) < 0) goto cleanup; } } =20 + virBufferTrim(&bufAdded, ",", -1); + virBufferTrim(&bufRemoved, ",", -1); + + if (virBufferCheckError(&bufAdded) < 0 || + virBufferCheckError(&bufRemoved) < 0) + goto cleanup; + + added =3D virBufferContentAndReset(&bufAdded); + removed =3D virBufferContentAndReset(&bufRemoved); + + if (added || removed) { + if (added && removed) + virReportError(VIR_ERR_OPERATION_FAILED, + _("guest CPU doesn't match specification: " + "extra features: %s, missing features: %s"), + added, removed); + else if (added) + virReportError(VIR_ERR_OPERATION_FAILED, + _("guest CPU doesn't match specification: " + "extra features: %s"), + added); + else + virReportError(VIR_ERR_OPERATION_FAILED, + _("guest CPU doesn't match specification: " + "missing features: %s"), + removed); + goto cleanup; + } + + if (cpu->check =3D=3D VIR_CPU_CHECK_FULL && + !x86DataIsEmpty(&disabled)) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("guest CPU doesn't match specification")); + goto cleanup; + } + ret =3D 0; =20 cleanup: x86ModelFree(model); virCPUx86DataClear(&enabled); virCPUx86DataClear(&disabled); + VIR_FREE(added); + VIR_FREE(removed); + virBufferFreeAndReset(&bufAdded); + virBufferFreeAndReset(&bufRemoved); return ret; } =20 --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list