As bhyve options are passed as a comma separated list, e.g.:
-s N:0,ahci,hd:/tmp/my.img,nmrr=7200,ser=BHYVE-SER01-0001
Do not allow using "," in the serial name. This applies to both NVMe and
SATA disks.
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
---
src/bhyve/bhyve_domain.c | 15 ++++++++++++
.../bhyvexml2argv-nvme-invalid-serial.xml | 20 ++++++++++++++++
...bhyvexml2argv-sata-disk-invalid-serial.xml | 23 +++++++++++++++++++
tests/bhyvexml2argvtest.c | 2 ++
tests/bhyvexml2xmltest.c | 2 ++
5 files changed, 62 insertions(+)
create mode 100644 tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-nvme-invalid-serial.xml
create mode 100644 tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-disk-invalid-serial.xml
diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index b6344185b7..1c588d9243 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -338,6 +338,13 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev,
_("Bhyve virtio-serial controller supports up to 16 ports"));
return -1;
}
+ } else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_NVME &&
+ controller->opts.nvmeopts.serial) {
+ if (strchr(controller->opts.nvmeopts.serial, ',')) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Serial number may not contain ',' character"));
+ return -1;
+ }
}
break;
}
@@ -423,6 +430,14 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev,
return -1;
}
+ if (disk->bus == VIR_DOMAIN_DISK_BUS_SATA && disk->serial) {
+ if (strchr(disk->serial, ',')) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Serial number may not contain ',' character"));
+ return -1;
+ }
+ }
+
break;
}
case VIR_DOMAIN_DEVICE_NET: {
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-nvme-invalid-serial.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-nvme-invalid-serial.xml
new file mode 100644
index 0000000000..b9da5352ea
--- /dev/null
+++ b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-nvme-invalid-serial.xml
@@ -0,0 +1,20 @@
+<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>
+ <controller type='nvme' index='0'>
+ <serial>BHYVE-NVME0,01234</serial>
+ </controller>
+ <disk type='file'>
+ <driver name='file' type='raw' queues='2' queue_size='256'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='nvme0n1' bus='nvme'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-disk-invalid-serial.xml b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-disk-invalid-serial.xml
new file mode 100644
index 0000000000..b5d7da8c1e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-disk-invalid-serial.xml
@@ -0,0 +1,23 @@
+<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='file' device='disk'>
+ <serial>A,B,C</serial>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ </disk>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 436eecb003..95969a641b 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -282,7 +282,9 @@ mymain(void)
DO_TEST("2-nvme-2-controllers");
DO_TEST("nvme-explicit-controller");
DO_TEST_FAILURE("2-nvme-same-controller");
+ DO_TEST_FAILURE("nvme-invalid-serial");
DO_TEST("sata-rotation-rate");
+ DO_TEST_FAILURE("sata-disk-invalid-serial");
DO_TEST_FAILURE("disk-virtio-rotation-rate");
DO_TEST_FAILURE("disk-virtio-queue-opts");
DO_TEST("slirp");
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index 51ce2adb33..3c90673f5e 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -130,6 +130,7 @@ mymain(void)
DO_TEST_DIFFERENT("nvme");
DO_TEST_DIFFERENT("2-nvme-2-controllers");
DO_TEST_DIFFERENT("nvme-explicit-controller");
+ DO_TEST_FAILURE("nvme-invalid-serial");
DO_TEST_DIFFERENT("passthru-multiple-devs");
DO_TEST_DIFFERENT("slirp");
DO_TEST_DIFFERENT("virtio-scsi");
@@ -146,6 +147,7 @@ mymain(void)
DO_TEST_FAILURE("virtio-console-too-many-ports");
DO_TEST_FAILURE("virtio-console-invalid-name");
DO_TEST_FAILURE("virtio-console-invalid-path");
+ DO_TEST_FAILURE("sata-disk-invalid-serial");
/* Address allocation tests */
DO_TEST_DIFFERENT("addr-single-sata-disk");
--
2.52.0
On Fri, Jul 31, 2026 at 19:52:05 +0200, Roman Bogorodskiy wrote:
> As bhyve options are passed as a comma separated list, e.g.:
>
> -s N:0,ahci,hd:/tmp/my.img,nmrr=7200,ser=BHYVE-SER01-0001
>
> Do not allow using "," in the serial name. This applies to both NVMe and
> SATA disks.
>
> Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
> ---
> src/bhyve/bhyve_domain.c | 15 ++++++++++++
> .../bhyvexml2argv-nvme-invalid-serial.xml | 20 ++++++++++++++++
> ...bhyvexml2argv-sata-disk-invalid-serial.xml | 23 +++++++++++++++++++
> tests/bhyvexml2argvtest.c | 2 ++
> tests/bhyvexml2xmltest.c | 2 ++
> 5 files changed, 62 insertions(+)
> create mode 100644 tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-nvme-invalid-serial.xml
> create mode 100644 tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-disk-invalid-serial.xml
This patch should go first before you do the actual impl.
>
> diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
> index b6344185b7..1c588d9243 100644
> --- a/src/bhyve/bhyve_domain.c
> +++ b/src/bhyve/bhyve_domain.c
> @@ -338,6 +338,13 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev,
> _("Bhyve virtio-serial controller supports up to 16 ports"));
> return -1;
> }
> + } else if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_NVME &&
> + controller->opts.nvmeopts.serial) {
> + if (strchr(controller->opts.nvmeopts.serial, ',')) {
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> + _("Serial number may not contain ',' character"));
> + return -1;
> + }
> }
> break;
> }
> @@ -423,6 +430,14 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev,
> return -1;
> }
>
> + if (disk->bus == VIR_DOMAIN_DISK_BUS_SATA && disk->serial) {
> + if (strchr(disk->serial, ',')) {
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> + _("Serial number may not contain ',' character"));
> + return -1;
> + }
> + }
> +
> break;
> }
> case VIR_DOMAIN_DEVICE_NET: {
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
© 2016 - 2026 Red Hat, Inc.