From 93c4b1bf55843a5be34b6e1e328f97eb6258ca18 Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Sat, 25 Oct 2025 13:47:15 +0200 Subject: [PATCH] bhyve: support specifying disk rotation rate Bhyve supports specifying disk rotation rate using the nmrr attribute, e.g.: -s 3:0,ahci,hd:/data/img/freebsd.img,nmrr=1 Where 1 means the SSD, 0 (default) means do not report, and other values specify the actual RPM. Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_command.c | 4 +++ src/bhyve/bhyve_domain.c | 6 ++++ ...hyvexml2argv-disk-virtio-rotation-rate.xml | 23 ++++++++++++++ .../bhyvexml2argv-sata-rotation-rate.args | 10 ++++++ .../bhyvexml2argv-sata-rotation-rate.ldargs | 4 +++ .../bhyvexml2argv-sata-rotation-rate.xml | 31 +++++++++++++++++++ tests/bhyvexml2argvtest.c | 2 ++ 7 files changed, 80 insertions(+) create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio-rotation-rate.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.xml diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 14d07909ae..4c5b4518ea 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -278,6 +278,10 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def, _("unsupported disk device")); return -1; } + + if (disk->rotation_rate) + virBufferAsprintf(&device, ",nmrr=%u", disk->rotation_rate); + virBufferAddBuffer(&buf, &device); } diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index 6b47890c93..3c7997ad86 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -299,6 +299,12 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev, return -1; } } + } else if (dev->type == VIR_DOMAIN_DEVICE_DISK && + dev->data.disk->rotation_rate && + dev->data.disk->bus != VIR_DOMAIN_DISK_BUS_SATA) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("rotation rate is only valid for SATA bus")); + return -1; } return 0; diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio-rotation-rate.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio-rotation-rate.xml new file mode 100644 index 0000000000..0ec14018c1 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio-rotation-rate.xml @@ -0,0 +1,23 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 1 + + hvm + + + + + + +
+ + + + + +
+ + + diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.args b/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.args new file mode 100644 index 0000000000..2cf40953e8 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.args @@ -0,0 +1,10 @@ +bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 2:0,ahci,hd:/tmp/freebsd1.img,nmrr=7200,hd:/tmp/freebsd2.img,nmrr=5400,hd:/tmp/freebsd3.img,nmrr=1 \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \ +bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.ldargs new file mode 100644 index 0000000000..4257ffccee --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.ldargs @@ -0,0 +1,4 @@ +bhyveload \ +-m 214 \ +-d /tmp/freebsd1.img \ +bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.xml new file mode 100644 index 0000000000..a0d80cb908 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.xml @@ -0,0 +1,31 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 1 + + hvm + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index eb4a1eb2fd..6837db2c7a 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -263,6 +263,8 @@ mymain(void) DO_TEST("nvme"); DO_TEST("2-nvme-2-controllers"); DO_TEST_FAILURE("2-nvme-same-controller"); + DO_TEST("sata-rotation-rate"); + DO_TEST_FAILURE("disk-virtio-rotation-rate"); /* Address allocation tests */ DO_TEST("addr-single-sata-disk"); -- 2.47.3