The bhyve driver currently rejects <disk type='block'> configurations
for AHCI and virtio-blk disks, though bhyve supports them:
>From the bhyve(8) manual page:
Block storage device backends:
• /filename[,block-device-options]
• /dev/xxx[,block-device-options]
Thus, relax disk type checks and permit these configurations.
Signed-off-by: Roman Bogorodskiy <[email protected]>
---
src/bhyve/bhyve_command.c | 9 ++--
.../x86_64/bhyvexml2argv-disk-block.args | 13 ++++++
.../x86_64/bhyvexml2argv-disk-block.ldargs | 1 +
.../x86_64/bhyvexml2argv-disk-block.xml | 27 +++++++++++
tests/bhyvexml2argvtest.c | 1 +
.../x86_64/bhyvexml2xmlout-disk-block.xml | 46 +++++++++++++++++++
tests/bhyvexml2xmltest.c | 1 +
7 files changed, 95 insertions(+), 3 deletions(-)
create mode 100644 tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.args
create mode 100644
tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.ldargs
create mode 100644 tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.xml
create mode 100644
tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-disk-block.xml
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 49c3101027..f5ee2b041f 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -341,7 +341,8 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def,
VIR_DEBUG("disk %zu controller %d", i, controller->idx);
- if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) &&
+ if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_BLOCK) &&
+ (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) &&
(virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_VOLUME)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported disk type"));
@@ -609,7 +610,8 @@ bhyveBuildVirtIODiskArgStr(const virDomainDef *def
G_GNUC_UNUSED,
return -1;
}
- if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) &&
+ if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_BLOCK) &&
+ (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) &&
(virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_VOLUME)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported disk type"));
@@ -1524,7 +1526,8 @@ virBhyveUsableDisk(virDomainDiskDef *disk)
return false;
}
- if ((disk_type != VIR_STORAGE_TYPE_FILE) &&
+ if ((disk_type != VIR_STORAGE_TYPE_BLOCK) &&
+ (disk_type != VIR_STORAGE_TYPE_FILE) &&
(disk_type != VIR_STORAGE_TYPE_VOLUME) &&
(disk_type != VIR_STORAGE_TYPE_CTL)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.args
b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.args
new file mode 100644
index 0000000000..64c3aca2a0
--- /dev/null
+++ b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.args
@@ -0,0 +1,13 @@
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-l bootrom,/path/to/test.fd,fwcfg=qemu \
+-s 1:0,lpc \
+-s 2:0,ahci,hd:/dev/zvol/zroot/bhyve-sata \
+-s 3:0,nvme,/dev/zvol/zroot/bhyve-nvme \
+-s 4:0,virtio-blk,/dev/zvol/zroot/bhyve-virtio \
+bhyve
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.ldargs
b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.ldargs
new file mode 100644
index 0000000000..421376db9e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.ldargs
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.xml
b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.xml
new file mode 100644
index 0000000000..7ba7450f20
--- /dev/null
+++ b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-disk-block.xml
@@ -0,0 +1,27 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+ </os>
+ <devices>
+ <disk type='block'>
+ <driver name='file' type='raw'/>
+ <source dev='/dev/zvol/zroot/bhyve-sata'/>
+ <target dev='hda' bus='sata'/>
+ </disk>
+ <disk type='block'>
+ <driver name='file' type='raw'/>
+ <source dev='/dev/zvol/zroot/bhyve-virtio'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <disk type='block'>
+ <driver name='file' type='raw'/>
+ <source dev='/dev/zvol/zroot/bhyve-nvme'/>
+ <target dev='nvme0n1' bus='nvme'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 28b5ee981b..c86929b308 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -237,6 +237,7 @@ mymain(void)
DO_TEST("acpiapic");
virBhyveCapsClear(driver.bhyvecaps, BHYVE_CAP_ACPI);
DO_TEST_FAILURE("acpiapic");
+ DO_TEST("disk-block");
DO_TEST("disk-cdrom");
DO_TEST("disk-virtio");
DO_TEST("disk-readonly");
diff --git a/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-disk-block.xml
b/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-disk-block.xml
new file mode 100644
index 0000000000..553695dec9
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/x86_64/bhyvexml2xmlout-disk-block.xml
@@ -0,0 +1,46 @@
+<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>
+ <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+ <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='block' device='disk'>
+ <driver name='file' type='raw'/>
+ <source dev='/dev/zvol/zroot/bhyve-sata'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='block' device='disk'>
+ <driver name='file' type='raw'/>
+ <source dev='/dev/zvol/zroot/bhyve-virtio'/>
+ <target dev='vda' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04'
function='0x0'/>
+ </disk>
+ <disk type='block' device='disk'>
+ <driver name='file' type='raw'/>
+ <source dev='/dev/zvol/zroot/bhyve-nvme'/>
+ <target dev='nvme0n1' bus='nvme'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='isa' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01'
function='0x0'/>
+ </controller>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02'
function='0x0'/>
+ </controller>
+ <controller type='nvme' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03'
function='0x0'/>
+ </controller>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index 724ba4d85f..208d87b280 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -111,6 +111,7 @@ mymain(void)
DO_TEST_DIFFERENT("console");
DO_TEST_DIFFERENT("console-master-slave-not-specified");
DO_TEST_DIFFERENT("custom-loader");
+ DO_TEST_DIFFERENT("disk-block");
DO_TEST_DIFFERENT("disk-cdrom");
DO_TEST_DIFFERENT("disk-cdrom-grub");
DO_TEST_DIFFERENT("disk-virtio");
--
2.55.0