From nobody Mon Dec 15 03:16:38 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1496824702232870.9873668536685; Wed, 7 Jun 2017 01:38:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB19561D16; Wed, 7 Jun 2017 08:38:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6861117A85; Wed, 7 Jun 2017 08:38:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1D3434A496; Wed, 7 Jun 2017 08:38:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v578brtK004877 for ; Wed, 7 Jun 2017 04:37:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3050118364; Wed, 7 Jun 2017 08:37:53 +0000 (UTC) Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 042BD183A9 for ; Wed, 7 Jun 2017 08:37:52 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 8B1BB10193A; Wed, 7 Jun 2017 10:37:46 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AB19561D16 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AB19561D16 From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 7 Jun 2017 10:37:40 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 15/20] qemu: Remember CPU def from domain start 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-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 07 Jun 2017 08:38:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When starting a domain we update the guest CPU definition to match what QEMU actually provided (since it is allowed to add or removed some features unless check=3D'full' is specified). Let's store the original CPU in domain private data so that we can use it to provide a backward compatible domain XML. Signed-off-by: Jiri Denemark Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/libvirt_private.syms | 2 ++ src/qemu/qemu_domain.c | 7 +++++++ src/qemu/qemu_domain.h | 4 ++++ src/qemu/qemu_process.c | 13 +++++++++++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 003db6b65..b6c828fc2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -77,9 +77,11 @@ virCPUDefCopyModelFilter; virCPUDefCopyWithoutModel; virCPUDefFormat; virCPUDefFormatBuf; +virCPUDefFormatBufFull; virCPUDefFree; virCPUDefFreeFeatures; virCPUDefFreeModel; +virCPUDefIsEqual; virCPUDefParseXML; virCPUDefStealModel; virCPUDefUpdateFeature; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 80e9fea98..ba8079ba0 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1726,6 +1726,8 @@ qemuDomainObjPrivateFree(void *data) VIR_FREE(priv->migTLSAlias); qemuDomainMasterKeyFree(priv); =20 + virCPUDefFree(priv->origCPU); + VIR_FREE(priv); } =20 @@ -1881,6 +1883,8 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, virBufferEscapeString(buf, "\n", priv->channelTargetDir); =20 + virCPUDefFormatBufFull(buf, priv->origCPU, NULL, false); + return 0; } =20 @@ -2149,6 +2153,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, if (qemuDomainSetPrivatePathsOld(driver, vm) < 0) goto error; =20 + if (virCPUDefParseXML(ctxt, "./cpu", VIR_CPU_TYPE_GUEST, &priv->origCP= U) < 0) + goto error; + return 0; =20 error: diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index cc2e21bdf..f6dad4378 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -293,6 +293,10 @@ struct _qemuDomainObjPrivate { /* Used when fetching/storing the current 'tls-creds' migration settin= g */ /* (not to be saved in our private XML). */ char *migTLSAlias; + + /* CPU def used to start the domain when it differs from the one actua= lly + * provided by QEMU. */ + virCPUDefPtr origCPU; }; =20 # define QEMU_DOMAIN_PRIVATE(vm) \ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 32ba8e373..c06349474 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3915,6 +3915,7 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver, qemuDomainObjPrivatePtr priv =3D vm->privateData; int rc; int ret =3D -1; + virCPUDefPtr orig =3D NULL; =20 if (ARCH_IS_X86(def->os.arch)) { if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) @@ -3945,10 +3946,17 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driv= er, if (qemuProcessVerifyCPUFeatures(def, cpu) < 0) goto cleanup; =20 - if ((rc =3D virCPUUpdateLive(def->os.arch, def->cpu, cpu, disabled= )) < 0) + if (!(orig =3D virCPUDefCopy(def->cpu))) goto cleanup; - else if (rc =3D=3D 0) + + if ((rc =3D virCPUUpdateLive(def->os.arch, def->cpu, cpu, disabled= )) < 0) { + goto cleanup; + } else if (rc =3D=3D 0) { + if (!virCPUDefIsEqual(def->cpu, orig, false)) + VIR_STEAL_PTR(priv->origCPU, orig); + def->cpu->check =3D VIR_CPU_CHECK_FULL; + } } =20 ret =3D 0; @@ -3956,6 +3964,7 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver, cleanup: virCPUDataFree(cpu); virCPUDataFree(disabled); + virCPUDefFree(orig); return ret; } =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list