|
|
99cbc7 |
From 8f8cc927a643f9bd02ff37f0fe6167e44359fb12 Mon Sep 17 00:00:00 2001
|
|
|
99cbc7 |
Message-Id: <8f8cc927a643f9bd02ff37f0fe6167e44359fb12@dist-git>
|
|
|
99cbc7 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
99cbc7 |
Date: Fri, 16 Aug 2019 14:52:35 +0200
|
|
|
99cbc7 |
Subject: [PATCH] qemu: Pass correct qemuCaps to virDomainDefParseNode
|
|
|
99cbc7 |
MIME-Version: 1.0
|
|
|
99cbc7 |
Content-Type: text/plain; charset=UTF-8
|
|
|
99cbc7 |
Content-Transfer-Encoding: 8bit
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Since qemuDomainDefPostParse callback requires qemuCaps, we need to make
|
|
|
99cbc7 |
sure it gets the capabilities stored in the domain's private data if the
|
|
|
99cbc7 |
domain is running. Passing NULL may cause QEMU capabilities probing to
|
|
|
99cbc7 |
be triggered in case QEMU binary changed in the meantime. When this
|
|
|
99cbc7 |
happens while a running domain object is locked, QMP event delivered to
|
|
|
99cbc7 |
the domain before QEMU capabilities probing finishes will deadlock the
|
|
|
99cbc7 |
event loop.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Several general snapshot and checkpoint APIs were lazily passing NULL as
|
|
|
99cbc7 |
the parseOpaque pointer instead of letting their callers pass the right
|
|
|
99cbc7 |
data. This patch fixes all paths leading to virDomainDefParseNode.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
99cbc7 |
(cherry picked from commit 577a1f98fc84e4152c246695942502ef9a45c7f7)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Conflicts:
|
|
|
99cbc7 |
src/conf/checkpoint_conf.c
|
|
|
99cbc7 |
src/conf/checkpoint_conf.h
|
|
|
99cbc7 |
src/conf/snapshot_conf.c
|
|
|
99cbc7 |
src/conf/snapshot_conf.h
|
|
|
99cbc7 |
src/esx/esx_driver.c
|
|
|
99cbc7 |
src/qemu/qemu_driver.c
|
|
|
99cbc7 |
src/test/test_driver.c
|
|
|
99cbc7 |
src/vbox/vbox_common.c
|
|
|
99cbc7 |
tests/qemudomaincheckpointxml2xmltest.c
|
|
|
99cbc7 |
- no checkpoint APIs
|
|
|
99cbc7 |
- snapshot parsing APIs do not have bool *current parameter
|
|
|
99cbc7 |
|
|
|
99cbc7 |
tests/qemudomainsnapshotxml2xmltest.c
|
|
|
99cbc7 |
- this is called domainsnapshotxml2xmltest.c downstream
|
|
|
99cbc7 |
- snapshot parsing APIs do not have bool *current parameter
|
|
|
99cbc7 |
|
|
|
99cbc7 |
https://bugzilla.redhat.com/show_bug.cgi?id=1731783
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
99cbc7 |
Message-Id: <da71e1d080893d3290d18281cb375588d5bc7e7b.1565959866.git.jdenemar@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
99cbc7 |
---
|
|
|
99cbc7 |
src/conf/snapshot_conf.c | 9 ++++++---
|
|
|
99cbc7 |
src/conf/snapshot_conf.h | 2 ++
|
|
|
99cbc7 |
src/esx/esx_driver.c | 2 +-
|
|
|
99cbc7 |
src/qemu/qemu_driver.c | 10 +++++++---
|
|
|
99cbc7 |
src/test/test_driver.c | 3 ++-
|
|
|
99cbc7 |
src/vbox/vbox_common.c | 4 ++--
|
|
|
99cbc7 |
tests/domainsnapshotxml2xmltest.c | 2 +-
|
|
|
99cbc7 |
7 files changed, 21 insertions(+), 11 deletions(-)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
|
|
|
99cbc7 |
index 9c537ac7d1..75df496201 100644
|
|
|
99cbc7 |
--- a/src/conf/snapshot_conf.c
|
|
|
99cbc7 |
+++ b/src/conf/snapshot_conf.c
|
|
|
99cbc7 |
@@ -203,6 +203,7 @@ static virDomainSnapshotDefPtr
|
|
|
99cbc7 |
virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
|
|
99cbc7 |
virCapsPtr caps,
|
|
|
99cbc7 |
virDomainXMLOptionPtr xmlopt,
|
|
|
99cbc7 |
+ void *parseOpaque,
|
|
|
99cbc7 |
unsigned int flags)
|
|
|
99cbc7 |
{
|
|
|
99cbc7 |
virDomainSnapshotDefPtr def = NULL;
|
|
|
99cbc7 |
@@ -284,7 +285,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
def->dom = virDomainDefParseNode(ctxt->node->doc, domainNode,
|
|
|
99cbc7 |
- caps, xmlopt, NULL, domainflags);
|
|
|
99cbc7 |
+ caps, xmlopt, parseOpaque, domainflags);
|
|
|
99cbc7 |
if (!def->dom)
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
} else {
|
|
|
99cbc7 |
@@ -389,6 +390,7 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml,
|
|
|
99cbc7 |
xmlNodePtr root,
|
|
|
99cbc7 |
virCapsPtr caps,
|
|
|
99cbc7 |
virDomainXMLOptionPtr xmlopt,
|
|
|
99cbc7 |
+ void *parseOpaque,
|
|
|
99cbc7 |
unsigned int flags)
|
|
|
99cbc7 |
{
|
|
|
99cbc7 |
xmlXPathContextPtr ctxt = NULL;
|
|
|
99cbc7 |
@@ -406,7 +408,7 @@ virDomainSnapshotDefParseNode(xmlDocPtr xml,
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
ctxt->node = root;
|
|
|
99cbc7 |
- def = virDomainSnapshotDefParse(ctxt, caps, xmlopt, flags);
|
|
|
99cbc7 |
+ def = virDomainSnapshotDefParse(ctxt, caps, xmlopt, parseOpaque, flags);
|
|
|
99cbc7 |
cleanup:
|
|
|
99cbc7 |
xmlXPathFreeContext(ctxt);
|
|
|
99cbc7 |
return def;
|
|
|
99cbc7 |
@@ -416,6 +418,7 @@ virDomainSnapshotDefPtr
|
|
|
99cbc7 |
virDomainSnapshotDefParseString(const char *xmlStr,
|
|
|
99cbc7 |
virCapsPtr caps,
|
|
|
99cbc7 |
virDomainXMLOptionPtr xmlopt,
|
|
|
99cbc7 |
+ void *parseOpaque,
|
|
|
99cbc7 |
unsigned int flags)
|
|
|
99cbc7 |
{
|
|
|
99cbc7 |
virDomainSnapshotDefPtr ret = NULL;
|
|
|
99cbc7 |
@@ -425,7 +428,7 @@ virDomainSnapshotDefParseString(const char *xmlStr,
|
|
|
99cbc7 |
if ((xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)")))) {
|
|
|
99cbc7 |
xmlKeepBlanksDefault(keepBlanksDefault);
|
|
|
99cbc7 |
ret = virDomainSnapshotDefParseNode(xml, xmlDocGetRootElement(xml),
|
|
|
99cbc7 |
- caps, xmlopt, flags);
|
|
|
99cbc7 |
+ caps, xmlopt, parseOpaque, flags);
|
|
|
99cbc7 |
xmlFreeDoc(xml);
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
xmlKeepBlanksDefault(keepBlanksDefault);
|
|
|
99cbc7 |
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
|
|
|
99cbc7 |
index 20a42bd572..733f1dd071 100644
|
|
|
99cbc7 |
--- a/src/conf/snapshot_conf.h
|
|
|
99cbc7 |
+++ b/src/conf/snapshot_conf.h
|
|
|
99cbc7 |
@@ -106,11 +106,13 @@ typedef enum {
|
|
|
99cbc7 |
virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr,
|
|
|
99cbc7 |
virCapsPtr caps,
|
|
|
99cbc7 |
virDomainXMLOptionPtr xmlopt,
|
|
|
99cbc7 |
+ void *parseOpaque,
|
|
|
99cbc7 |
unsigned int flags);
|
|
|
99cbc7 |
virDomainSnapshotDefPtr virDomainSnapshotDefParseNode(xmlDocPtr xml,
|
|
|
99cbc7 |
xmlNodePtr root,
|
|
|
99cbc7 |
virCapsPtr caps,
|
|
|
99cbc7 |
virDomainXMLOptionPtr xmlopt,
|
|
|
99cbc7 |
+ void *parseOpaque,
|
|
|
99cbc7 |
unsigned int flags);
|
|
|
99cbc7 |
void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def);
|
|
|
99cbc7 |
char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
|
|
99cbc7 |
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
|
|
|
99cbc7 |
index 60aa5fc252..4ef856d71c 100644
|
|
|
99cbc7 |
--- a/src/esx/esx_driver.c
|
|
|
99cbc7 |
+++ b/src/esx/esx_driver.c
|
|
|
99cbc7 |
@@ -4156,7 +4156,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
|
|
|
99cbc7 |
return NULL;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
def = virDomainSnapshotDefParseString(xmlDesc, priv->caps,
|
|
|
99cbc7 |
- priv->xmlopt, 0);
|
|
|
99cbc7 |
+ priv->xmlopt, NULL, 0);
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (!def)
|
|
|
99cbc7 |
return NULL;
|
|
|
99cbc7 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
99cbc7 |
index cc7210c6f4..00213a5f80 100644
|
|
|
99cbc7 |
--- a/src/qemu/qemu_driver.c
|
|
|
99cbc7 |
+++ b/src/qemu/qemu_driver.c
|
|
|
99cbc7 |
@@ -431,8 +431,12 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
|
|
|
99cbc7 |
int ret = -1;
|
|
|
99cbc7 |
virCapsPtr caps = NULL;
|
|
|
99cbc7 |
int direrr;
|
|
|
99cbc7 |
+ qemuDomainObjPrivatePtr priv;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
virObjectLock(vm);
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ priv = vm->privateData;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
if (virAsprintf(&snapDir, "%s/%s", baseDir, vm->def->name) < 0) {
|
|
|
99cbc7 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
99cbc7 |
_("Failed to allocate memory for "
|
|
|
99cbc7 |
@@ -472,6 +476,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
|
|
|
99cbc7 |
|
|
|
99cbc7 |
def = virDomainSnapshotDefParseString(xmlStr, caps,
|
|
|
99cbc7 |
qemu_driver->xmlopt,
|
|
|
99cbc7 |
+ priv->qemuCaps,
|
|
|
99cbc7 |
flags);
|
|
|
99cbc7 |
if (def == NULL) {
|
|
|
99cbc7 |
/* Nothing we can do here, skip this one */
|
|
|
99cbc7 |
@@ -15312,6 +15317,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|
|
99cbc7 |
if (!(vm = qemuDomObjFromDomain(domain)))
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+ priv = vm->privateData;
|
|
|
99cbc7 |
cfg = virQEMUDriverGetConfig(driver);
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (virDomainSnapshotCreateXMLEnsureACL(domain->conn, vm->def, flags) < 0)
|
|
|
99cbc7 |
@@ -15336,7 +15342,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|
|
99cbc7 |
parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (!(def = virDomainSnapshotDefParseString(xmlDesc, caps, driver->xmlopt,
|
|
|
99cbc7 |
- parse_flags)))
|
|
|
99cbc7 |
+ priv->qemuCaps, parse_flags)))
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
/* reject snapshot names containing slashes or starting with dot as
|
|
|
99cbc7 |
@@ -15405,8 +15411,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|
|
|
99cbc7 |
|
|
|
99cbc7 |
qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE);
|
|
|
99cbc7 |
|
|
|
99cbc7 |
- priv = vm->privateData;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
if (redefine) {
|
|
|
99cbc7 |
if (virDomainSnapshotRedefinePrep(domain, vm, &def, &snap,
|
|
|
99cbc7 |
driver->xmlopt,
|
|
|
99cbc7 |
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
|
|
|
99cbc7 |
index 1a25b37729..1c7e4f4982 100644
|
|
|
99cbc7 |
--- a/src/test/test_driver.c
|
|
|
99cbc7 |
+++ b/src/test/test_driver.c
|
|
|
99cbc7 |
@@ -849,6 +849,7 @@ testParseDomainSnapshots(testDriverPtr privconn,
|
|
|
99cbc7 |
def = virDomainSnapshotDefParseNode(ctxt->doc, node,
|
|
|
99cbc7 |
privconn->caps,
|
|
|
99cbc7 |
privconn->xmlopt,
|
|
|
99cbc7 |
+ NULL,
|
|
|
99cbc7 |
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
|
|
|
99cbc7 |
VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL |
|
|
|
99cbc7 |
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE);
|
|
|
99cbc7 |
@@ -6403,6 +6404,7 @@ testDomainSnapshotCreateXML(virDomainPtr domain,
|
|
|
99cbc7 |
if (!(def = virDomainSnapshotDefParseString(xmlDesc,
|
|
|
99cbc7 |
privconn->caps,
|
|
|
99cbc7 |
privconn->xmlopt,
|
|
|
99cbc7 |
+ NULL,
|
|
|
99cbc7 |
parse_flags)))
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
@@ -6808,7 +6810,6 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
static virHypervisorDriver testHypervisorDriver = {
|
|
|
99cbc7 |
.name = "Test",
|
|
|
99cbc7 |
.connectOpen = testConnectOpen, /* 0.1.1 */
|
|
|
99cbc7 |
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
|
|
|
99cbc7 |
index 664650f217..46d2b7afa3 100644
|
|
|
99cbc7 |
--- a/src/vbox/vbox_common.c
|
|
|
99cbc7 |
+++ b/src/vbox/vbox_common.c
|
|
|
99cbc7 |
@@ -5496,7 +5496,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
|
|
|
99cbc7 |
VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT, NULL);
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (!(def = virDomainSnapshotDefParseString(xmlDesc, data->caps,
|
|
|
99cbc7 |
- data->xmlopt,
|
|
|
99cbc7 |
+ data->xmlopt, NULL,
|
|
|
99cbc7 |
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
|
|
|
99cbc7 |
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE)))
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
@@ -6941,7 +6941,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
def = virDomainSnapshotDefParseString(defXml,
|
|
|
99cbc7 |
data->caps,
|
|
|
99cbc7 |
- data->xmlopt,
|
|
|
99cbc7 |
+ data->xmlopt, NULL,
|
|
|
99cbc7 |
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
|
|
|
99cbc7 |
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE);
|
|
|
99cbc7 |
if (!def) {
|
|
|
99cbc7 |
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c
|
|
|
99cbc7 |
index 2b594e626c..a4e31de811 100644
|
|
|
99cbc7 |
--- a/tests/domainsnapshotxml2xmltest.c
|
|
|
99cbc7 |
+++ b/tests/domainsnapshotxml2xmltest.c
|
|
|
99cbc7 |
@@ -96,7 +96,7 @@ testCompareXMLToXMLFiles(const char *inxml,
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
if (!(def = virDomainSnapshotDefParseString(inXmlData, driver.caps,
|
|
|
99cbc7 |
- driver.xmlopt,
|
|
|
99cbc7 |
+ driver.xmlopt, NULL,
|
|
|
99cbc7 |
flags)))
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
--
|
|
|
99cbc7 |
2.22.1
|
|
|
99cbc7 |
|