HVM vif without bridge
Hello,
When using xen without a bridge but NAT or routing, HVM domains can't boot, and qemu-dm-n.log contains:
config qemu network with xen bridge for tap0 xenbr0 bridge xenbr0 does not exist!
That's because the qemu-ifup script always tries to add the vif to a default-named xenbr0 bridge. On the contrary, PV domains just work fine with the same configuration file except HVM parameters.
I can see several solutions:
- The attached "patch" just ignores brctl failure. Far from elegant, but works fine
- The attached "patch2" drops the default xenbr0 bridge, and then people have to set bridge=xenbr0 in their configuration file.
- move qemu-ifup into three bridge, nat and route scripts, and add another xend-config parameter, along network-script and vif-script, which should point to either of those according to the values of network-script and vif-script.
It looks to me like the first solution could be used as a workaround for now and the last one would be preferable for the long run.
Samuel
tools/ioemu/target-i386-dm/qemu-ifup +1 -1
@@ -34,4 +34,4 @@ fi fi ifconfig $1 0.0.0.0 up -brctl addif $bridge $1 +brctl addif $bridge $1 || true
tools/ioemu/target-i386-dm/qemu-ifup +11 -7
@@ -5,8 +5,12 @@ echo 'config qemu network with xen bridge for ' $* +ifconfig $1 0.0.0.0 up + bridge=$2 +if [ -n "$bridge" ] +then # # Old style bridge setup with netloop, used to have a bridge name # of xenbrX, enslaving pethX and vif0.X, and then configuring
@@ -25,13 +29,13 @@ bridge=$2 # # This lets old config files work without modification # -if [ ! -e "/sys/class/net/$bridge" ] && [ -z "${bridge##xenbr*}" ] -then - if [ -e "/sys/class/net/eth${bridge#xenbr}/bridge" ] + if [ ! -e "/sys/class/net/$bridge" ] && [ -z "${bridge##xenbr*}" ] then - bridge="eth${bridge#xenbr}" + if [ -e "/sys/class/net/eth${bridge#xenbr}/bridge" ] + then + bridge="eth${bridge#xenbr}" + fi fi + + brctl addif $bridge $1 fi - -ifconfig $1 0.0.0.0 up -brctl addif $bridge $1
tools/ioemu/vl.c +5 -10
@@ -100,11 +100,6 @@#include "exec-all.h" #define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup" -#ifdef _BSD -#define DEFAULT_BRIDGE "bridge0" -#else -#define DEFAULT_BRIDGE "xenbr0" -#endif #ifdef __sun__#define SMBD_COMMAND "/usr/sfw/sbin/smbd"#else
@@ -4111,7 +4106,7 @@ static int net_client_init(const char *sif (!strcmp (device,"tap" )) {char ifname[64 ];char setup_script[1024 ]; -char bridge[16 ]; +char bridge[16 ], *_bridge =NULL ;int fd;memset (ifname,0 ,sizeof (ifname));
@@ -4129,10 +4124,10 @@ static int net_client_init(const char *sif (get_param_value (setup_script,sizeof (setup_script),"script" , p) ==0 ) {pstrcpy (setup_script,sizeof (setup_script),DEFAULT_NETWORK_SCRIPT ); } -if (get_param_value (bridge,sizeof (bridge),"bridge" , p) ==0 ) { -pstrcpy (bridge,sizeof (bridge),DEFAULT_BRIDGE ); - } - ret = net_tap_init(vlan, ifname, setup_script, bridge); +if (get_param_value (bridge,sizeof (bridge),"bridge" , p) >0 ) { + _bridge = bridge; + } + ret = net_tap_init(vlan, ifname, setup_script, _bridge); } } else#endif
tools/python/xen/xend/image.py +6 -2
@@ -485,13 +485,17 @@ class HVMImageHandler(ImageHandler): mac = devinfo.get('mac') if mac is None: raise VmError("MAC address not specified or generated.") - bridge = devinfo.get('bridge', 'xenbr0') + bridge = devinfo.get('bridge') model = devinfo.get('model', 'rtl8139') ret.append("-net") ret.append("nic,vlan=%d,macaddr=%s,model=%s" % (nics, mac, model)) ret.append("-net") - ret.append("tap,vlan=%d,bridge=%s" % (nics, bridge)) + if bridge is None: + bridge = "" + else: + bridge = (",bridge=%s" % (bridge)) + ret.append("tap,vlan=%d%s" % (nics, bridge)) return ret
tools/xm-test/lib/XmTestLib/XenDevice.py +0 -2
@@ -179,8 +179,6 @@ class XenNetDevice(XenDevice): if domain.getDomainType() == "HVM": self.config["type"] = "ioemu" - if not self.config.has_key('bridge'): - self.config["bridge"] = "xenbr0" if self.config.has_key("ip"): self.setNetDevIP(ip=self.config["ip"])
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel