diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 7f22b1ce7a..e2940e8c02 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -152,13 +152,31 @@ bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, virCommandPtr cmd) { const char *bus_type; + const char *disk_source; switch (disk->bus) { case VIR_DOMAIN_DISK_BUS_SATA: - bus_type = "ahci-hd"; + switch (disk->device) { + case VIR_DOMAIN_DISK_DEVICE_DISK: + bus_type = "ahci-hd"; + break; + case VIR_DOMAIN_DISK_DEVICE_CDROM: + bus_type = "ahci-cd"; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported disk device")); + return -1; + } break; case VIR_DOMAIN_DISK_BUS_VIRTIO: - bus_type = "virtio-blk"; + if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { + bus_type = "virtio-blk"; + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported disk device")); + return -1; + } break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -166,22 +184,26 @@ bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, return -1; } - if (disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported disk device")); - return -1; - } - if (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk type")); 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; + } + virCommandAddArg(cmd, "-s"); virCommandAddArgFormat(cmd, "%d:0,%s,%s", disk->info.addr.pci.slot, bus_type, - virDomainDiskGetSource(disk)); + disk_source); return 0; } @@ -282,7 +304,8 @@ virBhyveProcessBuildLoadCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED, disk = def->disks[0]; - if (disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) { + if ((disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) && + (disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk device")); return NULL; diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args new file mode 100644 index 0000000000..eb38969e12 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args @@ -0,0 +1,3 @@ +/usr/sbin/bhyve -c 1 -m 214 -H -P -s 0:0,hostbridge \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \ +-s 2:0,ahci-cd,/tmp/cdrom.iso bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.xml new file mode 100644 index 0000000000..d70219c19a --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.xml @@ -0,0 +1,22 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 1 + + hvm + + + + + + +
+ + + + +
+ + + diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index f6f2bc4c6c..408c73aa0b 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -104,6 +104,7 @@ mymain(void) DO_TEST("base"); DO_TEST("acpiapic"); + DO_TEST("disk-cdrom"); DO_TEST("disk-virtio"); DO_TEST("macaddr"); DO_TEST("serial");