summaryrefslogtreecommitdiff
path: root/contrib/ivshmem-server/main.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2016-03-15 19:34:18 +0100
committerMarkus Armbruster <armbru@redhat.com>2016-03-18 17:34:40 +0100
commit3625c739eaf304fdf8ab3552ea6140cce07962a2 (patch)
tree1e00501ce39ec56cea2598f3e0d656b0d4200825 /contrib/ivshmem-server/main.c
parente3ad72965a86b19df5d011117e186c62893085ef (diff)
downloadqemu-3625c739eaf304fdf8ab3552ea6140cce07962a2.tar.gz
ivshmem-server: Don't overload POSIX shmem and file name
Option -m NAME is interpreted as directory name if we can statfs() it and its on hugetlbfs. Else it's interpreted as POSIX shared memory object name. This is nuts. Always interpret -m as directory. Create new -M for POSIX shared memory. Last of -m or -M wins. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1458066895-20632-4-git-send-email-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'contrib/ivshmem-server/main.c')
-rw-r--r--contrib/ivshmem-server/main.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/contrib/ivshmem-server/main.c b/contrib/ivshmem-server/main.c
index 3332a8cee6..5afa8eef11 100644
--- a/contrib/ivshmem-server/main.c
+++ b/contrib/ivshmem-server/main.c
@@ -29,6 +29,7 @@ typedef struct IvshmemServerArgs {
const char *pid_file;
const char *unix_socket_path;
const char *shm_path;
+ bool use_shm_open;
uint64_t shm_size;
unsigned n_vectors;
} IvshmemServerArgs;
@@ -44,8 +45,9 @@ ivshmem_server_usage(const char *progname)
" default " IVSHMEM_SERVER_DEFAULT_PID_FILE "\n"
" -S <unix-socket-path>: path to the unix socket to listen to\n"
" default " IVSHMEM_SERVER_DEFAULT_UNIX_SOCK_PATH "\n"
- " -m <shm-path>: POSIX shared memory object name or a hugetlbfs mount point\n"
+ " -M <shm-name>: POSIX shared memory object to use\n"
" default " IVSHMEM_SERVER_DEFAULT_SHM_PATH "\n"
+ " -m <dir-name>: where to create shared memory\n"
" -l <size>: size of shared memory in bytes\n"
" suffixes K, M and G can be used, e.g. 1K means 1024\n"
" default %u\n"
@@ -69,7 +71,7 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[])
unsigned long long v;
Error *err = NULL;
- while ((c = getopt(argc, argv, "hvFp:S:m:l:n:")) != -1) {
+ while ((c = getopt(argc, argv, "hvFp:S:m:M:l:n:")) != -1) {
switch (c) {
case 'h': /* help */
@@ -93,8 +95,10 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[])
args->unix_socket_path = optarg;
break;
- case 'm': /* shm path */
+ case 'M': /* shm name */
+ case 'm': /* dir name */
args->shm_path = optarg;
+ args->use_shm_open = c == 'M';
break;
case 'l': /* shm size */
@@ -190,6 +194,7 @@ main(int argc, char *argv[])
.pid_file = IVSHMEM_SERVER_DEFAULT_PID_FILE,
.unix_socket_path = IVSHMEM_SERVER_DEFAULT_UNIX_SOCK_PATH,
.shm_path = IVSHMEM_SERVER_DEFAULT_SHM_PATH,
+ .use_shm_open = true,
.shm_size = IVSHMEM_SERVER_DEFAULT_SHM_SIZE,
.n_vectors = IVSHMEM_SERVER_DEFAULT_N_VECTORS,
};
@@ -217,7 +222,8 @@ main(int argc, char *argv[])
}
/* init the ivshms structure */
- if (ivshmem_server_init(&server, args.unix_socket_path, args.shm_path,
+ if (ivshmem_server_init(&server, args.unix_socket_path,
+ args.shm_path, args.use_shm_open,
args.shm_size, args.n_vectors, args.verbose) < 0) {
fprintf(stderr, "cannot init server\n");
goto err;