[PATCH 0/2] virnetdevtap: Output nicer message for common user error

See PATCH 2/2 (duh!). Martin Kletzander (2): virnetdevtap: Do (not) use NULLSTR consistently virnetdevtap: Add better error message for a possible common user error src/util/virnetdevtap.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.46.0

The function generates *ifname from the get go and most functions do not wrap the string in a NULLSTR as it is not necessary. The few leftovers are outliers that are changed to fit the theme better. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virnetdevtap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 9a4866a4e4df..55536b5f4be2 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -232,7 +232,7 @@ int virNetDevTapCreate(char **ifname, if (ioctl(fd, TUNSETIFF, &ifr) < 0) { virReportSystemError(errno, _("Unable to create tap device %1$s"), - NULLSTR(*ifname)); + *ifname); goto cleanup; } @@ -247,7 +247,7 @@ int virNetDevTapCreate(char **ifname, ioctl(fd, TUNSETPERSIST, 1) < 0) { virReportSystemError(errno, _("Unable to set tap device %1$s to persistent"), - NULLSTR(*ifname)); + *ifname); goto cleanup; } tapfd[i] = fd; -- 2.46.0

When users pre-create a tap device to use with multiqueue interface that has `managed="no"`, change the error so that it does not indicate we are trying to create the device, and on top of that hint at the most probable error cause. Resolves: https://issues.redhat.com/browse/RHEL-55749 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virnetdevtap.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 55536b5f4be2..3df4dc129f0c 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -230,9 +230,16 @@ int virNetDevTapCreate(char **ifname, } if (ioctl(fd, TUNSETIFF, &ifr) < 0) { - virReportSystemError(errno, - _("Unable to create tap device %1$s"), - *ifname); + if (flags & VIR_NETDEV_TAP_CREATE_ALLOW_EXISTING && + tapfdSize > 0) { + virReportSystemError(errno, + _("Unable to create multiple fds for tap device %1$s (maybe existing device was created without multi_queue flag)"), + *ifname); + } else { + virReportSystemError(errno, + _("Unable to create tap device %1$s"), + *ifname); + } goto cleanup; } @@ -247,7 +254,7 @@ int virNetDevTapCreate(char **ifname, ioctl(fd, TUNSETPERSIST, 1) < 0) { virReportSystemError(errno, _("Unable to set tap device %1$s to persistent"), - *ifname); + NULLSTR(*ifname)); goto cleanup; } tapfd[i] = fd; -- 2.46.0

On 9/4/24 10:39, Martin Kletzander wrote:
When users pre-create a tap device to use with multiqueue interface that has `managed="no"`, change the error so that it does not indicate we are trying to create the device, and on top of that hint at the most probable error cause.
Resolves: https://issues.redhat.com/browse/RHEL-55749 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virnetdevtap.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 55536b5f4be2..3df4dc129f0c 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c
@@ -247,7 +254,7 @@ int virNetDevTapCreate(char **ifname, ioctl(fd, TUNSETPERSIST, 1) < 0) { virReportSystemError(errno, _("Unable to set tap device %1$s to persistent"), - *ifname); + NULLSTR(*ifname)); goto cleanup; } tapfd[i] = fd;
This hunk does not belong here. Michal

On 9/4/24 10:39, Martin Kletzander wrote:
See PATCH 2/2 (duh!).
Martin Kletzander (2): virnetdevtap: Do (not) use NULLSTR consistently virnetdevtap: Add better error message for a possible common user error
src/util/virnetdevtap.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
participants (2)
-
Martin Kletzander
-
Michal Prívozník