]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add API for 'stop' monitor command
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 23 Sep 2009 11:14:53 +0000 (12:14 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 29 Sep 2009 10:51:06 +0000 (11:51 +0100)
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h: Add a new
  qemuMonitorStopCPUs() API
* src/qemu/qemu_driver.c: Replace direct monitor commands for 'stop'
  with qemuMonitorStopCPUs()

src/qemu/qemu_driver.c
src/qemu/qemu_monitor_text.c
src/qemu/qemu_monitor_text.h

index 1717cbd08fd5b7294be278da2f31f75e6f89e5f4..793e8dbce1770fc3ab8389a83a5aa2dd22056ca3 100644 (file)
@@ -2749,7 +2749,6 @@ cleanup:
 
 static int qemudDomainSuspend(virDomainPtr dom) {
     struct qemud_driver *driver = dom->conn->privateData;
-    char *info;
     virDomainObjPtr vm;
     int ret = -1;
     virDomainEventPtr event = NULL;
@@ -2770,17 +2769,12 @@ static int qemudDomainSuspend(virDomainPtr dom) {
         goto cleanup;
     }
     if (vm->state != VIR_DOMAIN_PAUSED) {
-        if (qemudMonitorCommand(vm, "stop", &info) < 0) {
-            qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
-                             "%s", _("suspend operation failed"));
+        if (qemuMonitorStopCPUs(vm) < 0)
             goto cleanup;
-        }
         vm->state = VIR_DOMAIN_PAUSED;
-        qemudDebug("Reply %s", info);
         event = virDomainEventNewFromObj(vm,
                                          VIR_DOMAIN_EVENT_SUSPENDED,
                                          VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
-        VIR_FREE(info);
     }
     if (virDomainSaveStatus(dom->conn, driver->stateDir, vm) < 0)
         goto cleanup;
@@ -3365,14 +3359,9 @@ static int qemudDomainSave(virDomainPtr dom,
     /* Pause */
     if (vm->state == VIR_DOMAIN_RUNNING) {
         header.was_running = 1;
-        if (qemudMonitorCommand(vm, "stop", &info) < 0) {
-            qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
-                             "%s", _("suspend operation failed"));
+        if (qemuMonitorStopCPUs(vm) < 0)
             goto cleanup;
-        }
         vm->state = VIR_DOMAIN_PAUSED;
-        qemudDebug("Reply %s", info);
-        VIR_FREE(info);
     }
 
     /* Get XML for the domain */
@@ -3527,13 +3516,8 @@ static int qemudDomainCoreDump(virDomainPtr dom,
 
     /* Pause domain for non-live dump */
     if (vm->state == VIR_DOMAIN_RUNNING) {
-        if (qemudMonitorCommand (vm, "stop", &info) < 0) {
-            qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
-                             "%s", _("suspending before dump failed"));
+        if (qemuMonitorStopCPUs(vm) < 0)
             goto cleanup;
-        }
-        DEBUG ("%s: stop reply: %s", vm->def->name, info);
-        VIR_FREE(info);
         paused = 1;
     }
 
@@ -6747,13 +6731,8 @@ qemudDomainMigratePerform (virDomainPtr dom,
 
     if (!(flags & VIR_MIGRATE_LIVE)) {
         /* Pause domain for non-live migration */
-        if (qemudMonitorCommand (vm, "stop", &info) < 0) {
-            qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
-                             "%s", _("off-line migration specified, but suspend operation failed"));
+        if (qemuMonitorStopCPUs(vm) < 0)
             goto cleanup;
-        }
-        DEBUG ("%s: stop reply: %s", vm->def->name, info);
-        VIR_FREE(info);
         paused = 1;
 
         event = virDomainEventNewFromObj(vm,
index 1414e657ad35403d1fc7525fcb65b2b65b68816c..2a301e5442b21ffcb0ac86c57d25da47052cb016 100644 (file)
@@ -438,6 +438,19 @@ qemuMonitorStartCPUs(virConnectPtr conn,
 }
 
 
+int
+qemuMonitorStopCPUs(const virDomainObjPtr vm) {
+    char *info;
+
+    if (qemudMonitorCommand(vm, "stop", &info) < 0) {
+        qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_FAILED,
+                         "%s", _("cannot stop CPU execution"));
+        return -1;
+    }
+    VIR_FREE(info);
+    return 0;
+}
+
 int qemuMonitorGetCPUInfo(const virDomainObjPtr vm,
                           int **pids)
 {
index 6c78ca8fc40dccadfbafde29023213298e2979c0..3504e8d3163bdf7979dd7456c19d336cad6aa1ba 100644 (file)
@@ -67,6 +67,7 @@ int qemudMonitorCommandExtra(const virDomainObjPtr vm,
 
 int qemuMonitorStartCPUs(virConnectPtr conn,
                          const virDomainObjPtr vm);
+int qemuMonitorStopCPUs(const virDomainObjPtr vm);
 
 int qemuMonitorGetCPUInfo(const virDomainObjPtr vm,
                           int **pids);