[libvirt] [PATCH 1/2] Check if qemu-bridge-helper exists and is executable

Otherwise the error is just error: Failed to create domain from test1.xml error: failed to retrieve file descriptor for interface: Transport endpoint is not connected since we don't get a sensible error after the fork. --- src/qemu/qemu_command.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5a92ad4..bddc955 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -295,6 +295,12 @@ static int qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr cfg, return -1; } + if (!virFileIsExecutable(cfg->bridgeHelperName)) { + virReportSystemError(errno, _("'%s' not a suitable bridge helper"), + cfg->bridgeHelperName); + return -1; + } + cmd = virCommandNew(cfg->bridgeHelperName); if (flags & VIR_NETDEV_TAP_CREATE_VNET_HDR) virCommandAddArgFormat(cmd, "--use-vnet"); -- 2.1.4

RedHat and Debian based distros use different locations Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=790935 --- configure.ac | 3 +++ src/qemu/qemu_conf.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 46c80ce..965858b 100644 --- a/configure.ac +++ b/configure.ac @@ -2523,6 +2523,9 @@ AC_ARG_WITH([qemu-group], AC_DEFINE_UNQUOTED([QEMU_USER], ["$QEMU_USER"], [QEMU user account]) AC_DEFINE_UNQUOTED([QEMU_GROUP], ["$QEMU_GROUP"], [QEMU group account]) +AC_PATH_PROG([QEMU_BRIDGE_HELPER], [qemu-bridge-helper], [/usr/libexec/qemu-bridge-helper], + [/usr/libexec:/usr/lib/qemu]) +AC_DEFINE_UNQUOTED([QEMU_BRIDGE_HELPER], ["$QEMU_BRIDGE_HELPER"], [QEMU bridge helper]) AC_ARG_WITH([macvtap], [AS_HELP_STRING([--with-macvtap], diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index da26c2d..1ce459f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -295,7 +295,7 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged) goto error; } - if (VIR_STRDUP(cfg->bridgeHelperName, "/usr/libexec/qemu-bridge-helper") < 0) + if (VIR_STRDUP(cfg->bridgeHelperName, QEMU_BRIDGE_HELPER) < 0) goto error; cfg->clearEmulatorCapabilities = true; -- 2.1.4

On Thu, Aug 13, 2015 at 02:42:44PM +0200, Guido Günther wrote:
Otherwise the error is just
error: Failed to create domain from test1.xml error: failed to retrieve file descriptor for interface: Transport endpoint is not connected
since we don't get a sensible error after the fork. --- src/qemu/qemu_command.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5a92ad4..bddc955 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -295,6 +295,12 @@ static int qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr cfg, return -1; }
+ if (!virFileIsExecutable(cfg->bridgeHelperName)) { + virReportSystemError(errno, _("'%s' not a suitable bridge helper"),
I think you meant s/ not/is not/ ACK to both with that fixed.
+ cfg->bridgeHelperName); + return -1; + } + cmd = virCommandNew(cfg->bridgeHelperName); if (flags & VIR_NETDEV_TAP_CREATE_VNET_HDR) virCommandAddArgFormat(cmd, "--use-vnet"); -- 2.1.4
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On Thu, Aug 13, 2015 at 03:59:53PM +0200, Martin Kletzander wrote:
On Thu, Aug 13, 2015 at 02:42:44PM +0200, Guido Günther wrote:
Otherwise the error is just
error: Failed to create domain from test1.xml error: failed to retrieve file descriptor for interface: Transport endpoint is not connected
since we don't get a sensible error after the fork. --- src/qemu/qemu_command.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5a92ad4..bddc955 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -295,6 +295,12 @@ static int qemuCreateInBridgePortWithHelper(virQEMUDriverConfigPtr cfg, return -1; }
+ if (!virFileIsExecutable(cfg->bridgeHelperName)) { + virReportSystemError(errno, _("'%s' not a suitable bridge helper"),
I think you meant s/ not/is not/
Fixed up and pushed. Thanks, -- Guido
participants (2)
-
Guido Günther
-
Martin Kletzander