]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: support VNC 'wait' attribute
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Tue, 18 Nov 2025 18:01:52 +0000 (19:01 +0100)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Thu, 20 Nov 2025 18:22:13 +0000 (19:22 +0100)
Bhyve supports the 'wait' option for the VNC device configuration.
When enabled, VM boots only upon a VNC connection.

Sample device configuration looks like this:

 -s 29,fbuf,tcp=0.0.0.0:5900,w=800,h=600,wait

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/bhyve/bhyve_command.c
tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.args [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.xml [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.args [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.ldargs [new file with mode: 0644]
tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.xml [new file with mode: 0644]
tests/bhyvexml2argvtest.c
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml [new file with mode: 0644]
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait.xml [new file with mode: 0644]
tests/bhyvexml2xmltest.c

index 8bfd5a6f936230b3e47b5bae40bbf69ab9f7a925..e42e7b1eccce034c2ed4aa361bc00a65aebe2a1e 100644 (file)
@@ -651,6 +651,9 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def,
         virBufferAsprintf(&opt, ",vga=%s",
                           virDomainVideoVGAConfTypeToString(video->driver->vgaconf));
 
+    if (graphics->data.vnc.wait == VIR_TRISTATE_BOOL_YES)
+        virBufferAddLit(&opt, ",wait");
+
     virCommandAddArg(cmd, "-s");
     virCommandAddArgBuffer(cmd, &opt);
     return 0;
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.args b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.args
new file mode 100644 (file)
index 0000000..049e652
--- /dev/null
@@ -0,0 +1,13 @@
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-l bootrom,/path/to/test.fd \
+-s 1:0,lpc \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 4:0,fbuf,tcp=127.0.0.1:5904 \
+bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.ldargs
new file mode 100644 (file)
index 0000000..421376d
--- /dev/null
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.xml
new file mode 100644 (file)
index 0000000..61c028b
--- /dev/null
@@ -0,0 +1,26 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+    <loader readonly="yes" type="pflash">/path/to/test.fd</loader>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <interface type='bridge'>
+      <model type='virtio'/>
+      <source bridge="virbr0"/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+    <graphics type='vnc' port='5904' wait='no'>
+      <listen type='address' address='127.0.0.1'/>
+    </graphics>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.args b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.args
new file mode 100644 (file)
index 0000000..4394bdf
--- /dev/null
@@ -0,0 +1,13 @@
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-l bootrom,/path/to/test.fd \
+-s 1:0,lpc \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:00:00:00 \
+-s 4:0,fbuf,tcp=127.0.0.1:5904,wait \
+bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.ldargs
new file mode 100644 (file)
index 0000000..421376d
--- /dev/null
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.xml
new file mode 100644 (file)
index 0000000..8cfd40a
--- /dev/null
@@ -0,0 +1,26 @@
+<domain type='bhyve'>
+  <name>bhyve</name>
+  <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+  <memory>219136</memory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>hvm</type>
+    <loader readonly="yes" type="pflash">/path/to/test.fd</loader>
+  </os>
+  <devices>
+    <disk type='file'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <interface type='bridge'>
+      <model type='virtio'/>
+      <source bridge="virbr0"/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+    <graphics type='vnc' port='5904' wait='yes'>
+      <listen type='address' address='127.0.0.1'/>
+    </graphics>
+  </devices>
+</domain>
index 2a785ef8aa3b91745a182e9e9db11f87454e941e..650313c2da1ec1cbed02b672fc7954fc127d3a42 100644 (file)
@@ -235,6 +235,8 @@ mymain(void)
     DO_TEST("vnc-autoport");
     DO_TEST("vnc-resolution");
     DO_TEST("vnc-password");
+    DO_TEST("vnc-wait");
+    DO_TEST("vnc-wait-no");
     DO_TEST_FAILURE("vnc-password-comma");
     DO_TEST("cputopology");
     DO_TEST_FAILURE("cputopology-nvcpu-mismatch");
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml
new file mode 100644 (file)
index 0000000..4ba003e
--- /dev/null
@@ -0,0 +1,44 @@
+<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>
+    <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+    <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'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='isa' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='sata' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <interface type='bridge'>
+      <mac address='52:54:00:00:00:00'/>
+      <source bridge='virbr0'/>
+      <model type='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+    <graphics type='vnc' port='5904' autoport='no' wait='no' listen='127.0.0.1'>
+      <listen type='address' address='127.0.0.1'/>
+    </graphics>
+    <video>
+      <model type='gop' heads='1' primary='yes'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </video>
+  </devices>
+</domain>
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait.xml
new file mode 100644 (file)
index 0000000..d5ff19b
--- /dev/null
@@ -0,0 +1,44 @@
+<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>
+    <loader readonly='yes' type='pflash'>/path/to/test.fd</loader>
+    <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'>
+      <driver name='file' type='raw'/>
+      <source file='/tmp/freebsd.img'/>
+      <target dev='hda' bus='sata'/>
+      <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+    </disk>
+    <controller type='pci' index='0' model='pci-root'/>
+    <controller type='isa' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    </controller>
+    <controller type='sata' index='0'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    </controller>
+    <interface type='bridge'>
+      <mac address='52:54:00:00:00:00'/>
+      <source bridge='virbr0'/>
+      <model type='virtio'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+    </interface>
+    <graphics type='vnc' port='5904' autoport='no' wait='yes' listen='127.0.0.1'>
+      <listen type='address' address='127.0.0.1'/>
+    </graphics>
+    <video>
+      <model type='gop' heads='1' primary='yes'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+    </video>
+  </devices>
+</domain>
index 97c8647192c82b29c1878feb8d16111e5cd86a56..c2458b9fc4f1b2a7d52c7045f91abeb2e1459e3a 100644 (file)
@@ -109,6 +109,8 @@ mymain(void)
     DO_TEST_DIFFERENT("vnc-autoport");
     DO_TEST_DIFFERENT("vnc-resolution");
     DO_TEST_DIFFERENT("vnc-password");
+    DO_TEST_DIFFERENT("vnc-wait");
+    DO_TEST_DIFFERENT("vnc-wait-no");
     DO_TEST_DIFFERENT("commandline");
     DO_TEST_DIFFERENT("msrs");
     DO_TEST_DIFFERENT("sound");