From: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
virtio-fs@redhat.com, Yuval Shaia <yuval.shaia.ml@gmail.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Konstantin Kostiuk <kkostiuk@redhat.com>,
Michael Roth <michael.roth@amd.com>,
Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>, Stefan Weil <sw@weilnetz.de>,
Yan Vugenfirer <yan@daynix.com>,
Akihiko Odaki <akihiko.odaki@daynix.com>
Subject: [Virtio-fs] [PATCH v3 3/8] contrib/rdmacm-mux: Use qemu_get_runtime_dir()
Date: Thu, 21 Sep 2023 16:54:17 +0900 [thread overview]
Message-ID: <20230921075425.16738-4-akihiko.odaki@daynix.com> (raw)
In-Reply-To: <20230921075425.16738-1-akihiko.odaki@daynix.com>
qemu_get_runtime_dir() is used to construct the default Unix socket
path.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
contrib/rdmacm-mux/main.c | 22 ++++++++++++++--------
contrib/rdmacm-mux/meson.build | 2 +-
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/contrib/rdmacm-mux/main.c b/contrib/rdmacm-mux/main.c
index 771ca01e03..00c14031ca 100644
--- a/contrib/rdmacm-mux/main.c
+++ b/contrib/rdmacm-mux/main.c
@@ -14,6 +14,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/cutils.h"
#include <sys/poll.h>
#include <sys/ioctl.h>
#include <pthread.h>
@@ -40,8 +41,6 @@
#define CM_REQ_DGID_POS 80
#define CM_SIDR_REQ_DGID_POS 44
-/* The below can be override by command line parameter */
-#define UNIX_SOCKET_PATH "/var/run/rdmacm-mux"
/* Has format %s-%s-%d" <path>-<rdma-dev--name>-<port> */
#define SOCKET_PATH_MAX (PATH_MAX - NAME_MAX - sizeof(int) - 2)
#define RDMA_PORT_NUM 1
@@ -77,7 +76,13 @@ typedef struct RdmaCmServer {
static RdmaCMServer server = {0};
-static void usage(const char *progname)
+static char *get_default_unix_socket_path(void)
+{
+ g_autofree char *run = qemu_get_runtime_dir();
+ return g_build_filename(run, "rdmacm-mux", NULL);
+}
+
+static void usage(const char *progname, const char *default_unix_socket_path)
{
printf("Usage: %s [OPTION]...\n"
"Start a RDMA-CM multiplexer\n"
@@ -86,7 +91,7 @@ static void usage(const char *progname)
"\t-d rdma-device-name Name of RDMA device to register with\n"
"\t-s unix-socket-path Path to unix socket to listen on (default %s)\n"
"\t-p rdma-device-port Port number of RDMA device to register with (default %d)\n",
- progname, UNIX_SOCKET_PATH, RDMA_PORT_NUM);
+ progname, default_unix_socket_path, RDMA_PORT_NUM);
}
static void help(const char *progname)
@@ -97,16 +102,16 @@ static void help(const char *progname)
static void parse_args(int argc, char *argv[])
{
int c;
- char unix_socket_path[SOCKET_PATH_MAX];
+ g_autofree char *default_unix_socket_path = get_default_unix_socket_path();
+ char *unix_socket_path = default_unix_socket_path;
strcpy(server.args.rdma_dev_name, "");
- strcpy(unix_socket_path, UNIX_SOCKET_PATH);
server.args.rdma_port_num = RDMA_PORT_NUM;
while ((c = getopt(argc, argv, "hs:d:p:")) != -1) {
switch (c) {
case 'h':
- usage(argv[0]);
+ usage(argv[0], default_unix_socket_path);
exit(0);
case 'd':
@@ -115,7 +120,7 @@ static void parse_args(int argc, char *argv[])
case 's':
/* This is temporary, final name will build below */
- strncpy(unix_socket_path, optarg, SOCKET_PATH_MAX - 1);
+ unix_socket_path = optarg;
break;
case 'p':
@@ -811,6 +816,7 @@ int main(int argc, char *argv[])
{
int rc;
+ qemu_init_exec_dir(argv[0]);
memset(&server, 0, sizeof(server));
parse_args(argc, argv);
diff --git a/contrib/rdmacm-mux/meson.build b/contrib/rdmacm-mux/meson.build
index 36c9c89630..59f60f9cac 100644
--- a/contrib/rdmacm-mux/meson.build
+++ b/contrib/rdmacm-mux/meson.build
@@ -1,7 +1,7 @@
if have_pvrdma
# FIXME: broken on big endian architectures
executable('rdmacm-mux', files('main.c'), genh,
- dependencies: [glib, libumad],
+ dependencies: [glib, libumad, qemuutil],
build_by_default: false,
install: false)
endif
--
2.41.0
next prev parent reply other threads:[~2023-09-21 7:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 7:54 [Virtio-fs] [PATCH v3 0/8] util: Introduce qemu_get_runtime_dir() Akihiko Odaki
2023-09-21 7:54 ` [Virtio-fs] [PATCH v3 1/8] " Akihiko Odaki
2023-09-21 7:54 ` [Virtio-fs] [PATCH v3 2/8] ivshmem-server: Use qemu_get_runtime_dir() Akihiko Odaki
2023-09-21 7:54 ` Akihiko Odaki [this message]
2023-09-21 7:54 ` [Virtio-fs] [PATCH v3 4/8] qga: " Akihiko Odaki
2023-09-21 7:54 ` [Virtio-fs] [PATCH v3 5/8] scsi: " Akihiko Odaki
2023-09-21 7:54 ` [Virtio-fs] [PATCH v3 6/8] module: " Akihiko Odaki
2023-09-21 7:54 ` [Virtio-fs] [PATCH v3 7/8] util: Remove qemu_get_local_state_dir() Akihiko Odaki
2023-09-21 7:54 ` [Virtio-fs] [PATCH v3 8/8] spice-app: Use qemu_get_runtime_dir() 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=20230921075425.16738-4-akihiko.odaki@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=dgilbert@redhat.com \
--cc=fam@euphon.net \
--cc=kkostiuk@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=sw@weilnetz.de \
--cc=virtio-fs@redhat.com \
--cc=yan@daynix.com \
--cc=yuval.shaia.ml@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).