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

Daniel P. Berrange berrange at redhat.com
Thu Jul 7 14:17:26 UTC 2011


From: "Daniel P. Berrange" <berrange at 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
---
 .gitignore                  |    1 +
 src/locking/lock_protocol.x |   98 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 src/locking/lock_protocol.x

diff --git a/.gitignore b/.gitignore
index 1bfb7b9..e6ab70b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,6 +51,7 @@
 /po/*
 /proxy/
 /src/libvirt_iohelper
+/src/locking/lock_protocol.[ch]
 /src/remote/*_client_bodies.h
 /src/remote/*_protocol.[ch]
 /src/rpc/virnetprotocol.[ch]
diff --git a/src/locking/lock_protocol.x b/src/locking/lock_protocol.x
new file mode 100644
index 0000000..ece1652
--- /dev/null
+++ b/src/locking/lock_protocol.x
@@ -0,0 +1,98 @@
+/* -*- c -*-
+ */
+
+%#include "locking/lock_driver.h"
+
+typedef opaque lock_uuid[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 LOCK_STRING_MAX = 65536;
+
+const LOCK_PARAMETERS_MAX = 20;
+
+/* A long string, which may NOT be NULL. */
+typedef string lock_nonnull_string<LOCK_STRING_MAX>;
+
+/* A long string, which may be NULL. */
+typedef lock_nonnull_string *lock_string;
+
+union lock_param_value switch (int type) {
+case VIR_LOCK_MANAGER_PARAM_TYPE_STRING:
+    lock_nonnull_string s;
+case VIR_LOCK_MANAGER_PARAM_TYPE_INT:
+    int i;
+case VIR_LOCK_MANAGER_PARAM_TYPE_LONG:
+    hyper l;
+case VIR_LOCK_MANAGER_PARAM_TYPE_UINT:
+    unsigned int ui;
+case VIR_LOCK_MANAGER_PARAM_TYPE_ULONG:
+    unsigned hyper ul;
+case VIR_LOCK_MANAGER_PARAM_TYPE_DOUBLE:
+    double d;
+case VIR_LOCK_MANAGER_PARAM_TYPE_UUID:
+    lock_uuid u;
+};
+
+struct lock_param {
+    lock_nonnull_string key;
+    lock_param_value value;
+};
+
+struct lock_register_args {
+    unsigned int type;
+    lock_param params<LOCK_PARAMETERS_MAX>;
+    unsigned int flags;
+    bool restrictAccess;
+};
+
+
+struct lock_add_resource_args {
+    unsigned int type;
+    lock_nonnull_string name;
+    lock_param params<LOCK_PARAMETERS_MAX>;
+    unsigned int flags;
+};
+
+struct lock_acquire_args {
+    unsigned int flags;
+    lock_string state;
+};
+
+
+struct lock_release_args {
+    unsigned int flags;
+};
+
+struct lock_release_ret {
+    lock_string state;
+};
+
+
+struct lock_inquire_args {
+    unsigned int flags;
+};
+
+struct lock_inquire_ret {
+    lock_string state;
+};
+
+
+/* Define the program number, protocol version and procedure numbers here. */
+const LOCK_PROGRAM = 0xEA7BEEF;
+const LOCK_PROTOCOL_VERSION = 1;
+
+enum lock_procedure {
+    /* 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.
+     */
+    LOCK_PROC_REGISTER = 1, /* skipgen skipgen */
+    LOCK_PROC_ADD_RESOURCE = 2, /* skipgen skipgen */
+    LOCK_PROC_ACQUIRE = 3, /* skipgen skipgen */
+    LOCK_PROC_RELEASE = 4, /* skipgen skipgen */
+    LOCK_PROC_INQUIRE = 5 /* skipgen skipgen */
+};
-- 
1.7.6




More information about the libvir-list mailing list