]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: rename stubdomain when renaming domain.
authorIan Campbell <ian.campbell@citrix.com>
Mon, 23 Jul 2012 12:09:43 +0000 (13:09 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 23 Jul 2012 12:09:43 +0000 (13:09 +0100)
Otherwise after a localhost migrate of an HVM domain with a stubdomain we end
up with domains called "FOO" and "FOO--incoming-dm". This because we initially
create the domains as "FOO--incoming" and then rename to "FOO" inorder to
maintain the uniqueness of domain names on a host.

In this state a second attempt to migrate will fail upon attempting to create
a new domain named "FOO--incoming-dm"

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_dm.c
tools/libxl/libxl_internal.h

index 0600ce43f366cea5ab19f14b93f11fdf4b917954..7e8bf45cf54668e51fbf195db731edafe35ae8ab 100644 (file)
@@ -276,6 +276,8 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
     char *got_old_name;
     unsigned int got_old_len;
     xs_transaction_t our_trans = 0;
+    uint32_t stub_dm_domid;
+    const char *stub_dm_old_name = NULL, *stub_dm_new_name = NULL;
     int rc;
 
     dom_path = libxl__xs_get_dompath(gc, domid);
@@ -284,6 +286,12 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
     name_path= libxl__sprintf(gc, "%s/name", dom_path);
     if (!name_path) goto x_nomem;
 
+    stub_dm_domid = libxl_get_stubdom_id(CTX, domid);
+    if (stub_dm_domid) {
+        stub_dm_old_name = libxl__stub_dm_name(gc, old_name);
+        stub_dm_new_name = libxl__stub_dm_name(gc, new_name);
+    }
+
  retry_transaction:
     if (!trans) {
         trans = our_trans = xs_transaction_start(ctx->xsh);
@@ -341,6 +349,17 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
         goto x_fail;
     }
 
+    if (stub_dm_domid) {
+        rc = libxl__domain_rename(gc, stub_dm_domid,
+                                  stub_dm_old_name,
+                                  stub_dm_new_name,
+                                  trans);
+        if (rc) {
+            LOGE(ERROR, "unable to rename stub-domain");
+            goto x_rc;
+        }
+    }
+
     if (our_trans) {
         if (!xs_transaction_end(ctx->xsh, our_trans, 0)) {
             trans = our_trans = 0;
index 6a041f96b95699d788f65601dccc6aabc4188f32..0591c1c909e5490ad17c2f952d8796ed06942650 100644 (file)
@@ -698,6 +698,11 @@ static void spaw_stubdom_pvqemu_destroy_cb(libxl__egc *egc,
                                            libxl__destroy_domid_state *dis,
                                            int rc);
 
+char *libxl__stub_dm_name(libxl__gc *gc, const char *guest_name)
+{
+    return libxl__sprintf(gc, "%s-dm", guest_name);
+}
+
 void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
 {
     STATE_AO_GC(sdss->dm.spawn.ao);
@@ -727,7 +732,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
 
     libxl_domain_create_info_init(&dm_config->c_info);
     dm_config->c_info.type = LIBXL_DOMAIN_TYPE_PV;
-    dm_config->c_info.name = libxl__sprintf(gc, "%s-dm",
+    dm_config->c_info.name = libxl__stub_dm_name(gc,
                                     libxl__domid_to_name(gc, guest_domid));
     dm_config->c_info.ssidref = guest_config->b_info.device_model_ssidref;
 
index 52d79a95d6aae243064f07f1afac604c02c477dd..f832fbd9e5e071905e21da0dc1f6c778e4b6bfaf 100644 (file)
@@ -2247,6 +2247,8 @@ typedef struct {
 
 _hidden void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state*);
 
+_hidden char *libxl__stub_dm_name(libxl__gc *gc, const char * guest_name);
+
 /*----- Domain creation -----*/
 
 typedef struct libxl__domain_create_state libxl__domain_create_state;