[PATCH 2/2] bhyve: support VNC 'wait' attribute

Roman Bogorodskiy posted 2 patches 1 day, 16 hours ago
[PATCH 2/2] bhyve: support VNC 'wait' attribute
Posted by Roman Bogorodskiy 1 day, 16 hours ago
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>
---
 src/bhyve/bhyve_command.c                     |  3 ++
 .../bhyvexml2argv-vnc-wait-no.args            | 13 ++++++
 .../bhyvexml2argv-vnc-wait-no.ldargs          |  1 +
 .../bhyvexml2argv-vnc-wait-no.xml             | 26 +++++++++++
 .../bhyvexml2argv-vnc-wait.args               | 13 ++++++
 .../bhyvexml2argv-vnc-wait.ldargs             |  1 +
 .../bhyvexml2argv-vnc-wait.xml                | 26 +++++++++++
 tests/bhyvexml2argvtest.c                     |  2 +
 .../bhyvexml2xmlout-vnc-wait-no.xml           | 44 +++++++++++++++++++
 .../bhyvexml2xmlout-vnc-wait.xml              | 44 +++++++++++++++++++
 tests/bhyvexml2xmltest.c                      |  2 +
 11 files changed, 175 insertions(+)
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.xml
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.args
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.ldargs
 create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.xml
 create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml
 create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait.xml

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 8bfd5a6f93..057715102e 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -651,6 +651,9 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def,
         virBufferAsprintf(&opt, ",vga=%s",
                           virDomainVideoVGAConfTypeToString(video->driver->vgaconf));
 
+    if (graphics->data.vnc.wait)
+        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
index 0000000000..049e65227d
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.args
@@ -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
index 0000000000..421376db9e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.ldargs
@@ -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
index 0000000000..61c028bfc7
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.xml
@@ -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
index 0000000000..4394bdfb4b
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.args
@@ -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
index 0000000000..421376db9e
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.ldargs
@@ -0,0 +1 @@
+dummy
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.xml
new file mode 100644
index 0000000000..8cfd40ad7d
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.xml
@@ -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>
diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c
index 2a785ef8aa..650313c2da 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -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
index 0000000000..58e71282e7
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml
@@ -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' 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
index 0000000000..d5ff19bd41
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait.xml
@@ -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>
diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c
index 97c8647192..c2458b9fc4 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -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");
-- 
2.51.2
Re: [PATCH 2/2] bhyve: support VNC 'wait' attribute
Posted by Martin Kletzander via Devel 19 hours ago
On Wed, Nov 19, 2025 at 06:54:26PM +0100, Roman Bogorodskiy wrote:
>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>
>---
> src/bhyve/bhyve_command.c                     |  3 ++
> .../bhyvexml2argv-vnc-wait-no.args            | 13 ++++++
> .../bhyvexml2argv-vnc-wait-no.ldargs          |  1 +
> .../bhyvexml2argv-vnc-wait-no.xml             | 26 +++++++++++
> .../bhyvexml2argv-vnc-wait.args               | 13 ++++++
> .../bhyvexml2argv-vnc-wait.ldargs             |  1 +
> .../bhyvexml2argv-vnc-wait.xml                | 26 +++++++++++
> tests/bhyvexml2argvtest.c                     |  2 +
> .../bhyvexml2xmlout-vnc-wait-no.xml           | 44 +++++++++++++++++++
> .../bhyvexml2xmlout-vnc-wait.xml              | 44 +++++++++++++++++++
> tests/bhyvexml2xmltest.c                      |  2 +
> 11 files changed, 175 insertions(+)
> create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.args
> create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.ldargs
> create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.xml
> create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.args
> create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.ldargs
> create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.xml
> create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml
> create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait.xml
>
>diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
>index 8bfd5a6f93..057715102e 100644
>--- a/src/bhyve/bhyve_command.c
>+++ b/src/bhyve/bhyve_command.c
>@@ -651,6 +651,9 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def,
>         virBufferAsprintf(&opt, ",vga=%s",
>                           virDomainVideoVGAConfTypeToString(video->driver->vgaconf));
>
>+    if (graphics->data.vnc.wait)

If you agree with my suggestion from PATCH 1/2, this should be changed
to:

`if (graphics->data.vnc.wait != VIR_TRISTATE_BOOL_YES)`

But if you don't (which also makes sense since bhyve only has a way to
enable the wait and not explicitly disable it) then PATCH 1/2 needs an
adjustment.

To elaborate on this a bit, using any tristate gives us the ability to
keep some setting around even when it is the default, just in case it
changes in the future or the default is different in some other driver.

Since both of the scenarios are highly unlikely with respect to VNC
server's `wait` parameter, I guess I am fine with both.

Either way, if adjusted along with tests:

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>

>diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml
>new file mode 100644
>index 0000000000..58e71282e7
>--- /dev/null
>+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml
>@@ -0,0 +1,44 @@

[...]

>+    <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1'>

See ^^ =)
Re: [PATCH 2/2] bhyve: support VNC 'wait' attribute
Posted by Roman Bogorodskiy 15 hours ago
  Martin Kletzander wrote:

> On Wed, Nov 19, 2025 at 06:54:26PM +0100, Roman Bogorodskiy wrote:
> > 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>
> > ---
> > src/bhyve/bhyve_command.c                     |  3 ++
> > .../bhyvexml2argv-vnc-wait-no.args            | 13 ++++++
> > .../bhyvexml2argv-vnc-wait-no.ldargs          |  1 +
> > .../bhyvexml2argv-vnc-wait-no.xml             | 26 +++++++++++
> > .../bhyvexml2argv-vnc-wait.args               | 13 ++++++
> > .../bhyvexml2argv-vnc-wait.ldargs             |  1 +
> > .../bhyvexml2argv-vnc-wait.xml                | 26 +++++++++++
> > tests/bhyvexml2argvtest.c                     |  2 +
> > .../bhyvexml2xmlout-vnc-wait-no.xml           | 44 +++++++++++++++++++
> > .../bhyvexml2xmlout-vnc-wait.xml              | 44 +++++++++++++++++++
> > tests/bhyvexml2xmltest.c                      |  2 +
> > 11 files changed, 175 insertions(+)
> > create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.args
> > create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.ldargs
> > create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait-no.xml
> > create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.args
> > create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.ldargs
> > create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-vnc-wait.xml
> > create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml
> > create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait.xml
> > 
> > diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
> > index 8bfd5a6f93..057715102e 100644
> > --- a/src/bhyve/bhyve_command.c
> > +++ b/src/bhyve/bhyve_command.c
> > @@ -651,6 +651,9 @@ bhyveBuildGraphicsArgStr(const virDomainDef *def,
> >         virBufferAsprintf(&opt, ",vga=%s",
> >                           virDomainVideoVGAConfTypeToString(video->driver->vgaconf));
> > 
> > +    if (graphics->data.vnc.wait)
> 
> If you agree with my suggestion from PATCH 1/2, this should be changed
> to:
> 
> `if (graphics->data.vnc.wait != VIR_TRISTATE_BOOL_YES)`

I've pushed with your suggestions incorporated and ^ this changed to
" == VIR_TRISTATE_BOOL_YES". Thanks for review!

> But if you don't (which also makes sense since bhyve only has a way to
> enable the wait and not explicitly disable it) then PATCH 1/2 needs an
> adjustment.
> 
> To elaborate on this a bit, using any tristate gives us the ability to
> keep some setting around even when it is the default, just in case it
> changes in the future or the default is different in some other driver.
> 
> Since both of the scenarios are highly unlikely with respect to VNC
> server's `wait` parameter, I guess I am fine with both.
> 
> Either way, if adjusted along with tests:
> 
> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
> 
> > diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml
> > new file mode 100644
> > index 0000000000..58e71282e7
> > --- /dev/null
> > +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml
> > @@ -0,0 +1,44 @@
> 
> [...]
> 
> > +    <graphics type='vnc' port='5904' autoport='no' listen='127.0.0.1'>
> 
> See ^^ =)