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

[libvirt] [PATCH 06/27] Add API for the 'system_powerdown' monitor command



* src/qemu/qemu_driver.c: Remove use of 'system_powerdown'
* src/qemu/qemu_monitor.h, src/qemu/qemu_monitor.c: Add a new
  qemuMonitorSystemPowerdown() api call
---
 src/qemu/qemu_driver.c       |    8 ++------
 src/qemu/qemu_monitor_text.c |   14 ++++++++++++++
 src/qemu/qemu_monitor_text.h |    2 ++
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5ebd4b7..841ab68 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2841,7 +2841,6 @@ cleanup:
 static int qemudDomainShutdown(virDomainPtr dom) {
     struct qemud_driver *driver = dom->conn->privateData;
     virDomainObjPtr vm;
-    char* info;
     int ret = -1;
 
     qemuDriverLock(driver);
@@ -2862,12 +2861,9 @@ static int qemudDomainShutdown(virDomainPtr dom) {
         goto cleanup;
     }
 
-    if (qemudMonitorCommand(vm, "system_powerdown", &info) < 0) {
-        qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
-                         "%s", _("shutdown operation failed"));
+    if (qemuMonitorSystemPowerdown(vm) < 0)
         goto cleanup;
-    }
-    VIR_FREE(info);
+
     ret = 0;
 
 cleanup:
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index ec30e72..ec5f670 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -451,6 +451,20 @@ qemuMonitorStopCPUs(const virDomainObjPtr vm) {
     return 0;
 }
 
+
+int qemuMonitorSystemPowerdown(const virDomainObjPtr vm) {
+    char *info;
+
+    if (qemudMonitorCommand(vm, "system_powerdown", &info) < 0) {
+        qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
+                         "%s", _("system shutdown operation failed"));
+        return -1;
+    }
+    VIR_FREE(info);
+    return 0;
+}
+
+
 int qemuMonitorGetCPUInfo(const virDomainObjPtr vm,
                           int **pids)
 {
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index eb1ba44..342a3f3 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -69,6 +69,8 @@ int qemuMonitorStartCPUs(virConnectPtr conn,
                          const virDomainObjPtr vm);
 int qemuMonitorStopCPUs(const virDomainObjPtr vm);
 
+int qemuMonitorSystemPowerdown(const virDomainObjPtr vm);
+
 int qemuMonitorGetCPUInfo(const virDomainObjPtr vm,
                           int **pids);
 
-- 
1.6.2.5


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