[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxl/xend: name tap devices vifX.Y-emu
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1335354957 -3600 # Node ID 7a6dcecb1781838c9f5d0e0a51c89a718f85c85d # Parent 42553101ccfe90b021df00986b6a0990f7900b98 libxl/xend: name tap devices vifX.Y-emu This prevents the udev scripts from operating on other tap devices (e.g. openvpn etc) Correct the documentation for the "vifname" option which suggested it applied to HVM tap devices only, which is not the case. Reported by Michael Young. Also fix the use of vifname with emulated devices. This is slightly complex. The current hotplug scripts rely on being able to parse the "tapX.Y" (now "vifX.Y-emu") name in order to locate the xenstore backend dir relating to the corresponding vif. This is because we cannot inject our own environment vars into the tap hotplug events. However this means that if the tap is initially named with a user specified name (which will not match the expected scheme) we fail to do anything useful with the device. So now we create the initial tap device with the standard "vifX.Y-emu" name and the hotplug script will handle the rename to the desired name. This is also how PV vif devices work -- they are always created by netback with the name vifX.Y and renamed in the script. Lastly also move libxl__device_* to a better place in the header, otherwise the comment about evgen stuff isn't next to the associated functions (noticed jsut because I was going to add nic_devname near to the setdefault functions) Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Committed-by: Ian Jackson <ian.jackson.citrix.com> --- diff -r 42553101ccfe -r 7a6dcecb1781 docs/misc/xl-network-configuration.markdown --- a/docs/misc/xl-network-configuration.markdown Fri May 11 12:42:57 2012 +0100 +++ b/docs/misc/xl-network-configuration.markdown Wed Apr 25 12:55:57 2012 +0100 @@ -93,11 +93,14 @@ are: ### vifname -This keyword is valid for HVM guest devices with `type=ioemu` only. +Specifies the backend device name for the virtual device. -Specifies the backend device name for an emulated device. The default -is `tapDOMID.DEVID` where `DOMID` is the guest domain ID and `DEVID` -is the device number. +If the domain is an HVM domain then the associated emulated (tap) +device will have a "-emu" suffice added. + +The default name for the virtual device is `vifDOMID.DEVID` where +`DOMID` is the guest domain ID and `DEVID` is the device +number. Likewise the default tap name is `vifDOMID.DEVID-emu`. ### script diff -r 42553101ccfe -r 7a6dcecb1781 tools/hotplug/Linux/vif-common.sh --- a/tools/hotplug/Linux/vif-common.sh Fri May 11 12:42:57 2012 +0100 +++ b/tools/hotplug/Linux/vif-common.sh Wed Apr 25 12:55:57 2012 +0100 @@ -85,12 +85,23 @@ elif [ "$type_if" = tap ]; then : ${INTERFACE:?} # Get xenbus_path from device name. - # The name is built like that: "tap${domid}.${devid}". - dev_=${dev#tap} + # The name is built like that: "vif${domid}.${devid}-emu". + dev_=${dev#vif} + dev_=${dev_%-emu} domid=${dev_%.*} devid=${dev_#*.} XENBUS_PATH="/local/domain/0/backend/vif/$domid/$devid" + vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "") + if [ "$vifname" ] + then + vifname="${vifname}-emu" + if [ "$command" == "add" ] && ! ip link show "$vifname" >&/dev/null + then + do_or_die ip link set "$dev" name "$vifname" + fi + dev="$vifname" + fi fi ip=${ip:-} diff -r 42553101ccfe -r 7a6dcecb1781 tools/hotplug/Linux/xen-backend.rules --- a/tools/hotplug/Linux/xen-backend.rules Fri May 11 12:42:57 2012 +0100 +++ b/tools/hotplug/Linux/xen-backend.rules Wed Apr 25 12:55:57 2012 +0100 @@ -13,4 +13,4 @@ KERNEL=="blktap-control", NAME="xen/blkt KERNEL=="gntdev", NAME="xen/%k", MODE="0600" KERNEL=="pci_iomul", NAME="xen/%k", MODE="0600" KERNEL=="tapdev[a-z]*", NAME="xen/blktap-2/tapdev%m", MODE="0600" -SUBSYSTEM=="net", KERNEL=="tap*", ACTION=="add", RUN+="/etc/xen/scripts/vif-setup $env{ACTION} type_if=tap" +SUBSYSTEM=="net", KERNEL=="vif*-emu", ACTION=="add", RUN+="/etc/xen/scripts/vif-setup $env{ACTION} type_if=tap" diff -r 42553101ccfe -r 7a6dcecb1781 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Fri May 11 12:42:57 2012 +0100 +++ b/tools/libxl/libxl.c Wed Apr 25 12:55:57 2012 +0100 @@ -2087,6 +2087,21 @@ int libxl_device_nic_getinfo(libxl_ctx * return 0; } +const char *libxl__device_nic_devname(libxl__gc *gc, + uint32_t domid, + uint32_t devid, + libxl_nic_type type) +{ + switch (type) { + case LIBXL_NIC_TYPE_VIF: + return GCSPRINTF("vif%u.%d", domid, devid); + case LIBXL_NIC_TYPE_IOEMU: + return GCSPRINTF("vif%u.%d" TAP_DEVICE_SUFFIX, domid, devid); + default: + abort(); + } +} + /******************************************************************************/ int libxl__device_console_add(libxl__gc *gc, uint32_t domid, libxl__device_console *console, diff -r 42553101ccfe -r 7a6dcecb1781 tools/libxl/libxl_dm.c --- a/tools/libxl/libxl_dm.c Fri May 11 12:42:57 2012 +0100 +++ b/tools/libxl/libxl_dm.c Wed Apr 25 12:55:57 2012 +0100 @@ -209,12 +209,9 @@ static char ** libxl__build_device_model if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) { char *smac = libxl__sprintf(gc, LIBXL_MAC_FMT, LIBXL_MAC_BYTES(vifs[i].mac)); - char *ifname; - if (!vifs[i].ifname) - ifname = libxl__sprintf(gc, - "tap%d.%d", domid, vifs[i].devid); - else - ifname = vifs[i].ifname; + const char *ifname = libxl__device_nic_devname(gc, + domid, vifs[i].devid, + LIBXL_NIC_TYPE_IOEMU); flexarray_vappend(dm_args, "-net", GCSPRINTF( @@ -456,13 +453,9 @@ static char ** libxl__build_device_model if (vifs[i].nictype == LIBXL_NIC_TYPE_IOEMU) { char *smac = libxl__sprintf(gc, LIBXL_MAC_FMT, LIBXL_MAC_BYTES(vifs[i].mac)); - char *ifname; - if (!vifs[i].ifname) { - ifname = libxl__sprintf(gc, "tap%d.%d", - guest_domid, vifs[i].devid); - } else { - ifname = vifs[i].ifname; - } + const char *ifname = libxl__device_nic_devname(gc, + guest_domid, vifs[i].devid, + LIBXL_NIC_TYPE_IOEMU); flexarray_append(dm_args, "-device"); flexarray_append(dm_args, libxl__sprintf(gc, "%s,id=nic%d,netdev=net%d,mac=%s", diff -r 42553101ccfe -r 7a6dcecb1781 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Fri May 11 12:42:57 2012 +0100 +++ b/tools/libxl/libxl_internal.h Wed Apr 25 12:55:57 2012 +0100 @@ -83,6 +83,7 @@ #define STUBDOM_CONSOLE_RESTORE 2 #define STUBDOM_CONSOLE_SERIAL 3 #define STUBDOM_SPECIAL_CONSOLES 3 +#define TAP_DEVICE_SUFFIX "-emu" #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) @@ -196,17 +197,6 @@ _hidden libxl__ev_xswatch *libxl__watch_ * version of the _evdisable_FOO function; the internal one is * used during cleanup. */ -_hidden int libxl__domain_create_info_setdefault(libxl__gc *gc, - libxl_domain_create_info *c_info); -_hidden int libxl__domain_build_info_setdefault(libxl__gc *gc, - libxl_domain_build_info *b_info); -_hidden int libxl__device_disk_setdefault(libxl__gc *gc, - libxl_device_disk *disk); -_hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic); -_hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb); -_hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb); -_hidden int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci); - struct libxl__evgen_domain_death { uint32_t domid; unsigned shutdown_reported:1, death_reported:1; @@ -705,6 +695,21 @@ _hidden int libxl__wait_for_backend(libx * All libxl API functions are expected to have arranged for this * to be called before using any values within these structures. */ +_hidden int libxl__domain_create_info_setdefault(libxl__gc *gc, + libxl_domain_create_info *c_info); +_hidden int libxl__domain_build_info_setdefault(libxl__gc *gc, + libxl_domain_build_info *b_info); +_hidden int libxl__device_disk_setdefault(libxl__gc *gc, + libxl_device_disk *disk); +_hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic); +_hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb); +_hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb); +_hidden int libxl__device_pci_setdefault(libxl__gc *gc, libxl_device_pci *pci); + +_hidden const char *libxl__device_nic_devname(libxl__gc *gc, + uint32_t domid, + uint32_t devid, + libxl_nic_type type); /* Arranges that dev will be removed from its guest. When * this is done, the ao will be completed. An error diff -r 42553101ccfe -r 7a6dcecb1781 tools/python/xen/xend/image.py --- a/tools/python/xen/xend/image.py Fri May 11 12:42:57 2012 +0100 +++ b/tools/python/xen/xend/image.py Wed Apr 25 12:55:57 2012 +0100 @@ -917,11 +917,7 @@ class HVMImageHandler(ImageHandler): ret.append("-net") ret.append("nic,vlan=%d,macaddr=%s,model=%s" % (nics, mac, model)) - vifname = devinfo.get('vifname') - if vifname: - vifname = "tap-" + vifname - else: - vifname = "tap%d.%d" % (self.vm.getDomid(), nics-1) + vifname = "vif%d.%d-emu" % (self.vm.getDomid(), nics-1) ret.append("-net") ret.append("tap,vlan=%d,ifname=%s,bridge=%s" % (nics, vifname, bridge)) _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |