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

[libvirt] [PATCH 3/7] qemu: Move and rename qemuDomainCheckEjectableMedia to qemuProcessRefreshDisks



Move it to a more sane place since it's refreshing data about disks.
---
 src/qemu/qemu_hotplug.c   | 48 ----------------------------------------
 src/qemu/qemu_hotplug.h   |  3 ---
 src/qemu/qemu_migration.c |  2 +-
 src/qemu/qemu_process.c   | 56 ++++++++++++++++++++++++++++++++++++++++++++---
 src/qemu/qemu_process.h   |  5 +++++
 5 files changed, 59 insertions(+), 55 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 5f34a76..286a4a4 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -283,54 +283,6 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
     goto cleanup;
 }

-int
-qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver,
-                              virDomainObjPtr vm,
-                              qemuDomainAsyncJob asyncJob)
-{
-    qemuDomainObjPrivatePtr priv = vm->privateData;
-    virHashTablePtr table = NULL;
-    int ret = -1;
-    size_t i;
-
-    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
-        table = qemuMonitorGetBlockInfo(priv->mon);
-        if (qemuDomainObjExitMonitor(driver, vm) < 0)
-            goto cleanup;
-    }
-
-    if (!table)
-        goto cleanup;
-
-    for (i = 0; i < vm->def->ndisks; i++) {
-        virDomainDiskDefPtr disk = vm->def->disks[i];
-        struct qemuDomainDiskInfo *info;
-
-        if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
-            disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
-                 continue;
-        }
-
-        info = qemuMonitorBlockInfoLookup(table, disk->info.alias);
-        if (!info)
-            goto cleanup;
-
-        if (info->tray_open) {
-            if (virDomainDiskGetSource(disk))
-                ignore_value(virDomainDiskSetSource(disk, NULL));
-
-            disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN;
-        } else {
-            disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;
-        }
-    }
-
-    ret = 0;
-
- cleanup:
-    virHashFree(table);
-    return ret;
-}

 static int
 qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
index 868b4cf..165d345 100644
--- a/src/qemu/qemu_hotplug.h
+++ b/src/qemu/qemu_hotplug.h
@@ -33,9 +33,6 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
                                    virDomainDiskDefPtr disk,
                                    virStorageSourcePtr newsrc,
                                    bool force);
-int qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver,
-                                  virDomainObjPtr vm,
-                                  qemuDomainAsyncJob asyncJob);
 int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
                                      virDomainObjPtr vm,
                                      virDomainControllerDefPtr controller);
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 25093ac..c5b2963 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3263,7 +3263,7 @@ qemuMigrationBegin(virConnectPtr conn,
      * We don't want to require them on the destination.
      */
     if (!(flags & VIR_MIGRATE_OFFLINE) &&
-        qemuDomainCheckEjectableMedia(driver, vm, asyncJob) < 0)
+        qemuProcessRefreshDisks(driver, vm, asyncJob) < 0)
         goto endjob;

     if (!(xml = qemuMigrationBeginPhase(driver, vm, xmlin, dname,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index b2669c0..f2e284f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3306,7 +3306,7 @@ qemuProcessReconnect(void *opaque)
     if (qemuProcessFiltersInstantiate(obj->def))
         goto error;

-    if (qemuDomainCheckEjectableMedia(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
+    if (qemuProcessRefreshDisks(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
         goto error;

     if (qemuRefreshVirtioChannelState(driver, obj) < 0)
@@ -5316,8 +5316,8 @@ qemuProcessLaunch(virConnectPtr conn,
     if (qemuProcessUpdateVideoRamSize(driver, vm, asyncJob) < 0)
         goto cleanup;

-    VIR_DEBUG("Updating ejectable media status");
-    if (qemuDomainCheckEjectableMedia(driver, vm, asyncJob) < 0)
+    VIR_DEBUG("Updating disk data");
+    if (qemuProcessRefreshDisks(driver, vm, asyncJob) < 0)
         goto cleanup;

     if (flags & VIR_QEMU_PROCESS_START_AUTODESTROY &&
@@ -6231,3 +6231,53 @@ bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver,
     cb = virCloseCallbacksGet(driver->closeCallbacks, vm, NULL);
     return cb == qemuProcessAutoDestroy;
 }
+
+
+int
+qemuProcessRefreshDisks(virQEMUDriverPtr driver,
+                        virDomainObjPtr vm,
+                        qemuDomainAsyncJob asyncJob)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    virHashTablePtr table = NULL;
+    int ret = -1;
+    size_t i;
+
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
+        table = qemuMonitorGetBlockInfo(priv->mon);
+        if (qemuDomainObjExitMonitor(driver, vm) < 0)
+            goto cleanup;
+    }
+
+    if (!table)
+        goto cleanup;
+
+    for (i = 0; i < vm->def->ndisks; i++) {
+        virDomainDiskDefPtr disk = vm->def->disks[i];
+        struct qemuDomainDiskInfo *info;
+
+        if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
+            disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
+                 continue;
+        }
+
+        info = qemuMonitorBlockInfoLookup(table, disk->info.alias);
+        if (!info)
+            goto cleanup;
+
+        if (info->tray_open) {
+            if (virDomainDiskGetSource(disk))
+                ignore_value(virDomainDiskSetSource(disk, NULL));
+
+            disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN;
+        } else {
+            disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED;
+        }
+    }
+
+    ret = 0;
+
+ cleanup:
+    virHashFree(table);
+    return ret;
+}
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 623e1e7..61d9f56 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -192,4 +192,9 @@ int qemuRefreshVirtioChannelState(virQEMUDriverPtr driver,
 int qemuProcessRefreshBalloonState(virQEMUDriverPtr driver,
                                    virDomainObjPtr vm,
                                    int asyncJob);
+
+int qemuProcessRefreshDisks(virQEMUDriverPtr driver,
+                            virDomainObjPtr vm,
+                            qemuDomainAsyncJob asyncJob);
+
 #endif /* __QEMU_PROCESS_H__ */
-- 
2.8.2


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