[libvirt] [PATCH] maint: avoid C99 loop declaration
by Eric Blake
Commit 3d0e3c1 reintroduced a problem previously squelched in
commit 7e5aa78. Add a syntax check this time around.
util/virutil.c: In function 'virGetGroupList':
util/virutil.c:1015: error: 'for' loop initial declaration used outside C99 mode
* cfg.mk (sc_prohibit_loop_var_decl): New rule.
* src/util/virutil.c (virGetGroupList): Fix offender.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule.
cfg.mk | 12 +++++++++---
src/util/virutil.c | 8 ++++----
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 13de268..791c393 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -546,15 +546,21 @@ sc_avoid_attribute_unused_in_header:
$(_sc_search_regexp)
sc_prohibit_int_ijk:
- @prohibit='\<(int|unsigned) ([^(]* )*(i|j|k)(\s|,|;)' \
+ @prohibit='\<(int|unsigned) ([^(]* )*(i|j|k)(\s|,|;)' \
halt='use size_t, not int/unsigned int for loop vars i, j, k' \
$(_sc_search_regexp)
sc_prohibit_loop_iijjkk:
- @prohibit='\<(int|unsigned) ([^=]+ )*(ii|jj|kk)(\s|,|;)' \
- halt='use i, j, k for loop iterators, not ii, jj, kk' \
+ @prohibit='\<(int|unsigned) ([^=]+ )*(ii|jj|kk)(\s|,|;)' \
+ halt='use i, j, k for loop iterators, not ii, jj, kk' \
$(_sc_search_regexp)
+# RHEL 5 gcc can't grok "for (int i..."
+sc_prohibit_loop_var_decl:
+ @prohibit='\<for *\(\w+[ *]+\w+' \
+ in_vc_files='\.[ch]$$' \
+ halt='declare loop iterators outside the for statement' \
+ $(_sc_search_regexp)
# Many of the function names below came from this filter:
# git grep -B2 '\<_('|grep -E '\.c- *[[:alpha:]_][[:alnum:]_]* ?\(.*[,;]$' \
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 3de72ea..34f5998 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1010,18 +1010,18 @@ virGetGroupList(uid_t uid, gid_t gid, gid_t **list)
}
if (gid != (gid_t)-1) {
- size_t n = ret;
+ size_t i;
- for (size_t i = 0; i < ret; i++) {
+ for (i = 0; i < ret; i++) {
if ((*list)[i] == gid)
goto cleanup;
}
- if (VIR_APPEND_ELEMENT(*list, n, gid) < 0) {
+ if (VIR_APPEND_ELEMENT(*list, i, gid) < 0) {
ret = -1;
VIR_FREE(*list);
goto cleanup;
} else {
- ret = n;
+ ret = i;
}
}
--
1.8.3.1
11 years, 4 months
[libvirt] [PATCH] libxl: fix libvirtd segfault
by Jim Fehlig
Commit d72ef888 introduced a bug in the libxl driver that will
segfault libvirtd if libxl reports an error message, e.g. when
attempting to initialize the driver on a non-Xen system. I
assumed it was valid to pass a NULL logger to libxl_ctx_alloc(),
but that is not the case since any errors associated with the ctx
that are emitted by libxl will dereference the logger and crash
libvirtd.
Errors associated with the libxl driver-wide ctx could be useful
for debugging anyway, so create a 'libxl-driver.log' to capture
these errors.
---
src/libxl/libxl_conf.h | 3 +++
src/libxl/libxl_driver.c | 30 ++++++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 78133b9..9d72b72 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -57,6 +57,9 @@ struct _libxlDriverPrivate {
virDomainXMLOptionPtr xmlopt;
unsigned int version;
+ /* log stream for driver-wide libxl ctx */
+ FILE *logger_file;
+ xentoollog_logger *logger;
/* libxl ctx for driver wide ops; getVersion, getNodeInfo, ... */
libxl_ctx *ctx;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index cc9e772..9dc7261 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1180,6 +1180,9 @@ libxlStateCleanup(void)
virObjectUnref(libxl_driver->xmlopt);
virObjectUnref(libxl_driver->domains);
libxl_ctx_free(libxl_driver->ctx);
+ xtl_logger_destroy(libxl_driver->logger);
+ if (libxl_driver->logger_file)
+ VIR_FORCE_FCLOSE(libxl_driver->logger_file);
virObjectUnref(libxl_driver->reservedVNCPorts);
@@ -1229,6 +1232,7 @@ libxlStateInitialize(bool privileged,
void *opaque ATTRIBUTE_UNUSED)
{
const libxl_version_info *ver_info;
+ char *log_file = NULL;
virCommandPtr cmd;
int status, ret = 0;
unsigned int free_mem;
@@ -1308,6 +1312,17 @@ libxlStateInitialize(bool privileged,
goto error;
}
+ if (virAsprintf(&log_file, "%s/libxl-driver.log", libxl_driver->logDir) < 0)
+ goto error;
+
+ if ((libxl_driver->logger_file = fopen(log_file, "a")) == NULL) {
+ virReportSystemError(errno,
+ _("failed to create logfile %s"),
+ log_file);
+ goto error;
+ }
+ VIR_FREE(log_file);
+
/* read the host sysinfo */
if (privileged)
libxl_driver->hostsysinfo = virSysinfoRead();
@@ -1316,8 +1331,18 @@ libxlStateInitialize(bool privileged,
if (!libxl_driver->domainEventState)
goto error;
- if (libxl_ctx_alloc(&libxl_driver->ctx, LIBXL_VERSION, 0, NULL)) {
- VIR_INFO("cannot initialize libxenlight context, probably not running in a Xen Dom0, disabling driver");
+ libxl_driver->logger =
+ (xentoollog_logger *)xtl_createlogger_stdiostream(libxl_driver->logger_file, XTL_DEBUG, 0);
+ if (!libxl_driver->logger) {
+ VIR_INFO("cannot create logger for libxenlight, disabling driver");
+ goto fail;
+ }
+
+ if (libxl_ctx_alloc(&libxl_driver->ctx,
+ LIBXL_VERSION, 0,
+ libxl_driver->logger)) {
+ VIR_INFO("cannot initialize libxenlight context, probably not running "
+ "in a Xen Dom0, disabling driver");
goto fail;
}
@@ -1383,6 +1408,7 @@ libxlStateInitialize(bool privileged,
error:
ret = -1;
fail:
+ VIR_FREE(log_file);
if (libxl_driver)
libxlDriverUnlock(libxl_driver);
libxlStateCleanup();
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH] remote: Fix a segfault in remoteDomainCreateWithFlags
by Alex Jia
Valgrind defects memory error:
==16759== 1 errors in context 1 of 8:
==16759== Invalid free() / delete / delete[] / realloc()
==16759== at 0x4A074C4: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==16759== by 0x83CD329: xdr_string (in /usr/lib64/libc-2.17.so)
==16759== by 0x4D93E4D: xdr_remote_nonnull_string (remote_protocol.c:31)
==16759== by 0x4D94350: xdr_remote_nonnull_domain (remote_protocol.c:58)
==16759== by 0x4D976C8: xdr_remote_domain_create_with_flags_ret (remote_protocol.c:1762)
==16759== by 0x83CC734: xdr_free (in /usr/lib64/libc-2.17.so)
==16759== by 0x4D7F1E0: remoteDomainCreateWithFlags (remote_driver.c:2441)
==16759== by 0x4D4BF17: virDomainCreateWithFlags (libvirt.c:9499)
==16759== by 0x13127A: cmdStart (virsh-domain.c:3376)
==16759== by 0x12BF83: vshCommandRun (virsh.c:1751)
==16759== by 0x126FFB: main (virsh.c:3205)
==16759== Address 0xe1394a0 is not stack'd, malloc'd or (recently) free'd
==16759== 1 errors in context 2 of 8:
==16759== Conditional jump or move depends on uninitialised value(s)
==16759== at 0x4A07477: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==16759== by 0x83CD329: xdr_string (in /usr/lib64/libc-2.17.so)
==16759== by 0x4D93E4D: xdr_remote_nonnull_string (remote_protocol.c:31)
==16759== by 0x4D94350: xdr_remote_nonnull_domain (remote_protocol.c:58)
==16759== by 0x4D976C8: xdr_remote_domain_create_with_flags_ret (remote_protocol.c:1762)
==16759== by 0x83CC734: xdr_free (in /usr/lib64/libc-2.17.so)
==16759== by 0x4D7F1E0: remoteDomainCreateWithFlags (remote_driver.c:2441)
==16759== by 0x4D4BF17: virDomainCreateWithFlags (libvirt.c:9499)
==16759== by 0x13127A: cmdStart (virsh-domain.c:3376)
==16759== by 0x12BF83: vshCommandRun (virsh.c:1751)
==16759== by 0x126FFB: main (virsh.c:3205)
==16759== Uninitialised value was created by a stack allocation
==16759== at 0x4D7F120: remoteDomainCreateWithFlags (remote_driver.c:2423)
How to reproduce?
# virsh start <domain> --paused
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=994855
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/remote/remote_driver.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f828eef..71d0034 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2431,6 +2431,7 @@ remoteDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
make_nonnull_domain(&args.dom, dom);
args.flags = flags;
+ memset(&ret, 0, sizeof(ret));
if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS,
(xdrproc_t)xdr_remote_domain_create_with_flags_args, (char *)&args,
(xdrproc_t)xdr_remote_domain_create_with_flags_ret, (char *)&ret) == -1) {
--
1.7.1
11 years, 4 months
[libvirt] [PATCH] Make check for /dev/loop device names stricter to avoid /dev/loop-control
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Recentish (2011) kernels introduced a new device called /dev/loop-control,
which causes libvirt's detection of loop devices to get confused
since it only checks for a prefix of 'loop'. Also check that the
next character is a digit
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/util/virfile.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 8f0eec3..2b07ac9 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -546,7 +546,11 @@ static int virFileLoopDeviceOpen(char **dev_name)
errno = 0;
while ((de = readdir(dh)) != NULL) {
- if (!STRPREFIX(de->d_name, "loop"))
+ /* Checking 'loop' prefix is insufficient, since
+ * new kernels have a dev named 'loop-control'
+ */
+ if (!STRPREFIX(de->d_name, "loop") ||
+ !c_isdigit(de->d_name[4]))
continue;
if (virAsprintf(&looppath, "/dev/%s", de->d_name) < 0)
--
1.8.3.1
11 years, 4 months
[libvirt] Hyper-V driver API version support
by surface@me.is-a-linux-user.org
Hello
The "version" function is not supported by the hyperv driver:
$ virsh --connect=hyperv://hypervhost version
Compiled against library: libvirt 1.1.1
Using library: libvirt 1.1.1
Using API: Hyper-V 1.1.1
error: failed to get the hypervisor version
error: this function is not supported by the connection driver:
virConnectGetVersion
But we need this funtion for the "external/libvirt" stonith plugin of
clusterglue:
$ cat /usr/lib/stonith/plugins/libvirt | more
# get status of stonith device (*NOT* of the domain).
# If we can retrieve some info from the hypervisor
# the stonith device is OK.
libvirt_status() {
out=$($VIRSH -c $hypervisor_uri version 2>&1)
if [ $? -eq 0 ]
then
out=`echo "$out" | tail -1`
ha_log.sh notice "$hypervisor_uri: $out"
return 0
fi
ha_log.sh err "Failed to get status for $hypervisor_uri"
ha_log.sh err "$out"
return 1
}
So, we can't implement libvirt stonith with hyperv support in our
corosync/pacemaker cluster. Is it possible to implement the "version"
function for hyperv into virConnectGetVersion? Or exist any workaround
for this problem?
Regards
Rocco
11 years, 4 months
[libvirt] [PATCH] Fix VPATH build of ACL docs
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The aclperms.htmlinc file must be generated in $(srcdir) to
let includes work when doing a VPATH build
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
docs/Makefile.am | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 9057432..0b0d2d4 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -141,13 +141,13 @@ EXTRA_DIST= \
BUILT_SOURCES += aclperms.htmlinc
-CLEANFILES = aclperms.htmlinc
+CLEANFILES = $(srcdir)/aclperms.htmlinc
-acl.html:: aclperms.htmlinc
+acl.html:: $(srcdir)/aclperms.htmlinc
-aclperms.htmlinc: $(top_srcdir)/src/access/viraccessperm.h \
- genaclperms.pl Makefile.am
- $(PERL) genaclperms.pl $< > $@
+$(srcdir)/aclperms.htmlinc: $(top_srcdir)/src/access/viraccessperm.h \
+ $(srcdir)/genaclperms.pl Makefile.am
+ $(PERL) $(srcdir)/genaclperms.pl $< > $@
MAINTAINERCLEANFILES = \
$(addprefix $(srcdir)/,$(dot_html)) \
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH] tests: avoid too-large constants
by Eric Blake
Compiling with gcc 4.1.2 (RHEL 5) complains:
virdbustest.c: In function 'testMessageSimple':
virdbustest.c:61: warning: integer constant is too large for 'long' type
virdbustest.c:62: warning: integer constant is too large for 'long' type
virdbustest.c: In function 'testMessageArray':
virdbustest.c:183: warning: this decimal constant is unsigned only in ISO C90
virdbustest.c: In function 'testMessageStruct':
virdbustest.c:239: warning: integer constant is too large for 'long' type
virdbustest.c:240: warning: integer constant is too large for 'long' type
* tests/virdbustest.c (testMessageSiple, testMessageArray)
(testMessageStruct): Don't violate C89 constant constraints.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule.
tests/virdbustest.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/virdbustest.c b/tests/virdbustest.c
index 61de937..528342b 100644
--- a/tests/virdbustest.c
+++ b/tests/virdbustest.c
@@ -58,8 +58,8 @@ static int testMessageSimple(const void *args ATTRIBUTE_UNUSED)
unsigned short in_uint16 = 32000, out_uint16 = 0;
int in_int32 = 100000000, out_int32 = 0;
unsigned int in_uint32 = 200000000, out_uint32 = 0;
- long long in_int64 = 1000000000000, out_int64 = 0;
- unsigned long long in_uint64 = 2000000000000, out_uint64 = 0;
+ long long in_int64 = 1000000000000LL, out_int64 = 0;
+ unsigned long long in_uint64 = 2000000000000LL, out_uint64 = 0;
double in_double = 3.14159265359, out_double = 0;;
const char *in_string = "Hello World";
char *out_string = NULL;
@@ -178,9 +178,9 @@ static int testMessageArray(const void *args ATTRIBUTE_UNUSED)
DBusMessage *msg = NULL;
int ret = -1;
const char *in_str1 = "Hello";
- int in_int32a = 1000000000, out_int32a = 0;
- int in_int32b = 2000000000, out_int32b = 0;
- int in_int32c = 3000000000, out_int32c = 0;
+ int in_int32a = 100000000, out_int32a = 0;
+ int in_int32b = 200000000, out_int32b = 0;
+ int in_int32c = 300000000, out_int32c = 0;
const char *in_str2 = "World";
char *out_str1 = NULL, *out_str2 = NULL;
@@ -236,8 +236,8 @@ static int testMessageStruct(const void *args ATTRIBUTE_UNUSED)
unsigned short in_uint16 = 32000, out_uint16 = 0;
int in_int32 = 100000000, out_int32 = 0;
unsigned int in_uint32 = 200000000, out_uint32 = 0;
- long long in_int64 = 1000000000000, out_int64 = 0;
- unsigned long long in_uint64 = 2000000000000, out_uint64 = 0;
+ long long in_int64 = 1000000000000LL, out_int64 = 0;
+ unsigned long long in_uint64 = 2000000000000LL, out_uint64 = 0;
double in_double = 3.14159265359, out_double = 0;;
const char *in_string = "Hello World";
char *out_string = NULL;
--
1.8.3.1
11 years, 4 months
[libvirt] Proposing Archive / Unarchive VM Guest functionality.
by Suhas Mane
Hello Team,
Me and few of my friends are planning to add VM Guest archival
functionality.
What we are proposing is:
1. Below diagram shows: possible states of VM guest (*archived new state
introduced*)
2. For any reason, User / Admin expects to archive the VM guest to remote
storage space, so that storage space consumed by VM guest (disk image...
.vmdk / .img etc..) will be relived. Rest configuration files will be
intact.
3. Later on when so called archived VM guest is to be booted, libvirt
should unarchive the VM guest to local place, and booting should proceed as
usual.
[image: Inline image 1]
I am new to Virtualization. I am using QEMU/KVM hypervisor.
Requesting to suggest how it can be achieved.
What all things I need to do.
Thanks,
Suhas Mane.
11 years, 4 months
[libvirt] [PATCH] qemu: Drop qemuDomainMemoryLimit
by Michal Privoznik
This function is to guess the correct limit for maximal memory
usage by qemu for given domain. This can never be guessed
correctly, not to mention all the pains and sleepless nights this
code has caused. Once somebody discovers algorithm to solve the
Halting Problem, we can compute the limit algorithmically. But
till then, this code should never see the light of the release
again.
---
src/qemu/qemu_cgroup.c | 3 +--
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_domain.c | 49 -------------------------------------------------
src/qemu/qemu_domain.h | 2 --
src/qemu/qemu_hotplug.c | 2 +-
5 files changed, 3 insertions(+), 55 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index dc949db..9673e8e 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -428,8 +428,7 @@ qemuSetupMemoryCgroup(virDomainObjPtr vm)
}
}
- if (virCgroupSetMemoryHardLimit(priv->cgroup,
- qemuDomainMemoryLimit(vm->def)) < 0)
+ if (virCgroupSetMemoryHardLimit(priv->cgroup, vm->def->mem.hard_limit) < 0)
return -1;
if (vm->def->mem.soft_limit != 0 &&
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b811e1d..a0a1773 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9220,7 +9220,7 @@ qemuBuildCommandLine(virConnectPtr conn,
}
if (mlock)
- virCommandSetMaxMemLock(cmd, qemuDomainMemoryLimit(def) * 1024);
+ virCommandSetMaxMemLock(cmd, def->mem.hard_limit * 1024);
virObjectUnref(cfg);
return cmd;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 393af6b..7f4d17d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2306,55 +2306,6 @@ cleanup:
return ret;
}
-
-unsigned long long
-qemuDomainMemoryLimit(virDomainDefPtr def)
-{
- unsigned long long mem;
- size_t i;
-
- if (def->mem.hard_limit) {
- mem = def->mem.hard_limit;
- } else {
- /* If there is no hard_limit set, compute a reasonable one to avoid
- * system thrashing caused by exploited qemu. A 'reasonable
- * limit' has been chosen:
- * (1 + k) * (domain memory + total video memory) + (32MB for
- * cache per each disk) + F
- * where k = 0.5 and F = 400MB. The cache for disks is important as
- * kernel cache on the host side counts into the RSS limit.
- * Moreover, VFIO requires some amount for IO space. Alex Williamson
- * suggested adding 1GiB for IO space just to be safe (some finer
- * tuning might be nice, though).
- *
- * Technically, the disk cache does not have to be included in
- * RLIMIT_MEMLOCK but it doesn't hurt as it's just an upper limit and
- * it makes this function and its usage simpler.
- */
- mem = def->mem.max_balloon;
- for (i = 0; i < def->nvideos; i++)
- mem += def->videos[i]->vram;
- mem *= 1.5;
- mem += def->ndisks * 32768;
- mem += 409600;
-
- for (i = 0; i < def->nhostdevs; i++) {
- virDomainHostdevDefPtr hostdev = def->hostdevs[i];
- if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
- hostdev->source.subsys.type ==
- VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
- hostdev->source.subsys.u.pci.backend ==
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
- mem += 1024 * 1024;
- break;
- }
- }
- }
-
- return mem;
-}
-
-
int
qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
virDomainObjPtr vm)
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 0a4a51e..21f116c 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -365,8 +365,6 @@ extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks;
extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace;
extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig;
-unsigned long long qemuDomainMemoryLimit(virDomainDefPtr def);
-
int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
virDomainObjPtr vm);
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index c9748d9..fa64dd7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1030,7 +1030,7 @@ int qemuDomainAttachHostPciDevice(virQEMUDriverPtr driver,
*/
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
virProcessSetMaxMemLock(vm->pid,
- qemuDomainMemoryLimit(vm->def) * 1024);
+ vm->def->mem.hard_limit * 1024);
vm->def->hostdevs[vm->def->nhostdevs--] = NULL;
}
--
1.8.1.5
11 years, 4 months
[libvirt] [PATCH] Add an example config file for virtlockd
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The virtlockd daemon supports an /etc/libvirt/virtlockd.conf
config file, but we never installed a default config, nor
created any augeas scripts. This change addresses that omission.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
.gitignore | 1 +
libvirt.spec.in | 3 ++
src/Makefile.am | 20 ++++++++++++-
src/locking/test_virtlockd.aug.in | 12 ++++++++
src/locking/virtlockd.aug | 44 ++++++++++++++++++++++++++++
src/locking/virtlockd.conf | 60 +++++++++++++++++++++++++++++++++++++++
6 files changed, 139 insertions(+), 1 deletion(-)
create mode 100644 src/locking/test_virtlockd.aug.in
create mode 100644 src/locking/virtlockd.aug
create mode 100644 src/locking/virtlockd.conf
diff --git a/.gitignore b/.gitignore
index 26bd829..e47421a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -141,6 +141,7 @@
/src/rpc/virkeepaliveprotocol.[ch]
/src/rpc/virnetprotocol.[ch]
/src/test_libvirt*.aug
+/src/test_virtlockd.aug
/src/util/virkeymaps.h
/src/virt-aa-helper
/src/virtlockd
diff --git a/libvirt.spec.in b/libvirt.spec.in
index a95b783..fba7658 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1759,6 +1759,7 @@ fi
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
%config(noreplace) %{_sysconfdir}/sysconfig/virtlockd
%config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
+%config(noreplace) %{_sysconfdir}/libvirt/virtlockd.conf
%if 0%{?fedora} >= 14 || 0%{?rhel} >= 6
%config(noreplace) %{_prefix}/lib/sysctl.d/libvirtd.conf
%endif
@@ -1840,6 +1841,8 @@ fi
%{_datadir}/augeas/lenses/libvirtd.aug
%{_datadir}/augeas/lenses/tests/test_libvirtd.aug
+%{_datadir}/augeas/lenses/virtlockd.aug
+%{_datadir}/augeas/lenses/tests/test_virtlockd.aug
%{_datadir}/augeas/lenses/libvirt_lockd.aug
%{_datadir}/augeas/lenses/tests/test_libvirt_lockd.aug
diff --git a/src/Makefile.am b/src/Makefile.am
index d351539..6c13d80 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1608,7 +1608,7 @@ check-local: check-augeas
$(NULL)
check-augeas: check-augeas-qemu check-augeas-lxc check-augeas-sanlock \
- check-augeas-lockd
+ check-augeas-lockd check-augeas-virtlockd
AUG_GENTEST = $(PERL) $(top_srcdir)/build-aux/augeas-gentest.pl
EXTRA_DIST += $(top_srcdir)/build-aux/augeas-gentest.pl
@@ -1656,11 +1656,20 @@ test_libvirt_lockd.aug: locking/test_libvirt_lockd.aug.in \
locking/qemu-lockd.conf $(AUG_GENTEST)
$(AM_V_GEN)$(AUG_GENTEST) locking/qemu-lockd.conf $< $@
+test_virtlockd.aug: locking/test_virtlockd.aug.in \
+ locking/virtlockd.conf $(AUG_GENTEST)
+ $(AM_V_GEN)$(AUG_GENTEST) locking/virtlockd.conf $< $@
+
check-augeas-lockd: test_libvirt_lockd.aug
$(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
'$(AUGPARSE)' -I $(srcdir)/locking test_libvirt_lockd.aug; \
fi
+check-augeas-virtlockd: test_virtlockd.aug
+ $(AM_V_GEN)if test -x '$(AUGPARSE)'; then \
+ '$(AUGPARSE)' -I $(srcdir)/locking test_virtlockd.aug; \
+ fi
+
#
# Build our version script. This is composed of three parts:
#
@@ -2035,6 +2044,12 @@ virtlockd.8: $(srcdir)/virtlockd.8.in
man8_MANS = virtlockd.8
+conf_DATA += locking/virtlockd.conf
+
+augeas_DATA += locking/virtlockd.aug
+augeastest_DATA += test_virtlockd.aug
+
+CLEANFILES += test_virtlockd.aug
MAINTAINERCLEANFILES += $(srcdir)/virtlockd.8.in
EXTRA_DIST += \
@@ -2042,6 +2057,9 @@ EXTRA_DIST += \
locking/virtlockd.socket.in \
locking/virtlockd.pod.in \
virtlockd.8.in \
+ locking/virtlockd.aug \
+ locking/virtlockd.conf \
+ locking/test_virtlockd.aug.in \
$(NULL)
diff --git a/src/locking/test_virtlockd.aug.in b/src/locking/test_virtlockd.aug.in
new file mode 100644
index 0000000..dcd47c3
--- /dev/null
+++ b/src/locking/test_virtlockd.aug.in
@@ -0,0 +1,12 @@
+module Test_virtlockd =
+ let conf = "log_level = 3
+log_filters=\"3:remote 4:event\"
+log_outputs=\"3:syslog:libvirtd\"
+log_buffer_size = 64
+"
+
+ test Libvirtd.lns get conf =
+ { "log_level" = "3" }
+ { "log_filters" = "3:remote 4:event" }
+ { "log_outputs" = "3:syslog:libvirtd" }
+ { "log_buffer_size" = "64" }
diff --git a/src/locking/virtlockd.aug b/src/locking/virtlockd.aug
new file mode 100644
index 0000000..9d20e72
--- /dev/null
+++ b/src/locking/virtlockd.aug
@@ -0,0 +1,44 @@
+(* /etc/libvirt/libvirtd.conf *)
+
+module Libvirtd =
+ autoload xfm
+
+ let eol = del /[ \t]*\n/ "\n"
+ let value_sep = del /[ \t]*=[ \t]*/ " = "
+ let indent = del /[ \t]*/ ""
+
+ let array_sep = del /,[ \t\n]*/ ", "
+ let array_start = del /\[[ \t\n]*/ "[ "
+ let array_end = del /\]/ "]"
+
+ let str_val = del /\"/ "\"" . store /[^\"]*/ . del /\"/ "\""
+ let bool_val = store /0|1/
+ let int_val = store /[0-9]+/
+ let str_array_element = [ seq "el" . str_val ] . del /[ \t\n]*/ ""
+ let str_array_val = counter "el" . array_start . ( str_array_element . ( array_sep . str_array_element ) * ) ? . array_end
+
+ 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 ]
+ let str_array_entry (kw:string) = [ key kw . value_sep . str_array_val ]
+
+
+ (* Config entry grouped by function - same order as example config *)
+ let logging_entry = int_entry "log_level"
+ | str_entry "log_filters"
+ | str_entry "log_outputs"
+ | int_entry "log_buffer_size"
+
+ (* Each enty in the config is one of the following three ... *)
+ let entry = logging_entry
+ 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/virtlockd.conf"
+ . Util.stdexcl
+
+ let xfm = transform lns filter
diff --git a/src/locking/virtlockd.conf b/src/locking/virtlockd.conf
new file mode 100644
index 0000000..b6450b4
--- /dev/null
+++ b/src/locking/virtlockd.conf
@@ -0,0 +1,60 @@
+# Master virtlockd daemon configuration file
+#
+
+#################################################################
+#
+# Logging controls
+#
+
+# Logging level: 4 errors, 3 warnings, 2 information, 1 debug
+# basically 1 will log everything possible
+#log_level = 3
+
+# Logging filters:
+# A filter allows to select a different logging level for a given category
+# of logs
+# The format for a filter is one of:
+# x:name
+# x:+name
+# where name is a string which is matched against source file name,
+# e.g., "remote", "qemu", or "util/json", the optional "+" prefix
+# tells libvirt to log stack trace for each message matching name,
+# and x is the minimal level where matching messages should be logged:
+# 1: DEBUG
+# 2: INFO
+# 3: WARNING
+# 4: ERROR
+#
+# Multiple filter can be defined in a single @filters, they just need to be
+# separated by spaces.
+#
+# e.g. to only get warning or errors from the remote layer and only errors
+# from the event layer:
+#log_filters="3:remote 4:event"
+
+# Logging outputs:
+# An output is one of the places to save logging information
+# The format for an output can be:
+# x:stderr
+# output goes to stderr
+# x:syslog:name
+# use syslog for the output and use the given name as the ident
+# x:file:file_path
+# output to a file, with the given filepath
+# In all case the x prefix is the minimal level, acting as a filter
+# 1: DEBUG
+# 2: INFO
+# 3: WARNING
+# 4: ERROR
+#
+# Multiple output can be defined, they just need to be separated by spaces.
+# e.g. to log all warnings and errors to syslog under the virtlockd ident:
+#log_outputs="3:syslog:virtlockd"
+#
+
+# Log debug buffer size: default 64
+# The daemon keeps an internal debug log buffer which will be dumped in case
+# of crash or upon receiving a SIGUSR2 signal. This setting allows to override
+# the default buffer size in kilobytes.
+# If value is 0 or less the debug log buffer is deactivated
+#log_buffer_size = 64
--
1.8.3.1
11 years, 4 months