From: Michael Vrable Subject: Re: Inconsistent domain parameter passed to vif-bridge Date: Wed, 4 Aug 2004 13:26:25 -0700 Sender: xen-devel-admin@lists.sourceforge.net Message-ID: <20040804132625.A22054@gradlab.ucsd.edu> References: <20040730152006.A15608@gradlab.ucsd.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="vGgW1X5XWziG23Ko" Return-path: Content-Disposition: inline In-Reply-To: ; from Ian.Pratt@cl.cam.ac.uk on Sat, Jul 31, 2004 at 12:16:10PM +0100 Errors-To: xen-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: xen-devel@lists.sourceforge.net List-Id: xen-devel@lists.xenproject.org --vGgW1X5XWziG23Ko Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Jul 31, 2004 at 12:16:10PM +0100, Ian Pratt wrote: > > 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", where 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. > > > 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? > > 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 --vGgW1X5XWziG23Ko Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="xen-netif-domname.patch" diff -urN xeno-unstable.orig/tools/python/xen/xend/server/controller.py xeno-unstable/tools/python/xen/xend/server/controller.py --- xeno-unstable.orig/tools/python/xen/xend/server/controller.py 2004-08-03 19:56:00.000000000 -0700 +++ xeno-unstable/tools/python/xen/xend/server/controller.py 2004-08-04 10:11:55.579833196 -0700 @@ -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 diff -urN xeno-unstable.orig/tools/python/xen/xend/server/netif.py xeno-unstable/tools/python/xen/xend/server/netif.py --- xeno-unstable.orig/tools/python/xen/xend/server/netif.py 2004-08-03 19:56:03.000000000 -0700 +++ xeno-unstable/tools/python/xen/xend/server/netif.py 2004-08-04 10:25:18.133042332 -0700 @@ -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 ] diff -urN xeno-unstable.orig/tools/python/xen/xend/server/SrvDaemon.py xeno-unstable/tools/python/xen/xend/server/SrvDaemon.py --- xeno-unstable.orig/tools/python/xen/xend/server/SrvDaemon.py 2004-08-03 19:56:05.000000000 -0700 +++ xeno-unstable/tools/python/xen/xend/server/SrvDaemon.py 2004-08-04 10:22:22.224596425 -0700 @@ -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() ] diff -urN xeno-unstable.orig/tools/python/xen/xend/XendDomainInfo.py xeno-unstable/tools/python/xen/xend/XendDomainInfo.py --- xeno-unstable.orig/tools/python/xen/xend/XendDomainInfo.py 2004-08-03 19:56:01.000000000 -0700 +++ xeno-unstable/tools/python/xen/xend/XendDomainInfo.py 2004-08-04 10:22:31.193650434 -0700 @@ -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): --vGgW1X5XWziG23Ko-- ------------------------------------------------------- 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