]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: support specifying disk rotation rate
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Sat, 25 Oct 2025 11:47:15 +0000 (13:47 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 29 Oct 2025 10:45:42 +0000 (11:45 +0100)
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 <bogorodskiy@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/bhyve/bhyve_command.c
src/bhyve/bhyve_domain.c
tests/bhyvexml2argvdata/bhyvexml2argv-disk-virtio-rotation-rate.xml [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.args [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.xml [new file with mode: 0644]
tests/bhyvexml2argvtest.c

index 14d07909ae4e98d93fa2a85129cd4b41dc3a41f5..4c5b4518eab7615d2f202e11e1500d3cc941d6ff 100644 (file)
@@ -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);
     }
 
index 6b47890c93b274589044709156286a34adfb2f1e..3c7997ad8617a793e4946be183241874a92c2eb9 100644 (file)
@@ -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 (file)
index 0000000..0ec1401
--- /dev/null
@@ -0,0 +1,23 @@
+<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='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='vda' bus='virtio' rotation_rate='10000'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </disk>
+    <interface type='bridge'>
+      <mac address='52:54:00:bc:85:fe'/>
+      <model type='virtio'/>
+      <source bridge="virbr0"/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.args b/tests/bhyvexml2argvdata/bhyvexml2argv-sata-rotation-rate.args
new file mode 100644 (file)
index 0000000..2cf4095
--- /dev/null
@@ -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 (file)
index 0000000..4257ffc
--- /dev/null
@@ -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 (file)
index 0000000..a0d80cb
--- /dev/null
@@ -0,0 +1,31 @@
+<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='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd1.img'/>
+      <target dev='hda' bus='sata' rotation_rate='7200'/>
+    </disk>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd2.img'/>
+      <target dev='hdb' bus='sata' rotation_rate='5400'/>
+    </disk>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd3.img'/>
+      <target dev='hdc' bus='sata' rotation_rate='1'/>
+    </disk>
+    <interface type='bridge'>
+      <mac address='52:54:00:b9:94:02'/>
+      <model type='virtio'/>
+      <source bridge="virbr0"/>
+    </interface>
+  </devices>
+</domain>
index eb4a1eb2fdff04a41f6f0188eb552e6d1b695d14..6837db2c7ae93f8f22717281bf028a5365c46650 100644 (file)
@@ -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");