bhyve supports passing disk serial number using the "ser=<SN>"
option, so update bhyveBuildAHCIControllerArgStr() to set it
from the "serial" element.

Closes: https://gitlab.com/libvirt/libvirt/-/work_items/901
Signed-off-by: Roman Bogorodskiy <[email protected]>
---
 src/bhyve/bhyve_command.c                                      | 3 +++
 .../x86_64/bhyvexml2argv-sata-rotation-rate.args               | 2 +-
 .../x86_64/bhyvexml2argv-sata-rotation-rate.xml                | 3 +++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index a4f9c8823b..f0c3cf03c5 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -333,6 +333,9 @@ bhyveBuildAHCIControllerArgStr(const virDomainDef *def,
         if (disk->rotation_rate)
             virBufferAsprintf(&device, ",nmrr=%u", disk->rotation_rate);
 
+        if (disk->serial)
+            virBufferAsprintf(&device, ",ser=%s", disk->serial);
+
         virBufferAddBuffer(&buf, &device);
     }
 
diff --git 
a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-rotation-rate.args 
b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-rotation-rate.args
index 2cf40953e8..3ae510e2ed 100644
--- a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-rotation-rate.args
+++ b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-rotation-rate.args
@@ -5,6 +5,6 @@ bhyve \
 -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 
2:0,ahci,hd:/tmp/freebsd1.img,nmrr=7200,ser=BHYVE-SER01-0001,hd:/tmp/freebsd2.img,nmrr=5400,ser=BHYVE-SER02-0004,hd:/tmp/freebsd3.img,nmrr=1,ser=BHYVE-SER03-1234
 \
 -s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \
 bhyve
diff --git 
a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-rotation-rate.xml 
b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-rotation-rate.xml
index a0d80cb908..ed6da8e317 100644
--- a/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-rotation-rate.xml
+++ b/tests/bhyvexml2argvdata/x86_64/bhyvexml2argv-sata-rotation-rate.xml
@@ -8,16 +8,19 @@
   </os>
   <devices>
     <disk type='file'>
+      <serial>BHYVE-SER01-0001</serial>
       <driver name='file' type='raw'/>
       <source file='/tmp/freebsd1.img'/>
       <target dev='hda' bus='sata' rotation_rate='7200'/>
     </disk>
     <disk type='file'>
+      <serial>BHYVE-SER02-0004</serial>
       <driver name='file' type='raw'/>
       <source file='/tmp/freebsd2.img'/>
       <target dev='hdb' bus='sata' rotation_rate='5400'/>
     </disk>
     <disk type='file'>
+      <serial>BHYVE-SER03-1234</serial>
       <driver name='file' type='raw'/>
       <source file='/tmp/freebsd3.img'/>
       <target dev='hdc' bus='sata' rotation_rate='1'/>
-- 
2.52.0

Reply via email to