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:
v4:
- Rebase
- Rebased to current master (21 November)
- s/virDomainPCIAddressEnsureAddr/qemuDomainEnsurePCIAddress/
(per commit abb7a4bd)
- Renaming (apologies if this list is off slightly from the code)
- Per comments in v3.2, some renaming has been performed:
-- virDomainHostdevSubsysHostProtocol =>
virDomainHostdevSubsysSCSIHostProtocol
-- VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_HOST =>
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST
-- VIR_DOMAIN_HOSTDEV_SUBSYS_HOST_PROTOCOL_TYPE_ =>
VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_
-- virDomainHostdevSubsysHost => virDomainHostdevSubsysSCSIVHost
-- virDomainHostdevSubsysHost host; => virDomainHostdevSubsysSCSIVHost
scsi_host;
-- src/util/virhost.[ch] => src/util/virscsivhost.[ch]
-- virHost... => virSCSIVHost...
-- activeHostHostdevs => activeSCSIVHostHostdevs
-- qemuBuildHostHostdevDevStr => qemuBuildSCSIVHostHostdevDevStr
-- qemuSetupHostHostDeviceCgroup => qemuSetupHostSCSIVHostDeviceCgroup
- Comments
- Checked for a guest address tag that is of type PCI or CCW
(it is optional, and should be calculated automatically)
- Removed the array of "used by" information in hostdev utilities,
since devices will not be shared
- Fixed the existing tests to properly check for an address
- Added a set of CCW tests in addition to the existing PCI ones
- Removed protocol check in PrimeVirtioDeviceAddresses
- Things *NOT* done (later?) from v2 feedback
- 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
v3.2:
https://www.redhat.com/archives/libvir-list/2016-November/msg00454.html
v3.1:
https://www.redhat.com/archives/libvir-list/2016-October/msg01324.html
v3:
https://www.redhat.com/archives/libvir-list/2016-October/msg01201.html
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 (9):
qemu: Introduce vhost-scsi capability
Introduce framework for a hostdev SCSI_host subsystem 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 tests
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 | 101 +++++++-
src/conf/domain_conf.h | 18 ++
src/libvirt_private.syms | 18 ++
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_cgroup.c | 39 +++
src/qemu/qemu_command.c | 80 ++++++
src/qemu/qemu_command.h | 5 +
src/qemu/qemu_domain_address.c | 14 +-
src/qemu/qemu_hostdev.c | 41 +++
src/qemu/qemu_hostdev.h | 8 +
src/qemu/qemu_hotplug.c | 166 ++++++++++++
src/security/security_apparmor.c | 22 ++
src/security/security_dac.c | 50 ++++
src/security/security_selinux.c | 47 ++++
src/util/virhostdev.c | 163 ++++++++++++
src/util/virhostdev.h | 16 ++
src/util/virscsivhost.c | 288 +++++++++++++++++++++
src/util/virscsivhost.h | 65 +++++
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-ccw.args | 23 ++
.../qemuxml2argv-hostdev-scsi-vhost-scsi-ccw.xml | 34 +++
.../qemuxml2argv-hostdev-scsi-vhost-scsi-pci.args | 24 ++
.../qemuxml2argv-hostdev-scsi-vhost-scsi-pci.xml | 42 +++
tests/qemuxml2argvmock.c | 9 +
tests/qemuxml2argvtest.c | 6 +
.../qemuxml2xmlout-hostdev-scsi-vhost-scsi-ccw.xml | 1 +
.../qemuxml2xmlout-hostdev-scsi-vhost-scsi-pci.xml | 1 +
tests/qemuxml2xmltest.c | 6 +
45 files changed, 1355 insertions(+), 3 deletions(-)
create mode 100644 src/util/virscsivhost.c
create mode 100644 src/util/virscsivhost.h
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-ccw.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-ccw.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-pci.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-vhost-scsi-pci.xml
create mode 120000
tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-vhost-scsi-ccw.xml
create mode 120000
tests/qemuxml2xmloutdata/qemuxml2xmlout-hostdev-scsi-vhost-scsi-pci.xml
--
1.9.1