[Libvir] [patch] qemu/kvm: use_system_powerdown instead of killing the vm hard

Guido Guenther agx at sigxcpu.org
Wed Jan 9 16:39:34 UTC 2008


On Wed, Jan 09, 2008 at 03:56:52PM +0000, Daniel P. Berrange wrote:
> Well there's a 'system_reset'  monitor command, but its unclear if
> its actually working - when i run it, it stops the guest from responding
> to any keyboard input and makes it take 100% CPU, but doesn't reboot :-(
> If that's not suitable i think the ctrl-alt-delete thing is probably the
> best we can do.
system_reset *resets* the machine (like hitting the reset switch). It
doesn't shutdown anything, probaly not what we want. Here's a patch that
does the ctrl-alt-del (on top of the previous domainsShutdown patch).
This looks much more friendly to the filesystem. There are issues in kvm
where after the reboot the ACPI tables are borked, but that's another
issue.

Index: libvirt-0.4.0/src/qemu_driver.c
===================================================================
--- libvirt-0.4.0.orig/src/qemu_driver.c	2008-01-09 16:23:34.000000000 +0000
+++ libvirt-0.4.0/src/qemu_driver.c	2008-01-09 16:24:27.000000000 +0000
@@ -1866,7 +1866,26 @@
         return -1;
     }
     return 0;
+}
+
+
+static int qemudDomainReboot(virDomainPtr dom) {
+    struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
+    struct qemud_vm *vm = qemudFindVMByID(driver, dom->id);
+    char* info;
 
+    if (!vm) {
+        qemudReportError(dom->conn, dom, NULL, VIR_ERR_INVALID_DOMAIN,
+                         "no domain with matching id %d", dom->id);
+        return -1;
+    }
+
+    if (qemudMonitorCommand(driver, vm, "sendkey ctrl-alt-delete", &info) < 0) {
+        qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+                         "reboot operation failed");
+        return -1;
+    }
+    return 0;
 }
 
 
@@ -2877,7 +2896,7 @@
     qemudDomainSuspend, /* domainSuspend */
     qemudDomainResume, /* domainResume */
     qemudDomainShutdown, /* domainShutdown */
-    NULL, /* domainReboot */
+    qemudDomainReboot, /* domainReboot */
     qemudDomainDestroy, /* domainDestroy */
     qemudDomainGetOSType, /* domainGetOSType */
     NULL, /* domainGetMaxMemory */

Cheers,
 -- Guido




More information about the libvir-list mailing list