[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxl: rename stubdomain when renaming domain.


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Mon, 23 Jul 2012 19:55:14 +0000
  • Delivery-date: Mon, 23 Jul 2012 19:55:22 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1343045383 -3600
# Node ID 2b8b5c0d3a174ca13a29c5868a45cefe13379243
# Parent  4e0221514a57e1530dcae4b403d44b72cfbc193d
libxl: rename stubdomain when renaming domain.

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@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---


diff -r 4e0221514a57 -r 2b8b5c0d3a17 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Mon Jul 23 13:09:42 2012 +0100
+++ b/tools/libxl/libxl.c       Mon Jul 23 13:09:43 2012 +0100
@@ -276,6 +276,8 @@ int libxl__domain_rename(libxl__gc *gc, 
     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, 
     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, 
         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;
diff -r 4e0221514a57 -r 2b8b5c0d3a17 tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Mon Jul 23 13:09:42 2012 +0100
+++ b/tools/libxl/libxl_dm.c    Mon Jul 23 13:09:43 2012 +0100
@@ -698,6 +698,11 @@ static void spaw_stubdom_pvqemu_destroy_
                                            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 *eg
 
     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;
 
diff -r 4e0221514a57 -r 2b8b5c0d3a17 tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Mon Jul 23 13:09:42 2012 +0100
+++ b/tools/libxl/libxl_internal.h      Mon Jul 23 13:09:43 2012 +0100
@@ -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;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.