[libvirt] [PATCH] Reboot support for QEMU/KVM

Eduardo Habkost ehabkost at redhat.com
Tue Oct 7 20:55:37 UTC 2008


This patch implements reboot support on qemu_driver.

It is so simple that I am wondering if there is some problem I am missing,
that would be the reason it wasn't implemented yet. I hope not.  :)

Signed-off-by: Eduardo Habkost <ehabkost at redhat.com>
---
 src/qemu_driver.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index a88cb75..9ce53ad 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2182,6 +2182,27 @@ static int qemudDomainShutdown(virDomainPtr dom) {
 }
 
 
+static int qemudDomainReboot(virDomainPtr dom) {
+    struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
+    virDomainObjPtr vm = virDomainFindByID(driver->domains, 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, "system_reset", &info) < 0) {
+        qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+                         "%s", _("reboot operation failed"));
+        return -1;
+    }
+    VIR_FREE(info);
+    return 0;
+}
+
+
 static int qemudDomainDestroy(virDomainPtr dom) {
     struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
     virDomainObjPtr vm = virDomainFindByID(driver->domains, dom->id);
@@ -4032,7 +4053,7 @@ static virDriver qemuDriver = {
     qemudDomainSuspend, /* domainSuspend */
     qemudDomainResume, /* domainResume */
     qemudDomainShutdown, /* domainShutdown */
-    NULL, /* domainReboot */
+    qemudDomainReboot, /* domainReboot */
     qemudDomainDestroy, /* domainDestroy */
     qemudDomainGetOSType, /* domainGetOSType */
     qemudDomainGetMaxMemory, /* domainGetMaxMemory */
-- 
1.5.5.GIT




More information about the libvir-list mailing list