Libvirt or other high level software can use this command query colo status. You can test this command like that: {'execute':'query-colo-status'}
Signed-off-by: Zhang Chen <zhangc...@gmail.com> --- migration/colo.c | 31 +++++++++++++++++++++++++++++++ qapi/migration.json | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index 8ca6381..127db3c 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -237,6 +237,37 @@ void qmp_xen_colo_do_checkpoint(Error **errp) #endif } +COLOStatus *qmp_query_colo_status(Error **errp) +{ + MigrationState *m; + MigrationIncomingState *mis; + COLOStatus *s = g_new0(COLOStatus, 1); + + if (get_colo_mode() == COLO_MODE_PRIMARY) { + m = migrate_get_current(); + + if (m->state == MIGRATION_STATUS_COLO) { + s->colo_running = true; + } else { + s->colo_running = false; + } + s->mode = COLO_MODE_PRIMARY; + } else { + mis = migration_incoming_get_current(); + + if (mis->state == MIGRATION_STATUS_COLO) { + s->colo_running = true; + } else { + s->colo_running = false; + } + s->mode = COLO_MODE_SECONDARY; + } + + s->reason = failover_get_state(); + + return s; +} + static void colo_send_message(QEMUFile *f, COLOMessage msg, Error **errp) { diff --git a/qapi/migration.json b/qapi/migration.json index 6c6c50e..8ccdd21 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1201,3 +1201,36 @@ # Since: 2.9 ## { 'command': 'xen-colo-do-checkpoint' } + +## +# @COLOStatus: +# +# The result format for 'query-colo-status'. +# +# @mode: which COLO mode the VM was in when it exited. +# +# @colo-running: if true means COLO running well, otherwise COLO have done. +# +# @reason: describes the reason for the COLO exit. +# +# Since: 2.12 +## +{ 'struct': 'COLOStatus', + 'data': { 'mode': 'COLOMode', 'colo-running': 'bool', 'reason': 'COLOExitReason' } } + +## +# @query-colo-status: +# +# Query COLO status while the vm is running. +# +# Returns: A @COLOStatus object showing the status. +# +# Example: +# +# -> { "execute": "query-colo-status" } +# <- { "return": { "mode": "primary", "colo-running": true, "reason": "request" } } +# +# Since: 2.12 +## +{ 'command': 'query-colo-status', + 'returns': 'COLOStatus' } -- 2.7.4