diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2012-04-25 12:55:57 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2012-04-25 12:55:57 +0100 |
commit | 4535a36a93331c03ad18d8e11e5a6e51332f58da (patch) | |
tree | 01546446d84f3385501d8b6622b677abfd9b2dab /tools/hotplug | |
parent | 9645bae1c6b0d2dbb77ce97ae8fbb5dc383664f0 (diff) | |
download | xen-4535a36a93331c03ad18d8e11e5a6e51332f58da.tar.gz xen-4535a36a93331c03ad18d8e11e5a6e51332f58da.tar.bz2 xen-4535a36a93331c03ad18d8e11e5a6e51332f58da.zip |
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@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools/hotplug')
-rw-r--r-- | tools/hotplug/Linux/vif-common.sh | 15 | ||||
-rw-r--r-- | tools/hotplug/Linux/xen-backend.rules | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/tools/hotplug/Linux/vif-common.sh b/tools/hotplug/Linux/vif-common.sh index c9c5d41da0..fff22bbf9d 100644 --- a/tools/hotplug/Linux/vif-common.sh +++ b/tools/hotplug/Linux/vif-common.sh @@ -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 --git a/tools/hotplug/Linux/xen-backend.rules b/tools/hotplug/Linux/xen-backend.rules index 40f2658eb2..405387f1a9 100644 --- a/tools/hotplug/Linux/xen-backend.rules +++ b/tools/hotplug/Linux/xen-backend.rules @@ -13,4 +13,4 @@ KERNEL=="blktap-control", NAME="xen/blktap-2/control", MODE="0600" 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" |