summaryrefslogtreecommitdiff
path: root/block/nbd-client.h
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@amazon.com>2013-12-16 09:44:13 -0800
committerAnthony Liguori <aliguori@amazon.com>2013-12-16 09:44:13 -0800
commitb91f93243bbe36dc436a64a662a9bbfb2362534a (patch)
tree6a635a56f1b180aadaeba9d4c20fc9180dba5170 /block/nbd-client.h
parent80d6f5eae79b009bf3e02e59e9e225db42ddf887 (diff)
parent75c70e37bc4a6bdc394b4d1b163fe730abb82c72 (diff)
downloadqemu-b91f93243bbe36dc436a64a662a9bbfb2362534a.tar.gz
Merge remote-tracking branch 'spice/tags/pull-spice-1' into staging
Collection of little cleanups anf bugfixes. nbd patches in preparation of spice-nbd. # gpg: Signature made Mon 16 Dec 2013 01:27:45 AM PST using RSA key ID D3E87138 # gpg: Can't check signature: public key not found # By Marc-André Lureau (12) and Gerd Hoffmann (4) # Via Gerd Hoffmann * spice/tags/pull-spice-1: spice: stop server for qxl hard reset spice: move spice_server_vm_{start,stop} calls into qemu_spice_display_*() spice: move qemu_spice_display_*() from spice-graphics to spice-core nbd: avoid uninitialized warnings nbd: finish any pending coroutine nbd: make nbd_client_session_close() idempotent nbd: pass export name as init argument nbd: don't change socket block during negotiate Split nbd block client code spice-char: implement chardev port event char: add qemu_chr_fe_event() include: add missing config-host.h include qmp_change_blockdev() remove unused has_format spice-char: remove unused field vscclient: do not add a socket watch if there is not data to send spice: flip streaming video mode to off by default
Diffstat (limited to 'block/nbd-client.h')
-rw-r--r--block/nbd-client.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/block/nbd-client.h b/block/nbd-client.h
new file mode 100644
index 0000000000..f2a63378bb
--- /dev/null
+++ b/block/nbd-client.h
@@ -0,0 +1,50 @@
+#ifndef NBD_CLIENT_H
+#define NBD_CLIENT_H
+
+#include "qemu-common.h"
+#include "block/nbd.h"
+#include "block/block_int.h"
+
+/* #define DEBUG_NBD */
+
+#if defined(DEBUG_NBD)
+#define logout(fmt, ...) \
+ fprintf(stderr, "nbd\t%-24s" fmt, __func__, ##__VA_ARGS__)
+#else
+#define logout(fmt, ...) ((void)0)
+#endif
+
+#define MAX_NBD_REQUESTS 16
+
+typedef struct NbdClientSession {
+ int sock;
+ uint32_t nbdflags;
+ off_t size;
+ size_t blocksize;
+
+ CoMutex send_mutex;
+ CoMutex free_sema;
+ Coroutine *send_coroutine;
+ int in_flight;
+
+ Coroutine *recv_coroutine[MAX_NBD_REQUESTS];
+ struct nbd_reply reply;
+
+ bool is_unix;
+
+ BlockDriverState *bs;
+} NbdClientSession;
+
+int nbd_client_session_init(NbdClientSession *client, BlockDriverState *bs,
+ int sock, const char *export_name);
+void nbd_client_session_close(NbdClientSession *client);
+
+int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num,
+ int nb_sectors);
+int nbd_client_session_co_flush(NbdClientSession *client);
+int nbd_client_session_co_writev(NbdClientSession *client, int64_t sector_num,
+ int nb_sectors, QEMUIOVector *qiov);
+int nbd_client_session_co_readv(NbdClientSession *client, int64_t sector_num,
+ int nb_sectors, QEMUIOVector *qiov);
+
+#endif /* NBD_CLIENT_H */