[PATCH 02/11] qemu: domain: Allow overriding disk source in qemuDomainDetermineDiskChain

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

 



When we need to detect a chain for a image which will become the new
source for a disk (e.g. after a disk media change or a blockjob) we'd
need to replace disk->src temporarily to do so.

Move the 'disksrc' temporary variable as an argument and adjust callers.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_blockjob.c |  2 +-
 src/qemu/qemu_domain.c   | 15 ++++++++++++++-
 src/qemu/qemu_domain.h   |  1 +
 src/qemu/qemu_driver.c   |  2 +-
 src/qemu/qemu_hotplug.c  |  4 ++--
 src/qemu/qemu_process.c  |  4 ++--
 6 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index 9b638b7ef6..e69aa1b6fb 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -287,7 +287,7 @@ qemuBlockJobEventProcessLegacyCompleted(virQEMUDriverPtr driver,
     disk->mirrorJob = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
     disk->src->id = 0;
     virStorageSourceBackingStoreClear(disk->src);
-    ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk, true));
+    ignore_value(qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true));
     ignore_value(qemuBlockNodeNamesDetect(driver, vm, asyncJob));
     qemuBlockJobTerminate(job);
 }
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8e3d0dd374..e42b93e051 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8938,14 +8938,27 @@ qemuDomainStorageAlias(const char *device, int depth)
 }


+/**
+ * qemuDomainDetermineDiskChain:
+ * @driver: qemu driver object
+ * @vm: domain object
+ * @disk: disk definition
+ * @disksrc: source to determine the chain for, may be NULL
+ * @report_broken: report broken chain verbosely
+ *
+ * Prepares and initializes the backing chain of disk @disk. In cases where
+ * a new source is to be associated with @disk the @disksrc parameter can be
+ * used to override the source. If @report_broken is true missing images
+ * in the backing chain are reported.
+ */
 int
 qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
                              virDomainObjPtr vm,
                              virDomainDiskDefPtr disk,
+                             virStorageSourcePtr disksrc,
                              bool report_broken)
 {
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
-    virStorageSourcePtr disksrc = NULL; /* disk source */
     virStorageSourcePtr src; /* iterator for the backing chain declared in XML */
     virStorageSourcePtr n; /* iterator for the backing chain detected from disk */
     qemuDomainObjPrivatePtr priv = vm->privateData;
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index defbffbf94..e7c5a0a49c 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -742,6 +742,7 @@ int qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
 int qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
                                  virDomainObjPtr vm,
                                  virDomainDiskDefPtr disk,
+                                 virStorageSourcePtr disksrc,
                                  bool report_broken);

 bool qemuDomainDiskChangeSupported(virDomainDiskDefPtr disk,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 90319261ff..b254e96131 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17183,7 +17183,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
         oldsrc = disk->src;
         disk->src = disk->mirror;

-        if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0)
+        if (qemuDomainDetermineDiskChain(driver, vm, disk, disk->mirror, true) < 0)
             goto cleanup;

         if (disk->mirror->format &&
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1df80fcab6..615105d595 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -820,7 +820,7 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,

     sharedAdded = true;

-    if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0)
+    if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true) < 0)
         goto cleanup;

     if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0)
@@ -1197,7 +1197,7 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriverPtr driver,
     if (qemuSetUnprivSGIO(dev) < 0)
         goto cleanup;

-    if (qemuDomainDetermineDiskChain(driver, vm, disk, true) < 0)
+    if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true) < 0)
         goto cleanup;

     for (i = 0; i < vm->def->ndisks; i++) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 8120201eb6..fb596d960f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6210,7 +6210,7 @@ qemuProcessPrepareHostStorage(virQEMUDriverPtr driver,
         if (qemuDomainDiskIsMissingLocalOptional(disk) && cold_boot)
             VIR_INFO("optional disk '%s' source file is missing, "
                      "skip checking disk chain", disk->dst);
-        else if (qemuDomainDetermineDiskChain(driver, vm, disk, true) >= 0)
+        else if (qemuDomainDetermineDiskChain(driver, vm, disk, NULL, true) >= 0)
             continue;

         if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) >= 0)
@@ -8032,7 +8032,7 @@ qemuProcessReconnect(void *opaque)
              * qemuDomainDetermineDiskChain with @report_broken == false
              * to guarantee best-effort domain reconnect */
             virStorageSourceBackingStoreClear(disk->src);
-            if (qemuDomainDetermineDiskChain(driver, obj, disk, false) < 0)
+            if (qemuDomainDetermineDiskChain(driver, obj, disk, NULL, false) < 0)
                 goto error;
         } else {
             VIR_DEBUG("skipping backing chain detection for '%s'", disk->dst);
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux