From: Simon Horman Subject: xend: Fix check for request to detatch non-existent device Date: Fri, 29 May 2009 16:57:51 +1000 Message-ID: <20090529065750.GA20733@verge.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Masaki Kanno List-Id: xen-devel@lists.xenproject.org This fixes the check for a request to detatch a non-existent device in pci_device_configure. The previous check was bogus because the format of AUTO_PHP_SLOT_STR is not the same as that of x['vslot']. However, it works in a slightly non-obvious way, checking taht vslot hasn't been altered from its initial value AUTO_PHP_SLOT_STR. To make this shceme a little clearer, use an empty string as the inital value. Formting issues asside, neither AUTO_PHP_SLOT_STR nor the empty string are valid values for x['vslot']. In the event of invalid data (indicating a bug), it should be caught by self.hvm_destroyPCIDevice. Cc: Masaki Kanno Signed-off-by: Simon Horman Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xend/XendDomainInfo.py 2009-04-23 02:53:43.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py 2009-04-23 02:57:07.000000000 +1000 @@ -809,7 +809,7 @@ class XendDomainInfo: existing_dev_uuid = sxp.child_value(existing_dev_info, 'uuid') existing_pci_conf = self.info['devices'][existing_dev_uuid][1] existing_pci_devs = existing_pci_conf['devs'] - vslot = AUTO_PHP_SLOT_STR + vslot = "" for x in existing_pci_devs: if ( int(x['domain'], 16) == int(dev['domain'], 16) and int(x['bus'], 16) == int(dev['bus'], 16) and @@ -817,7 +817,7 @@ class XendDomainInfo: int(x['func'], 16) == int(dev['func'], 16) ): vslot = x['vslot'] break - if vslot == AUTO_PHP_SLOT_STR: + if vslot == "": raise VmError("Device %04x:%02x:%02x.%01x is not connected" % (int(dev['domain'],16), int(dev['bus'],16), int(dev['slot'],16), int(dev['func'],16)))