[libvirt] [PATCH 3/3] Add configuration files for dlm plugin

river lfu at suse.com
Mon Feb 5 09:07:56 UTC 2018


Signed-off-by: river <lfu at suse.com>
---
 .gitignore                          |  2 ++
 src/Makefile.am                     | 40 +++++++++++++++++++++++++++-
 src/libxl/libxl.conf                |  8 +++---
 src/locking/dlm.conf                | 52 +++++++++++++++++++++++++++++++++++++
 src/locking/libvirt_dlm.aug         | 35 +++++++++++++++++++++++++
 src/locking/test_libvirt_dlm.aug.in |  9 +++++++
 src/qemu/qemu.conf                  |  8 +++---
 7 files changed, 146 insertions(+), 8 deletions(-)
 create mode 100644 src/locking/dlm.conf
 create mode 100644 src/locking/libvirt_dlm.aug
 create mode 100644 src/locking/test_libvirt_dlm.aug.in

diff --git a/.gitignore b/.gitignore
index 189116a3d..d9b0aaec1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -139,10 +139,12 @@
 /src/libvirt_*helper
 /src/libvirt_*probes.h
 /src/libvirt_lxc
+/src/locking/libxl-dlm.conf
 /src/locking/libxl-lockd.conf
 /src/locking/libxl-sanlock.conf
 /src/locking/lock_daemon_dispatch_stubs.h
 /src/locking/lock_protocol.[ch]
+/src/locking/qemu-dlm.conf
 /src/locking/qemu-lockd.conf
 /src/locking/qemu-sanlock.conf
 /src/locking/test_libvirt_sanlock.aug
diff --git a/src/Makefile.am b/src/Makefile.am
index 8742921fa..95b46dc89 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2111,6 +2111,19 @@ else ! WITH_LXC
 check-augeas-lxc:
 endif ! WITH_LXC
 
+if WITH_DLM
+test_libvirt_dlm.aug: locking/test_libvirt_dlm.aug.in \
+		locking/qemu-dlm.conf $(AUG_GENTEST)
+	$(AM_V_GEN)$(AUG_GENTEST) locking/qemu-dlm.conf $< $@
+
+check-augeas-dlm: test_libvirt_dlm.aug
+	$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
+	    '$(AUGPARSE)' -I $(srcdir)/locking test_libvirt_dlm.aug; \
+	fi
+else ! WITH_DLM
+check-augeas-dlm:
+endif ! WITH_DLM
+
 if WITH_SANLOCK
 test_libvirt_sanlock.aug: locking/test_libvirt_sanlock.aug.in \
 		locking/qemu-sanlock.conf $(AUG_GENTEST)
@@ -2891,9 +2904,34 @@ dlm_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
 dlm_la_LIBADD = ../gnulib/lib/libgnu.la \
 				$(CPG_LIBS) \
 				$(DLM_LIBS)
+
+augeas_DATA += locking/libvirt_dlm.aug
+augeastest_DATA += test_libvirt_dlm.aug
+CLEANFILES += test_libvirt_dlm.aug
+
+locking/%-dlm.conf: $(srcdir)/locking/dlm.conf
+	$(AM_V_GEN)$(MKDIR_P) locking ; \
+	cp $< $@
+
+if WITH_QEMU
+nodist_conf_DATA += locking/qemu-dlm.conf
+BUILT_SOURCES += locking/qemu-dlm.conf
+DISTCLEANFILES += locking/qemu-dlm.conf
+endif WITH_QEMU
+
+if WITH_LIBXL
+nodist_conf_DATA += locking/libxl-dlm.conf
+BUILT_SOURCES += locking/libxl-dlm.conf
+DISTCLEANFILES += locking/libxl-dlm.conf
+endif WITH_LIBXL
+
 else ! WITH_DLM
 EXTRA_DIST += $(LOCK_DRIVER_DLM_SOURCES)
-endif
+endif ! WITH_DLM
+
+EXTRA_DIST += locking/dlm.conf \
+	locking/libvirt_dlm.aug \
+	locking/test_libvirt_dlm.aug.in
 
 if WITH_SANLOCK
 lockdriver_LTLIBRARIES += sanlock.la
diff --git a/src/libxl/libxl.conf b/src/libxl/libxl.conf
index 264af7cf9..85be09b99 100644
--- a/src/libxl/libxl.conf
+++ b/src/libxl/libxl.conf
@@ -13,11 +13,13 @@
 
 
 # In order to prevent accidentally starting two domains that
-# share one writable disk, libvirt offers two approaches for
-# locking files: sanlock and virtlockd.  sanlock is an external
+# share one writable disk, libvirt offers three approaches for
+# locking files: sanlock, virtlockd and dlm.  sanlock is an external
 # project which libvirt integrates with via the libvirt-lock-sanlock
 # package.  virtlockd is a libvirt implementation that is enabled with
-# "lockd".  Accepted values are "sanlock" and "lockd".
+# "lockd", dlm is the linux kernel implementation lock manager that
+# is using cluster software by other projects. Accepted values are
+# "sanlock", "lockd" and "dlm".
 #
 #lock_manager = "lockd"
 
diff --git a/src/locking/dlm.conf b/src/locking/dlm.conf
new file mode 100644
index 000000000..7cc60f5c2
--- /dev/null
+++ b/src/locking/dlm.conf
@@ -0,0 +1,52 @@
+#
+# The default lockd behaviour is to acquire locks directly
+# against each configured disk file / block device. If the
+# application wishes to instead manually manage leases in
+# the guest XML, then this parameter can be disabled
+#
+#auto_disk_leases = 1
+
+#
+# Flag to determine whether we allow starting of guests
+# which do not have any <lease> elements defined in their
+# configuration.
+#
+# If 'auto_disk_leases' is disabled, this setting defaults
+# to enabled, otherwise it defaults to disabled.
+#
+#require_lease_for_disks = 0
+
+#
+# The DLM allows locks to be partitioned into "lockspaces",
+# The purpose of lockspaces is to provide a private namespace
+# for locks that are part of a single application. Lockspaces
+# are identified by name and are cluster-wide. A lockspace
+# named "myLS" is the same lockspace on all nodes in the
+# cluster and locks will contend for resources the same as
+# if they were on the same system. Lockspace names are
+# case-sensitive so "MyLS" is a distinct lockspace to "myLS".
+#
+# More information refers to '3.8. Lockspaces' in
+#   http://people.redhat.com/ccaulfie/docs/rhdlmbook.pdf
+#
+#lockspace_name = "libvirt"
+
+#
+# One lock must belong to one lockspace, and is associated
+# with one lock resource, owned by one process. The lock
+# without `LKF_PERSISTENT` would disappear if owner process
+# was dead. However, a lock with `LKF_PERSISTENT` flag means
+# lock is alive although owner process was dead. However, it
+# will become a orphan lock and could't be released. In order
+# to adopt those orphan locks we need a file to record the
+# lock information.
+#
+#lock_record_file_path = "/tmp/libvirtd-dlm-file"
+#
+
+#
+# Flag to determine to whether purge orphan locks which could
+# not be adopted or not during the dlm lock plugin
+# initialization.
+#
+#purge_lockspace = 1
diff --git a/src/locking/libvirt_dlm.aug b/src/locking/libvirt_dlm.aug
new file mode 100644
index 000000000..257e4c421
--- /dev/null
+++ b/src/locking/libvirt_dlm.aug
@@ -0,0 +1,35 @@
+(* /etc/libvirt/qemu-lockd.conf *)
+
+module Libvirt_lockd =
+   autoload xfm
+
+   let eol   = del /[ \t]*\n/ "\n"
+   let value_sep   = del /[ \t]*=[ \t]*/  " = "
+   let indent = del /[ \t]*/ ""
+
+   let str_val = del /\"/ "\"" . store /[^\"]*/ . del /\"/ "\""
+   let bool_val = store /0|1/
+   let int_val = store /[0-9]+/
+
+   let str_entry       (kw:string) = [ key kw . value_sep . str_val ]
+   let bool_entry      (kw:string) = [ key kw . value_sep . bool_val ]
+   let int_entry       (kw:string) = [ key kw . value_sep . int_val ]
+
+
+   (* Each enty in the config is one of the following three ... *)
+   let entry = bool_entry "auto_disk_leases"
+             | bool_entry "require_lease_for_disks"
+             | str_entry "lockspace_name"
+             | str_entry "lock_record_file_path"
+             | str_entry "purge_lockspace"
+   let comment = [ label "#comment" . del /#[ \t]*/ "# " .  store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
+   let empty = [ label "#empty" . eol ]
+
+   let record = indent . entry . eol
+
+   let lns = ( record | comment | empty ) *
+
+   let filter = incl "/etc/libvirt/qemu-lockd.conf"
+              . Util.stdexcl
+
+   let xfm = transform lns filter
diff --git a/src/locking/test_libvirt_dlm.aug.in b/src/locking/test_libvirt_dlm.aug.in
new file mode 100644
index 000000000..ceb8a0324
--- /dev/null
+++ b/src/locking/test_libvirt_dlm.aug.in
@@ -0,0 +1,9 @@
+module Test_libvirt_dlm =
+  ::CONFIG::
+
+   test Libvirt_dlm.lns get conf =
+{ "auto_disk_leases" = "1" }
+{ "require_lease_for_disks" = "0" }
+{ "lockspace_name" = "libvirt" }
+{ "lock_record_file_path" = "/tmp/libvirtd-dlm-file" }
+{ "purge_lockspace" = "1" }
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 62c4265ea..bcb6b80bd 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -629,10 +629,10 @@
 
 
 # In order to prevent accidentally starting two domains that
-# share one writable disk, libvirt offers two approaches for
-# locking files. The first one is sanlock, the other one,
-# virtlockd, is then our own implementation. Accepted values
-# are "sanlock" and "lockd".
+# share one writable disk, libvirt offers three approaches for
+# locking files. The first one is sanlock, the second one,
+# virtlockd, is then our own implementation, the third one is
+# dlm. Accepted values are "sanlock", "lockd" and "dlm".
 #
 #lock_manager = "lockd"
 
-- 
2.15.1




More information about the libvir-list mailing list