From 5a9cbc6265c14f2071f015341ae15dee7f236473 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Tue, 5 Jan 2016 12:08:37 +0100 Subject: [PATCH] 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 --- 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 afac1007b1..1e3256f01d 100644 --- a/examples/object-events/event-test.c +++ b/examples/object-events/event-test.c @@ -161,6 +161,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: @@ -174,6 +180,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 4ac29cd788..f97a808143 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 @@ -2407,6 +2410,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 @@ -2422,6 +2427,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 361e79ef50..43b2f1f005 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 7dcbc5cc4e..47a9995814 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 854823ebca..bbf41b8c87 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -11449,14 +11449,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,