195 lines
6.5 KiB
Diff
195 lines
6.5 KiB
Diff
From: Peter Krempa <pkrempa@redhat.com>
|
|
Date: Mon, 23 May 2016 14:00:35 +0200
|
|
Subject: [PATCH] qemu: Move and rename qemuDomainCheckEjectableMedia to
|
|
qemuProcessRefreshDisks
|
|
|
|
Move it to a more sane place since it's refreshing data about disks.
|
|
|
|
(cherry picked from commit d9bee413ade28e1e43ef222c7aaaa3c6d6fda0f1)
|
|
---
|
|
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 b8ab068..a58dd57 100644
|
|
--- a/src/qemu/qemu_hotplug.c
|
|
+++ b/src/qemu/qemu_hotplug.c
|
|
@@ -267,54 +267,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 4140da3..fe7c563 100644
|
|
--- a/src/qemu/qemu_hotplug.h
|
|
+++ b/src/qemu/qemu_hotplug.h
|
|
@@ -34,9 +34,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 8d2ca3b..6808a9c 100644
|
|
--- a/src/qemu/qemu_migration.c
|
|
+++ b/src/qemu/qemu_migration.c
|
|
@@ -3273,7 +3273,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 2698178..f13d902 100644
|
|
--- a/src/qemu/qemu_process.c
|
|
+++ b/src/qemu/qemu_process.c
|
|
@@ -3603,7 +3603,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)
|
|
@@ -5457,8 +5457,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 &&
|
|
@@ -6380,3 +6380,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 d5f50f2..7c67274 100644
|
|
--- a/src/qemu/qemu_process.h
|
|
+++ b/src/qemu/qemu_process.h
|
|
@@ -193,4 +193,9 @@ int qemuProcessSetupIOThread(virDomainObjPtr vm,
|
|
|
|
int qemuRefreshVirtioChannelState(virQEMUDriverPtr driver,
|
|
virDomainObjPtr vm);
|
|
+
|
|
+int qemuProcessRefreshDisks(virQEMUDriverPtr driver,
|
|
+ virDomainObjPtr vm,
|
|
+ qemuDomainAsyncJob asyncJob);
|
|
+
|
|
#endif /* __QEMU_PROCESS_H__ */
|