On Mon, Mar 10, 2025 at 16:11:03 -0400, Laine Stump wrote:
> The original implementation of the passt backend for vhost-user
> interfaces erroneously forgot to parse:
>
> <source dev='blah'/>
>
> for interface type='vhostuser', so it wasn't being added to the passt
> commandline, and also wasn't being saved to the domain config. Now we
> parse it no matter what the interface type, and then throw an error
> during validation if source/@dev was specified and backend type !=
> 'passt' (or if interface type != 'user|vhostuser').
>
> Fixes: 1e9054b9c79d721a55f413c2983c5370044f8f60
> Resolves: https://issues.redhat.com/browse/RHEL-82539
> Signed-off-by: Laine Stump <[email protected]>
> ---
> src/conf/domain_conf.c | 10 +++++++---
> src/conf/domain_validate.c | 5 +++++
> .../net-vhostuser-passt.x86_64-latest.xml | 2 ++
> 3 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index d555873848..5daa1f89e8 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -9938,14 +9938,18 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
> break;
>
> case VIR_DOMAIN_NET_TYPE_USER:
> - def->sourceDev = virXMLPropString(source_node, "dev");
> - break;
> -
> case VIR_DOMAIN_NET_TYPE_NULL:
> case VIR_DOMAIN_NET_TYPE_LAST:
> break;
> }
>
> + /* source/@dev is used for two different interface types and *not*
> + * stored inside the union, so we can parse it out always, and
> + * then log an error during validation if it was specified for one
> + * of the interface types that doesn't support it.
> + */
> + def->sourceDev = virXMLPropString(source_node, "dev");
> +
> if ((virtualport_node = virXPathNode("./virtualport", ctxt))) {
> if (virtualport_flags == 0) {
> virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
> index f2a98f143d..9de442d7d7 100644
> --- a/src/conf/domain_validate.c
> +++ b/src/conf/domain_validate.c
> @@ -2196,6 +2196,11 @@ virDomainNetDefValidate(const virDomainNetDef *net)
> }
> }
>
> + if (net->sourceDev && net->backend.type != VIR_DOMAIN_NET_BACKEND_PASST)
> {
> + virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("The 'dev' attribute of the <source> element can
> only be used with interface type='user' or type='vhostuser' and
> backend='passt'."));
Missing return/goto statement. Also config errors must not use
VIR_ERR_INTERNAL_ERROR. Use the XML_ERROR or XML_DETAIL codes that I
can't remember the exact spelling of.
> + }
> +
> if (net->nPortForwards > 0) {
> size_t p;
>
Reviewed-by: Peter Krempa <[email protected]>