[virt-tools-list] [PATCH v2 2/2] addhardware: use bus, device to distingush usb products

Cole Robinson crobinso at redhat.com
Mon Apr 29 16:04:17 UTC 2013


On 04/29/2013 09:07 AM, Guan Nan Ren wrote:
> 
>  I realized this patch only tries to solve one aspect of the whole duplicate usb devices issue.
>  If there is a usb device which has been attached to guest with vendor/product, then I plug a new
>  duplicate usb device into host, the new device will use vendor/product/bus/addr to be attached
>  to the same guest. If so, we have to update the first usb device with bus/addr info too, otherwise,
>  the guest will throw an error at next boot. Reverse the process when removing the duplicate. 
> 
>  One way of doing this is before adding the duplicate usb device into guest, we update the persistent
>  guest XML with corresponding bus/addr of first usb device. The hard part is its bus/addr info is lost
>  already at this time.
> 
>  The other way is updating first device in tick(), when new duplicate node device is added, the
>  signal handler of 'nodedev-added' can help update the first device which has been attached to
>  a guest by redefining guest persistent XML. The downside is there too, we have to go through all of
>  guest to update every time when new node device is plugged into host.
> 
>  And currently, one usb device only use vendor/product after attached into a guest, that means I can
>  can change it to any usb device as long as they own the same vendorId/productId after vm reboot. If we
>  use vendor/product/bus/addr, there is no such problem.
> 
>  Any idea to fix the issue is welcome :)
>  About above words, please feel free to correct me.
> 

Hmm, indeed this is a tricky problem. But it makes me think that
differentiating on duplicate vendor/product by bus/addr just isn't the best
fix (although it's definitely good that libvirt supports it now). Was any
thought given to allowing USB device serial numbers in the XML? Should be
basically the same of libvirt looking up the bits in sysfs like is done for
vendor/product, and _should_ be unique although I don't know how well that's
true in the wild.

The case where a duplicate device is added to the host later, honestly the
best we can do is to try and provide a useful error here, and tell the users
to re-attach their devices. We could do that with a pre-start validation hook
which could be useful for other things in the future.

But honestly I'd be quite comfortable just telling people that their scenario
is not one where virt-manager is going to help them out much, and they will
just need to remove and reattach the devices to all guests to get the updated
bus/addr info.

- Cole

> 
> 
> 
> ----- Original Message -----
> From: "Cole Robinson" <crobinso at redhat.com>
> To: "Guannan Ren" <gren at redhat.com>
> Cc: virt-tools-list at redhat.com
> Sent: Saturday, April 27, 2013 3:56:00 AM
> Subject: Re: [virt-tools-list] [PATCH v2 2/2] addhardware: use bus, device to distingush usb products
> 
> 
> Doing this bit unconditionally in virtinst, then undoing the bus/addr bits in
> virt-manager is not a good idea, since now virt-install is still 'broken' in
> this way. We want to avoid setting bus/addr unless it's the only option to
> make things work (duplicate devices).
> 
> You could do the duplicate check before creating the HostDevice, then passdown
> an option like is_dup to device_from_node
> 
> - Cole
> 




More information about the virt-tools-list mailing list