[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 08/12] Define a wire protocol for talking to the virtlockd daemon



From: "Daniel P. Berrange" <berrange redhat com>

The virtlockd daemon will be responsible for managing locks
on virtual machines. Communication will be via the standard
RPC infrastructure. This provides the XDR protocol definition

* src/locking/lock_protocol.x: Wire protocol for virtlockd
* src/Makefile.am: Include lock_protocol.[ch] in virtlockd

Signed-off-by: Daniel P. Berrange <berrange redhat com>
---
 .gitignore                  |  1 +
 cfg.mk                      |  3 ++
 src/Makefile.am             | 14 ++++++-
 src/locking/lock_protocol.x | 89 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 106 insertions(+), 1 deletion(-)
 create mode 100644 src/locking/lock_protocol.x

diff --git a/.gitignore b/.gitignore
index 619d481..c93433b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -103,6 +103,7 @@
 /src/libvirt_*helper
 /src/libvirt_*probes.h
 /src/libvirt_lxc
+/src/locking/lock_protocol.[ch]
 /src/locking/qemu-sanlock.conf
 /src/locking/test_libvirt_sanlock.aug
 /src/lxc/lxc_controller_dispatch.h
diff --git a/cfg.mk b/cfg.mk
index 087bd74..72f00b0 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -818,3 +818,6 @@ exclude_file_name_regexp--sc_unmarked_diagnostics = \
   ^(docs/apibuild.py|tests/virt-aa-helper-test)$$
 
 exclude_file_name_regexp--sc_size_of_brackets = cfg.mk
+
+exclude_file_name_regexp--sc_correct_id_types = \
+  (^src/locking/lock_protocol.x$$)
diff --git a/src/Makefile.am b/src/Makefile.am
index a60a772..0b0367b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -142,6 +142,15 @@ DRIVER_SOURCES =							\
 LOCK_DRIVER_SANLOCK_SOURCES = \
 		locking/lock_driver_sanlock.c
 
+LOCK_PROTOCOL_GENERATED = \
+		locking/lock_protocol.h \
+		locking/lock_protocol.c \
+		$(NULL)
+
+EXTRA_DIST += locking/lock_protocol.x
+BUILT_SOURCES += $(LOCK_PROTOCOL_GENERATED)
+MAINTAINERCLEANFILES += $(LOCK_PROTOCOL_GENERATED)
+
 LOCK_DAEMON_SOURCES = \
 		locking/lock_daemon.h \
 		locking/lock_daemon.c \
@@ -1482,7 +1491,10 @@ EXTRA_DIST += $(LIBVIRT_QEMU_SYMBOL_FILE)
 if WITH_LIBVIRTD
 sbin_PROGRAMS = virtlockd
 
-virtlockd_SOURCES = $(LOCK_DAEMON_SOURCES)
+virtlockd_SOURCES = \
+		$(LOCK_DAEMON_SOURCES) \
+		$(LOCK_PROTOCOL_GENERATED) \
+		$(NULL)
 virtlockd_CFLAGS = \
 		$(AM_CFLAGS) \
 		$(NULL)
diff --git a/src/locking/lock_protocol.x b/src/locking/lock_protocol.x
new file mode 100644
index 0000000..d3f6fb1
--- /dev/null
+++ b/src/locking/lock_protocol.x
@@ -0,0 +1,89 @@
+/* -*- c -*-
+ */
+
+%#include "internal.h"
+
+typedef opaque virLockSpaceProtocolUUID[VIR_UUID_BUFLEN];
+
+/* Length of long, but not unbounded, strings.
+ * This is an arbitrary limit designed to stop the decoder from trying
+ * to allocate unbounded amounts of memory when fed with a bad message.
+ */
+const VIR_LOCK_SPACE_PROTOCOL_STRING_MAX = 65536;
+
+/* A long string, which may NOT be NULL. */
+typedef string virLockSpaceProtocolNonNullString<VIR_LOCK_SPACE_PROTOCOL_STRING_MAX>;
+
+/* A long string, which may be NULL. */
+typedef virLockSpaceProtocolNonNullString *virLockSpaceProtocolString;
+
+struct virLockSpaceProtocolOwner {
+    virLockSpaceProtocolUUID uuid;
+    virLockSpaceProtocolNonNullString name;
+    unsigned int id;
+    unsigned int pid;
+};
+
+struct virLockSpaceProtocolRegisterArgs {
+    virLockSpaceProtocolOwner owner;
+    unsigned int flags;
+};
+
+struct virLockSpaceProtocolRestrictArgs {
+    unsigned int flags;
+};
+
+struct virLockSpaceProtocolNewArgs {
+    virLockSpaceProtocolNonNullString path;
+    unsigned int flags;
+};
+
+struct virLockSpaceProtocolCreateResourceArgs {
+    virLockSpaceProtocolNonNullString path;
+    virLockSpaceProtocolNonNullString name;
+    unsigned int flags;
+};
+
+struct virLockSpaceProtocolDeleteResourceArgs {
+    virLockSpaceProtocolNonNullString path;
+    virLockSpaceProtocolNonNullString name;
+    unsigned int flags;
+};
+
+enum virLockSpaceProtocolAcquireResourceFlags {
+    VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED     = 1,
+    VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE = 2
+};
+
+struct virLockSpaceProtocolAcquireResourceArgs {
+    virLockSpaceProtocolNonNullString path;
+    virLockSpaceProtocolNonNullString name;
+    unsigned int flags;
+};
+
+struct virLockSpaceProtocolReleaseResourceArgs {
+    virLockSpaceProtocolNonNullString path;
+    virLockSpaceProtocolNonNullString name;
+    unsigned int flags;
+};
+
+
+/* Define the program number, protocol version and procedure numbers here. */
+const VIR_LOCK_SPACE_PROTOCOL_PROGRAM = 0xEA7BEEF;
+const VIR_LOCK_SPACE_PROTOCOL_PROGRAM_VERSION = 1;
+
+enum virLockSpaceProtocolProcedure {
+    /* Each function must have a two-word comment.  The first word is
+     * whether remote_generator.pl handles daemon, the second whether
+     * it handles src/remote.  Additional flags can be specified after a
+     * pipe.
+     */
+    VIR_LOCK_SPACE_PROTOCOL_PROC_REGISTER = 1, /* skipgen skipgen */
+    VIR_LOCK_SPACE_PROTOCOL_PROC_RESTRICT = 2, /* skipgen skipgen */
+    VIR_LOCK_SPACE_PROTOCOL_PROC_NEW = 3, /* skipgen skipgen */
+    VIR_LOCK_SPACE_PROTOCOL_PROC_CREATE_RESOURCE = 4, /* skipgen skipgen */
+    VIR_LOCK_SPACE_PROTOCOL_PROC_DELETE_RESOURCE = 5, /* skipgen skipgen */
+
+    VIR_LOCK_SPACE_PROTOCOL_PROC_ACQUIRE_RESOURCE = 6, /* skipgen skipgen */
+    VIR_LOCK_SPACE_PROTOCOL_PROC_RELEASE_RESOURCE = 7 /* skipgen skipgen */
+};
-- 
1.7.11.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]