WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

RE: [Xen-devel] [PATCH] disallow duplicate pci device strings in guest c

To: Simon Horman <horms@xxxxxxxxxxxx>
Subject: RE: [Xen-devel] [PATCH] disallow duplicate pci device strings in guest config file
From: "Cui, Dexuan" <dexuan.cui@xxxxxxxxx>
Date: Mon, 18 May 2009 08:57:29 +0800
Accept-language: zh-CN, en-US
Acceptlanguage: zh-CN, en-US
Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Keir Fraser <Keir.Fraser@xxxxxxxxxxxxx>
Delivery-date: Sun, 17 May 2009 17:59:48 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20090516045239.GB1827@xxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <EADF0A36011179459010BDF5142A457501C990A939@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <20090516045239.GB1827@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcnV4iZO8sLwh38sR/K4A7lVCpXTlwBcMAUg
Thread-topic: [Xen-devel] [PATCH] disallow duplicate pci device strings in guest config file
Simon Horman wrote:
> On Fri, May 15, 2009 at 07:31:23PM +0800, Cui, Dexuan wrote:
>> When we specify duplicate pci device strings in guest config file,
>> like pci=['01:00.0', '01:00.0'], or  pci=['01:00.0',
>> '0000:01:00.0'], or  pci=['01:00.0', '0000:01:00.0@7'],  
>> xend doesn't detect this case and passes the pci string to ioemu and
>> ioemu invokes register_real_device() twice for the same physical
>> device and this could cause unexpected behavior.  
>> 
>> The patch detects this case and makes the domain construction fail.
>> 
>> diff -r 40d4267296ad tools/python/xen/xend/server/pciif.py
>> --- a/tools/python/xen/xend/server/pciif.py  Fri May 15 08:12:39 2009
>> +0100 +++ b/tools/python/xen/xend/server/pciif.py    Fri May 15
>> 17:14:43 2009 +0800 @@ -396,6 +396,9 @@ class
>>              PciController(DevController): pci_str =
>>              '%04x:%02x:%02x.%01x' % (domain, bus, slot, func)
>>              pci_str_list = pci_str_list + [pci_str] pci_dev_list =
>> pci_dev_list + [(domain, bus, slot, func)] + +        if
>> pci_str_list != list(set(pci_str_list)): +            raise
>> VmError('pci: duplicate devices specified in guest config?') 
>> 
>>          for (domain, bus, slot, func) in pci_dev_list:
>>              try:
> 
> Hi Dexuan, Hi Keir,
> 
> At a glance it seems that this might not be correct,
> as set() may not preserve the order of pci_str_list.
Thanks for pointing this out !

> However, as set will remove any duplicates, its probably
> sufficient to use:
> 
>       if len(pci_str_list) != len(set(pci_str_list):
Yes. This should be the right way.

Thanks,
-- Dexuan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel