[PATCH] During a migrate, grab xml, do migration, define at the end
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1205785376 25200
# Node ID 802a5fbe87ed0dff07f2dc75622a9e674d891156
# Parent 47f5fc1ac66dad65785dd050d6b4b9fe95948f8a
During a migrate, grab xml, do migration, define at the end
...in a more consistent manner that makes offline migration an effective
NOP.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 47f5fc1ac66d -r 802a5fbe87ed src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Mon Mar 17 13:22:42 2008 -0700
+++ b/src/Virt_VSMigrationService.c Mon Mar 17 13:22:56 2008 -0700
@@ -860,6 +860,23 @@ static CMPIStatus handle_migrate(virConn
{
CMPIStatus s = {CMPI_RC_OK, NULL};
virDomainPtr ddom = NULL;
+ virDomainInfo info;
+ int ret;
+
+ ret = virDomainGetInfo(dom, &info);
+ if (ret == -1) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Error getting domain info");
+ goto out;
+ }
+
+ if ((const int)info.state == VIR_DOMAIN_SHUTOFF) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_INVALID_PARAMETER,
+ "Domain must not be shut off for live migration");
+ goto out;
+ }
CU_DEBUG("Migrating %s -> %s", job->domain, uri);
ddom = virDomainMigrate(dom, dconn, type, NULL, NULL, 0);
@@ -869,71 +886,75 @@ static CMPIStatus handle_migrate(virConn
CMPI_RC_ERR_FAILED,
"Migration Failed");
}
-
+ out:
virDomainFree(ddom);
return s;
}
-static CMPIStatus prepare_offline_migrate(virDomainPtr dom,
- char **xml)
+static CMPIStatus prepare_migrate(virDomainPtr dom,
+ char **xml)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+
+ *xml = virDomainGetXMLDesc(dom, 0);
+ if (*xml == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to retrieve domain XML.");
+ goto out;
+ }
+
+ out:
+ return s;
+}
+
+static CMPIStatus complete_migrate(virDomainPtr ldom,
+ virConnectPtr rconn,
+ const char *xml)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ virDomainPtr newdom = NULL;
+
+ if (virDomainUndefine(ldom) == -1) {
+ CU_DEBUG("Undefine of local domain failed");
+ }
+
+ newdom = virDomainDefineXML(rconn, xml);
+ if (newdom == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to define domain");
+ goto out;
+ }
+
+ CU_DEBUG("Defined domain on destination host");
+ out:
+ virDomainFree(newdom);
+
+ return s;
+}
+
+static CMPIStatus ensure_dom_offline(virDomainPtr dom)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
virDomainInfo info;
int ret;
ret = virDomainGetInfo(dom, &info);
- if (ret != 0) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Unabled to get info for domain.");
+ if (ret == -1) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Error getting domain info");
goto out;
}
if ((const int)info.state != VIR_DOMAIN_SHUTOFF) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_INVALID_PARAMETER,
- "Domain must be shutoff for offline migration.");
- goto out;
- }
-
- *xml = virDomainGetXMLDesc(dom, 0);
- if (*xml == NULL) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Unable to retrieve domain XML.");
- goto out;
- }
-
- out:
- return s;
-}
-
-static CMPIStatus handle_offline_migrate(virConnectPtr dconn,
- virDomainPtr dom,
- char *uri,
- char *xml,
- struct migration_job *job)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- virDomainPtr new_dom;
-
- if (domain_exists(dconn, job->domain)) {
- CU_DEBUG("This domain already exists on the target system.");
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "This domain already exists on the target system");
- goto out;
- }
-
- new_dom = virDomainDefineXML(dconn, xml);
- if (new_dom == NULL) {
- CU_DEBUG("Failed to define domain from XML");
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Failed to create domain");
- }
-
+ "Domain must be shut off for offline migration");
+ goto out;
+ }
out:
return s;
}
@@ -959,27 +980,33 @@ static CMPIStatus migrate_vs(struct migr
goto out;
}
- if (job->type == CIM_MIGRATE_OTHER) {
- s = prepare_offline_migrate(dom, &xml);
- if (s.rc != CMPI_RC_OK)
- goto out;
- }
+ if (domain_exists(job->conn, job->domain)) {
+ CU_DEBUG("Remote domain `%s' exists", job->domain);
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Remote already has domain `%s'", job->domain);
+ goto out;
+ }
+
+ s = prepare_migrate(dom, &xml);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
switch(job->type) {
case CIM_MIGRATE_OTHER:
- CU_DEBUG("Preparing for offline migration");
- s = handle_offline_migrate(job->conn, dom, uri, xml, job);
+ CU_DEBUG("Offline migration");
+ s = ensure_dom_offline(dom);
break;
case CIM_MIGRATE_LIVE:
- CU_DEBUG("Preparing for live migration");
+ CU_DEBUG("Live migration");
s = handle_migrate(job->conn, dom, uri, VIR_MIGRATE_LIVE, job);
break;
case CIM_MIGRATE_RESUME:
case CIM_MIGRATE_RESTART:
- CU_DEBUG("Preparing for static migration");
+ CU_DEBUG("Static migration");
s = handle_migrate(job->conn, dom, uri, 0, job);
break;
- default:
+ default:
CU_DEBUG("Unsupported migration type (%d)", job->type);
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -990,11 +1017,13 @@ static CMPIStatus migrate_vs(struct migr
if (s.rc != CMPI_RC_OK)
goto out;
- CU_DEBUG("Migration succeeded");
- cu_statusf(_BROKER, &s,
- CMPI_RC_OK,
- "");
-
+ s = complete_migrate(dom, job->conn, xml);
+ if (s.rc == CMPI_RC_OK) {
+ CU_DEBUG("Migration succeeded");
+ } else {
+ CU_DEBUG("Migration failed: %s",
+ CMGetCharPtr(s.msg));
+ }
out:
raise_deleted_ind(job);
16 years, 9 months
[PATCH] Make external check code not consider absence of the check dir a failure
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1205775186 25200
# Node ID 420c2f10feb2cacc2081a65a0022fcb8355c7887
# Parent 6a4ee1677ad7c63aabcb1291b6f677b82d8098db
Make external check code not consider absence of the check dir a failure
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 6a4ee1677ad7 -r 420c2f10feb2 src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Mon Mar 17 10:14:16 2008 -0700
+++ b/src/Virt_VSMigrationService.c Mon Mar 17 10:33:06 2008 -0700
@@ -316,7 +316,7 @@ static char **list_migration_checks(int
CU_DEBUG("Unable to open migration checks dir: %s (%s)",
MIG_CHECKS_DIR,
strerror(errno));
- *count = -1;
+ *count = 0;
return NULL;
}
16 years, 9 months
[PATCH] Make migration indications not crash the provider if they fail to be
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1205785362 25200
# Node ID 47f5fc1ac66dad65785dd050d6b4b9fe95948f8a
# Parent 0c1fb92b677674d5f94648020f72707c5eb16dd8
Make migration indications not crash the provider if they fail to be
created. Also make raise_indication() tolerant of getting a NULL.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 0c1fb92b6776 -r 47f5fc1ac66d src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Mon Mar 17 12:22:19 2008 -0700
+++ b/src/Virt_VSMigrationService.c Mon Mar 17 13:22:42 2008 -0700
@@ -692,6 +692,9 @@ static bool raise_indication(const CMPIC
CMPIStatus s;
const char *ind_name = NULL;
+ if (ind == NULL)
+ return false;
+
ind_name = ind_type_to_name(ind_type);
CU_DEBUG("Setting SourceInstance");
@@ -730,6 +733,7 @@ static CMPIInstance *prepare_indication(
if (ind == NULL) {
CU_DEBUG("Failed to create ind, type '%s:%s_%s'",
ns, "Xen", ind_name);
+ goto out;
}
if (ind_type == MIG_MODIFIED) {
16 years, 9 months
[PATCH] Remove stale parameter in handle_migrate() function
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1205785395 25200
# Node ID 4c26cc6ccb4f239d97ebfadd6f3913b54f52c9cd
# Parent 802a5fbe87ed0dff07f2dc75622a9e674d891156
Remove stale parameter in handle_migrate() function
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 802a5fbe87ed -r 4c26cc6ccb4f src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Mon Mar 17 13:22:56 2008 -0700
+++ b/src/Virt_VSMigrationService.c Mon Mar 17 13:23:15 2008 -0700
@@ -854,7 +854,6 @@ static void migrate_job_set_state(struct
static CMPIStatus handle_migrate(virConnectPtr dconn,
virDomainPtr dom,
- char *uri,
int type,
struct migration_job *job)
{
@@ -878,7 +877,7 @@ static CMPIStatus handle_migrate(virConn
goto out;
}
- CU_DEBUG("Migrating %s -> %s", job->domain, uri);
+ CU_DEBUG("Migrating %s", job->domain);
ddom = virDomainMigrate(dom, dconn, type, NULL, NULL, 0);
if (ddom == NULL) {
CU_DEBUG("Migration failed");
@@ -999,12 +998,12 @@ static CMPIStatus migrate_vs(struct migr
break;
case CIM_MIGRATE_LIVE:
CU_DEBUG("Live migration");
- s = handle_migrate(job->conn, dom, uri, VIR_MIGRATE_LIVE, job);
+ s = handle_migrate(job->conn, dom, VIR_MIGRATE_LIVE, job);
break;
case CIM_MIGRATE_RESUME:
case CIM_MIGRATE_RESTART:
CU_DEBUG("Static migration");
- s = handle_migrate(job->conn, dom, uri, 0, job);
+ s = handle_migrate(job->conn, dom, 0, job);
break;
default:
CU_DEBUG("Unsupported migration type (%d)", job->type);
16 years, 9 months
[PATCH] Make sure RegisteredProfile.registration gets included in pkgdata_DATA
by Dan Smith
# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1205515109 25200
# Node ID 5ba7f26dd986188b2b2b6f257f27e1261570185a
# Parent 58da2f9d92e39567b75d8537a833aba0da994f92
Make sure RegisteredProfile.registration gets included in pkgdata_DATA
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 58da2f9d92e3 -r 5ba7f26dd986 Makefile.am
--- a/Makefile.am Mon Mar 03 09:58:19 2008 -0800
+++ b/Makefile.am Fri Mar 14 10:18:29 2008 -0700
@@ -91,7 +91,7 @@ INTEROP_REGS = \
schema/RegisteredProfile.registration \
schema/ElementConformsToProfile.registration
-pkgdata_DATA = $(MOFS) $(REGS)
+pkgdata_DATA = $(MOFS) $(REGS) $(INTEROP_REGS)
pkgdata_SCRIPTS = provider-register.sh
EXTRA_DIST = schema $(pkgdata_DATA) $(pkgdata_SCRIPTS) \
16 years, 9 months