aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_dm.c
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2012-07-24 10:29:17 +0100
committerIan Campbell <ian.campbell@citrix.com>2012-07-24 10:29:17 +0100
commitfd7687a4a5dfe5d6030ea3ace4f79dd2e7bcf838 (patch)
tree0f308816fbf3ae126cc38c8c846b44c5647bb73a /tools/libxl/libxl_dm.c
parenta7889bdd566f1dd1f98d755118c80784aeda71c6 (diff)
downloadxen-fd7687a4a5dfe5d6030ea3ace4f79dd2e7bcf838.tar.gz
xen-fd7687a4a5dfe5d6030ea3ace4f79dd2e7bcf838.tar.bz2
xen-fd7687a4a5dfe5d6030ea3ace4f79dd2e7bcf838.zip
libxl: fix vif.ifname when used with stub device model.
Currently the same libxl_device_nic is used to create both the HVM domain and its stub domain's NICs. This means that if a vifname is provided both the HVM domains PV NIC and the stub domains PV NIC will get the same name and the DM's NIC will fail to be attached. Instead launder the libxl_device_nic to add the TAP_DEVICE_SUFFIX ("-emu"). This is a bit of a misnomer, since the device is actually PV, but it is used to "back" the emulated device in the stub domain and this naming scheme is consistent with the non-stub case and is known to work e.g. with our hotplug scripts. 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>
Diffstat (limited to 'tools/libxl/libxl_dm.c')
-rw-r--r--tools/libxl/libxl_dm.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 0591c1c909..2c81d5ce9d 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -616,6 +616,24 @@ static char ** libxl__build_device_model_args(libxl__gc *gc,
}
}
+static void libxl__dm_vifs_from_hvm_guest_config(libxl__gc *gc,
+ libxl_domain_config * const guest_config,
+ libxl_domain_config *dm_config)
+{
+ int i, nr = guest_config->num_vifs;
+
+ GCNEW_ARRAY(dm_config->vifs, nr);
+
+ for (i=0; i<nr; i++) {
+ dm_config->vifs[i] = guest_config->vifs[i];
+ if (dm_config->vifs[i].ifname)
+ dm_config->vifs[i].ifname = GCSPRINTF("%s" TAP_DEVICE_SUFFIX,
+ dm_config->vifs[i].ifname);
+ }
+
+ dm_config->num_vifs = nr;
+}
+
static int libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,
const libxl_domain_config *guest_config,
libxl_device_vfb *vfb,
@@ -758,8 +776,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
dm_config->disks = guest_config->disks;
dm_config->num_disks = guest_config->num_disks;
- dm_config->vifs = guest_config->vifs;
- dm_config->num_vifs = guest_config->num_vifs;
+ libxl__dm_vifs_from_hvm_guest_config(gc, guest_config, dm_config);
ret = libxl__domain_create_info_setdefault(gc, &dm_config->c_info);
if (ret) goto out;