Inconsistent domain parameter passed to vif-bridge
It seems that the "domain" parameter passed to the vif-bridge script isn't always consistent. When calling "vif-bridge up", domain refers to the name assigned to the domain. When "vif-bridge down" is called, domain is of the form "DOM<n>", where <n> is the numeric identifier for the domain.
This is a problem since I'm using modifying the vif-bridge script for a different network configuration, and was encoding the vmid used when creating the domain into the domain's name. The vmid is then used in configuring network settings. This works fine when bringing the network up, but I have trouble when bringing the network down--specifically, I want to remove a firewall rule, but need to know the vmid to specify the firewall rule to delete.
Passing the name seems a more useful behavior to me, or perhaps both name and id should be supplied to vif-bridge. In any case, the current behavior (different for up and down) seems broken.
So far I've tracked the problem as far as noticing that NetDev.destroy in python/xen/xend/server/netif.py isn't passed the name of the domain, but I haven't figured out how to best fix this. I'm willing to work on it a bit; any suggestions for how to approach it?
--Michael Vrable
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com
Quoted 5 lines
It seems that the "domain" parameter passed to the vif-bridge script isn't always consistent. When calling "vif-bridge up", domain refers to the name assigned to the domain. When "vif-bridge down" is called, domain is of the form "DOM<n>", where <n> is the numeric identifier for the domain.
Oops -- that's a bug not a feature.
We probably should be making both the name and the domid available to the script anyhow.
Quoted 4 lines
So far I've tracked the problem as far as noticing that NetDev.destroy in
python/xen/xend/server/netif.pyisn't passed the name of the domain, but I haven't figured out how to best fix this. I'm willing to work on it a bit; any suggestions for how to approach it?
Mike would be the best person to fix this, but he's on holiday for a week. Any takers?
Ian
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com
Quoted 11 lines · Ian Pratt
Quoted 5 lines
It seems that the "domain" parameter passed to the vif-bridge script isn't always consistent. When calling "vif-bridge up", domain refers to the name assigned to the domain. When "vif-bridge down" is called, domain is of the form "DOM<n>", where <n> is the numeric identifier for the domain.
Oops -- that's a bug not a feature.
We probably should be making both the name and the domid available to the script anyhow.
Quoted 7 lines
Quoted 4 lines
So far I've tracked the problem as far as noticing that NetDev.destroy in
python/xen/xend/server/netif.pyisn't passed the name of the domain, but I haven't figured out how to best fix this. I'm willing to work on it a bit; any suggestions for how to approach it?Mike would be the best person to fix this, but he's on holiday for a week. Any takers?
I took a closer look at the problem this week and came up with a fix. My approach for now is to store the domain name as well as the domain ID in the Controller instance for the domain's network interfaces. Right now I have the code structured so that the domain name can be made available to block devices, console devices, etc., but I only have everything implemented for network devices.
I don't know if this is the best approach to take. I also considered making the full XendDomainInfo object available, but decided for now just to pass the name along.
Preliminary patch is attached, but it shouldn't be applied because I'd at least like to do some other cleanup first. Plus, it might be decided that another approach is better. But it works for me.
--Michael Vrable
tools/python/xen/xend/server/controller.py +2 -1
@@ -305,10 +305,11 @@ """Abstract class for a device controller attached to a domain. """ - def __init__(self, factory, dom): + def __init__(self, factory, dom, name=None): CtrlMsgRcvr.__init__(self) self.factory = factory self.dom = int(dom) + self.name = name self.channel = None self.idx = None
tools/python/xen/xend/server/netif.py +6 -5
@@ -33,17 +33,18 @@ self.attached = 1 self.registerChannel() - def createInstance(self, dom, recreate=0): + def createInstance(self, dom, recreate=0, name=None): """Create or find the network interface controller for a domain. dom domain recreate if true this is a recreate (xend restarted) + name domain name returns netif controller """ netif = self.getInstanceByDom(dom) if netif is None: - netif = NetifController(self, dom) + netif = NetifController(self, dom, name) self.addInstance(netif) return netif
@@ -168,7 +169,7 @@ def vifctl_params(self, vmname=None): dom = self.controller.dom - name = vmname or ('DOM%d' % dom) + name = self.controller.name or ('DOM%d' % dom) return { 'domain': name, 'vif' : self.get_vifname(), 'mac' : self.get_mac(),
@@ -201,8 +202,8 @@ """Network interface controller. Handles all network devices for a domain. """ - def __init__(self, factory, dom): - controller.Controller.__init__(self, factory, dom) + def __init__(self, factory, dom, name=None): + controller.Controller.__init__(self, factory, dom, name) self.devices = {} self.majorTypes = [ CMSG_NETIF_FE ]
tools/python/xen/xend/server/SrvDaemon.py +2 -2
@@ -699,11 +699,11 @@ """ return self.netifCF.getControlDomain() - def netif_create(self, dom, recreate=0): + def netif_create(self, dom, recreate=0, name=None): """Create a network interface controller. """ - return self.netifCF.createInstance(dom, recreate=recreate) + return self.netifCF.createInstance(dom, recreate=recreate, name=name) def netifs(self): return [ x.sxpr() for x in self.netifCF.getInstances() ]
tools/python/xen/xend/XendDomainInfo.py +1 -1
@@ -1015,7 +1015,7 @@ raise VmError('vif: vif in netif backend domain') vif = vm.next_device_index('vif') vmac = sxp.child_value(val, "mac") - xend.netif_create(vm.dom, recreate=vm.recreate) + xend.netif_create(vm.dom, name=vm.name, recreate=vm.recreate) log.debug("Creating vif dom=%d vif=%d mac=%s", vm.dom, vif, str(vmac)) defer = xend.netif_dev_create(vm.dom, vif, val, recreate=vm.recreate) def fn(id):