From nobody Mon Feb 9 12:10:16 2026 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 1496654858885562.2196709137544; Mon, 5 Jun 2017 02:27:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31AB53DBE1; Mon, 5 Jun 2017 09:27:37 +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 0914A81975; Mon, 5 Jun 2017 09:27:37 +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 B9F564A492; Mon, 5 Jun 2017 09:27:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v559RBML002029 for ; Mon, 5 Jun 2017 05:27:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8F3B18B1C9; Mon, 5 Jun 2017 09:27:11 +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 5FDC27E9F6 for ; Mon, 5 Jun 2017 09:27:11 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B939610CD03; Mon, 5 Jun 2017 11:27:04 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 31AB53DBE1 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.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 31AB53DBE1 From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 5 Jun 2017 11:27:02 +0200 Message-Id: <4a87f7d2fae5883e53e9e7194ba8e9f9f7a9eec9.1496654484.git.jdenemar@redhat.com> 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.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/15] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 05 Jun 2017 09:27:38 +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 --- 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