[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [patch 5/5] xen: net features
Allow (1) the making of both frontend and backend vif MACs read-only (independently), (2) the addition of some xen-specific sysfs attributes on front/back vifs, (3) an option to set several vif defaults in a domain config file, for ease of use when creating multiple vifs. Signed-off-by: Jody Belka <knew@xxxxxxxx> diffstat: linux-2.6.10-xen-sparse/drivers/xen/netback/common.h | 10 + linux-2.6.10-xen-sparse/drivers/xen/netback/interface.c | 121 +++++++++++++++- linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c | 73 +++++++++ tools/python/xen/lowlevel/xu/xu.c | 18 ++ tools/python/xen/xend/XendDomainInfo.py | 1 tools/python/xen/xend/server/messages.py | 9 + tools/python/xen/xend/server/netif.py | 62 ++++++++ tools/python/xen/xm/create.py | 91 +++++++++++- xen/include/public/io/domain_controller.h | 10 - 9 files changed, 388 insertions(+), 7 deletions(-) diff -durN xen.patched/linux-2.6.10-xen-sparse/drivers/xen/netback/common.h xen/linux-2.6.10-xen-sparse/drivers/xen/netback/common.h --- xen.patched/linux-2.6.10-xen-sparse/drivers/xen/netback/common.h 2005-01-31 20:54:55.151986808 +0100 +++ xen/linux-2.6.10-xen-sparse/drivers/xen/netback/common.h 2005-01-31 20:01:47.463589104 +0100 @@ -35,7 +35,17 @@ domid_t domid; unsigned int handle; + /* Frontend information */ u8 fe_dev_addr[6]; + unsigned char fe_dom_name[16]; + + /* netif flags */ +#define NETIF_IFFLAG_MAC_WRITE (1 << 0) +#define NETIF_IFFLAG_BE_MAC_WRITE (1 << 1) +#define NETIF_IFFLAG_EXT_SYSFS (1 << 2) + u16 flags; + + int (*set_mac_address)(struct net_device *dev, void *addr); /* Physical parameters of the comms window. */ unsigned long tx_shmem_frame; diff -durN xen.patched/linux-2.6.10-xen-sparse/drivers/xen/netback/interface.c xen/linux-2.6.10-xen-sparse/drivers/xen/netback/interface.c --- xen.patched/linux-2.6.10-xen-sparse/drivers/xen/netback/interface.c 2005-01-31 20:54:55.160985440 +0100 +++ xen/linux-2.6.10-xen-sparse/drivers/xen/netback/interface.c 2005-01-31 20:01:47.474587432 +0100 @@ -112,6 +112,96 @@ schedule_work(&netif->work); } +#ifdef CONFIG_SYSFS + +#define DOMNAMSIZ 15 +#define SYSFS_NETIF_ATTR "xen" + +#define to_net_dev(class) container_of(class, struct net_device, class_dev) +#define to_netif(cd) ((netif_t *)(to_net_dev(cd)->priv)) + +static ssize_t show_fe_dom_name(struct class_device *cd, char *buf) +{ + netif_t *netif = to_netif(cd); + if ( strlen(netif->fe_dom_name) > DOMNAMSIZ ) + return 0; + return sprintf(buf, "%s\n", netif->fe_dom_name); +} + +struct class_device_attribute class_device_attr_fe_domain = \ + __ATTR(fe.domain, S_IRUGO, show_fe_dom_name, NULL); + +static ssize_t show_fe_dev_addr(struct class_device *cd, char *buf) +{ + netif_t *netif = to_netif(cd); + return sprintf(buf, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", + netif->fe_dev_addr[0], netif->fe_dev_addr[1], + netif->fe_dev_addr[2], netif->fe_dev_addr[3], + netif->fe_dev_addr[4], netif->fe_dev_addr[5]); +} + +struct class_device_attribute class_device_attr_fe_initial_address = \ + __ATTR(fe.initial_address, S_IRUGO, show_fe_dev_addr, NULL); + +static ssize_t show_fe_mac_mode(struct class_device *cd, char *buf) +{ + netif_t *netif = to_netif(cd); + if ( (netif->flags & NETIF_IFFLAG_MAC_WRITE) == 0 ) + return sprintf(buf, "r\n"); + else + return sprintf(buf, "w\n"); +} + +struct class_device_attribute class_device_attr_fe_mac_mode = \ + __ATTR(fe.mac_mode, S_IRUGO, show_fe_mac_mode, NULL); + +static ssize_t show_be_mac_mode(struct class_device *cd, char *buf) +{ + netif_t *netif = to_netif(cd); + if ( (netif->flags & NETIF_IFFLAG_BE_MAC_WRITE) == 0 ) + return sprintf(buf, "r\n"); + else + return sprintf(buf, "w\n"); +} + +struct class_device_attribute class_device_attr_be_mac_mode = \ + __ATTR(be.mac_mode, S_IRUGO, show_be_mac_mode, NULL); + +static struct attribute *netif_attrs[] = { + &class_device_attr_fe_domain.attr, + &class_device_attr_fe_initial_address.attr, + &class_device_attr_fe_mac_mode.attr, + &class_device_attr_be_mac_mode.attr, + NULL +}; + +static struct attribute_group netif_group = { + .name = SYSFS_NETIF_ATTR, + .attrs = netif_attrs, +}; + +static int netif_sysfs_addif(struct net_device *dev) +{ + struct kobject *netifobj = &dev->class_dev.kobj; + int err; + + err = sysfs_create_group(netifobj, &netif_group); + return err; +} + +#else +#define netif_sysfs_addif(dev) (0) +#endif /* CONFIG_SYSFS */ + +static int network_set_mac_address(struct net_device *dev, void *addr) +{ + netif_t *netif = netdev_priv(dev); + if ( (netif->flags & NETIF_IFFLAG_MAC_WRITE) == 0 ) + return -EPERM; + else + return netif->set_mac_address(dev, addr); +} + void netif_create(netif_be_create_t *create) { int err = 0; @@ -160,6 +250,9 @@ dev->open = net_open; dev->stop = net_close; + netif->set_mac_address = dev->set_mac_address; + dev->set_mac_address = network_set_mac_address; + /* Disable queuing. */ dev->tx_queue_len = 0; @@ -181,10 +274,12 @@ } memcpy(netif->fe_dev_addr, create->mac, ETH_ALEN); + memcpy(netif->fe_dom_name, create->fe_dom_name, DOMNAMSIZ + 1); + + netif->flags = create->flags; rtnl_lock(); err = register_netdevice(dev); - rtnl_unlock(); if ( err != 0 ) { @@ -192,6 +287,30 @@ dev->name, err); create->status = NETIF_BE_STATUS_OUT_OF_MEMORY; free_netdev(dev); + rtnl_unlock(); + return; + } + + /* network device kobject is not setup until + * after rtnl_unlock does it's hotplug magic. + * so hold reference to avoid race. + */ + dev_hold(dev); + rtnl_unlock(); + + if ( (netif->flags & NETIF_IFFLAG_EXT_SYSFS) > 0 ) + err = netif_sysfs_addif(dev); + else + err = 0; + dev_put(dev); + + if ( err != 0 ) + { + DPRINTK("Could not register sysfs attributes for new net device %s: err=%d\n", + dev->name, err); + create->status = NETIF_BE_STATUS_OUT_OF_MEMORY; + unregister_netdev(dev); + free_netdev(dev); return; } diff -durN xen.patched/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c xen/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c --- xen.patched/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c 2005-01-30 00:46:28.000000000 +0100 +++ xen/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c 2005-01-31 20:44:11.130892896 +0100 @@ -99,6 +99,14 @@ NETIF_RING_IDX rx_resp_cons, tx_resp_cons; unsigned int tx_full; + /* netif flags */ +#define NETIF_IFFLAG_MAC_WRITE (1 << 0) +#define NETIF_IFFLAG_BE_MAC_WRITE (1 << 1) /* never gets set for frontend */ +#define NETIF_IFFLAG_EXT_SYSFS (1 << 2) + u16 flags; + + int (*set_mac_address)(struct net_device *dev, void *addr); + netif_tx_interface_t *tx; netif_rx_interface_t *rx; @@ -722,6 +730,16 @@ } +static int network_set_mac_address(struct net_device *dev, void *addr) +{ + struct net_private *np = netdev_priv(dev); + if ( (np->flags & NETIF_IFFLAG_MAC_WRITE) == 0 ) + return -EPERM; + else + return np->set_mac_address(dev, addr); +} + + static void network_connect(struct net_device *dev, netif_fe_interface_status_t *status) { @@ -928,6 +946,49 @@ vif_show(np); } + +#ifdef CONFIG_SYSFS + +#define SYSFS_NETIF_ATTR "xen" + +#define to_net_dev(class) container_of(class, struct net_device, class_dev) +#define to_np(cd) ((struct net_private *)(to_net_dev(cd)->priv)) + +static ssize_t show_mac_mode(struct class_device *cd, char *buf) +{ + struct net_private *np = to_np(cd); + if ( (np->flags & NETIF_IFFLAG_MAC_WRITE) == 0 ) + return sprintf(buf, "r\n"); + else + return sprintf(buf, "w\n"); +} + +CLASS_DEVICE_ATTR(mac_mode, S_IRUGO, show_mac_mode, NULL); + +static struct attribute *netif_attrs[] = { + &class_device_attr_mac_mode.attr, + NULL +}; + +static struct attribute_group netif_group = { + .name = SYSFS_NETIF_ATTR, + .attrs = netif_attrs, +}; + +static int netif_sysfs_addif(struct net_device *dev) +{ + struct kobject *netifobj = &dev->class_dev.kobj; + int err; + + err = sysfs_create_group(netifobj, &netif_group); + return err; +} + +#else +#define netif_sysfs_addif(dev) (0) +#endif /* CONFIG_SYSFS */ + + /* Move the vif into connected state. * Sets the mac and event channel from the message. * Binds the irq to the event channel. @@ -937,7 +998,13 @@ struct net_private *np, netif_fe_interface_status_t *status) { struct net_device *dev = np->dev; + int err = 0; memcpy(dev->dev_addr, status->mac, ETH_ALEN); + np->flags = status->flags; + if ( (np->flags & NETIF_IFFLAG_EXT_SYSFS) > 0 ) + if ( (err = netif_sysfs_addif(dev)) != 0 ) + WPRINTK("Could not register sysfs attributes for new net device %s: err=%d\n", + dev->name, err); network_connect(dev, status); np->evtchn = status->evtchn; np->irq = bind_evtchn_to_irq(np->evtchn); @@ -989,18 +1056,22 @@ dev->get_stats = network_get_stats; dev->poll = netif_poll; dev->weight = 64; + + np->set_mac_address = dev->set_mac_address; + dev->set_mac_address = network_set_mac_address; if ( (err = register_netdev(dev)) != 0 ) { printk(KERN_WARNING "%s> register_netdev err=%d\n", __FUNCTION__, err); goto exit; } + np->dev = dev; list_add(&np->list, &dev_list); exit: if ( (err != 0) && (dev != NULL ) ) - kfree(dev); + free_netdev(dev); else if ( val != NULL ) *val = dev; return err; diff -durN xen.patched/tools/python/xen/lowlevel/xu/xu.c xen/tools/python/xen/lowlevel/xu/xu.c --- xen.patched/tools/python/xen/lowlevel/xu/xu.c 2005-01-31 20:54:55.171983768 +0100 +++ xen/tools/python/xen/lowlevel/xu/xu.c 2005-01-31 20:01:47.497583936 +0100 @@ -607,6 +607,7 @@ P2C(netif_fe_interface_status_t, status, u32); P2C(netif_fe_interface_status_t, evtchn, u16); P2C(netif_fe_interface_status_t, domid, u16); + P2C(netif_fe_interface_status_t, flags, u16); P2C(netif_fe_interface_status_t, mac[0], u8); P2C(netif_fe_interface_status_t, mac[1], u8); P2C(netif_fe_interface_status_t, mac[2], u8); @@ -617,6 +618,7 @@ case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_CREATE): P2C(netif_be_create_t, domid, u32); P2C(netif_be_create_t, netif_handle, u32); + P2C(netif_be_create_t, flags, u16); P2C(netif_be_create_t, mac[0], u8); P2C(netif_be_create_t, mac[1], u8); P2C(netif_be_create_t, mac[2], u8); @@ -629,6 +631,22 @@ P2C(netif_be_create_t, be_mac[3], u8); P2C(netif_be_create_t, be_mac[4], u8); P2C(netif_be_create_t, be_mac[5], u8); + P2C(netif_be_create_t, fe_dom_name[0], u8); + P2C(netif_be_create_t, fe_dom_name[1], u8); + P2C(netif_be_create_t, fe_dom_name[2], u8); + P2C(netif_be_create_t, fe_dom_name[3], u8); + P2C(netif_be_create_t, fe_dom_name[4], u8); + P2C(netif_be_create_t, fe_dom_name[5], u8); + P2C(netif_be_create_t, fe_dom_name[6], u8); + P2C(netif_be_create_t, fe_dom_name[7], u8); + P2C(netif_be_create_t, fe_dom_name[8], u8); + P2C(netif_be_create_t, fe_dom_name[9], u8); + P2C(netif_be_create_t, fe_dom_name[10], u8); + P2C(netif_be_create_t, fe_dom_name[11], u8); + P2C(netif_be_create_t, fe_dom_name[12], u8); + P2C(netif_be_create_t, fe_dom_name[13], u8); + P2C(netif_be_create_t, fe_dom_name[14], u8); + P2C(netif_be_create_t, fe_dom_name[15], u8); break; case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY): P2C(netif_be_destroy_t, domid, u32); diff -durN xen.patched/tools/python/xen/xend/XendDomainInfo.py xen/tools/python/xen/xend/XendDomainInfo.py --- xen.patched/tools/python/xen/xend/XendDomainInfo.py 2005-01-30 00:46:29.000000000 +0100 +++ xen/tools/python/xen/xend/XendDomainInfo.py 2005-01-31 20:01:47.507582416 +0100 @@ -1106,6 +1106,7 @@ ctrl = xend.netif_create(vm.dom, recreate=vm.recreate) log.debug("Creating vif dom=%d vif=%d mac=%s", vm.dom, vif, str(vmac)) recreate = vm.get_device_recreate('vif', index) + val.append(['vmname', vm.name]) defer = ctrl.attachDevice(vif, val, recreate=recreate) def cbok(dev): dev.vifctl('up', vmname=vm.name) diff -durN xen.patched/tools/python/xen/xend/server/messages.py xen/tools/python/xen/xend/server/messages.py --- xen.patched/tools/python/xen/xend/server/messages.py 2005-01-31 20:54:55.181982248 +0100 +++ xen/tools/python/xen/xend/server/messages.py 2005-01-31 20:01:47.517580896 +0100 @@ -152,6 +152,10 @@ CMSG_NETIF_BE_DISCONNECT = 3 CMSG_NETIF_BE_DRIVER_STATUS = 32 +NETIF_IFFLAG_MAC_WRITE = 1<<0 +NETIF_IFFLAG_BE_MAC_WRITE = 1<<1 +NETIF_IFFLAG_EXT_SYSFS = 1<<2 + NETIF_INTERFACE_STATUS_CLOSED = 0 #/* Interface doesn't exist. */ NETIF_INTERFACE_STATUS_DISCONNECTED = 1 #/* Exists but is disconnected. */ NETIF_INTERFACE_STATUS_CONNECTED = 2 #/* Exists and is connected. */ @@ -269,6 +273,11 @@ if k in ['mac', 'be_mac']: for i in range(0, 6): args['%s[%d]' % (k, i)] = v[i] + elif k == 'fe_dom_name': + for i in range(min(len(v), 15)): + args['fe_dom_name[%d]' % i] = ord(v[i]) + for i in range(len(v), max(len(v), 16)): + args['fe_dom_name[%d]' % i] = 0 else: args[k] = v msg = xu.message(major, minor, msgid, args) diff -durN xen.patched/tools/python/xen/xend/server/netif.py xen/tools/python/xen/xend/server/netif.py --- xen.patched/tools/python/xen/xend/server/netif.py 2005-01-31 20:54:55.191980728 +0100 +++ xen/tools/python/xen/xend/server/netif.py 2005-01-31 20:01:47.530578920 +0100 @@ -138,6 +138,11 @@ self.bridge = None self.script = None self.ipaddr = [] + self.vmname = '' + self.mac_mode = 'w' + self.be_mac_mode = 'w' + self.ext_sysfs = 0 + self.be_ext_sysfs = 0 mac = self._get_config_mac(config) if mac is None: @@ -147,6 +152,19 @@ self.bridge = sxp.child_value(config, 'bridge') self.script = sxp.child_value(config, 'script') self.ipaddr = self._get_config_ipaddr(config) or [] + self.mac_mode = sxp.child_value(config, 'mac_mode') + self.be_mac_mode = sxp.child_value(config, 'be_mac_mode') + ext_sysfs = sxp.child_value(config, 'ext_sysfs') + if ext_sysfs in ['yes']: self.ext_sysfs = 1 + if ext_sysfs in ['no']: self.ext_sysfs = 0 + be_ext_sysfs = sxp.child_value(config, 'be_ext_sysfs') + if be_ext_sysfs in ['yes']: self.be_ext_sysfs = 1 + if be_ext_sysfs in ['no']: self.be_ext_sysfs = 0 + + vmname = sxp.child_value(config, 'vmname') + if vmname is None: + raise XendError("missing vmname. that shouldn't be possible!!") + self.vmname = vmname try: xd = get_component('xen.xend.XendDomain') @@ -172,6 +190,15 @@ bridge = sxp.child_value(config, 'bridge') script = sxp.child_value(config, 'script') ipaddr = self._get_config_ipaddr(config) + mac_mode = sxp.child_value(config, 'mac_mode') + be_mac_mode = sxp.child_value(config, 'be_mac_mode') + ext_sysfs = sxp.child_value(config, 'ext_sysfs') + if ext_sysfs in ['yes']: ext_sysfs = 1 + if ext_sysfs in ['no']: ext_sysfs = 0 + be_ext_sysfs = sxp.child_value(config, 'be_ext_sysfs') + if be_ext_sysfs in ['yes']: be_ext_sysfs = 1 + if be_ext_sysfs in ['no']: be_ext_sysfs = 0 + vmname = sxp.child_value(config, 'vmname') xd = get_component('xen.xend.XendDomain') backendDomain = str(xd.domain_lookup(sxp.child_value(config, 'backend', '0')).id) if (mac is not None) and (mac != self.mac): @@ -180,6 +207,18 @@ raise XendError("cannot change backend mac") if (backendDomain is not None) and (backendDomain != str(self.backendDomain)): raise XendError("cannot change backend") + if (vmname is None): + raise XendError("aiee aiee. no vmname") + if (vmname != self.vmname): + raise XendError("aiee aiee. vmname has changed. that shouldn't be possible!!") + if (mac_mode is not None) and (mac_mode != self.mac_mode): + raise XendError("cannot change mac_mode") + if (be_mac_mode is not None) and (be_mac_mode != self.be_mac_mode): + raise XendError("cannot change be_mac_mode") + if (ext_sysfs is not None) and (ext_sysfs != self.ext_sysfs): + raise XendError("cannot change ext_sysfs") + if (be_ext_sysfs is not None) and (be_ext_sysfs != self.be_ext_sysfs): + raise XendError("cannot change be_ext_sysfs") if (bridge is not None) and (bridge != self.bridge): changes['bridge'] = bridge if (script is not None) and (script != self.script): @@ -204,6 +243,12 @@ ['mac', mac]] if self.be_mac: val.append(['be_mac', self.get_be_mac()]) + if self.mac_mode is not None: + val.append(['mac_mode', self.mac_mode]) + if self.be_mac_mode is not None: + val.append(['be_mac_mode', self.be_mac_mode]) + if self.be_ext_sysfs is not None: + val.append(['be_ext_sysfs', ['no', 'yes'][self.be_ext_sysfs]]) if self.bridge: val.append(['bridge', self.bridge]) if self.script: @@ -283,9 +328,20 @@ def send_be_create(self): d = defer.Deferred() + flags = 0 + vmname = '' + if self.be_ext_sysfs is None or self.be_ext_sysfs == 1: + flags |= NETIF_IFFLAG_EXT_SYSFS + vmname = self.vmname + if self.mac_mode is None or self.mac_mode == 'w': + flags |= NETIF_IFFLAG_MAC_WRITE + if self.be_mac_mode is None or self.be_mac_mode == 'w': + flags |= NETIF_IFFLAG_BE_MAC_WRITE msg = packMsg('netif_be_create_t', { 'domid' : self.controller.dom, 'netif_handle' : self.vif, + 'fe_dom_name' : vmname, + 'flags' : flags, 'be_mac' : self.be_mac or [0, 0, 0, 0, 0, 0], 'mac' : self.mac }) self.getBackendInterface().writeRequest(msg, response=d) @@ -348,11 +404,17 @@ self.reportStatus() def reportStatus(self, resp=0): + flags = 0 + if self.ext_sysfs is None or self.ext_sysfs == 1: + flags |= NETIF_IFFLAG_EXT_SYSFS + if self.mac_mode is None or self.mac_mode == 'w': + flags |= NETIF_IFFLAG_MAC_WRITE msg = packMsg('netif_fe_interface_status_t', { 'handle' : self.vif, 'status' : self.status, 'evtchn' : self.getEventChannelFrontend(), 'domid' : self.backendDomain, + 'flags' : flags, 'mac' : self.mac }) if resp: self.controller.writeResponse(msg) diff -durN xen.patched/tools/python/xen/xm/create.py xen/tools/python/xen/xm/create.py --- xen.patched/tools/python/xen/xm/create.py 2005-01-31 20:54:55.237973736 +0100 +++ xen/tools/python/xen/xm/create.py 2005-01-31 20:01:47.540577400 +0100 @@ -151,19 +151,43 @@ fn=append_value, default=[], use="Add an IP address to the domain.") -gopts.var('vif', val="mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM", +gopts.var('vif', + val="mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM," \ + "mac_mode=MODE,be_mac_mode=MODE,ext_sysfs=no|yes,be_ext_sysfs=no|yes", fn=append_value, default=[], use="""Add a network interface with the given MAC address and bridge. The vif is configured by calling the given configuration script. If mac is not specified a random MAC address is used. The MAC address of the backend interface can be selected with be_mac. If not specified then the network backend chooses it's own MAC address. + + The MAC is read-only if MODE is 'r', read-write if MODE is 'w'. + mac_mode controls the frontend interface, be_mac_mode the backend + interface. Defaults to read-write. + + If be_ext_sysfs is set (default=disabled), then some additional sysfs + attributes will be enabled on the backend interface: + - xen/fe.domain: frontend domain name + - xen/fe.initial_address: initial frontend interface mac address + - xen/fe.mac_mode: mac mode of the frontend interface + - xen/be.mac_mode: mac mode of the backend interface + + If ext_sysfs is set (default=disabled), then some additional sysfs + attributes will be enabled on the frontend interface: + - xen/mac_mode: mac mode of the interface + If bridge is not specified the default bridge is used. If script is not specified the default script is used. If backend is not specified the default backend driver domain is used. This option may be repeated to add more than one vif. Specifying vifs will increase the number of interfaces as needed.""") +gopts.var('vif_defaults', + val="bridge=BRIDGE,script=SCRIPT,backend=DOM," \ + "mac_mode=MODE,be_mac_mode=MODE,ext_sysfs=no|yes,be_ext_sysfs=no|yes", + fn=append_value, default=[], + use="""Set defaults for various vif options.""") + gopts.var('nics', val="NUM", fn=set_int, default=1, use="""Set the number of network interfaces. @@ -293,6 +317,10 @@ if not mac: mac = randomMAC() be_mac = d.get('be_mac') + mac_mode = d.get('mac_mode') + be_mac_mode = d.get('be_mac_mode') + ext_sysfs = d.get('ext_sysfs') + be_ext_sysfs = d.get('be_ext_sysfs') bridge = d.get('bridge') script = d.get('script') backend = d.get('backend') @@ -300,6 +328,10 @@ else: mac = randomMAC() be_mac = None + mac_mode = None + be_mac_mode = None + ext_sysfs = None + be_ext_sysfs = None bridge = None script = None backend = None @@ -310,10 +342,33 @@ macs.append(mac) mac_vifs[mac] = idx + 1 + if not mac_mode: + mac_mode = vals.vif_defaults.get('mac_mode') + if not be_mac_mode: + be_mac_mode = vals.vif_defaults.get('be_mac_mode') + if not ext_sysfs: + ext_sysfs = vals.vif_defaults.get('ext_sysfs') + if not be_ext_sysfs: + be_ext_sysfs = vals.vif_defaults.get('be_ext_sysfs') + if not bridge: + bridge = vals.vif_defaults.get('bridge') + if not script: + script = vals.vif_defaults.get('script') + if not backend: + backend = vals.vif_defaults.get('backend') + config_vif = ['vif'] config_vif.append(['mac', mac]) if be_mac: config_vif.append(['be_mac', be_mac]) + if mac_mode: + config_vif.append(['mac_mode', mac_mode]) + if be_mac_mode: + config_vif.append(['be_mac_mode', be_mac_mode]) + if ext_sysfs: + config_vif.append(['ext_sysfs', ext_sysfs]) + if be_ext_sysfs: + config_vif.append(['be_ext_sysfs', be_ext_sysfs]) if bridge: config_vif.append(['bridge', bridge]) if script: @@ -400,12 +455,43 @@ (k, v) = b.strip().split('=', 1) k = k.strip() v = v.strip() - if k not in ['mac', 'be_mac', 'bridge', 'script', 'backend', 'ip']: + if k not in ['mac', 'mac_mode', 'be_mac', 'be_mac_mode', \ + 'be_ext_sysfs', 'bridge', 'script', 'backend', 'ip']: + opts.err('Invalid vif specifier: ' + vif) + if k in ['mac_mode', 'be_mac_mode'] and v not in ['r', 'w']: + opts.err('Invalid vif specifier: ' + vif) + if k in ['be_ext_sysfs'] and v not in ['yes', 'no']: opts.err('Invalid vif specifier: ' + vif) d[k] = v vifs.append(d) vals.vif = vifs +def preprocess_vif_defaults(opts, vals): + if not vals.vif_defaults: + vals.vif_defaults = {} + return + + vif_defaults = {} + if type(vals.vif_defaults) is not list: + vals.vif_defaults = [ vals.vif_defaults ] + for vifd in vals.vif_defaults: + a = vifd.split(',') + for b in a: + (k, v) = b.strip().split('=', 1) + k = k.strip() + v = v.strip() + if k not in ['mac_mode', 'be_mac_mode', 'ext_sysfs', 'be_ext_sysfs', \ + 'bridge', 'script', 'backend']: + opts.err('Invalid vif_defaults specifier: ' + vals.vif_defaults) + if k in ['mac_mode', 'be_mac_mode'] and v not in ['r', 'w']: + opts.err('Invalid vif_defaults specifier: ' + vals.vif_defaults) + if k in ['ext_sysfs'] and v not in ['yes', 'no']: + opts.err('Invalid vif_defaults specifier: ' + vals.vif_defaults) + if k in ['be_ext_sysfs'] and v not in ['yes', 'no']: + opts.err('Invalid vif_defaults specifier: ' + vals.vif_defaults) + vif_defaults[k] = v + vals.vif_defaults = vif_defaults + def preprocess_ip(opts, vals): if vals.ip or vals.dhcp != 'off': dummy_nfs_server = '1.2.3.4' @@ -433,6 +519,7 @@ preprocess_disk(opts, vals) preprocess_pci(opts, vals) preprocess_vifs(opts, vals) + preprocess_vif_defaults(opts, vals) preprocess_ip(opts, vals) preprocess_nfs(opts, vals) diff -durN xen.patched/xen/include/public/io/domain_controller.h xen/xen/include/public/io/domain_controller.h --- xen.patched/xen/include/public/io/domain_controller.h 2005-01-31 20:54:55.247972216 +0100 +++ xen/xen/include/public/io/domain_controller.h 2005-01-31 20:01:47.551575728 +0100 @@ -366,7 +366,8 @@ u16 evtchn; /* 8: status == NETIF_INTERFACE_STATUS_CONNECTED */ u8 mac[6]; /* 10: status == NETIF_INTERFACE_STATUS_CONNECTED */ domid_t domid; /* 16: status != NETIF_INTERFACE_STATUS_DESTROYED */ -} PACKED netif_fe_interface_status_t; /* 18 bytes */ + u16 flags; /* 18 */ +} PACKED netif_fe_interface_status_t; /* 20 bytes */ /* * CMSG_NETIF_FE_DRIVER_STATUS: @@ -480,9 +481,12 @@ u16 __pad1; /* 14 */ u8 be_mac[6]; /* 16 */ u16 __pad2; /* 22 */ + u8 fe_dom_name[16]; /* 24 */ + u16 flags; /* 40 */ + u16 __pad3; /* 42 */ /* OUT */ - u32 status; /* 24 */ -} PACKED netif_be_create_t; /* 28 bytes */ + u32 status; /* 44 */ +} PACKED netif_be_create_t; /* 48 bytes */ /* * CMSG_NETIF_BE_DESTROY: ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |