From d6580c10a113300a22394c54cf271e8545c1d0a6 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 31 Jan 2017 13:10:30 +0100 Subject: [PATCH] conf: domain: Format out user provided backing chains in XML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a user configures the backing chain in the XML we should not ignore it. We already do parse it but don't format it out. As a safety-precaution don't attempt to format detected chain into the inactive XML. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 8 +- .../disk-backing-chains-inactive.xml | 35 ++++++++ .../disk-backing-chains-index-active.xml | 80 +++++++++++++++++++ .../disk-backing-chains-index-inactive.xml | 80 +++++++++++++++++++ .../disk-backing-chains-noindex-active.xml | 80 +++++++++++++++++++ .../disk-backing-chains-noindex-inactive.xml | 80 +++++++++++++++++++ .../disk-mirror-inactive.xml | 4 + .../disk-mirror-old-inactive.xml | 4 + 8 files changed, 369 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 123abec1ba..26f35fa4ee 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23997,10 +23997,15 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, unsigned int flags) { const char *format; + bool inactive = flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE; if (!backingStore) return 0; + /* don't write detected backing chain members to inactive xml */ + if (inactive && backingStore->detected) + return 0; + if (backingStore->type == VIR_STORAGE_TYPE_NONE) { virBufferAddLit(buf, "\n"); return 0; @@ -24266,8 +24271,7 @@ virDomainDiskDefFormat(virBufferPtr buf, /* Don't format backingStore to inactive XMLs until the code for * persistent storage of backing chains is ready. */ - if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) && - virDomainDiskBackingStoreFormat(buf, def->src->backingStore, + if (virDomainDiskBackingStoreFormat(buf, def->src->backingStore, xmlopt, flags) < 0) return -1; diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-inactive.xml b/tests/qemuxml2xmloutdata/disk-backing-chains-inactive.xml index a9db12ba4d..c1af58ff6f 100644 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-inactive.xml +++ b/tests/qemuxml2xmloutdata/disk-backing-chains-inactive.xml @@ -19,6 +19,10 @@ + + + +
@@ -27,6 +31,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -35,6 +64,7 @@ +
@@ -48,6 +78,11 @@ + + + + +
diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml b/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml index db70ae2b53..724afa4e83 100644 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml +++ b/tests/qemuxml2xmloutdata/disk-backing-chains-index-active.xml @@ -19,6 +19,10 @@ + + + +
@@ -27,6 +31,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -35,6 +64,7 @@ +
@@ -48,6 +78,11 @@ + + + + +
@@ -60,6 +95,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-index-inactive.xml b/tests/qemuxml2xmloutdata/disk-backing-chains-index-inactive.xml index db70ae2b53..29d1ad002d 100644 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-index-inactive.xml +++ b/tests/qemuxml2xmloutdata/disk-backing-chains-index-inactive.xml @@ -19,6 +19,10 @@ + + + +
@@ -27,6 +31,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -35,6 +64,7 @@ +
@@ -48,6 +78,11 @@ + + + + +
@@ -60,6 +95,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-noindex-active.xml b/tests/qemuxml2xmloutdata/disk-backing-chains-noindex-active.xml index db70ae2b53..29d1ad002d 100644 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-noindex-active.xml +++ b/tests/qemuxml2xmloutdata/disk-backing-chains-noindex-active.xml @@ -19,6 +19,10 @@ + + + +
@@ -27,6 +31,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -35,6 +64,7 @@ +
@@ -48,6 +78,11 @@ + + + + +
@@ -60,6 +95,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/tests/qemuxml2xmloutdata/disk-backing-chains-noindex-inactive.xml b/tests/qemuxml2xmloutdata/disk-backing-chains-noindex-inactive.xml index db70ae2b53..29d1ad002d 100644 --- a/tests/qemuxml2xmloutdata/disk-backing-chains-noindex-inactive.xml +++ b/tests/qemuxml2xmloutdata/disk-backing-chains-noindex-inactive.xml @@ -19,6 +19,10 @@ + + + +
@@ -27,6 +31,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -35,6 +64,7 @@ +
@@ -48,6 +78,11 @@ + + + + +
@@ -60,6 +95,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/tests/qemuxml2xmloutdata/disk-mirror-inactive.xml b/tests/qemuxml2xmloutdata/disk-mirror-inactive.xml index cc7aed0873..5c9b72738d 100644 --- a/tests/qemuxml2xmloutdata/disk-mirror-inactive.xml +++ b/tests/qemuxml2xmloutdata/disk-mirror-inactive.xml @@ -17,12 +17,14 @@ +
+
@@ -30,12 +32,14 @@ +
+
diff --git a/tests/qemuxml2xmloutdata/disk-mirror-old-inactive.xml b/tests/qemuxml2xmloutdata/disk-mirror-old-inactive.xml index cc7aed0873..5c9b72738d 100644 --- a/tests/qemuxml2xmloutdata/disk-mirror-old-inactive.xml +++ b/tests/qemuxml2xmloutdata/disk-mirror-old-inactive.xml @@ -17,12 +17,14 @@ +
+
@@ -30,12 +32,14 @@ +
+
-- GitLab