[PATCH] (#3) MigrationJob will write a migration flag to the infostore of the guest migrating

# HG changeset patch # User Richard Maciel <rmaciel@linux.vnet.ibm.com> # Date 1250182294 10800 # Node ID 69ee9e708fe8fb2f5af562fdc412290e30fa41e7 # Parent 20528f913ec18441bf1ef2f812d110580fa01015 (#3) MigrationJob will write a migration flag to the infostore of the guest migrating This allows ComputerSystem to know when its respective guest is being migrated #2: Fixed patch submission date #3: Changed 'mark' word to 'flag' Removed unneeded code Signed-off-by: Richard Maciel <rmaciel@linux.vnet.ibm.com> diff -r 20528f913ec1 -r 69ee9e708fe8 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Tue Jun 16 14:25:50 2009 -0700 +++ b/src/Virt_VSMigrationService.c Thu Aug 13 13:51:34 2009 -0300 @@ -48,6 +48,7 @@ #include "Virt_ComputerSystem.h" #include "Virt_VSMigrationSettingData.h" #include "svpc_types.h" +#include "libxkutil/infostore.h" #include "config.h" @@ -1135,6 +1136,24 @@ return s; } +static void clear_infstore_migration_flag(virDomainPtr dom) +{ + struct infostore_ctx *infp; + bool ret = false; + + infp = infostore_open(dom); + if (infp == NULL) { + CU_DEBUG("Unable to open domain information store." + "Migration flag won't be cleared"); + return; + } + + ret = infostore_set_bool(infp, "migrating", false); + CU_DEBUG("Clearing infostore migrating flag"); + + infostore_close(infp); +} + static CMPIStatus migrate_vs(struct migration_job *job) { CMPIStatus s; @@ -1210,6 +1229,7 @@ CMGetCharPtr(s.msg)); } out: + clear_infstore_migration_flag(dom); raise_deleted_ind(job); free(uri); @@ -1251,6 +1271,38 @@ return NULL; } +static bool set_infstore_migration_flag(const virConnectPtr conn, + const char *domain) +{ + struct infostore_ctx *infp; + bool ret = false; + virDomainPtr dom = NULL; + + dom = virDomainLookupByName(conn, domain); + if (dom == NULL) { + CU_DEBUG("No such domain"); + goto out; + } + + infp = infostore_open(dom); + if (infp == NULL) { + CU_DEBUG("Unable to open domain information store." + "Migration flag won't be placed"); + goto out; + } + + ret = infostore_set_bool(infp, "migrating", true); + CU_DEBUG("Migration flag set"); + + infostore_close(infp); + + out: + virDomainFree(dom); + virConnectClose(conn); + + return ret; +} + static CMPIInstance *_migrate_job_new_instance(const char *cn, const char *ns) { @@ -1411,6 +1463,10 @@ goto out; } + rc = set_infstore_migration_flag(job->conn, domain); + if (!rc) + CU_DEBUG("Failed to set migration flag in infostore"); + ind = prepare_indication(_BROKER, inst, job, MIG_CREATED, &s); rc = raise_indication(job->context, MIG_CREATED, job->ref_ns, inst, ind);
participants (1)
-
Richard Maciel