[libvirt PATCH] conf: Restrict use of <portForward> to the passt backend

Ján Tomko jtomko at redhat.com
Tue Apr 18 13:43:41 UTC 2023


On a Tuesday in 2023, Andrea Bolognani wrote:
>On Tue, Apr 18, 2023 at 03:19:45PM +0200, Ján Tomko wrote:
>> On a Tuesday in 2023, Andrea Bolognani wrote:
>> > That's already the case in practice, but it's a better
>> > experience for the user if we reject this configuration
>> > outright instead of silently ignoring part of it.
>> >
>> > Signed-off-by: Andrea Bolognani <abologna at redhat.com>
>> > ---
>> > src/conf/domain_validate.c                    |  9 +++++++++
>> > ...t-user-slirp-portforward.x86_64-latest.err |  1 +
>> > .../net-user-slirp-portforward.xml            | 20 +++++++++++++++++++
>> > tests/qemuxml2argvtest.c                      |  1 +
>> > 4 files changed, 31 insertions(+)
>> > create mode 100644 tests/qemuxml2argvdata/net-user-slirp-portforward.x86_64-latest.err
>> > create mode 100644 tests/qemuxml2argvdata/net-user-slirp-portforward.xml
>>
>> Reviewed-by: Ján Tomko <jtomko at redhat.com>
>
>Thanks for the review!
>
>Right before pushing, I realized that VIR_ERR_INTERNAL_ERROR is
>probably not the best fit for this scenario. Are you okay with me
>squashing in the changes below?
>

Yes.

     VIR_ERR_CONFIG_UNSUPPORTED = 67,    /* unsupported configuration
                                            construct (Since: 0.7.3) */

We also use VIR_ERR_XML_ERROR in similar cases,
but I'm not sure whether it's more fitting, given its description:

     VIR_ERR_XML_ERROR = 27,             /* an XML description is not well
                                            formed or broken (Since: 0.1.1) */
Jano

>
>diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
>index 9c7ee6d75d..e04b85fee4 100644
>--- a/src/conf/domain_validate.c
>+++ b/src/conf/domain_validate.c
>@@ -2101,7 +2101,7 @@ virDomainNetDefValidate(const virDomainNetDef *net)
>         (net->type != VIR_DOMAIN_NET_TYPE_USER ||
>          (net->type == VIR_DOMAIN_NET_TYPE_USER &&
>           net->backend.type != VIR_DOMAIN_NET_BACKEND_PASST))) {
>-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>                        _("The <portForward> element can only be used
>with <interface type='user'> and its 'passt' backend"));
>         return -1;
>     }
>diff --git a/tests/qemuxml2argvdata/net-user-slirp-portforward.x86_64-latest.err
>b/tests/qemuxml2argvdata/net-user-slirp-portforward.x86_64-latest.err
>index f296db1e8c..eaa934742e 100644
>--- a/tests/qemuxml2argvdata/net-user-slirp-portforward.x86_64-latest.err
>+++ b/tests/qemuxml2argvdata/net-user-slirp-portforward.x86_64-latest.err
>@@ -1 +1 @@
>-internal error: The <portForward> element can only be used with
><interface type='user'> and its 'passt' backend
>+unsupported configuration: The <portForward> element can only be used
>with <interface type='user'> and its 'passt' backend
>-- 
>Andrea Bolognani / Red Hat / Virtualization
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230418/9927e361/attachment.sig>


More information about the libvir-list mailing list