Define a wire protocol for talking to the virtlockd daemon

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>
This commit is contained in:
Daniel P. Berrange 2011-07-06 17:20:04 +01:00
parent c57e3d8994
commit ad39fd83a8
4 changed files with 112 additions and 1 deletions

1
.gitignore vendored
View File

@ -108,6 +108,7 @@
/src/libvirt_*helper /src/libvirt_*helper
/src/libvirt_*probes.h /src/libvirt_*probes.h
/src/libvirt_lxc /src/libvirt_lxc
/src/locking/lock_protocol.[ch]
/src/locking/qemu-sanlock.conf /src/locking/qemu-sanlock.conf
/src/locking/test_libvirt_sanlock.aug /src/locking/test_libvirt_sanlock.aug
/src/lxc/lxc_controller_dispatch.h /src/lxc/lxc_controller_dispatch.h

3
cfg.mk
View File

@ -827,3 +827,6 @@ exclude_file_name_regexp--sc_unmarked_diagnostics = \
^(docs/apibuild.py|tests/virt-aa-helper-test)$$ ^(docs/apibuild.py|tests/virt-aa-helper-test)$$
exclude_file_name_regexp--sc_size_of_brackets = cfg.mk exclude_file_name_regexp--sc_size_of_brackets = cfg.mk
exclude_file_name_regexp--sc_correct_id_types = \
(^src/locking/lock_protocol.x$$)

View File

@ -148,6 +148,15 @@ LOCK_DRIVER_SANLOCK_SOURCES = \
LOCK_DRIVER_SANLOCK_HELPER_SOURCES = \ LOCK_DRIVER_SANLOCK_HELPER_SOURCES = \
locking/sanlock_helper.c locking/sanlock_helper.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 = \ LOCK_DAEMON_SOURCES = \
locking/lock_daemon.h \ locking/lock_daemon.h \
locking/lock_daemon.c \ locking/lock_daemon.c \
@ -1520,7 +1529,10 @@ EXTRA_DIST += $(LIBVIRT_QEMU_SYMBOL_FILE)
if WITH_LIBVIRTD if WITH_LIBVIRTD
sbin_PROGRAMS = virtlockd sbin_PROGRAMS = virtlockd
virtlockd_SOURCES = $(LOCK_DAEMON_SOURCES) virtlockd_SOURCES = \
$(LOCK_DAEMON_SOURCES) \
$(LOCK_PROTOCOL_GENERATED) \
$(NULL)
virtlockd_CFLAGS = \ virtlockd_CFLAGS = \
$(AM_CFLAGS) \ $(AM_CFLAGS) \
$(NULL) $(NULL)

View File

@ -0,0 +1,95 @@
/* -*- 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;
};
struct virLockSpaceProtocolCreateLockSpaceArgs {
virLockSpaceProtocolNonNullString path;
};
/* 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 */
VIR_LOCK_SPACE_PROTOCOL_PROC_CREATE_LOCKSPACE = 8 /* skipgen skipgen */
};