[libvirt] [PATCH RESEND v3.2 00/10] Implementation of QEMU vhost-scsi

Eric Farman farman at linux.vnet.ibm.com
Tue Nov 8 18:26:22 UTC 2016


[NOTE: Resending after a week, and rebased to apply to master after
last week's application of commit 22d94ca4]

This patch series provides a libvirt implementation of the vhost-scsi
interface in QEMU.  As near as I can see, this was discussed upstream in
July 2014[1], and ended in a desire to replace a vhost-scsi controller
in favor of a hostdev element instead[2].

Host setup via targetcli (SCSI LUN(s) are already defined to host):
  # targetcli
  targetcli shell version 2.1.fb35
  Copyright 2011-2013 by Datera, Inc and others.
  For help on commands, type 'help'.

  /> backstores/block create name=disk1 write_back=false \
     dev=/dev/disk/by-id/dm-name-36005076306ffc7630000000000002211
  Created block storage object disk1 using
     /dev/disk/by-id/dm-name-36005076306ffc7630000000000002211.
  /> vhost/ create
  Created target naa.5001405df3e54061.
  Created TPG 1.
  /> vhost/naa.5001405df3e54061/tpg1/luns create /backstores/block/disk1
  Created LUN 0.
  /> exit

Host Filesystem Example:
  # ls /sys/kernel/config/target/vhost/
  discovery_auth  naa.5001405df3e54061  version
  # ls /sys/kernel/config/target/vhost/naa.5001405df3e54061/tpgt_1/lun/
  lun_0

QEMU Example (snippet):
  -device vhost-scsi-ccw,wwpn=naa.5001405df3e54061,devno=fe.0.1000

Libvirt Example (snippet):
  <hostdev mode='subsystem' type='scsi_host'>
    <source protocol='vhost' wwpn='naa.5001405df3e54061'/>
    <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x1000'/>
  </hostdev>

Guest Viewpoint:
  # lsscsi
  [1:0:1:0]    disk    LIO-ORG  disk0            4.0   /dev/sda 
  # dmesg | grep 1:
  [    6.065735] scsi host1: Virtio SCSI HBA
  [    6.093892] scsi 1:0:1:0: Direct-Access     LIO-ORG  disk0            4.0  PQ: 0 ANSI: 5
  [    6.313615] sd 1:0:1:0: Attached scsi generic sg0 type 0
  [    6.314981] sd 1:0:1:0: [sda] 29360128 512-byte logical blocks: (15.0 GB/14.0 GiB)
  [    6.317290] sd 1:0:1:0: [sda] Write Protect is off
  [    6.317566] sd 1:0:1:0: [sda] Mode Sense: 43 00 10 08
  [    6.317853] sd 1:0:1:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
  [    6.352722] sd 1:0:1:0: [sda] Attached SCSI disk

Changelog:

  v3.2:
   - Rebase
      - Rebased to current master (8 November)
      - Minor changes to (new file) src/util/virhost.c for make syntax-check

  v3.1:  https://www.redhat.com/archives/libvir-list/2016-October/msg01324.html
   - Rebase
      - Rebased to current master (31 October)
      - Included the prereq patch for the subsystem type in switch statements (oops!)

  v3:    https://www.redhat.com/archives/libvir-list/2016-October/msg01201.html
   - Rebase
      - Rebased to current master (26 October)
   - Comments
      - Added an early patch to do some additional typecasting in the
        switch statements of hostdev.subsys.type
      - Did some reordering of patches, to hopefully flow better
      - Implemented an activeHostHostdevs list, which is used by the
        cgroup and security codepaths
      - doc changes -- s/2.2/2.5/ and s/HBI/HBA/
      - Added a "none" protocol type for scsi_host hostdevs (which is invalid)
      - Restored the apparmor and selinux codepaths that got lost from v1
      - Added a proper check for a valid scsi_host protocol, and saving that
        value within the HostdevDef struct
      - Fixed a compiler warning with call to virDomainPCIAddressEnsureAddr
      - Removed the rest of vhostfdSize, since multiple fd's are not allowed
        by QEMU
      - Fixed cleanup of vhostfd in error from building -device string
      - Moved the "conf" chunk from "hotplug" patch to "introduce" patch
      - Added xml2xml test
      - Added a proper calculation of "address" in virDomainAuditHostdev
      - Added a virFileExists check before open(/dev/vhost-scsi)
      - Addressed a number of lines >80 characters
   - Things *NOT* done (later?)
      - Investigation/tie-in with virsh nodedev-list stuff
      - Implementation of 'num_queues', 'max_sectors', and 'cmd_per_lun'
        (Need to research these in the virtio space, before figuring out
        how to apply to vhost-scsi)
      - Dropping the "naa." prefix of wwn
      - Split the "tests" patch into earlier patches
   - Other
  v2.1:  https://www.redhat.com/archives/libvir-list/2016-September/msg00148.html
  v2:    https://www.redhat.com/archives/libvir-list/2016-August/msg01028.html
  v1:    https://www.redhat.com/archives/libvir-list/2016-July/msg01004.html

[1] http://www.redhat.com/archives/libvir-list/2014-July/msg01235.html
[2] http://www.redhat.com/archives/libvir-list/2014-July/msg01390.html

Eric Farman (10):
  Cleanup switch statements on the hostdev subsystem type
  qemu: Introduce vhost-scsi capability
  Introduce a "scsi_host" hostdev type
  util: Management routines for scsi_host devices
  qemu: Add vhost-scsi string for -device parameter
  qemu: Allow hotplug of vhost-scsi device
  conf: Wire up the vhost-scsi connection from/to XML
  security: Include vhost-scsi in security labels
  tests: Introduce basic vhost-scsi test
  docs: Add vhost-scsi

 docs/formatdomain.html.in                          |  24 ++
 docs/schemas/domaincommon.rng                      |  23 ++
 po/POTFILES.in                                     |   1 +
 src/Makefile.am                                    |   1 +
 src/conf/domain_audit.c                            |   7 +
 src/conf/domain_conf.c                             | 102 ++++++-
 src/conf/domain_conf.h                             |  18 ++
 src/libvirt_private.syms                           |  19 ++
 src/qemu/qemu_capabilities.c                       |   2 +
 src/qemu/qemu_capabilities.h                       |   1 +
 src/qemu/qemu_cgroup.c                             |  50 +++-
 src/qemu/qemu_command.c                            |  79 ++++++
 src/qemu/qemu_command.h                            |   5 +
 src/qemu/qemu_domain_address.c                     |  10 +
 src/qemu/qemu_hostdev.c                            |  41 +++
 src/qemu/qemu_hostdev.h                            |   8 +
 src/qemu/qemu_hotplug.c                            | 160 +++++++++++
 src/security/security_apparmor.c                   |  24 +-
 src/security/security_dac.c                        |  46 ++++
 src/security/security_selinux.c                    |  51 +++-
 src/util/virhost.c                                 | 299 +++++++++++++++++++++
 src/util/virhost.h                                 |  72 +++++
 src/util/virhostdev.c                              | 155 +++++++++++
 src/util/virhostdev.h                              |  16 ++
 tests/domaincapsschemadata/full.xml                |   1 +
 tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml   |   1 +
 .../caps_2.6.0-gicv2.aarch64.xml                   |   1 +
 .../caps_2.6.0-gicv3.aarch64.xml                   |   1 +
 tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml  |   1 +
 tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml   |   1 +
 tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |   1 +
 .../qemuxml2argv-hostdev-scsi-vhost-scsi.args      |  24 ++
 .../qemuxml2argv-hostdev-scsi-vhost-scsi.xml       |  41 +++
 tests/qemuxml2argvmock.c                           |   9 +
 tests/qemuxml2argvtest.c                           |   3 +
 .../qemuxml2xmlout-hostdev-scsi-vhost-scsi.xml     |   1 +
 tests/qemuxml2xmltest.c                            |   3 +
 42 files changed, 1293 insertions(+), 14 deletions(-)
 create mode 100644 src/util/virhost.c
 create mode 100644 src/util/virhost.h
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi.xml
 create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-vhost-scsi.xml

-- 
1.9.1




More information about the libvir-list mailing list