From: Peter Krempa Date: Wed, 11 Apr 2018 13:35:02 +0000 (+0200) Subject: storage: Properly track that backing chain members are readonly X-Git-Tag: v4.4.0-rc1~292 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3817fa10c4ad9888798ac653d73166d8435bf45c;p=thirdparty%2Flibvirt.git storage: Properly track that backing chain members are readonly Everything besides the top of the chain is readonly. Track this when parsing the XML and detecting the chain from the disk. Also fix the state when taking snapshots. All other cases where the top image is changed already preserve the readonly state from the original image. Signed-off-by: Peter Krempa Reviewed-by: John Ferlan --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4e2de46d45..f678e26b28 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8735,6 +8735,9 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt, if (VIR_ALLOC(backingStore) < 0) goto cleanup; + /* backing store is always read-only */ + backingStore->readonly = true; + /* terminator does not have a type */ if (!(type = virXMLPropString(ctxt->node, "type"))) { VIR_STEAL_PTR(src->backingStore, backingStore); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 83fc191085..c129321a5c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -14680,6 +14680,9 @@ qemuDomainSnapshotUpdateDiskSources(qemuDomainSnapshotDiskDataPtr dd, if (dd->initialized) virStorageFileDeinit(dd->src); + /* the old disk image is now readonly */ + dd->disk->src->readonly = true; + VIR_STEAL_PTR(dd->disk->src->relPath, dd->relPath); VIR_STEAL_PTR(dd->src->backingStore, dd->disk->src); VIR_STEAL_PTR(dd->disk->src, dd->src); diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 185427f19c..b10a40e545 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3425,6 +3425,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent) if (virStorageSourceInitChainElement(ret, parent, true) < 0) goto error; + ret->readonly = true; ret->detected = true; }