Related: https://gitlab.com/libvirt/libvirt/-/issues/93 Signed-off-by: Amneesh Singh <natto@xxxxxxxxxxxxx> --- v1 PATCH: https://listman.redhat.com/archives/libvir-list/2022-April/230021.html src/conf/domain_validate.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 68190fc..e58b84e 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2347,10 +2347,35 @@ virDomainAudioDefValidate(const virDomainDef *def, return 0; } +static int +virDomainGraphicsDefListensValidate(const virDomainGraphicsDef *def) +{ + size_t i; + + for (i = 0; i < def->nListens; i++) { + if (def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK && + !def->listens[i].network) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'network' attribute is required for " + "listen type 'network'")); + return -1; + } + } + + return 0; +} + static int virDomainGraphicsDefValidate(const virDomainDef *def, const virDomainGraphicsDef *graphics) { + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC || + graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE || + graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP) { + if (virDomainGraphicsDefListensValidate(graphics) < 0) + return -1; + } + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) return virDomainEnsureAudioID(def, graphics->data.vnc.audioId); -- 2.35.1