[PATCH v1 10/12] add hostdev handling for bhyve

Daniel P. Berrangé berrange at redhat.com
Mon Feb 24 18:02:51 UTC 2020


On Mon, Feb 24, 2020 at 01:46:22AM -0500, Ryan Moeller wrote:
> Handle PCI passthrough and virtio-scsi using hostdev devices.
> 
> Example PCI passthrough:
> domain xml snippet
> ```
> <memoryBacking>
>   <locked/>
> </memoryBacking>
> <devices>
>   <hostdev mode='subsystem' type='pci'>
>     <source>
>       <address domain='0x0000' bus='0x06' slot='0x02' function='0x00'/>
>     </source>
>     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x00'/>
>   </hostdev>
> </devices>
> ```
> loader.conf snippet
> ```
> vmm_load="YES"
> pptdevs="6/2/0"
> ```
> 
> Example SCSI passthrough:
> domain xml snippet
> ```
> <hostdev mode='subsystem' type='scsi_ctl' model='virtio'>
>   <source protocol='ioctl' pp='5' vp='0'/>
>   <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x00'/>
> </hostdev>
> ```
> ctl.conf snippet
> ```
> portal-group "pg0" {
>         discovery-auth-group "no-authentication"
>         listen "127.0.0.1"
> }
> 
> target iqn.2020-01.com.example:target0 {
>         auth-group "no-authentication"
>         portal-group "pg0"
>         port ioctl/5/0
> 
>         lun 0 { path "/dev/zvol/storage/lun0" }
>         lun 1 { path "/dev/zvol/storage/lun1" }
>         lun 2 { path "/dev/zvol/storage/lun2" }
>         lun 3 { path "/dev/zvol/storage/lun3" }
> }
> ```

Can you split this patch up into a few pieces.

We generally want the changes to the XML parser/formatter to
be separate from any driver code, as the first part.

Then I'd suggest a separate patch for the PCI and the SCSI
hostdev support in bhyve.

> 
> Signed-off-by: Ryan Moeller <ryan at iXsystems.com>
> ---
>  docs/schemas/domaincommon.rng                 |  30 ++++
>  src/bhyve/bhyve_capabilities.c                |  14 ++
>  src/bhyve/bhyve_capabilities.h                |   1 +
>  src/bhyve/bhyve_command.c                     | 121 ++++++++++++++++
>  src/bhyve/bhyve_parse_command.c               |  90 ++++++++++++
>  src/conf/domain_audit.c                       |   5 +
>  src/conf/domain_conf.c                        | 131 ++++++++++++++++++
>  src/conf/domain_conf.h                        |  29 +++-

For the conf stuff we'll need a docs update in docs/formatdomain.html.in
at the same time as this parser additions.

If you can provide a little detail in the commit message on why the current
SCSI hostdev stuff doesn't work for FreeBSD that'd be useful too.

>  src/conf/virconftypes.h                       |   3 +
>  src/qemu/qemu_command.c                       |   2 +
>  src/qemu/qemu_domain.c                        |   5 +
>  src/qemu/qemu_hostdev.c                       |   1 +
>  src/qemu/qemu_hotplug.c                       |   2 +
>  src/qemu/qemu_migration.c                     |   1 +
>  src/security/security_apparmor.c              |   1 +
>  src/security/security_dac.c                   |  28 ++++
>  src/security/security_selinux.c               |   8 ++
>  .../bhyveargv2xml-passthru.args               |   8 ++
>  .../bhyveargv2xml-passthru.xml                |  26 ++++
>  .../bhyveargv2xml-virtio-scsi.args            |   9 ++
>  .../bhyveargv2xml-virtio-scsi.xml             |  20 +++
>  tests/bhyveargv2xmltest.c                     |   2 +
[>  .../bhyvexml2argv-passthru.args               |  11 ++
>  .../bhyvexml2argv-passthru.ldargs             |   1 +
>  .../bhyvexml2argv-passthru.xml                |  22 +++
>  .../bhyvexml2argv-virtio-scsi.args            |   9 ++
>  .../bhyvexml2argv-virtio-scsi.ldargs          |   1 +
>  .../bhyvexml2argv-virtio-scsi.xml             |  21 +++
>  tests/bhyvexml2argvtest.c                     |   4 +-
>  .../bhyvexml2xmlout-passthru.xml              |  29 ++++
>  .../bhyvexml2xmlout-virtio-scsi.xml           |  23 +++
>  tests/bhyvexml2xmltest.c                      |   2 +
>  32 files changed, 658 insertions(+), 2 deletions(-)
>  create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-passthru.args
>  create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-passthru.xml
>  create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-scsi.args
>  create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-virtio-scsi.xml
>  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-passthru.args
>  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-passthru.ldargs
>  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-passthru.xml
>  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.args
>  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.ldargs
>  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.xml
>  create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-passthru.xml
>  create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-virtio-scsi.xml

I didn't see anything in the code is keeping track of in-use PCI devices.
Does something else in FreeBSD guarantee that you won't have bad stuff
happening if the PCI device is attempted to be assigned to 2 guests ?

Also is it required to manually detach the host OS driver first, or
is that automatic ?  This ties into which 'managed=no|yes' attribute
choices you should permit for the hostdev.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list