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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]