[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



On 04/30/2013 12:04 AM, Cole Robinson wrote:
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.

Yeah, if each of usb devices has a identifier like MAC for NIC, things will be so hard. I checked for a while, there is no such serial number, it is reasonable though,
    there is so many kind of usb devices and vendors.



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.

    The pre-start hook is a good idea, I implemented one in my v3 path 3/3
    if you have time, please help review it.

    Guannan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]