On Wed, Nov 19, 2025 at 06:54:25PM +0100, Roman Bogorodskiy wrote:
Introduce an optional 'wait' attribute for 'VNC'. When set to 'yes', VM should only boot upon the initiation of a VNC connection.
Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com> --- src/conf/domain_conf.c | 11 +++++++++++ src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 5 +++++ 3 files changed, 17 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d2dea6952e..36cc1916d0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11891,6 +11891,7 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDef *def, xmlNodePtr audioNode; virTristateBool autoport; virTristateBool websocketGenerated; + virTristateBool wait; VIR_XPATH_NODE_AUTORESTORE(ctxt)
if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) @@ -11940,6 +11941,12 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDef *def,
def->data.vnc.keymap = virXMLPropString(node, "keymap");
+ if (virXMLPropTristateBool(node, "wait", VIR_XML_PROP_NONE, + &wait) < 0) + return -1; + + virTristateBoolToBool(wait, &def->data.vnc.wait); +
def->data.vnc.wait is a bool, yes
ctxt->node = node; audioNode = virXPathNode("./audio", ctxt); if (audioNode) { @@ -27213,6 +27220,10 @@ virDomainGraphicsDefFormatVNC(virBuffer *attrBuf, virBufferAsprintf(attrBuf, " websocketGenerated='%s'", def->data.vnc.websocketGenerated ? "yes" : "no");
+ if (def->data.vnc.wait != VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(attrBuf, " wait='%s'", + virTristateBoolTypeToString(def->data.vnc.wait));
But then you are treating it here as virTristateBool again.
+ virDomainGraphicsListenDefFormatAddr(attrBuf, glisten, flags); break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 11eb46ae53..e47e10c90c 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2048,6 +2048,7 @@ struct _virDomainGraphicsDef { virDomainGraphicsVNCSharePolicy sharePolicy; virTristateBool powerControl; unsigned int audioId; + bool wait;
I would suggest changing this to `virTristateBool wait;`, dropping the temporary @wait variable in the first hunk and just stick the value directly here when parsing. The current behaviour means you will lose any `wait="no"` in the parsed XML output (see PATCH 2/2, file tests/bhyvexml2xmloutdata/bhyvexml2xmlout-vnc-wait-no.xml where it disappears), and my suggestion keeps it around. With that one change (and tests adjusted): Reviewed-by: Martin Kletzander <mkletzan@redhat.com>