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 d9bee413ad)
This commit is contained in:
Peter Krempa 2016-05-23 14:00:35 +02:00 committed by Cole Robinson
parent 7200212536
commit a829ef0323
5 changed files with 59 additions and 55 deletions

View File

@ -267,54 +267,6 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
goto cleanup; 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 static int
qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,

View File

@ -34,9 +34,6 @@ int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
virStorageSourcePtr newsrc, virStorageSourcePtr newsrc,
bool force); bool force);
int qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob);
int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainControllerDefPtr controller); virDomainControllerDefPtr controller);

View File

@ -3273,7 +3273,7 @@ qemuMigrationBegin(virConnectPtr conn,
* We don't want to require them on the destination. * We don't want to require them on the destination.
*/ */
if (!(flags & VIR_MIGRATE_OFFLINE) && if (!(flags & VIR_MIGRATE_OFFLINE) &&
qemuDomainCheckEjectableMedia(driver, vm, asyncJob) < 0) qemuProcessRefreshDisks(driver, vm, asyncJob) < 0)
goto endjob; goto endjob;
if (!(xml = qemuMigrationBeginPhase(driver, vm, xmlin, dname, if (!(xml = qemuMigrationBeginPhase(driver, vm, xmlin, dname,

View File

@ -3603,7 +3603,7 @@ qemuProcessReconnect(void *opaque)
if (qemuProcessFiltersInstantiate(obj->def)) if (qemuProcessFiltersInstantiate(obj->def))
goto error; goto error;
if (qemuDomainCheckEjectableMedia(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) if (qemuProcessRefreshDisks(driver, obj, QEMU_ASYNC_JOB_NONE) < 0)
goto error; goto error;
if (qemuRefreshVirtioChannelState(driver, obj) < 0) if (qemuRefreshVirtioChannelState(driver, obj) < 0)
@ -5457,8 +5457,8 @@ qemuProcessLaunch(virConnectPtr conn,
if (qemuProcessUpdateVideoRamSize(driver, vm, asyncJob) < 0) if (qemuProcessUpdateVideoRamSize(driver, vm, asyncJob) < 0)
goto cleanup; goto cleanup;
VIR_DEBUG("Updating ejectable media status"); VIR_DEBUG("Updating disk data");
if (qemuDomainCheckEjectableMedia(driver, vm, asyncJob) < 0) if (qemuProcessRefreshDisks(driver, vm, asyncJob) < 0)
goto cleanup; goto cleanup;
if (flags & VIR_QEMU_PROCESS_START_AUTODESTROY && if (flags & VIR_QEMU_PROCESS_START_AUTODESTROY &&
@ -6380,3 +6380,53 @@ bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver,
cb = virCloseCallbacksGet(driver->closeCallbacks, vm, NULL); cb = virCloseCallbacksGet(driver->closeCallbacks, vm, NULL);
return cb == qemuProcessAutoDestroy; 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;
}

View File

@ -193,4 +193,9 @@ int qemuProcessSetupIOThread(virDomainObjPtr vm,
int qemuRefreshVirtioChannelState(virQEMUDriverPtr driver, int qemuRefreshVirtioChannelState(virQEMUDriverPtr driver,
virDomainObjPtr vm); virDomainObjPtr vm);
int qemuProcessRefreshDisks(virQEMUDriverPtr driver,
virDomainObjPtr vm,
qemuDomainAsyncJob asyncJob);
#endif /* __QEMU_PROCESS_H__ */ #endif /* __QEMU_PROCESS_H__ */