From 4e8201da07c5c78fe0d764a064f3fcd929f5bef7 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 5 Sep 2024 14:01:28 +1000 Subject: [PATCH] [common] ivshmem: default to /dev/kvmfr0 if it's found --- common/src/platform/linux/ivshmem.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common/src/platform/linux/ivshmem.c b/common/src/platform/linux/ivshmem.c index 0d9a7502..66087af8 100644 --- a/common/src/platform/linux/ivshmem.c +++ b/common/src/platform/linux/ivshmem.c @@ -86,6 +86,15 @@ static StringList ivshmemDeviceGetValues(struct Option * option) void ivshmemOptionsInit(void) { + char * shmFile; + struct stat st; + + // if there is a kvmfr device, default to using it instead + if (stat("/dev/kvmfr0", &st) == 0) + shmFile = "/dev/kvmfr0"; + else + shmFile = "/dev/shm/looking-glass"; + struct Option options[] = { { @@ -94,7 +103,7 @@ void ivshmemOptionsInit(void) .shortopt = 'f', .description = "The path to the shared memory file, or the name of the kvmfr device to use, e.g. kvmfr0", .type = OPTION_TYPE_STRING, - .value.x_string = "/dev/shm/looking-glass", + .value.x_string = shmFile, .validator = ivshmemDeviceValidator, .getValues = ivshmemDeviceGetValues },