[PATCH 0/3] bhyve: add virtio-scsi support
Roman Bogorodskiy (3): conf: introduce CTL storage type bhyve: add virtio-scsi support docs: bhyve: document virtio-scsi support docs/drvbhyve.rst | 19 +++++ docs/formatdomain.rst | 5 ++ src/bhyve/bhyve_command.c | 73 ++++++++++++++++++- src/bhyve/bhyve_device.c | 1 + src/bhyve/bhyve_process.c | 1 + src/ch/ch_monitor.c | 1 + src/conf/domain_conf.c | 7 ++ src/conf/schemas/domaincommon.rng | 13 ++++ src/conf/storage_source_conf.c | 6 +- src/conf/storage_source_conf.h | 1 + src/libxl/xen_xl.c | 1 + src/qemu/qemu_block.c | 2 + src/qemu/qemu_command.c | 1 + src/qemu/qemu_migration.c | 3 + src/qemu/qemu_process.c | 1 + src/qemu/qemu_snapshot.c | 4 + src/qemu/qemu_validate.c | 1 + src/storage_file/storage_source.c | 1 + .../bhyvexml2argv-virtio-scsi.args | 10 +++ .../bhyvexml2argv-virtio-scsi.ldargs | 4 + .../bhyvexml2argv-virtio-scsi.xml | 21 ++++++ tests/bhyvexml2argvtest.c | 1 + .../bhyvexml2xmlout-virtio-scsi.xml | 32 ++++++++ tests/bhyvexml2xmltest.c | 1 + 24 files changed, 205 insertions(+), 5 deletions(-) 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-virtio-scsi.xml -- 2.52.0
CTL stands for CAM Target Layer, and CAM stands for Common Access Method Storage subsystem, and is available on FreeBSD. Quoting the ctl(4) manual page: The ctl subsystem provides SCSI target devices emulation. It supports features such as: • Disk, CD-ROM and processor device emulation • Tagged queueing • SCSI task attribute support (ordered, head of queue, simple tags) • SCSI implicit command ordering support • Full task management support (abort, query, reset, etc.) • Support for multiple ports, initiators, targets and backing stores • Support for VMWare VAAI and Microsoft ODX offload (COMPARE AND WRITE, XCOPY, POPULATE TOKEN/WRITE USING TOKEN, WRITE SAME and UNMAP) • Persistent reservation support • Extensive VPD/mode/log pages support • Featured error reporting, error injection and basic SMART support • High Availability clustering support with ALUA • All I/O handled in-kernel, no userland context switch overhead This is a preparation for implementing virtio-scsi support for the bhyve driver. Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- src/bhyve/bhyve_process.c | 1 + src/ch/ch_monitor.c | 1 + src/conf/domain_conf.c | 7 +++++++ src/conf/schemas/domaincommon.rng | 13 +++++++++++++ src/conf/storage_source_conf.c | 6 +++++- src/conf/storage_source_conf.h | 1 + src/libxl/xen_xl.c | 1 + src/qemu/qemu_block.c | 2 ++ src/qemu/qemu_command.c | 1 + src/qemu/qemu_migration.c | 3 +++ src/qemu/qemu_process.c | 1 + src/qemu/qemu_snapshot.c | 4 ++++ src/qemu/qemu_validate.c | 1 + src/storage_file/storage_source.c | 1 + 14 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 7de614a1a3..1d436da609 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -405,6 +405,7 @@ bhyvePrepareNVRAM(bhyveConn *driver, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_LAST: case VIR_STORAGE_TYPE_NONE: break; diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index 46b31acc76..52f281cf73 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -285,6 +285,7 @@ virCHMonitorBuildDiskJson(virDomainDiskDef *diskdef) case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_LAST: default: virReportEnumRangeError(virStorageType, diskdef->src->type); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 541dad5bdc..b85bbbcaf6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7831,6 +7831,9 @@ virDomainStorageSourceParse(xmlNodePtr node, if (!(src->vdpadev = virXMLPropStringRequired(node, "dev"))) return -1; break; + case VIR_STORAGE_TYPE_CTL: + src->path = virXMLPropString(node, "dev"); + break; case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -23711,6 +23714,10 @@ virDomainDiskSourceFormat(virBuffer *buf, virBufferEscapeString(&attrBuf, " dev='%s'", src->vdpadev); break; + case VIR_STORAGE_TYPE_CTL: + virBufferEscapeString(&attrBuf, " dev='%s'", src->path); + break; + case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 1f9ac102a0..5d5fd87f87 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -1905,6 +1905,7 @@ <ref name="diskSourceNvme"/> <ref name="diskSourceVhostUser"/> <ref name="diskSourceVhostVdpa"/> + <ref name="diskSourceCtl"/> </choice> </define> @@ -2544,6 +2545,18 @@ </element> </define> + <define name="diskSourceCtl"> + <attribute name="type"> + <value>ctl</value> + </attribute> + <element name="source"> + <attribute name="dev"> + <ref name="absFilePath"/> + </attribute> + <empty/> + </element> + </define> + <define name="diskTargetDev"> <choice> <data type="string"> diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c index 087de1eaf2..d7b9bdfecb 100644 --- a/src/conf/storage_source_conf.c +++ b/src/conf/storage_source_conf.c @@ -48,7 +48,8 @@ VIR_ENUM_IMPL(virStorage, "volume", "nvme", "vhostuser", - "vhostvdpa" + "vhostvdpa", + "ctl", ); @@ -976,6 +977,7 @@ virStorageSourceIsSameLocation(virStorageSource *a, case VIR_STORAGE_TYPE_DIR: case VIR_STORAGE_TYPE_LAST: case VIR_STORAGE_TYPE_VOLUME: + case VIR_STORAGE_TYPE_CTL: /* nothing to do */ break; } @@ -1058,6 +1060,7 @@ virStorageSourceIsLocalStorage(const virStorageSource *src) case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_DIR: + case VIR_STORAGE_TYPE_CTL: return true; case VIR_STORAGE_TYPE_NETWORK: @@ -1263,6 +1266,7 @@ virStorageSourceIsRelative(virStorageSource *src) case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_DIR: + case VIR_STORAGE_TYPE_CTL: return !g_path_is_absolute(src->path); case VIR_STORAGE_TYPE_NETWORK: diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h index fc868b31af..22c35d420d 100644 --- a/src/conf/storage_source_conf.h +++ b/src/conf/storage_source_conf.h @@ -44,6 +44,7 @@ typedef enum { VIR_STORAGE_TYPE_NVME, VIR_STORAGE_TYPE_VHOST_USER, VIR_STORAGE_TYPE_VHOST_VDPA, + VIR_STORAGE_TYPE_CTL, VIR_STORAGE_TYPE_LAST } virStorageType; diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index b2ff0edcf2..e72e7d7f44 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1531,6 +1531,7 @@ xenFormatXLDiskSrc(virStorageSource *src, char **srcstr) case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index a7062d3e96..9b43279797 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1046,6 +1046,7 @@ qemuBlockStorageSourceGetBackendProps(virStorageSource *src, src->srcpool->pool, src->srcpool->volume); return NULL; + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportEnumRangeError(virStorageType, actualType); @@ -2417,6 +2418,7 @@ qemuBlockStorageSourceCreateGetStorageProps(virStorageSource *src, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: return 0; case VIR_STORAGE_TYPE_NONE: diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 98229d7cf9..0de0a79b46 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1486,6 +1486,7 @@ qemuBuildDriveSourceStr(virDomainDiskDef *disk, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 1371742529..08f05ff727 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -344,6 +344,7 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -499,6 +500,7 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm, /* Existance of 'volume' type disks are handled when pre-creating them */ break; + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_LAST: case VIR_STORAGE_TYPE_NONE: break; @@ -1725,6 +1727,7 @@ qemuMigrationSrcCheckStorageSourceSafety(virStorageSource *src, case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_DIR: case VIR_STORAGE_TYPE_VOLUME: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_LAST: *requires_safe_cache = true; break; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0e50cd1ccc..4e1d713809 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4994,6 +4994,7 @@ qemuPrepareNVRAM(virQEMUDriver *driver, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_LAST: case VIR_STORAGE_TYPE_NONE: if (reset_nvram) { diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 5b0b52e2ba..bad135ee61 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -689,6 +689,7 @@ qemuSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDef *snapdisk, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -708,6 +709,7 @@ qemuSnapshotPrepareDiskExternalInactive(virDomainSnapshotDiskDef *snapdisk, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -752,6 +754,7 @@ qemuSnapshotPrepareDiskExternalActive(virDomainSnapshotDiskDef *snapdisk, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, @@ -914,6 +917,7 @@ qemuSnapshotPrepareDiskInternal(virDomainDiskDef *disk, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index da08fd17cd..c43e794816 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -717,6 +717,7 @@ qemuValidateDomainDefNvram(const virDomainDef *def, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unsupported nvram disk type '%1$s'"), virStorageTypeToString(src->type)); diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_source.c index 1883225a8b..e886433bb4 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -625,6 +625,7 @@ virStorageSourceUpdatePhysicalSize(virStorageSource *src, case VIR_STORAGE_TYPE_NVME: case VIR_STORAGE_TYPE_VHOST_USER: case VIR_STORAGE_TYPE_VHOST_VDPA: + case VIR_STORAGE_TYPE_CTL: case VIR_STORAGE_TYPE_NONE: case VIR_STORAGE_TYPE_LAST: return -1; -- 2.52.0
Bhyve supports virtio-scsi devices using the following syntax: bhyve ... -s N,virtio-scsi,/dev/cam/ctl[pp.vp][,scsi-device-options] Where /dev/cam/ctl is a ctl(4) device path. The optional "scsi-device-options" include "iid" (Initiator ID) and "bootindex", which are currently not used by libvirt. Model this device using: <disk type='ctl'> <source dev='/dev/cam/ctl'/> <target dev='sda' bus='scsi'/> </disk> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- src/bhyve/bhyve_command.c | 73 ++++++++++++++++++- src/bhyve/bhyve_device.c | 1 + .../bhyvexml2argv-virtio-scsi.args | 10 +++ .../bhyvexml2argv-virtio-scsi.ldargs | 4 + .../bhyvexml2argv-virtio-scsi.xml | 21 ++++++ tests/bhyvexml2argvtest.c | 1 + .../bhyvexml2xmlout-virtio-scsi.xml | 32 ++++++++ tests/bhyvexml2xmltest.c | 1 + 8 files changed, 139 insertions(+), 4 deletions(-) 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-virtio-scsi.xml diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index bc37f4cef9..989af05f05 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -327,6 +327,63 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, return 0; } +static int +bhyveBuildSCSIControllerArgStr(const virDomainDef *def, + virDomainControllerDef *controller, + struct _bhyveConn *driver G_GNUC_UNUSED, + virCommand *cmd) +{ + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + const char *disk_source; + size_t i; + + for (i = 0; i < def->ndisks; i++) { + g_auto(virBuffer) device = VIR_BUFFER_INITIALIZER; + virDomainDiskDef *disk = def->disks[i]; + + if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI) + continue; + + if (disk->info.addr.drive.controller != controller->idx) + continue; + + VIR_DEBUG("disk %zu controller %d", i, controller->idx); + + if (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_CTL) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported disk type")); + return -1; + } + + if (virDomainDiskTranslateSourcePool(disk) < 0) + return -1; + + disk_source = virDomainDiskGetSource(disk); + + if ((disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) && + (disk_source == NULL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("cdrom device without source path not supported")); + return -1; + } + + if (disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported disk device")); + return -1; + } + + virCommandAddArg(cmd, "-s"); + virCommandAddArgFormat(cmd, "%d:0,virtio-scsi,%s", + controller->info.addr.pci.slot, + virDomainDiskGetSource(disk)); + + return 0; + } + + return 0; +} + static int bhyveBuildUSBControllerArgStr(const virDomainDef *def, virDomainControllerDef *controller, @@ -458,6 +515,9 @@ bhyveBuildDiskArgStr(const virDomainDef *def, case VIR_DOMAIN_DISK_BUS_SATA: /* Handled by bhyveBuildAHCIControllerArgStr() */ break; + case VIR_DOMAIN_DISK_BUS_SCSI: + /* Handled by bhyveBuildSCSIControllerArgStr() */ + break; case VIR_DOMAIN_DISK_BUS_NVME: /* Handled by bhyveBuildNVMeControllerArgStr() */ break; @@ -465,7 +525,6 @@ bhyveBuildDiskArgStr(const virDomainDef *def, if (bhyveBuildVirtIODiskArgStr(def, disk, cmd) < 0) return -1; break; - case VIR_DOMAIN_DISK_BUS_SCSI: case VIR_DOMAIN_DISK_BUS_IDE: case VIR_DOMAIN_DISK_BUS_FDC: case VIR_DOMAIN_DISK_BUS_NONE: @@ -502,6 +561,10 @@ bhyveBuildControllerArgStr(const virDomainDef *def, if (bhyveBuildAHCIControllerArgStr(def, controller, driver, cmd) < 0) return -1; break; + case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: + if (bhyveBuildSCSIControllerArgStr(def, controller, driver, cmd) < 0) + return -1; + break; case VIR_DOMAIN_CONTROLLER_TYPE_USB: if (++*nusbcontrollers > 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -528,7 +591,6 @@ bhyveBuildControllerArgStr(const virDomainDef *def, break; case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_FDC: - case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: case VIR_DOMAIN_CONTROLLER_TYPE_CCID: case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: @@ -1087,6 +1149,8 @@ virBhyveProcessBuildCustomLoaderCmd(virDomainDef *def) static bool virBhyveUsableDisk(virDomainDiskDef *disk) { + virStorageType disk_type = virDomainDiskGetType(disk); + if (virDomainDiskTranslateSourcePool(disk) < 0) return false; @@ -1097,8 +1161,9 @@ virBhyveUsableDisk(virDomainDiskDef *disk) return false; } - if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) && - (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_VOLUME)) { + if ((disk_type != VIR_STORAGE_TYPE_FILE) && + (disk_type != VIR_STORAGE_TYPE_VOLUME) && + (disk_type != VIR_STORAGE_TYPE_CTL)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk type")); return false; diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c index ead52ae704..28a9c82d7b 100644 --- a/src/bhyve/bhyve_device.c +++ b/src/bhyve/bhyve_device.c @@ -115,6 +115,7 @@ bhyveAssignDevicePCISlots(virDomainDef *def, if ((def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) || (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) || (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_NVME) || + (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) || ((def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) && (def->controllers[i]->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI)) || def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA) { diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.args b/tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.args new file mode 100644 index 0000000000..295c528135 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.args @@ -0,0 +1,10 @@ +bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 2:0,virtio-scsi,/dev/cam/ctl \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \ +bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.ldargs new file mode 100644 index 0000000000..06a51ead59 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.ldargs @@ -0,0 +1,4 @@ +bhyveload \ +-m 214 \ +-d /dev/cam/ctl \ +bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.xml new file mode 100644 index 0000000000..d8c10afe6d --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-virtio-scsi.xml @@ -0,0 +1,21 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + </os> + <devices> + <disk type='ctl'> + <source dev='/dev/cam/ctl'/> + <target dev='sda' bus='scsi'/> + </disk> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <model type='virtio'/> + <source bridge="virbr0"/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index b83051d3cd..c6d58821ac 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -273,6 +273,7 @@ mymain(void) DO_TEST("slirp"); DO_TEST("slirp-mac-addr"); DO_TEST_FAILURE("slirp-ip"); + DO_TEST("virtio-scsi"); /* Address allocation tests */ DO_TEST("addr-single-sata-disk"); diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-virtio-scsi.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-virtio-scsi.xml new file mode 100644 index 0000000000..94915ea8b7 --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-virtio-scsi.xml @@ -0,0 +1,32 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='ctl' device='disk'> + <source dev='/dev/cam/ctl'/> + <target dev='sda' bus='scsi'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <controller type='pci' index='0' model='pci-root'/> + <controller type='scsi' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <source bridge='virbr0'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index 0abc50b0de..8eecd5bf68 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -123,6 +123,7 @@ mymain(void) DO_TEST_DIFFERENT("2-nvme-2-controllers"); DO_TEST_DIFFERENT("passthru-multiple-devs"); DO_TEST_DIFFERENT("slirp"); + DO_TEST_DIFFERENT("virtio-scsi"); /* Address allocation tests */ DO_TEST_DIFFERENT("addr-single-sata-disk"); -- 2.52.0
Document the CTL device type in formatdomain.rst and the virtio-scsi device in drvbhyve.rst. Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- docs/drvbhyve.rst | 19 +++++++++++++++++++ docs/formatdomain.rst | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/docs/drvbhyve.rst b/docs/drvbhyve.rst index dfcdb011d2..5a45e9056f 100644 --- a/docs/drvbhyve.rst +++ b/docs/drvbhyve.rst @@ -718,6 +718,25 @@ any configuration on the host. Unfortunately, there is no (easy) way to probe its support in libvirt, so please consult the ``bhyve(8)`` manual page to make sure it is available. +virtio-scsi +~~~~~~~~~~~ +:since:`Since 12:0.0`, it is possible to use ``virtio-scsi`` devices. +It uses CAM Target layer (CTL) as a source. + +Example: + +:: + + ... + <disk type='ctl'> + <source dev='/dev/cam/ctl'/> + <target dev='sda' bus='scsi'/> + </disk> + ... + +Please refer to ``cam(4)``, ``ctl(4)``, and ``ctld(8)`` manual pages +for more details on CAM and CTL. + Guest-specific considerations ----------------------------- diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 1467fc7e10..bcb354a9d6 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3085,6 +3085,11 @@ paravirtualized driver is specified via the ``disk`` element. the fully-qualified path to the vhost-vdpa character device (e.g. ``/dev/vhost-vdpa-0``). + ``ctl`` + Enables the hypervisor to connect to the FreeBSD CAM Target Layer (CTL), + where CAM is a Common Access Method Storage subsystem. + :since:`Since 12.0.0, bhyve`. + With "file", "block", and "volume", one or more optional sub-elements ``seclabel`` (See `Security label`_) can be used to override the domain security labeling policy for just that source file. -- 2.52.0
On 1/3/26 15:11, Roman Bogorodskiy wrote:
Document the CTL device type in formatdomain.rst and the virtio-scsi device in drvbhyve.rst.
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- docs/drvbhyve.rst | 19 +++++++++++++++++++ docs/formatdomain.rst | 5 +++++ 2 files changed, 24 insertions(+)
diff --git a/docs/drvbhyve.rst b/docs/drvbhyve.rst index dfcdb011d2..5a45e9056f 100644 --- a/docs/drvbhyve.rst +++ b/docs/drvbhyve.rst @@ -718,6 +718,25 @@ any configuration on the host. Unfortunately, there is no (easy) way to probe its support in libvirt, so please consult the ``bhyve(8)`` manual page to make sure it is available.
+virtio-scsi +~~~~~~~~~~~ +:since:`Since 12:0.0`, it is possible to use ``virtio-scsi`` devices. +It uses CAM Target layer (CTL) as a source. + +Example: + +:: + + ... + <disk type='ctl'> + <source dev='/dev/cam/ctl'/> + <target dev='sda' bus='scsi'/> + </disk> + ... + +Please refer to ``cam(4)``, ``ctl(4)``, and ``ctld(8)`` manual pages +for more details on CAM and CTL. + Guest-specific considerations -----------------------------
Starting from here ... [1]
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 1467fc7e10..bcb354a9d6 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3085,6 +3085,11 @@ paravirtualized driver is specified via the ``disk`` element. the fully-qualified path to the vhost-vdpa character device (e.g. ``/dev/vhost-vdpa-0``).
+ ``ctl`` + Enables the hypervisor to connect to the FreeBSD CAM Target Layer (CTL), + where CAM is a Common Access Method Storage subsystem. + :since:`Since 12.0.0, bhyve`.
You'll also need to document the 'dev' attribute.
+ With "file", "block", and "volume", one or more optional sub-elements ``seclabel`` (See `Security label`_) can be used to override the domain security labeling policy for just that source file.
[1] ... this hunk should go into patch 1/3 where XML parser/formater and RNG schema is changed. Not only it is semantically closer to that change, we also like NEWS.rst change to be isolated (lessens chance of a conflict for eventual backports). Please squash in the following: diff --git i/docs/formatdomain.rst w/docs/formatdomain.rst index bcb354a9d6..04ef319a73 100644 --- i/docs/formatdomain.rst +++ w/docs/formatdomain.rst @@ -2826,6 +2826,10 @@ paravirtualized driver is specified via the ``disk`` element. <source dev='/dev/vhost-vdpa-0' /> <target dev='vdg' bus='virtio'/> </disk> + <disk type='ctl' device='disk'> + <source dev='/dev/cam/ctl'/> + <target dev='sda' bus='scsi'/> + </disk> <disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/path/to/datastore.qcow2'> @@ -2865,8 +2869,9 @@ paravirtualized driver is specified via the ``disk`` element. Valid values are "file", "block", "dir" ( :since:`since 0.7.5` ), "network" ( :since:`since 0.8.7` ), or "volume" ( :since:`since 1.0.5` ), or "nvme" ( :since:`since 6.0.0` ), or "vhostuser" ( :since:`since 7.1.0` ), - or "vhostvdpa" ( :since:`since 9.8.0 (QEMU 8.1.0)`) and refer to the - underlying source for the disk. :since:`Since 0.0.3` + or "vhostvdpa" ( :since:`since 9.8.0 (QEMU 8.1.0)`), or "ctl" ( + :since:`since 12.0.0` ) and refer to the underlying source for the disk. + :since:`Since 0.0.3` ``device`` Indicates how the disk is to be exposed to the guest OS. Possible values for this attribute are "floppy", "disk", "cdrom", and "lun", defaulting to @@ -3090,6 +3095,9 @@ paravirtualized driver is specified via the ``disk`` element. where CAM is a Common Access Method Storage subsystem. :since:`Since 12.0.0, bhyve`. + The ``source`` element has a mandatory attribute ``dev`` that specifies + the fully-qualified path to the CTL device (e.g. ``/dev/cam/ctl``). + With "file", "block", and "volume", one or more optional sub-elements ``seclabel`` (See `Security label`_) can be used to override the domain security labeling policy for just that source file. Michal
Michal Prívozník wrote:
+ Guest-specific considerations -----------------------------
Starting from here ... [1]
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 1467fc7e10..bcb354a9d6 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -3085,6 +3085,11 @@ paravirtualized driver is specified via the ``disk`` element. the fully-qualified path to the vhost-vdpa character device (e.g. ``/dev/vhost-vdpa-0``).
+ ``ctl`` + Enables the hypervisor to connect to the FreeBSD CAM Target Layer (CTL), + where CAM is a Common Access Method Storage subsystem. + :since:`Since 12.0.0, bhyve`.
You'll also need to document the 'dev' attribute.
+ With "file", "block", and "volume", one or more optional sub-elements ``seclabel`` (See `Security label`_) can be used to override the domain security labeling policy for just that source file.
[1] ... this hunk should go into patch 1/3 where XML parser/formater and RNG schema is changed. Not only it is semantically closer to that change, we also like NEWS.rst change to be isolated (lessens chance of a conflict for eventual backports).
Thanks for review! Yes, I remember about isolating the NEWS.rst changes, but these are drvbhyve.rst, not NEWS.rst. I have moved the formatdomain.rst changes into patch 1/3 with your changes squashed in. I'll send an update for NEWS.rst later this week, there are multiple changes to mention there for bhyve (this one, SLIRP, and arm64 bits). Roman
On 1/3/26 15:11, Roman Bogorodskiy wrote:
Roman Bogorodskiy (3): conf: introduce CTL storage type bhyve: add virtio-scsi support docs: bhyve: document virtio-scsi support
docs/drvbhyve.rst | 19 +++++ docs/formatdomain.rst | 5 ++ src/bhyve/bhyve_command.c | 73 ++++++++++++++++++- src/bhyve/bhyve_device.c | 1 + src/bhyve/bhyve_process.c | 1 + src/ch/ch_monitor.c | 1 + src/conf/domain_conf.c | 7 ++ src/conf/schemas/domaincommon.rng | 13 ++++ src/conf/storage_source_conf.c | 6 +- src/conf/storage_source_conf.h | 1 + src/libxl/xen_xl.c | 1 + src/qemu/qemu_block.c | 2 + src/qemu/qemu_command.c | 1 + src/qemu/qemu_migration.c | 3 + src/qemu/qemu_process.c | 1 + src/qemu/qemu_snapshot.c | 4 + src/qemu/qemu_validate.c | 1 + src/storage_file/storage_source.c | 1 + .../bhyvexml2argv-virtio-scsi.args | 10 +++ .../bhyvexml2argv-virtio-scsi.ldargs | 4 + .../bhyvexml2argv-virtio-scsi.xml | 21 ++++++ tests/bhyvexml2argvtest.c | 1 + .../bhyvexml2xmlout-virtio-scsi.xml | 32 ++++++++ tests/bhyvexml2xmltest.c | 1 + 24 files changed, 205 insertions(+), 5 deletions(-) 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-virtio-scsi.xml
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Michal Prívozník -
Roman Bogorodskiy