提交 85c82612 编写于 作者: P Peter Krempa

qemu: hotplug: Don't wait if cdrom tray is opened forcibly

Qemu always opens the tray if forced to. Skip the waiting step in such
case.

This also helps if qemu does not report the tray change event when
opening the cdrom forcibly (the documentation says that the event will
not be sent although qemu in fact does trigger it even if @force is
selceted).

This is a workaround for a qemu issue where qemu does not send the tray
change event in some cases (after migration with empty closed locked
drive) and thus renders the cdrom useless from libvirt's point of view.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1368368
上级 6e19cc59
...@@ -149,8 +149,7 @@ static int ...@@ -149,8 +149,7 @@ static int
qemuHotplugWaitForTrayEject(virQEMUDriverPtr driver, qemuHotplugWaitForTrayEject(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainDiskDefPtr disk, virDomainDiskDefPtr disk,
const char *driveAlias, const char *driveAlias)
bool force)
{ {
unsigned long long now; unsigned long long now;
int rc; int rc;
...@@ -175,7 +174,7 @@ qemuHotplugWaitForTrayEject(virQEMUDriverPtr driver, ...@@ -175,7 +174,7 @@ qemuHotplugWaitForTrayEject(virQEMUDriverPtr driver,
/* re-issue ejection command to pop out the media */ /* re-issue ejection command to pop out the media */
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
rc = qemuMonitorEjectMedia(qemuDomainGetMonitor(vm), driveAlias, force); rc = qemuMonitorEjectMedia(qemuDomainGetMonitor(vm), driveAlias, false);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
return -1; return -1;
...@@ -238,9 +237,9 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver, ...@@ -238,9 +237,9 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
/* If the tray is present and tray change event is supported wait for it to open. */ /* If the tray is present and tray change event is supported wait for it to open. */
if (diskPriv->tray && if (!force && diskPriv->tray &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_TRAY_MOVED)) { virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_TRAY_MOVED)) {
rc = qemuHotplugWaitForTrayEject(driver, vm, disk, driveAlias, force); rc = qemuHotplugWaitForTrayEject(driver, vm, disk, driveAlias);
if (rc < 0) if (rc < 0)
goto error; goto error;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册