[PATCH 2/3] qemuProcessRefreshDisks: Extract update of a single disk

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

 



Extract the logic to update one single disk (without emitting any
events) so that it can be reused when updating the state after a disk
hotplug.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_process.c | 39 ++++++++++++++++++++++++---------------
 src/qemu/qemu_process.h |  3 +++
 2 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0dc49b87d8..7e7178ecec 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -8673,6 +8673,29 @@ qemuProcessAutoDestroy(virDomainObj *dom,
 }


+void
+qemuProcessRefreshDiskProps(virDomainDiskDef *disk,
+                            struct qemuDomainDiskInfo *info)
+{
+    qemuDomainDiskPrivate *diskpriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+
+    if (info->removable) {
+        if (info->empty)
+            virDomainDiskEmptySource(disk);
+
+        if (info->tray) {
+            if (info->tray_open)
+                disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN;
+            else
+                disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;
+        }
+    }
+
+    diskpriv->removable = info->removable;
+    diskpriv->tray = info->tray;
+}
+
+
 int
 qemuProcessRefreshDisks(virDomainObj *vm,
                         virDomainAsyncJob asyncJob)
@@ -8703,21 +8726,7 @@ qemuProcessRefreshDisks(virDomainObj *vm,
         if (!(info = virHashLookup(table, entryname)))
             continue;

-        if (info->removable) {
-            if (info->empty)
-                virDomainDiskEmptySource(disk);
-
-            if (info->tray) {
-                if (info->tray_open)
-                    disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN;
-                else
-                    disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;
-            }
-        }
-
-        /* fill in additional data */
-        diskpriv->removable = info->removable;
-        diskpriv->tray = info->tray;
+        qemuProcessRefreshDiskProps(disk, info);

         if (diskpriv->tray &&
             old_tray_status != disk->tray_status) {
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index b171f0464c..f5c06c2915 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -235,3 +235,6 @@ bool qemuProcessRebootAllowed(const virDomainDef *def);

 void qemuProcessCleanupMigrationJob(virQEMUDriver *driver,
                                     virDomainObj *vm);
+
+void qemuProcessRefreshDiskProps(virDomainDiskDef *disk,
+                                 struct qemuDomainDiskInfo *info);
-- 
2.39.2




[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