diff options
author | John Levon <john.levon@nutanix.com> | 2020-11-19 09:23:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 09:23:10 +0000 |
commit | 58b89f9e0f7cd7847606fb22d2c0b9a38735cd62 (patch) | |
tree | 2fe5e0f56a1bb02572d8cd95cbd3c7f91a3ee9db /samples | |
parent | 57777a738b6945c203f28f7ee5829d04e8824f8c (diff) | |
download | libvfio-user-58b89f9e0f7cd7847606fb22d2c0b9a38735cd62.zip libvfio-user-58b89f9e0f7cd7847606fb22d2c0b9a38735cd62.tar.gz libvfio-user-58b89f9e0f7cd7847606fb22d2c0b9a38735cd62.tar.bz2 |
refactor socket code into lib/tran_sock.[ch] (#97)
Diffstat (limited to 'samples')
-rw-r--r-- | samples/CMakeLists.txt | 3 | ||||
-rw-r--r-- | samples/client.c | 23 | ||||
-rw-r--r-- | samples/gpio-pci-idio-16.c | 3 | ||||
-rw-r--r-- | samples/null.c | 3 | ||||
-rw-r--r-- | samples/server.c | 3 |
5 files changed, 29 insertions, 6 deletions
diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index bb963da..ca311e7 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -30,7 +30,8 @@ add_executable(server server.c) target_link_libraries(server muser ssl crypto) -add_executable(client client.c ../lib/muser_ctx.c ../lib/muser_pci.c ../lib/dma.c ../lib/cap.c) +add_executable(client client.c + ../lib/tran_sock.c) add_executable(null null.c) target_link_libraries(null muser pthread) diff --git a/samples/client.c b/samples/client.c index 1925f88..1c6f889 100644 --- a/samples/client.c +++ b/samples/client.c @@ -33,6 +33,7 @@ #include <sys/socket.h> #include <sys/un.h> #include <stdlib.h> +#include <stdarg.h> #include <errno.h> #include <sys/mman.h> #include <sys/eventfd.h> @@ -41,9 +42,27 @@ #include <assert.h> #include <sys/stat.h> -#include "../lib/muser.h" -#include "../lib/muser_priv.h" #include "../lib/common.h" +#include "../lib/muser.h" +#include "../lib/tran_sock.h" + +static char *irq_to_str[] = { + [LM_DEV_INTX_IRQ_IDX] = "INTx", + [LM_DEV_MSI_IRQ_IDX] = "MSI", + [LM_DEV_MSIX_IRQ_IDX] = "MSI-X", + [LM_DEV_ERR_IRQ_INDEX] = "ERR", + [LM_DEV_REQ_IRQ_INDEX] = "REQ" +}; + +void +lm_log(UNUSED lm_ctx_t *lm_ctx, UNUSED lm_log_lvl_t lvl, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} static int init_sock(const char *path) diff --git a/samples/gpio-pci-idio-16.c b/samples/gpio-pci-idio-16.c index 3e47fc9..3e9b1ed 100644 --- a/samples/gpio-pci-idio-16.c +++ b/samples/gpio-pci-idio-16.c @@ -41,8 +41,9 @@ #include <signal.h> #include <errno.h> +#include "../lib/common.h" #include "../lib/muser.h" -#include "../lib/muser_priv.h" +#include "../lib/tran_sock.h" static void _log(UNUSED void *pvt, UNUSED lm_log_lvl_t lvl, char const *msg) diff --git a/samples/null.c b/samples/null.c index 0253d05..caec23f 100644 --- a/samples/null.c +++ b/samples/null.c @@ -40,8 +40,9 @@ #include <errno.h> #include <string.h> +#include "../lib/common.h" #include "../lib/muser.h" -#include "../lib/muser_priv.h" +#include "../lib/tran_sock.h" static void null_log(UNUSED void *pvt, UNUSED lm_log_lvl_t lvl, char const *msg) diff --git a/samples/server.c b/samples/server.c index 2746d00..ac00bb6 100644 --- a/samples/server.c +++ b/samples/server.c @@ -44,8 +44,9 @@ #include <sys/param.h> #include <sys/time.h> +#include "../lib/common.h" #include "../lib/muser.h" -#include "../lib/muser_priv.h" +#include "../lib/tran_sock.h" struct dma_regions { uint64_t addr; |