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

[libvirt] [PATCH v3 01/14] Add event and state details for post-copy



VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY and VIR_DOMAIN_PAUSED_POSTCOPY are
used on the source host once migration enters post-copy mode (which
means the domain gets paused on the source. After the destination host
takes over the execution of the domain, its virtual CPUs are resumed and
the domain enters VIR_DOMAIN_RUNNING_POSTCOPY state and
VIR_DOMAIN_EVENT_RESUMED_POSTCOPY event is emitted.

In case migration fails during post-copy mode and none of the hosts have
complete state of the domain, both domains will remain paused with
VIR_DOMAIN_PAUSED_POSTCOPY_FAILED reason and an upper layer may decide
what to do.

Signed-off-by: Jiri Denemark <jdenemar redhat com>
---

Notes:
    ACKed in version 2
    
    Version 3:
    - no change
    
    Version 2:
    - no change

 examples/object-events/event-test.c | 9 +++++++++
 include/libvirt/libvirt-domain.h    | 7 +++++++
 src/conf/domain_conf.c              | 7 +++++--
 tools/virsh-domain-monitor.c        | 7 +++++--
 tools/virsh-domain.c                | 7 +++++--
 5 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index dcae981..70f1186 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -159,6 +159,12 @@ static const char *eventDetailToString(int event, int detail) {
             case VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR:
                 ret = "API error";
                 break;
+            case VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY:
+                ret = "Post-copy";
+                break;
+            case VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED:
+                ret = "Post-copy Error";
+                break;
             }
             break;
         case VIR_DOMAIN_EVENT_RESUMED:
@@ -172,6 +178,9 @@ static const char *eventDetailToString(int event, int detail) {
             case VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT:
                 ret = "Snapshot";
                 break;
+            case VIR_DOMAIN_EVENT_RESUMED_POSTCOPY:
+                ret = "Post-copy";
+                break;
             }
             break;
         case VIR_DOMAIN_EVENT_STOPPED:
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 8ea3df6..3846ab9 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -90,6 +90,7 @@ typedef enum {
     VIR_DOMAIN_RUNNING_WAKEUP = 8,          /* returned from pmsuspended due to
                                                wakeup event */
     VIR_DOMAIN_RUNNING_CRASHED = 9,         /* resumed from crashed */
+    VIR_DOMAIN_RUNNING_POSTCOPY = 10,       /* running in post-copy migration mode */
 
 # ifdef VIR_ENUM_SENTINELS
     VIR_DOMAIN_RUNNING_LAST
@@ -117,6 +118,8 @@ typedef enum {
     VIR_DOMAIN_PAUSED_SNAPSHOT = 9,      /* paused while creating a snapshot */
     VIR_DOMAIN_PAUSED_CRASHED = 10,     /* paused due to a guest crash */
     VIR_DOMAIN_PAUSED_STARTING_UP = 11, /* the domain is being started */
+    VIR_DOMAIN_PAUSED_POSTCOPY = 12,    /* paused for post-copy migration */
+    VIR_DOMAIN_PAUSED_POSTCOPY_FAILED = 13, /* paused after failed post-copy */
 
 # ifdef VIR_ENUM_SENTINELS
     VIR_DOMAIN_PAUSED_LAST
@@ -2396,6 +2399,8 @@ typedef enum {
     VIR_DOMAIN_EVENT_SUSPENDED_RESTORED = 4,  /* Restored from paused state file */
     VIR_DOMAIN_EVENT_SUSPENDED_FROM_SNAPSHOT = 5, /* Restored from paused snapshot */
     VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR = 6, /* suspended after failure during libvirt API call */
+    VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY = 7, /* suspended for post-copy migration */
+    VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED = 8, /* suspended after failed post-copy */
 
 # ifdef VIR_ENUM_SENTINELS
     VIR_DOMAIN_EVENT_SUSPENDED_LAST
@@ -2411,6 +2416,8 @@ typedef enum {
     VIR_DOMAIN_EVENT_RESUMED_UNPAUSED = 0,   /* Normal resume due to admin unpause */
     VIR_DOMAIN_EVENT_RESUMED_MIGRATED = 1,   /* Resumed for completion of migration */
     VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT = 2, /* Resumed from snapshot */
+    VIR_DOMAIN_EVENT_RESUMED_POSTCOPY = 3,   /* Resumed, but migration is still
+                                                running in post-copy mode */
 
 # ifdef VIR_ENUM_SENTINELS
     VIR_DOMAIN_EVENT_RESUMED_LAST
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8bfe895..df85720 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -675,7 +675,8 @@ VIR_ENUM_IMPL(virDomainRunningReason, VIR_DOMAIN_RUNNING_LAST,
               "migration canceled",
               "save canceled",
               "wakeup",
-              "crashed")
+              "crashed",
+              "post-copy")
 
 VIR_ENUM_IMPL(virDomainBlockedReason, VIR_DOMAIN_BLOCKED_LAST,
               "unknown")
@@ -692,7 +693,9 @@ VIR_ENUM_IMPL(virDomainPausedReason, VIR_DOMAIN_PAUSED_LAST,
               "shutdown",
               "snapshot",
               "panicked",
-              "starting up")
+              "starting up",
+              "post-copy",
+              "post-copy failed")
 
 VIR_ENUM_IMPL(virDomainShutdownReason, VIR_DOMAIN_SHUTDOWN_LAST,
               "unknown",
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 7dcbc5c..47a9995 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -182,7 +182,8 @@ VIR_ENUM_IMPL(virshDomainRunningReason,
               N_("migration canceled"),
               N_("save canceled"),
               N_("event wakeup"),
-              N_("crashed"))
+              N_("crashed"),
+              N_("post-copy"))
 
 VIR_ENUM_DECL(virshDomainBlockedReason)
 VIR_ENUM_IMPL(virshDomainBlockedReason,
@@ -203,7 +204,9 @@ VIR_ENUM_IMPL(virshDomainPausedReason,
               N_("shutting down"),
               N_("creating snapshot"),
               N_("crashed"),
-              N_("starting up"))
+              N_("starting up"),
+              N_("post-copy"),
+              N_("post-copy failed"))
 
 VIR_ENUM_DECL(virshDomainShutdownReason)
 VIR_ENUM_IMPL(virshDomainShutdownReason,
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f66faca..cf9250f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -11435,14 +11435,17 @@ VIR_ENUM_IMPL(virshDomainEventSuspended,
               N_("Watchdog"),
               N_("Restored"),
               N_("Snapshot"),
-              N_("API error"))
+              N_("API error"),
+              N_("Post-copy"),
+              N_("Post-copy Error"))
 
 VIR_ENUM_DECL(virshDomainEventResumed)
 VIR_ENUM_IMPL(virshDomainEventResumed,
               VIR_DOMAIN_EVENT_RESUMED_LAST,
               N_("Unpaused"),
               N_("Migrated"),
-              N_("Snapshot"))
+              N_("Snapshot"),
+              N_("Post-copy"))
 
 VIR_ENUM_DECL(virshDomainEventStopped)
 VIR_ENUM_IMPL(virshDomainEventStopped,
-- 
2.7.2


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