From: Osier Yang Date: Wed, 14 Mar 2012 15:26:50 +0000 (+0800) Subject: qemu: Update tray status while tray moved event is emitted X-Git-Tag: v0.9.11-rc1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d19e33f976ff24a3d055b8c57677ee628849dde;p=thirdparty%2Flibvirt.git qemu: Update tray status while tray moved event is emitted With this patch, libvirt won't start the guest with the medium source which already ejected by guest when doing migration, or saving/restoring. --- diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 3c785ce055..9d61277cc3 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1038,6 +1038,16 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED, event = virDomainEventTrayChangeNewFromObj(vm, devAlias, reason); + /* Update disk tray status */ + if (reason == VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN) + disk->tray_status = VIR_DOMAIN_DISK_TRAY_OPEN; + else if (reason == VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE) + disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED; + + if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) { + VIR_WARN("Unable to save status on vm %s after tray moved event", + vm->def->name); + } } virDomainObjUnlock(vm);