From nobody Fri May 16 08:20:05 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 149682475299634.07421878638365; Wed, 7 Jun 2017 01:39:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9AC12DC8EF; Wed, 7 Jun 2017 08:39:11 +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 6F8E57D971; Wed, 7 Jun 2017 08:39:11 +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 E22EB5EC69; Wed, 7 Jun 2017 08:38:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v578brKn004902 for ; Wed, 7 Jun 2017 04:37:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6F62A60E3F; 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 4228C82788 for ; Wed, 7 Jun 2017 08:37:52 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9D86910193E; Wed, 7 Jun 2017 10:37:46 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9AC12DC8EF Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.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 9AC12DC8EF From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 7 Jun 2017 10:37:44 +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.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 19/20] qemu: Store updated CPU in save cookie 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 07 Jun 2017 08:39:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Since the domain XML saved in a snapshot or saved image uses the original guest CPU definition but we still want to enforce ABI when restoring the domain if libvirt and QEMU are new enough, we save the live updated CPU definition in a save cookie. Signed-off-by: Jiri Denemark Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/qemu/qemu_domain.c | 22 +++++++++++++++++++--- src/qemu/qemu_domain.h | 2 ++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0da44f066..ec43d06d7 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9167,12 +9167,15 @@ qemuDomainSaveCookieDispose(void *obj) qemuDomainSaveCookiePtr cookie =3D obj; =20 VIR_DEBUG("cookie=3D%p", cookie); + + virCPUDefFree(cookie->cpu); } =20 =20 qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED) { + qemuDomainObjPrivatePtr priv =3D vm->privateData; qemuDomainSaveCookiePtr cookie =3D NULL; =20 if (qemuDomainInitialize() < 0) @@ -9181,7 +9184,10 @@ qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE= _UNUSED) if (!(cookie =3D virObjectNew(qemuDomainSaveCookieClass))) goto error; =20 - VIR_DEBUG("Save cookie %p", cookie); + if (priv->origCPU && !(cookie->cpu =3D virCPUDefCopy(vm->def->cpu))) + goto error; + + VIR_DEBUG("Save cookie %p, cpu=3D%p", cookie, cookie->cpu); =20 return cookie; =20 @@ -9203,6 +9209,10 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt AT= TRIBUTE_UNUSED, if (!(cookie =3D virObjectNew(qemuDomainSaveCookieClass))) goto error; =20 + if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, + &cookie->cpu) < 0) + goto error; + *obj =3D (virObjectPtr) cookie; return 0; =20 @@ -9213,9 +9223,15 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt AT= TRIBUTE_UNUSED, =20 =20 static int -qemuDomainSaveCookieFormat(virBufferPtr buf ATTRIBUTE_UNUSED, - virObjectPtr obj ATTRIBUTE_UNUSED) +qemuDomainSaveCookieFormat(virBufferPtr buf, + virObjectPtr obj) { + qemuDomainSaveCookiePtr cookie =3D (qemuDomainSaveCookiePtr) obj; + + if (cookie->cpu && + virCPUDefFormatBufFull(buf, cookie->cpu, NULL, false) < 0) + return -1; + return 0; } =20 diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 08c0b32f1..44c466cb7 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -424,6 +424,8 @@ typedef struct _qemuDomainSaveCookie qemuDomainSaveCook= ie; typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr; struct _qemuDomainSaveCookie { virObject parent; + + virCPUDefPtr cpu; }; =20 qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list