From 9b394b7eff681fc1b4c88d9dec88ed38ebf8c456 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Mon, 6 Jun 2016 11:52:07 +0100 Subject: [PATCH] xl: remus/colo: only initialise ha variable when necessary The original code is wrong because the common case is no HA enabled. It should have been set to NULL first. Instead of setting ha to NULL, move it to the scope where it is used. Signed-off-by: Wei Liu Acked-by: Ian Jackson --- tools/libxl/xl_cmdimpl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 8696ca702b..70d3fd9fc7 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -4788,8 +4788,6 @@ static void migrate_receive(int debug, int daemonize, int monitor, char rc_buf; char *migration_domname; struct domain_create dom_info; - const char *ha = checkpointed == LIBXL_CHECKPOINTED_STREAM_COLO ? - "COLO" : "Remus"; signal(SIGPIPE, SIG_IGN); /* if we get SIGPIPE we'd rather just have it as an error */ @@ -4824,6 +4822,9 @@ static void migrate_receive(int debug, int daemonize, int monitor, switch (checkpointed) { case LIBXL_CHECKPOINTED_STREAM_REMUS: case LIBXL_CHECKPOINTED_STREAM_COLO: + { + const char *ha = checkpointed == LIBXL_CHECKPOINTED_STREAM_COLO ? + "COLO" : "Remus"; /* If we are here, it means that the sender (primary) has crashed. * TODO: Split-Brain Check. */ @@ -4860,6 +4861,7 @@ static void migrate_receive(int debug, int daemonize, int monitor, ha, common_domname, domid, rc); exit(rc ? EXIT_FAILURE : EXIT_SUCCESS); + } default: /* do nothing */ break; -- 2.39.5