|
|
3e5111 |
From 910db8ca0b1a92d8d7ed9763b2ced958142dcaa4 Mon Sep 17 00:00:00 2001
|
|
|
3e5111 |
Message-Id: <910db8ca0b1a92d8d7ed9763b2ced958142dcaa4@dist-git>
|
|
|
3e5111 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
Date: Fri, 2 Jun 2017 22:52:03 +0200
|
|
|
3e5111 |
Subject: [PATCH] qemu: Store updated CPU in save cookie
|
|
|
3e5111 |
|
|
|
3e5111 |
Since the domain XML saved in a snapshot or saved image uses the
|
|
|
3e5111 |
original guest CPU definition but we still want to enforce ABI when
|
|
|
3e5111 |
restoring the domain if libvirt and QEMU are new enough, we save the
|
|
|
3e5111 |
live updated CPU definition in a save cookie.
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
3e5111 |
(cherry picked from commit 8c19fbf452372c7c1becf987497525ee8b61abbf)
|
|
|
3e5111 |
|
|
|
3e5111 |
https://bugzilla.redhat.com/show_bug.cgi?id=1441662
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
---
|
|
|
3e5111 |
src/qemu/qemu_domain.c | 22 +++++++++++++++++++---
|
|
|
3e5111 |
src/qemu/qemu_domain.h | 2 ++
|
|
|
3e5111 |
2 files changed, 21 insertions(+), 3 deletions(-)
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
3e5111 |
index 514b56b33c..7897a44634 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_domain.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_domain.c
|
|
|
3e5111 |
@@ -9152,12 +9152,15 @@ qemuDomainSaveCookieDispose(void *obj)
|
|
|
3e5111 |
qemuDomainSaveCookiePtr cookie = obj;
|
|
|
3e5111 |
|
|
|
3e5111 |
VIR_DEBUG("cookie=%p", cookie);
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ virCPUDefFree(cookie->cpu);
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
|
|
|
3e5111 |
qemuDomainSaveCookiePtr
|
|
|
3e5111 |
qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ qemuDomainObjPrivatePtr priv = vm->privateData;
|
|
|
3e5111 |
qemuDomainSaveCookiePtr cookie = NULL;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (qemuDomainInitialize() < 0)
|
|
|
3e5111 |
@@ -9166,7 +9169,10 @@ qemuDomainSaveCookieNew(virDomainObjPtr vm ATTRIBUTE_UNUSED)
|
|
|
3e5111 |
if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
|
|
|
3e5111 |
goto error;
|
|
|
3e5111 |
|
|
|
3e5111 |
- VIR_DEBUG("Save cookie %p", cookie);
|
|
|
3e5111 |
+ if (priv->origCPU && !(cookie->cpu = virCPUDefCopy(vm->def->cpu)))
|
|
|
3e5111 |
+ goto error;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ VIR_DEBUG("Save cookie %p, cpu=%p", cookie, cookie->cpu);
|
|
|
3e5111 |
|
|
|
3e5111 |
return cookie;
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -9188,6 +9194,10 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
|
|
|
3e5111 |
if (!(cookie = virObjectNew(qemuDomainSaveCookieClass)))
|
|
|
3e5111 |
goto error;
|
|
|
3e5111 |
|
|
|
3e5111 |
+ if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST,
|
|
|
3e5111 |
+ &cookie->cpu) < 0)
|
|
|
3e5111 |
+ goto error;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
*obj = (virObjectPtr) cookie;
|
|
|
3e5111 |
return 0;
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -9198,9 +9208,15 @@ qemuDomainSaveCookieParse(xmlXPathContextPtr ctxt ATTRIBUTE_UNUSED,
|
|
|
3e5111 |
|
|
|
3e5111 |
|
|
|
3e5111 |
static int
|
|
|
3e5111 |
-qemuDomainSaveCookieFormat(virBufferPtr buf ATTRIBUTE_UNUSED,
|
|
|
3e5111 |
- virObjectPtr obj ATTRIBUTE_UNUSED)
|
|
|
3e5111 |
+qemuDomainSaveCookieFormat(virBufferPtr buf,
|
|
|
3e5111 |
+ virObjectPtr obj)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ qemuDomainSaveCookiePtr cookie = (qemuDomainSaveCookiePtr) obj;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ if (cookie->cpu &&
|
|
|
3e5111 |
+ virCPUDefFormatBufFull(buf, cookie->cpu, NULL, false) < 0)
|
|
|
3e5111 |
+ return -1;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
return 0;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
|
|
3e5111 |
index 9567458849..2eea7924fb 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_domain.h
|
|
|
3e5111 |
+++ b/src/qemu/qemu_domain.h
|
|
|
3e5111 |
@@ -424,6 +424,8 @@ typedef struct _qemuDomainSaveCookie qemuDomainSaveCookie;
|
|
|
3e5111 |
typedef qemuDomainSaveCookie *qemuDomainSaveCookiePtr;
|
|
|
3e5111 |
struct _qemuDomainSaveCookie {
|
|
|
3e5111 |
virObject parent;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ virCPUDefPtr cpu;
|
|
|
3e5111 |
};
|
|
|
3e5111 |
|
|
|
3e5111 |
qemuDomainSaveCookiePtr qemuDomainSaveCookieNew(virDomainObjPtr vm);
|
|
|
3e5111 |
--
|
|
|
3e5111 |
2.13.1
|
|
|
3e5111 |
|