[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 08/10] qemu: snapshot: Skip overlay file creation/interogation if unsupported



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>
---
 src/qemu/qemu_driver.c | 53 ++++++++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0bbde4b52d..6e10b691e9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15326,6 +15326,8 @@ qemuDomainSnapshotDiskDataCollectOne(virQEMUDriverPtr driver,
 {
     char *backingStoreStr;
     virDomainDiskDefPtr persistdisk;
+    bool supportsCreate;
+    bool supportsBacking;

     dd->disk = disk;

@@ -15350,31 +15352,38 @@ qemuDomainSnapshotDiskDataCollectOne(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;
         }
     }

-- 
2.21.0


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]