]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: snapshot: Skip overlay file creation/interogation if unsupported
authorPeter Krempa <pkrempa@redhat.com>
Tue, 13 Aug 2019 10:23:00 +0000 (12:23 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 6 Sep 2019 06:12:21 +0000 (08:12 +0200)
With blockdev we'll be able to support protocols which are not supported
by the storage backends in libvirt. This means that we have to be able
to skip the creation and relative storage path reading if it's not
supported. This will make it impossible to use relative backing for
network protocols but that would be almost insane anyways.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_driver.c

index 9480df2b3963ac975d3d5041a8e6acf1cdf2707e..a332db333a860a877c80bc6328c71fcf109a1979 100644 (file)
@@ -15316,6 +15316,8 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
 {
     char *backingStoreStr;
     virDomainDiskDefPtr persistdisk;
+    bool supportsCreate;
+    bool supportsBacking;
 
     dd->disk = disk;
 
@@ -15343,31 +15345,38 @@ qemuDomainSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
             return -1;
     }
 
-    if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0)
-        return -1;
-
-    dd->initialized = true;
+    supportsCreate = virStorageFileSupportsCreate(dd->src);
+    supportsBacking = virStorageFileSupportsBackingChainTraversal(dd->src);
 
-    /* relative backing store paths need to be updated so that relative
-     * block commit still works */
-    if (reuse) {
-        if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr) < 0)
+    if (supportsCreate || supportsBacking) {
+        if (qemuDomainStorageFileInit(driver, vm, dd->src, NULL) < 0)
             return -1;
-        if (backingStoreStr != NULL) {
-            if (virStorageIsRelative(backingStoreStr))
-                VIR_STEAL_PTR(dd->relPath, backingStoreStr);
-            else
-                VIR_FREE(backingStoreStr);
-        }
-    } else {
-        /* pre-create the image file so that we can label it before handing it to qemu */
-        if (dd->src->type != VIR_STORAGE_TYPE_BLOCK) {
-            if (virStorageFileCreate(dd->src) < 0) {
-                virReportSystemError(errno, _("failed to create image file '%s'"),
-                                     NULLSTR(dd->src->path));
-                return -1;
+
+        dd->initialized = true;
+
+        /* relative backing store paths need to be updated so that relative
+         * block commit still works */
+        if (reuse) {
+            if (supportsBacking) {
+                if (virStorageFileGetBackingStoreStr(dd->src, &backingStoreStr) < 0)
+                    return -1;
+                if (backingStoreStr != NULL) {
+                    if (virStorageIsRelative(backingStoreStr))
+                        VIR_STEAL_PTR(dd->relPath, backingStoreStr);
+                    else
+                        VIR_FREE(backingStoreStr);
+                }
+            }
+        } else {
+            /* pre-create the image file so that we can label it before handing it to qemu */
+            if (supportsCreate && dd->src->type != VIR_STORAGE_TYPE_BLOCK) {
+                if (virStorageFileCreate(dd->src) < 0) {
+                    virReportSystemError(errno, _("failed to create image file '%s'"),
+                                         NULLSTR(dd->src->path));
+                    return -1;
+                }
+                dd->created = true;
             }
-            dd->created = true;
         }
     }