[PATCH 09/11] New domain state pmsuspended

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

 



This introduces a new domain state pmsuspended to represent
the domain which has been suspended by guest power management,
e.g. (entered itno s3 state). Because a "running" state could
be confused in this case, one will see the guest is paused
actually while playing. And state "paused" is for the domain
which was paused by virDomainSuspend.
---
 include/libvirt/libvirt.h.in |   23 ++++++++++++++++-------
 src/conf/domain_conf.c       |   38 +++++++++++++++++++++++++++++---------
 tools/virsh.c                |   10 ++++++++++
 tools/virsh.pod              |    7 ++++++-
 4 files changed, 61 insertions(+), 17 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index caf5085..12ba63f 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -86,13 +86,15 @@ typedef virDomain *virDomainPtr;
  * A domain may be in different states at a given point in time
  */
 typedef enum {
-     VIR_DOMAIN_NOSTATE = 0, /* no state */
-     VIR_DOMAIN_RUNNING = 1, /* the domain is running */
-     VIR_DOMAIN_BLOCKED = 2, /* the domain is blocked on resource */
-     VIR_DOMAIN_PAUSED  = 3, /* the domain is paused by user */
-     VIR_DOMAIN_SHUTDOWN= 4, /* the domain is being shut down */
-     VIR_DOMAIN_SHUTOFF = 5, /* the domain is shut off */
-     VIR_DOMAIN_CRASHED = 6, /* the domain is crashed */
+     VIR_DOMAIN_NOSTATE = 0,     /* no state */
+     VIR_DOMAIN_RUNNING = 1,     /* the domain is running */
+     VIR_DOMAIN_BLOCKED = 2,     /* the domain is blocked on resource */
+     VIR_DOMAIN_PAUSED  = 3,     /* the domain is paused by user */
+     VIR_DOMAIN_SHUTDOWN= 4,     /* the domain is being shut down */
+     VIR_DOMAIN_SHUTOFF = 5,     /* the domain is shut off */
+     VIR_DOMAIN_CRASHED = 6,     /* the domain is crashed */
+     VIR_DOMAIN_PMSUSPENDED = 7, /* the domain is suspended by guest
+                                    power management */
 
 #ifdef VIR_ENUM_SENTINELS
     /*
@@ -183,6 +185,13 @@ typedef enum {
 #endif
 } virDomainCrashedReason;
 
+typedef enum {
+    VIR_DOMAIN_PMSUSPENDED_UNKNOWN = 0,
+
+#ifdef VIR_ENUM_SENTINELS
+    VIR_DOMAIN_PMSUSPENDED_LAST
+#endif
+} virDomainPMSuspendedReason;
 
 /**
  * virDomainControlState:
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 10174ab..29ff556 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -511,7 +511,8 @@ VIR_ENUM_IMPL(virDomainState, VIR_DOMAIN_LAST,
               "paused",
               "shutdown",
               "shutoff",
-              "crashed")
+              "crashed",
+              "pmsuspended")
 
 /* virDomainSnapshotState is really virDomainState plus one extra state */
 VIR_ENUM_IMPL(virDomainSnapshotState, VIR_DOMAIN_SNAPSHOT_STATE_LAST,
@@ -522,6 +523,7 @@ VIR_ENUM_IMPL(virDomainSnapshotState, VIR_DOMAIN_SNAPSHOT_STATE_LAST,
               "shutdown",
               "shutoff",
               "crashed",
+              "pmsuspended",
               "disk-snapshot")
 
 #define VIR_DOMAIN_NOSTATE_LAST (VIR_DOMAIN_NOSTATE_UNKNOWN + 1)
@@ -14308,14 +14310,32 @@ virDomainObjSetState(virDomainObjPtr dom, virDomainState state, int reason)
     int last = -1;
 
     switch (state) {
-    case VIR_DOMAIN_NOSTATE:    last = VIR_DOMAIN_NOSTATE_LAST;     break;
-    case VIR_DOMAIN_RUNNING:    last = VIR_DOMAIN_RUNNING_LAST;     break;
-    case VIR_DOMAIN_BLOCKED:    last = VIR_DOMAIN_BLOCKED_LAST;     break;
-    case VIR_DOMAIN_PAUSED:     last = VIR_DOMAIN_PAUSED_LAST;      break;
-    case VIR_DOMAIN_SHUTDOWN:   last = VIR_DOMAIN_SHUTDOWN_LAST;    break;
-    case VIR_DOMAIN_SHUTOFF:    last = VIR_DOMAIN_SHUTOFF_LAST;     break;
-    case VIR_DOMAIN_CRASHED:    last = VIR_DOMAIN_CRASHED_LAST;     break;
-    default: last = -1;
+    case VIR_DOMAIN_NOSTATE:
+        last = VIR_DOMAIN_NOSTATE_LAST;
+        break;
+    case VIR_DOMAIN_RUNNING:
+        last = VIR_DOMAIN_RUNNING_LAST;
+        break;
+    case VIR_DOMAIN_BLOCKED:
+        last = VIR_DOMAIN_BLOCKED_LAST;
+        break;
+    case VIR_DOMAIN_PAUSED:
+        last = VIR_DOMAIN_PAUSED_LAST;
+        break;
+    case VIR_DOMAIN_SHUTDOWN:
+        last = VIR_DOMAIN_SHUTDOWN_LAST;
+        break;
+    case VIR_DOMAIN_SHUTOFF:
+        last = VIR_DOMAIN_SHUTOFF_LAST;
+        break;
+    case VIR_DOMAIN_CRASHED:
+        last = VIR_DOMAIN_CRASHED_LAST;
+        break;
+    case VIR_DOMAIN_PMSUSPENDED:
+        last = VIR_DOMAIN_PMSUSPENDED_LAST;
+        break;
+    default:
+        last = -1;
     }
 
     if (last < 0) {
diff --git a/tools/virsh.c b/tools/virsh.c
index 630b77f..7ef9807 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -18817,6 +18817,8 @@ vshDomainStateToString(int state)
         return N_("shut off");
     case VIR_DOMAIN_CRASHED:
         return N_("crashed");
+    case VIR_DOMAIN_PMSUSPENDED:
+        return N_("pmsuspended");
     case VIR_DOMAIN_NOSTATE:
     default:
         ;/*FALLTHROUGH*/
@@ -18930,6 +18932,14 @@ vshDomainStateReasonToString(int state, int reason)
         }
         break;
 
+    case VIR_DOMAIN_PMSUSPENDED:
+        switch ((virDomainPMSuspendedReason) reason) {
+        case VIR_DOMAIN_PMSUSPENDED_UNKNOWN:
+        case VIR_DOMAIN_PMSUSPENDED_LAST:
+            ;
+        }
+        break;
+
     case VIR_DOMAIN_LAST:
         ;
     }
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 64b00ee..88d04a5 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -327,7 +327,7 @@ State is the run state (see below).
 
 B<STATES>
 
-The State field lists 7 states for a domain, and which ones the
+The State field lists 8 states for a domain, and which ones the
 current domain is in.
 
 =over 4
@@ -371,6 +371,11 @@ restart on crash.
 The domain is in process of dying, but hasn't completely shutdown or
 crashed.
 
+=item B<pmsuspended>
+
+The domain has been suspended by guest power management, e.g. entered
+into s3 state.
+
 =back
 
 If I<--managed-save> is specified, then domains that have managed save
-- 
1.7.1

--
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]