|
|
6ae9ed |
From 83f771b2e5a114d84af3519125408a2da9579391 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <83f771b2e5a114d84af3519125408a2da9579391@dist-git>
|
|
|
6ae9ed |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
6ae9ed |
Date: Fri, 8 Jul 2016 16:44:02 +0200
|
|
|
6ae9ed |
Subject: [PATCH] qemu: Copy complete domain def in qemuDomainDefFormatBuf
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Playing directly with our live definition, updating it, and reverting it
|
|
|
6ae9ed |
back once we are done is very nice and it's quite dangerous too. Let's
|
|
|
6ae9ed |
just make a copy of the domain definition if needed and do all tricks on
|
|
|
6ae9ed |
the copy.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1320470
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
6ae9ed |
(cherry picked from commit b1305a6b8fcb807296a00458c5495ef321553cd0)
|
|
|
6ae9ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
src/conf/domain_conf.c | 10 ++++++----
|
|
|
6ae9ed |
src/qemu/qemu_domain.c | 44 ++++++++++++++++++++++++--------------------
|
|
|
6ae9ed |
2 files changed, 30 insertions(+), 24 deletions(-)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
6ae9ed |
index 78e394d..bb297f6 100644
|
|
|
6ae9ed |
--- a/src/conf/domain_conf.c
|
|
|
6ae9ed |
+++ b/src/conf/domain_conf.c
|
|
|
6ae9ed |
@@ -21032,10 +21032,12 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
|
|
|
6ae9ed |
break;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
|
|
6ae9ed |
- virBufferAsprintf(buf, "
|
|
|
6ae9ed |
- def->data.nix.listen ? "bind" : "connect");
|
|
|
6ae9ed |
- virBufferEscapeString(buf, " path='%s'", def->data.nix.path);
|
|
|
6ae9ed |
- virDomainSourceDefFormatSeclabel(buf, nseclabels, seclabels, flags);
|
|
|
6ae9ed |
+ if (def->data.nix.path) {
|
|
|
6ae9ed |
+ virBufferAsprintf(buf, "
|
|
|
6ae9ed |
+ def->data.nix.listen ? "bind" : "connect");
|
|
|
6ae9ed |
+ virBufferEscapeString(buf, " path='%s'", def->data.nix.path);
|
|
|
6ae9ed |
+ virDomainSourceDefFormatSeclabel(buf, nseclabels, seclabels, flags);
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
break;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
|
|
|
6ae9ed |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
6ae9ed |
index 2a42b1b..e81e63f 100644
|
|
|
6ae9ed |
--- a/src/qemu/qemu_domain.c
|
|
|
6ae9ed |
+++ b/src/qemu/qemu_domain.c
|
|
|
6ae9ed |
@@ -3061,19 +3061,25 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
virBuffer *buf)
|
|
|
6ae9ed |
{
|
|
|
6ae9ed |
int ret = -1;
|
|
|
6ae9ed |
- virCPUDefPtr cpu = NULL;
|
|
|
6ae9ed |
- virCPUDefPtr def_cpu = def->cpu;
|
|
|
6ae9ed |
- virDomainControllerDefPtr *controllers = NULL;
|
|
|
6ae9ed |
- int ncontrollers = 0;
|
|
|
6ae9ed |
+ virDomainDefPtr copy = NULL;
|
|
|
6ae9ed |
virCapsPtr caps = NULL;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+ if (!(flags & (VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_MIGRATABLE)))
|
|
|
6ae9ed |
+ goto format;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (!(copy = virDomainDefCopy(def, caps, driver->xmlopt,
|
|
|
6ae9ed |
+ flags & VIR_DOMAIN_XML_MIGRATABLE)))
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ def = copy;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
/* Update guest CPU requirements according to host CPU */
|
|
|
6ae9ed |
if ((flags & VIR_DOMAIN_XML_UPDATE_CPU) &&
|
|
|
6ae9ed |
- def_cpu &&
|
|
|
6ae9ed |
- (def_cpu->mode != VIR_CPU_MODE_CUSTOM || def_cpu->model)) {
|
|
|
6ae9ed |
+ def->cpu &&
|
|
|
6ae9ed |
+ (def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) {
|
|
|
6ae9ed |
if (!caps->host.cpu ||
|
|
|
6ae9ed |
!caps->host.cpu->model) {
|
|
|
6ae9ed |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
6ae9ed |
@@ -3081,10 +3087,8 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
- if (!(cpu = virCPUDefCopy(def_cpu)) ||
|
|
|
6ae9ed |
- cpuUpdate(cpu, caps->host.cpu) < 0)
|
|
|
6ae9ed |
+ if (cpuUpdate(def->cpu, caps->host.cpu) < 0)
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
- def->cpu = cpu;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if ((flags & VIR_DOMAIN_XML_MIGRATABLE)) {
|
|
|
6ae9ed |
@@ -3141,10 +3145,11 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if (toremove) {
|
|
|
6ae9ed |
- controllers = def->controllers;
|
|
|
6ae9ed |
- ncontrollers = def->ncontrollers;
|
|
|
6ae9ed |
+ virDomainControllerDefPtr *controllers = def->controllers;
|
|
|
6ae9ed |
+ int ncontrollers = def->ncontrollers;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
if (VIR_ALLOC_N(def->controllers, ncontrollers - toremove) < 0) {
|
|
|
6ae9ed |
- controllers = NULL;
|
|
|
6ae9ed |
+ def->controllers = controllers;
|
|
|
6ae9ed |
goto cleanup;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
@@ -3153,23 +3158,22 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
|
|
|
6ae9ed |
if (controllers[i] != usb && controllers[i] != pci)
|
|
|
6ae9ed |
def->controllers[def->ncontrollers++] = controllers[i];
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ VIR_FREE(controllers);
|
|
|
6ae9ed |
+ virDomainControllerDefFree(pci);
|
|
|
6ae9ed |
+ virDomainControllerDefFree(usb);
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
- ret = virDomainDefFormatInternal(def, driver->caps,
|
|
|
6ae9ed |
+ format:
|
|
|
6ae9ed |
+ ret = virDomainDefFormatInternal(def, caps,
|
|
|
6ae9ed |
virDomainDefFormatConvertXMLFlags(flags),
|
|
|
6ae9ed |
buf);
|
|
|
6ae9ed |
|
|
|
6ae9ed |
cleanup:
|
|
|
6ae9ed |
- def->cpu = def_cpu;
|
|
|
6ae9ed |
- virCPUDefFree(cpu);
|
|
|
6ae9ed |
- if (controllers) {
|
|
|
6ae9ed |
- VIR_FREE(def->controllers);
|
|
|
6ae9ed |
- def->controllers = controllers;
|
|
|
6ae9ed |
- def->ncontrollers = ncontrollers;
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
+ virDomainDefFree(copy);
|
|
|
6ae9ed |
virObjectUnref(caps);
|
|
|
6ae9ed |
return ret;
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.9.2
|
|
|
6ae9ed |
|