]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: process: move disk presence checking to host setup function
authorPeter Krempa <pkrempa@redhat.com>
Tue, 3 Oct 2017 10:38:19 +0000 (12:38 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 5 Oct 2017 07:46:46 +0000 (09:46 +0200)
Checking of disk presence accesses storage on the host so it should be
done from the host setup function. Move the code to new function called
qemuProcessPrepareHostStorage and remove qemuDomainCheckDiskPresence.

src/qemu/qemu_domain.c
src/qemu/qemu_process.c

index d3d5dbac66238e6a0c67e35df676041fda4bb704..a8c718f62df4eb2c54ab1506f9727833a8189adb 100644 (file)
@@ -5681,47 +5681,6 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr driver,
 }
 
 
-int
-qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
-                            virDomainObjPtr vm,
-                            unsigned int flags)
-{
-    size_t i;
-    bool pretend = flags & VIR_QEMU_PROCESS_START_PRETEND;
-    bool cold_boot = flags & VIR_QEMU_PROCESS_START_COLD;
-
-    VIR_DEBUG("Checking for disk presence");
-    for (i = vm->def->ndisks; i > 0; i--) {
-        size_t idx = i - 1;
-        virDomainDiskDefPtr disk = vm->def->disks[idx];
-        virStorageFileFormat format = virDomainDiskGetFormat(disk);
-
-        if (pretend)
-            continue;
-
-        if (virStorageSourceIsEmpty(disk->src))
-            continue;
-
-        /* There is no need to check the backing chain for disks
-         * without backing support, the fact that the file exists is
-         * more than enough */
-        if (virStorageSourceIsLocalStorage(disk->src) &&
-            format > VIR_STORAGE_FILE_NONE &&
-            format < VIR_STORAGE_FILE_BACKING &&
-            virFileExists(virDomainDiskGetSource(disk)))
-            continue;
-
-        if (qemuDomainDetermineDiskChain(driver, vm, disk, true, true) >= 0)
-            continue;
-
-        if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) >= 0)
-            continue;
-
-        return -1;
-    }
-
-    return 0;
-}
 
 /*
  * The vm must be locked when any of the following cleanup functions is
index 8fa53f7e2d366c162998cbc2ec23a2de4ba6d051..f29228bc1bbad573b2cf694e1df9400a023cc94a 100644 (file)
@@ -5394,10 +5394,6 @@ qemuProcessPrepareDomain(virConnectPtr conn,
     if (qemuProcessPrepareDomainStorage(conn, driver, vm, cfg, flags) < 0)
         goto cleanup;
 
-    /* Drop possibly missing disks from the definition. */
-    if (qemuDomainCheckDiskPresence(driver, vm, flags) < 0)
-        goto cleanup;
-
     VIR_DEBUG("Create domain masterKey");
     if (qemuDomainMasterKeyCreate(vm) < 0)
         goto cleanup;
@@ -5444,6 +5440,44 @@ qemuProcessPrepareDomain(virConnectPtr conn,
 }
 
 
+static int
+qemuProcessPrepareHostStorage(virQEMUDriverPtr driver,
+                              virDomainObjPtr vm,
+                              unsigned int flags)
+{
+    size_t i;
+    bool cold_boot = flags & VIR_QEMU_PROCESS_START_COLD;
+
+    for (i = vm->def->ndisks; i > 0; i--) {
+        size_t idx = i - 1;
+        virDomainDiskDefPtr disk = vm->def->disks[idx];
+        virStorageFileFormat format = virDomainDiskGetFormat(disk);
+
+        if (virStorageSourceIsEmpty(disk->src))
+            continue;
+
+        /* There is no need to check the backing chain for disks
+         * without backing support, the fact that the file exists is
+         * more than enough */
+        if (virStorageSourceIsLocalStorage(disk->src) &&
+            format > VIR_STORAGE_FILE_NONE &&
+            format < VIR_STORAGE_FILE_BACKING &&
+            virFileExists(virDomainDiskGetSource(disk)))
+            continue;
+
+        if (qemuDomainDetermineDiskChain(driver, vm, disk, true, true) >= 0)
+            continue;
+
+        if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) >= 0)
+            continue;
+
+        return -1;
+    }
+
+    return 0;
+}
+
+
 /**
  * qemuProcessPrepareHost:
  * @driver: qemu driver
@@ -5536,6 +5570,10 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
     if (qemuDomainWriteMasterKeyFile(driver, vm) < 0)
         goto cleanup;
 
+    VIR_DEBUG("Preparing disks (host)");
+    if (qemuProcessPrepareHostStorage(driver, vm, flags) < 0)
+        goto cleanup;
+
     ret = 0;
  cleanup:
     virObjectUnref(cfg);