diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 123abec1ba6d92cff28f8174624110ae81b8a5c7..26f35fa4eec51c2be323ee84b1ee002ba2470759 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 a9db12ba4d40e812a3ce7a371930ea74f9b6b657..c1af58ff6f57fb223ca0b8024621aef1fee7e716 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 db70ae2b53f869dfc1f0fee90ca592971f0112e5..724afa4e8311919c7b00474f29408f437ff283a3 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 db70ae2b53f869dfc1f0fee90ca592971f0112e5..29d1ad002d9cefd2e8a8aeb3ea2d2b6e209810d7 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 db70ae2b53f869dfc1f0fee90ca592971f0112e5..29d1ad002d9cefd2e8a8aeb3ea2d2b6e209810d7 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 db70ae2b53f869dfc1f0fee90ca592971f0112e5..29d1ad002d9cefd2e8a8aeb3ea2d2b6e209810d7 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 cc7aed0873d06908348b31d45e0c948c4da9d797..5c9b72738ddaf1603ae4e1a2f99904ec208b39f4 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 cc7aed0873d06908348b31d45e0c948c4da9d797..5c9b72738ddaf1603ae4e1a2f99904ec208b39f4 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 @@
+
+