qemu: hotplug: Skip waiting for tray opening if qemu doesn't notify us

If qemu doesn't support DEVICE_TRAY_MOVED event the code that attempts
to change media would attempt to re-eject the tray even if it wouldn't
be notified when the tray opened. Add a capability bit and skip retrying
for old qemus.

(cherry picked from commit 833ae6b4356934e7b779c4be01bd2bf051930dde)
This commit is contained in:
Peter Krempa 2016-04-29 13:49:13 +02:00 committed by Cole Robinson
parent 5247bd3aaf
commit 7dffff778e
13 changed files with 22 additions and 0 deletions

View File

@ -321,6 +321,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"qxl-vga.vram64_size_mb", /* 215 */
"chardev-logfile",
"debug-threads",
"device-tray-moved-event",
);
@ -1493,6 +1494,7 @@ struct virQEMUCapsStringFlags virQEMUCapsEvents[] = {
{ "DEVICE_DELETED", QEMU_CAPS_DEVICE_DEL_EVENT },
{ "MIGRATION", QEMU_CAPS_MIGRATION_EVENT },
{ "VSERPORT_CHANGE", QEMU_CAPS_VSERPORT_CHANGE },
{ "DEVICE_TRAY_MOVED", QEMU_CAPS_DEVICE_TRAY_MOVED },
};
struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {

View File

@ -351,6 +351,7 @@ typedef enum {
QEMU_CAPS_QXL_VGA_VRAM64, /* -device qxl-vga.vram64_size_mb */
QEMU_CAPS_CHARDEV_LOGFILE, /* -chardev logfile=xxxx */
QEMU_CAPS_NAME_DEBUG_THREADS, /* Is -name debug-threads= available */
QEMU_CAPS_DEVICE_TRAY_MOVED, /* DEVICE_TRAY_MOVED event */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;

View File

@ -202,6 +202,15 @@ qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
if (qemuDomainObjExitMonitor(driver, vm) < 0)
goto cleanup;
/* skip all retrying if qemu doesn't notify us on tray change */
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE_TRAY_MOVED)) {
if (rc == 0)
break;
if (rc < 0)
goto error;
}
if (rc < 0) {
/* we've already tried, error out */
if (ejectRetry)

View File

@ -114,4 +114,5 @@
<flag name='virtio-net'/>
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>

View File

@ -129,4 +129,5 @@
<flag name='virtio-net'/>
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>

View File

@ -130,4 +130,5 @@
<flag name='virtio-net'/>
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>

View File

@ -139,4 +139,5 @@
<flag name='virtio-net'/>
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>

View File

@ -145,4 +145,5 @@
<flag name='virtio-net'/>
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>

View File

@ -145,4 +145,5 @@
<flag name='virtio-net'/>
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>

View File

@ -163,4 +163,5 @@
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='debug-threads'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>

View File

@ -174,4 +174,5 @@
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='debug-threads'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>

View File

@ -175,4 +175,5 @@
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='debug-threads'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>

View File

@ -178,4 +178,5 @@
<flag name='qxl.vram64_size_mb'/>
<flag name='qxl-vga.vram64_size_mb'/>
<flag name='debug-threads'/>
<flag name='device-tray-moved-event'/>
</qemuCaps>