]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Properly track that backing chain members are readonly
authorPeter Krempa <pkrempa@redhat.com>
Wed, 11 Apr 2018 13:35:02 +0000 (15:35 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 7 May 2018 12:41:20 +0000 (14:41 +0200)
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 <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/conf/domain_conf.c
src/qemu/qemu_driver.c
src/util/virstoragefile.c

index 4e2de46d4502dd7707863458728e190ec634002c..f678e26b28fdc3762beb28e7e104d1b019f0de33 100644 (file)
@@ -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);
index 83fc191085505bb3952ef0417bcfc03ce2395e2e..c129321a5c2564347befe50a507bfe1570e64149 100644 (file)
@@ -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);
index 185427f19c7439bbeba2290b3691b59507398199..b10a40e545c8be96109681c2c6b46e57beba1293 100644 (file)
@@ -3425,6 +3425,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent)
         if (virStorageSourceInitChainElement(ret, parent, true) < 0)
             goto error;
 
+        ret->readonly = true;
         ret->detected = true;
     }