From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Alexander Bulekov" <alxndr@bu.edu>,
"Bandan Das" <bsd@redhat.com>, "Thomas Huth" <thuth@redhat.com>,
"Volker Rümelin" <vr_qemu@t-online.de>,
"Darren Kenny" <darren.kenny@oracle.com>,
"Qiuhao Li" <Qiuhao.Li@outlook.com>,
"Jason Wang" <jasowang@redhat.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Akihiko Odaki" <akihiko.odaki@gmail.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v3 4/4] net: convert to use qemu_find_file to locate bridge helper
Date: Wed, 15 Jun 2022 11:52:12 +0100 [thread overview]
Message-ID: <20220615105212.780256-5-berrange@redhat.com> (raw)
In-Reply-To: <20220615105212.780256-1-berrange@redhat.com>
The TAP device code currently uses get_relocate_path to find the bridge
helper, however, this fails when run from the build dir. Adding support
to qemu_find_file for helper binaries, allows it to work from both the
(relocated) install tree and build dir.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
include/net/net.h | 3 ++-
include/qemu/datadir.h | 1 +
net/tap.c | 5 ++++-
qemu-options.hx | 4 ++--
softmmu/datadir.c | 9 +++++++++
softmmu/trace-events | 2 +-
6 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/include/net/net.h b/include/net/net.h
index 523136c7ac..6a853512ac 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -228,7 +228,8 @@ NetClientState *net_hub_port_find(int hub_id);
#define DEFAULT_NETWORK_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifup"
#define DEFAULT_NETWORK_DOWN_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifdown"
-#define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
+#define DEFAULT_BRIDGE_HELPER "qemu-bridge-helper"
+#define DEFAULT_BRIDGE_HELPER_PATH CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
#define DEFAULT_BRIDGE_INTERFACE "br0"
void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
diff --git a/include/qemu/datadir.h b/include/qemu/datadir.h
index 427e90787a..a211b6b235 100644
--- a/include/qemu/datadir.h
+++ b/include/qemu/datadir.h
@@ -4,6 +4,7 @@
#define QEMU_FILE_TYPE_BIOS 0
#define QEMU_FILE_TYPE_KEYMAP 1
#define QEMU_FILE_TYPE_ICON 2
+#define QEMU_FILE_TYPE_HELPER 3
/**
* qemu_find_file:
diff --git a/net/tap.c b/net/tap.c
index b3ddfd4a74..161608e34a 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -42,6 +42,7 @@
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qemu/sockets.h"
+#include "qemu/datadir.h"
#include "net/tap.h"
@@ -507,9 +508,11 @@ static int net_bridge_run_helper(const char *helper, const char *bridge,
sigprocmask(SIG_BLOCK, &mask, &oldmask);
if (!helper) {
- helper = default_helper = get_relocated_path(DEFAULT_BRIDGE_HELPER);
+ helper = default_helper = qemu_find_file(QEMU_FILE_TYPE_HELPER,
+ DEFAULT_BRIDGE_HELPER);
}
+ g_printerr("Helper %s\n", helper);
if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
error_setg_errno(errp, errno, "socketpair() failed");
return -1;
diff --git a/qemu-options.hx b/qemu-options.hx
index 377d22fbd8..b5b7e75048 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2665,7 +2665,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
" to configure it and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n"
" to deconfigure it\n"
" use '[down]script=no' to disable script execution\n"
- " use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER ") to\n"
+ " use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER_PATH ") to\n"
" configure it\n"
" use 'fd=h' to connect to an already opened TAP interface\n"
" use 'fds=x:y:...:z' to connect to already opened multiqueue capable TAP interfaces\n"
@@ -2684,7 +2684,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
"-netdev bridge,id=str[,br=bridge][,helper=helper]\n"
" configure a host TAP network backend with ID 'str' that is\n"
" connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n"
- " using the program 'helper (default=" DEFAULT_BRIDGE_HELPER ")\n"
+ " using the program 'helper (default=" DEFAULT_BRIDGE_HELPER_PATH ")\n"
#endif
#ifdef __linux__
"-netdev l2tpv3,id=str,src=srcaddr,dst=dstaddr[,srcport=srcport][,dstport=dstport]\n"
diff --git a/softmmu/datadir.c b/softmmu/datadir.c
index e5d1fd0116..a68fe7167a 100644
--- a/softmmu/datadir.c
+++ b/softmmu/datadir.c
@@ -36,6 +36,7 @@ static char **extra_firmware_dirs;
/* Default built-in directories */
static char *default_data_dir;
static char *default_icon_dir;
+static char *default_helper_dir;
/* Whether we're known to be executing from a build tree */
static bool in_build_dir;
@@ -73,6 +74,12 @@ char *qemu_find_file(int type, const char *name)
default_install_dir = default_icon_dir;
break;
+ case QEMU_FILE_TYPE_HELPER:
+ rel_install_dir = "";
+ rel_build_dir = "";
+ default_install_dir = default_helper_dir;
+ break;
+
default:
abort();
}
@@ -140,9 +147,11 @@ void qemu_add_default_firmwarepath(void)
/* Add default dirs relative to the executable path */
default_data_dir = get_relocated_path(CONFIG_QEMU_DATADIR);
default_icon_dir = get_relocated_path(CONFIG_QEMU_ICONDIR);
+ default_helper_dir = get_relocated_path(CONFIG_QEMU_HELPERDIR);
trace_datadir_init(default_data_dir,
default_icon_dir,
+ default_helper_dir,
in_build_dir);
}
diff --git a/softmmu/trace-events b/softmmu/trace-events
index 9c00e9f389..b22d7e7714 100644
--- a/softmmu/trace-events
+++ b/softmmu/trace-events
@@ -6,7 +6,7 @@ balloon_event(void *opaque, unsigned long addr) "opaque %p addr %lu"
# datadir.c
datadir_load_file(const char *name, const char *path, int err) "name %s location %s errno %d"
-datadir_init(const char *defdatadir, const char *deficondir, bool inbuilddir) "default data dir %s icon dir %s in build dir %d"
+datadir_init(const char *defdatadir, const char *deficondir, const char *defhelperdir, bool inbuilddir) "default data dir %s icon dir %s helper dir %s in build dir %d"
# ioport.c
cpu_in(unsigned int addr, char size, unsigned int val) "addr 0x%x(%c) value %u"
--
2.36.1
next prev parent reply other threads:[~2022-06-15 11:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 10:52 [PATCH v3 0/4] softmmu: make qemu_find_file more flexible wrt build dir layout Daniel P. Berrangé
2022-06-15 10:52 ` [PATCH v3 1/4] softmmu: rewrite handling of qemu_find_file Daniel P. Berrangé
2022-06-15 10:52 ` [PATCH v3 2/4] ui: move 'pc-bios/keymaps' to 'ui/keymaps' Daniel P. Berrangé
2022-06-15 10:52 ` [PATCH v3 3/4] ui: find icons using qemu_find_file Daniel P. Berrangé
2022-06-15 10:52 ` Daniel P. Berrangé [this message]
2022-06-15 11:42 ` [PATCH v3 4/4] net: convert to use qemu_find_file to locate bridge helper Paolo Bonzini
2022-06-15 12:04 ` Daniel P. Berrangé
2022-06-15 16:47 ` Akihiko Odaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220615105212.780256-5-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=Qiuhao.Li@outlook.com \
--cc=akihiko.odaki@gmail.com \
--cc=alxndr@bu.edu \
--cc=bsd@redhat.com \
--cc=darren.kenny@oracle.com \
--cc=f4bug@amsat.org \
--cc=jasowang@redhat.com \
--cc=kraxel@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
--cc=vr_qemu@t-online.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.