Re: [PATCH 8/9] qemu: Update domain status to paused while suspend event is emitted

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

 



On 03/11/2012 10:37 PM, Paolo Bonzini wrote:
Il 05/03/2012 11:25, Osier Yang ha scritto:
This introduces a new paused reason VIR_DOMAIN_PAUSED_SUSPEND,
and new suspend event type VIR_DOMAIN_EVENT_SUSPENDED_SUSPEND.

While a SUSPEND event occurs, the running domain status will be
transferred to "paused" with reason "VIR_DOMAIN_PAUSED_SUSPEND",
and a new domain lifecycle event emitted with type
VIR_DOMAIN_EVENT_SUSPENDED_SUSPEND.
---

Does "virsh resume" correctly wakeup such a domain?

Ah, yes, I prohibited the situation waking up a domain which
wasn't paused by SUSPEND event. But here I forgot it.

If not, perhaps a
different state should be added so that "virsh resume" can look at the
state and issue the appropriate monitor command (or alternatively, it
could be considered a QEMU bug).

We have the paused reason. And the patch which should be
squashed in in the attachment.

But I'm interested in trying if "virsh resume" wakeup a
domain pasued by SUSPEND event.

Osier
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7b6e747..594c774 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1480,6 +1480,7 @@ static int qemudDomainResume(virDomainPtr dom) {
     virDomainObjPtr vm;
     int ret = -1;
     virDomainEventPtr event = NULL;
+    int reason;
 
     qemuDriverLock(driver);
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -1500,18 +1501,25 @@ static int qemudDomainResume(virDomainPtr dom) {
                         "%s", _("domain is not running"));
         goto endjob;
     }
-    if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
-        if (qemuProcessStartCPUs(driver, vm, dom->conn,
-                                 VIR_DOMAIN_RUNNING_UNPAUSED,
-                                 QEMU_ASYNC_JOB_NONE) < 0) {
-            if (virGetLastError() == NULL)
-                qemuReportError(VIR_ERR_OPERATION_FAILED,
-                                "%s", _("resume operation failed"));
+    if (virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED) {
+        if (reason != VIR_DOMAIN_PAUSED_SUSPEND) {
+            if (qemuProcessStartCPUs(driver, vm, dom->conn,
+                                     VIR_DOMAIN_RUNNING_UNPAUSED,
+                                     QEMU_ASYNC_JOB_NONE) < 0) {
+                if (virGetLastError() == NULL)
+                    qemuReportError(VIR_ERR_OPERATION_FAILED,
+                                    "%s", _("resume operation failed"));
+                goto endjob;
+            }
+            event = virDomainEventNewFromObj(vm,
+                                             VIR_DOMAIN_EVENT_RESUMED,
+                                             VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
+        } else {
+            qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                            _("domain paused from guest side can't be resumed, "
+                              "you might want to wakeup it"));
             goto endjob;
         }
-        event = virDomainEventNewFromObj(vm,
-                                         VIR_DOMAIN_EVENT_RESUMED,
-                                         VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
     }
     if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
         goto endjob;
--
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]