qemu-devel
[Top][All Lists]
Advanced

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

Re: device hotplug & file handles


From: Eric Blake
Subject: Re: device hotplug & file handles
Date: Thu, 7 May 2020 12:05:54 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 5/7/20 9:49 AM, Gerd Hoffmann wrote:
   Hi,

For usb device pass-through (aka -device usb-host) it would be very
useful to pass file handles from libvirt to qemu.  The workflow would
change from ...

   (1) libvirt enables access to /dev/usb/$bus/$dev
   (2) libvirt passes $bus + $dev (using hostbus + hostaddr properties)
       to qemu.
   (3) qemu opens /dev/usb/$bus/$dev

... to ...

   (1) libvirt opens /dev/usb/$bus/$dev
   (2) libvirt passes filehandle to qemu.

Question is how can we pass the file descriptor best?  My idea would be
to simply add an fd property to usb-host:

  * Coldplug would be "-device usb-host,fd=<nr>" (cmd line).
  * Hotplug would be "device_add usb-host,fd=<getfd-name>" (monitor).

Will that work from libvirt point of view?
Or does anyone have an better idea?

Qemu already has -add-fd (both a CLI version, and a QMP version when a Unix socket can pass fds), at which point any existing interface that uses qemu_open() will understand the magic syntax /dev/fdset/NNN to refer to the existing fd previously passed in via -add-fd. Libvirt is already able to use this feature for some cases (for example, see src/qemu/qemu_command.c:qemuBuildChrChardevFileStr). So all that remains is making sure -device usb-host uses qemu_open(), and if it didn't already do so, also making sure libvirt can find a way to introspect when usb-host started supporting fdset usage.

Or put another way, let's use the generic fd mechanism that qemu already supports, rather than inventing yet another syntax.


thanks,
   Gerd

PS: background: https://bugzilla.redhat.com/show_bug.cgi?id=1595525


--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]