[libvirt] [PATCH] virutil: Provide non-linux impl for virGetFCHostNameByFabricWWN
by Michal Privoznik
Currently, there's only linux implementation for
virGetFCHostNameByFabricWWN(). Since the symbol is exported in
our private symbols we ought to have implementation for other
platforms too. This also triggers compilation error on FreeBSD:
../src/.libs/libvirt_driver_storage_impl.a(libvirt_driver_storage_impl_la-storage_backend_scsi.o): In function `createVport':
/usr/home/jenkins/libvirt-master/systems/libvirt-freebsd/build/src/../../src/storage/storage_backend_scsi.c:740: undefined reference to `virGetFCHostNameByFabricWWN'
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Pushed under trivial and build-breaker rules.
src/util/virutil.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/util/virutil.c b/src/util/virutil.c
index da836b46d..aeaa7f98e 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2480,6 +2480,14 @@ virGetFCHostNameByWWN(const char *sysfs_prefix ATTRIBUTE_UNUSED,
return NULL;
}
+char *
+virGetFCHostNameByFabricWWN(const char *sysfs_prefix ATTRIBUTE_UNUSED,
+ const char *fabric_wwn ATTRIBUTE_UNUSED)
+{
+ virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
+ return NULL;
+}
+
char *
virFindFCHostCapableVport(const char *sysfs_prefix ATTRIBUTE_UNUSED)
{
--
2.11.0
7 years, 10 months
Re: [libvirt] [Qemu-devel] [PATCH 0/5] Use non-blacklisted family/model/stepping for Haswell CPU model
by Eduardo Habkost
Oops, there are 3 actual mistakes I missed among the false
positives, below:
On Sun, Jan 08, 2017 at 11:47:21AM -0800, no-reply(a)patchew.org wrote:
[...]
> === OUTPUT BEGIN ===
> Checking PATCH 1/5: i386: Add explicit array size to x86_cpu_vendor_words2str()...
> ERROR: line over 90 characters
> #27: FILE: target/i386/cpu.c:172:
> +static void x86_cpu_vendor_words2str(char dst[static (CPUID_VENDOR_SZ + 1)], uint32_t vendor1,
False positive.
>
> ERROR: space prohibited between function name and open parenthesis '('
> #27: FILE: target/i386/cpu.c:172:
> +static void x86_cpu_vendor_words2str(char dst[static (CPUID_VENDOR_SZ + 1)], uint32_t vendor1,
False positive.
>
> total: 2 errors, 0 warnings, 8 lines checked
>
> Your patch has style problems, please review. If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
>
> Checking PATCH 2/5: i386: host_vendor_fms() helper function...
> ERROR: line over 90 characters
> #20: FILE: target/i386/cpu.c:685:
> +void host_vendor_fms(char vendor[static (CPUID_VENDOR_SZ + 1)], int *family, int *model, int *stepping)
Oops, will fix it.
>
> ERROR: space prohibited between function name and open parenthesis '('
> #20: FILE: target/i386/cpu.c:685:
> +void host_vendor_fms(char vendor[static (CPUID_VENDOR_SZ + 1)], int *family, int *model, int *stepping)
False positive.
>
> ERROR: storage class should be at the beginning of the declaration
> #20: FILE: target/i386/cpu.c:685:
> +void host_vendor_fms(char vendor[static (CPUID_VENDOR_SZ + 1)], int *family, int *model, int *stepping)
>
False positive.
> ERROR: line over 90 characters
> #57: FILE: target/i386/cpu.c:1599:
> + host_vendor_fms(host_cpudef.vendor, &host_cpudef.family, &host_cpudef.model, &host_cpudef.stepping);
Will fix it.
>
> ERROR: line over 90 characters
> #69: FILE: target/i386/cpu.h:1426:
> +void host_vendor_fms(char vendor[static (CPUID_VENDOR_SZ + 1)], int *family, int *model, int *stepping);
Will fix it.
>
> ERROR: space prohibited between function name and open parenthesis '('
> #69: FILE: target/i386/cpu.h:1426:
> +void host_vendor_fms(char vendor[static (CPUID_VENDOR_SZ + 1)], int *family, int *model, int *stepping);
False positive.
>
> ERROR: storage class should be at the beginning of the declaration
> #69: FILE: target/i386/cpu.h:1426:
> +void host_vendor_fms(char vendor[static (CPUID_VENDOR_SZ + 1)], int *family, int *model, int *stepping);
False positive.
>
> total: 7 errors, 0 warnings, 50 lines checked
>
> Your patch has style problems, please review. If any of these errors
> are false positives report them to the maintainer, see
> CHECKPATCH in MAINTAINERS.
>
> Checking PATCH 3/5: i386/kvm: Blacklist TSX on known broken hosts...
> Checking PATCH 4/5: pc: Add 2.9 machine-types...
> Checking PATCH 5/5: i386: Change stepping of Haswell to non-blacklisted value...
> === OUTPUT END ===
>
> Test command exited with code: 1
>
>
> ---
> Email generated automatically by Patchew [http://patchew.org/].
> Please send your feedback to patchew-devel(a)freelists.org
--
Eduardo
7 years, 10 months
Re: [libvirt] [Qemu-devel] [PATCH v2 0/2] Allow migration with invtsc if TSC frequency is explicitly set
by Eduardo Habkost
On Sun, Jan 08, 2017 at 09:19:49AM -0800, no-reply(a)patchew.org wrote:
> Hi,
>
> Your series failed automatic build test. Please find the testing commands and
> their output below. If you have docker installed, you can probably reproduce it
> locally.
>
> Type: series
> Message-id: 20170108171330.11129-1-ehabkost(a)redhat.com
> Subject: [Qemu-devel] [PATCH v2 0/2] Allow migration with invtsc if TSC frequency is explicitly set
Ouch. I simply removed patches 3/4 and 4/4 from the series, and
didn't notice there was a mistake in patch 1/2 corrected by patch
4/4 in v1. I will fix it and send v3, sorry for the noise.
--
Eduardo
7 years, 10 months
[libvirt] [PATCH v2 0/2] Allow migration with invtsc if TSC frequency is explicitly set
by Eduardo Habkost
This series makes QEMU accept migration if tsc-frequency is
explicitly set on configuration. As management software is
required to keep device configuration the same on migration
source or destination, explicit tsc-frequency will ensure that
either:
* The destination host has a matching TSC frequency; or
* The destination host has TSC scaling available.
Changes series v1 -> v2
=======================
* v1 series subject was:
* [PATCH 0/4] Allow migration with invtsc if there's no
frequency mismatch
* Removed patches 3/4 and 4/4, that allowed migration
if no explicit tsc-frequency was set. Implementing the check on
post_load or post_init is not enough to make migration abort,
so we will need a more complex solution to implement that
feature.
Plans for future work
=====================
1) Querying host TSC frequency/scaling capability
-------------------------------------------------
I plan to include TSC frequency/scaling information on
query-cpu-model-expansion model="host" in a future series. Then
management software will be able to automatically configure TSC
frequency when invtsc is enabled, instead of requiring the user
to configure it explicitly. While we don't implement that, invtsc
migration will be possible only if the user configures TSC
frequency manually.
2) invtsc migration with no explicit TSC frequency
--------------------------------------------------
A future series can implement migration when TSC frequency is not
specified explicitly. It will be a bit more complex because it
requires either letting the destination abort the migration, or
sending TSC frequency/scaling information from destination to
source.
---
Cc: Marcelo Tosatti <mtosatti(a)redhat.com>
Cc: "Daniel P. Berrange" <berrange(a)redhat.com>
Cc: Paolo Bonzini <pbonzini(a)redhat.com>
Cc: kvm(a)vger.kernel.org
Cc: Haozhong Zhang <haozhong.zhang(a)intel.com>
Cc: "Michael S. Tsirkin" <mst(a)redhat.com>
Cc: Igor Mammedov <imammedo(a)redhat.com>
Cc: libvir-list(a)redhat.com
Cc: Jiri Denemark <jdenemar(a)redhat.com>
Eduardo Habkost (2):
kvm: Simplify invtsc check
kvm: Allow invtsc migration if tsc-khz is set explicitly
target/i386/kvm.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
--
2.11.0.259.g40922b1
7 years, 10 months
[libvirt] Regarding Migration Code
by Anubhav Guleria
Greetings,
I was trying to understand the flow of Migration Code in libvirt and
have few doubts:
1) libvirt talks to QEMU/KVM guests via QEMU API. So overall, in
order to manage QEMU/KVM guests I can either use libvirt (or tools
based on libvirt like virsh) or QEMU monitor. Is it so?
2) Since libvirt is Hypervisor neutral so actual migration
algorithm(precopy or postcopy) is present in the hypervisor ,i.e. in
case of QEMU it should be present in QEMU code base . I was going
through the code starting from libvirt-domain api and not able to
follow after virDomainMigrateVersion3Full(.....) . Kindly help.
3) I want to determine the Migration
Time, Downtime and other resource usage.
What is the correct way to determine the same? Should I use libvirt
API or directly virsh or something else? Which is fast and efficient
way for the same?
Thanks in advance. And sorry if that was too basic
7 years, 10 months
[libvirt] [PATCH] virsh: fix a typo
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)gmail.com>
s/rather then/rather than
Signed-off-by: Chen Hanxiao <chenhanxiao(a)gmail.com>
---
tools/virsh.pod | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index ef91223..e5c94e7 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1673,7 +1673,7 @@ periodically increased by I<auto-converge-increment>.
I<--rdma-pin-all> can be used with RDMA migration (i.e., when I<migrateuri>
starts with rdma://) to tell the hypervisor to pin all domain's memory at once
-before migration starts rather then letting it pin memory pages as needed.
+before migration starts rather than letting it pin memory pages as needed.
B<Note>: Individual hypervisors usually do not support all possible types of
migration. For example, QEMU does not support direct migration.
--
2.7.4
7 years, 10 months
[libvirt] [PATCH v2 0/4] Allow creation of vHBA by parent_wwnn/wwpn or fabric_name
by John Ferlan
v1: http://www.redhat.com/archives/libvir-list/2016-November/msg00866.html
Based on ACKs some of the v1 changes were pushed to make this series
appear shorter.
Changes since v1
- Patch 1 (formerly patch 4)
Rather than separate XML elements, use the existing <parent> and just
make attributes for wwnn, wwpn, and fabric_wwn. The parent element can
now be string text or empty.
Added checked for if either wwnn/wwpn provided, then the other is too.
- Patch 2 (formerly patch 5)
No changes, but no formal ACK either
- Patch 3 (formerly patch 10)
Rather than READ_WWN macro across two functions, I created a helper
function to read and compare the various wwn values (wwnn, wwpn, and
fabric_wwn).
John Ferlan (4):
nodedev: Add the ability to create vHBA by parent wwnn/wwpn or
fabric_wwn
conf: Add more fchost search fields for storage pool vHBA creation
util: Introduce virGetFCHostNameByFabricWWN
iscsi: Add parent wwnn/wwpn or fabric capability for createVport
docs/schemas/basictypes.rng | 15 ++++
docs/schemas/nodedev.rng | 24 +++++-
src/conf/node_device_conf.c | 126 +++++++++++++++++++++++++++++++
src/conf/node_device_conf.h | 14 ++++
src/conf/storage_conf.c | 21 +++++-
src/conf/storage_conf.h | 3 +
src/libvirt_private.syms | 3 +
src/node_device/node_device_driver.c | 13 ++++
src/storage/storage_backend_scsi.c | 21 +++++-
src/util/virutil.c | 141 ++++++++++++++++++++++++++---------
src/util/virutil.h | 4 +
11 files changed, 346 insertions(+), 39 deletions(-)
--
2.7.4
7 years, 10 months
[libvirt] [PATCH v2] libxl: define a per-domain logger.
by Cédric Bosdonnat
libxl doesn't provide a way to write one log for each domain. Thus
we need to demux the messages. If our logger doesn't know to which
domain to attribute a message, then it will write it to the default
log file.
Starting with Xen 4.9 (commit f9858025 and following), libxl will
write the domain ID in an easy to grab manner. The logger introduced
by this commit will use it to demux the libxl log messages.
Thanks to the default log file, this logger will also work with older
versions of Xen.
---
* v2: addressed Jim's comments
src/Makefile.am | 1 +
src/libxl/libxl_conf.c | 38 +-------
src/libxl/libxl_conf.h | 4 +-
src/libxl/libxl_domain.c | 4 +
src/libxl/libxl_driver.c | 2 +
src/libxl/libxl_logger.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++
src/libxl/libxl_logger.h | 39 +++++++++
7 files changed, 274 insertions(+), 37 deletions(-)
create mode 100644 src/libxl/libxl_logger.c
create mode 100644 src/libxl/libxl_logger.h
diff --git a/src/Makefile.am b/src/Makefile.am
index b71378728..e34d52345 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -851,6 +851,7 @@ LIBXL_DRIVER_SOURCES = \
libxl/libxl_capabilities.c libxl/libxl_capabilities.h \
libxl/libxl_domain.c libxl/libxl_domain.h \
libxl/libxl_driver.c libxl/libxl_driver.h \
+ libxl/libxl_logger.c libxl/libxl_logger.h \
libxl/libxl_migration.c libxl/libxl_migration.h
UML_DRIVER_SOURCES = \
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index b569ddad8..ac83b51c7 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -76,9 +76,7 @@ libxlDriverConfigDispose(void *obj)
virObjectUnref(cfg->caps);
libxl_ctx_free(cfg->ctx);
- xtl_logger_destroy(cfg->logger);
- if (cfg->logger_file)
- VIR_FORCE_FCLOSE(cfg->logger_file);
+ libxlLoggerFree(cfg->logger);
VIR_FREE(cfg->configDir);
VIR_FREE(cfg->autostartDir);
@@ -1356,8 +1354,6 @@ libxlDriverConfigPtr
libxlDriverConfigNew(void)
{
libxlDriverConfigPtr cfg;
- char *log_file = NULL;
- xentoollog_level log_level = XTL_DEBUG;
char ebuf[1024];
unsigned int free_mem;
@@ -1386,9 +1382,6 @@ libxlDriverConfigNew(void)
if (VIR_STRDUP(cfg->channelDir, LIBXL_CHANNEL_DIR) < 0)
goto error;
- if (virAsprintf(&log_file, "%s/libxl-driver.log", cfg->logDir) < 0)
- goto error;
-
if (virFileMakePath(cfg->logDir) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("failed to create log dir '%s': %s"),
@@ -1397,37 +1390,13 @@ libxlDriverConfigNew(void)
goto error;
}
- if ((cfg->logger_file = fopen(log_file, "a")) == NULL) {
- VIR_ERROR(_("Failed to create log file '%s': %s"),
- log_file, virStrerror(errno, ebuf, sizeof(ebuf)));
- goto error;
- }
- VIR_FREE(log_file);
-
- switch (virLogGetDefaultPriority()) {
- case VIR_LOG_DEBUG:
- log_level = XTL_DEBUG;
- break;
- case VIR_LOG_INFO:
- log_level = XTL_INFO;
- break;
- case VIR_LOG_WARN:
- log_level = XTL_WARN;
- break;
- case VIR_LOG_ERROR:
- log_level = XTL_ERROR;
- break;
- }
-
- cfg->logger =
- (xentoollog_logger *)xtl_createlogger_stdiostream(cfg->logger_file,
- log_level, XTL_STDIOSTREAM_SHOW_DATE);
+ cfg->logger = libxlLoggerNew(cfg->logDir, virLogGetDefaultPriority());
if (!cfg->logger) {
VIR_ERROR(_("cannot create logger for libxenlight, disabling driver"));
goto error;
}
- if (libxl_ctx_alloc(&cfg->ctx, LIBXL_VERSION, 0, cfg->logger)) {
+ if (libxl_ctx_alloc(&cfg->ctx, LIBXL_VERSION, 0, (xentoollog_logger *)cfg->logger)) {
VIR_ERROR(_("cannot initialize libxenlight context, probably not "
"running in a Xen Dom0, disabling driver"));
goto error;
@@ -1478,7 +1447,6 @@ libxlDriverConfigNew(void)
return cfg;
error:
- VIR_FREE(log_file);
virObjectUnref(cfg);
return NULL;
}
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 851f3afb4..69d78851a 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -41,6 +41,7 @@
# include "locking/lock_manager.h"
# include "virfirmware.h"
# include "libxl_capabilities.h"
+# include "libxl_logger.h"
# define LIBXL_DRIVER_NAME "xenlight"
# define LIBXL_VNC_PORT_MIN 5900
@@ -74,8 +75,7 @@ struct _libxlDriverConfig {
unsigned int version;
/* log stream for driver-wide libxl ctx */
- FILE *logger_file;
- xentoollog_logger *logger;
+ libxlLoggerPtr logger;
/* libxl ctx for driver wide ops; getVersion, getNodeInfo, ... */
libxl_ctx *ctx;
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 5cde576ef..3bc468f61 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -809,6 +809,8 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
VIR_FREE(xml);
}
+ libxlLoggerCloseFile(cfg->logger, vm->def->id);
+
virDomainObjRemoveTransientDef(vm);
virObjectUnref(cfg);
}
@@ -1291,6 +1293,8 @@ libxlDomainStart(libxlDriverPrivatePtr driver,
*/
vm->def->id = domid;
+ libxlLoggerOpenFile(cfg->logger, domid, vm->def->name);
+
/* Always enable domain death events */
if (libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW))
goto destroy_dom;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 7e5d9b69e..6a4ecddef 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -406,6 +406,8 @@ libxlReconnectDomain(virDomainObjPtr vm,
/* Update domid in case it changed (e.g. reboot) while we were gone? */
vm->def->id = d_info.domid;
+ libxlLoggerOpenFile(cfg->logger, vm->def->id, vm->def->name);
+
/* Update hostdev state */
if (virHostdevUpdateActiveDomainDevices(hostdev_mgr, LIBXL_DRIVER_NAME,
vm->def, hostdev_flags) < 0)
diff --git a/src/libxl/libxl_logger.c b/src/libxl/libxl_logger.c
new file mode 100644
index 000000000..d8ccdd852
--- /dev/null
+++ b/src/libxl/libxl_logger.c
@@ -0,0 +1,223 @@
+/*
+ * libxl_logger.c: libxl logger implementation
+ *
+ * Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Cédric Bosdonnat <cbosdonnat(a)suse.com>
+ */
+#include <config.h>
+
+#include <string.h>
+#include <libxl.h>
+
+#include "internal.h"
+#include "libxl_logger.h"
+#include "util/viralloc.h"
+#include "util/virerror.h"
+#include "util/virfile.h"
+#include "util/virhash.h"
+#include "util/virstring.h"
+#include "util/virtime.h"
+
+#define VIR_FROM_THIS VIR_FROM_LIBXL
+
+VIR_LOG_INIT("libxl.libxl_logger");
+
+typedef struct xentoollog_logger_libvirt xentoollog_logger_libvirt;
+
+struct xentoollog_logger_libvirt {
+ xentoollog_logger vtable;
+ xentoollog_level minLevel;
+ const char *logDir;
+
+ /* map storing the opened fds: "domid" -> FILE* */
+ virHashTablePtr files;
+ FILE *defaultLogFile;
+};
+
+static void
+libxlLoggerFileFree(void *payload, const void *key ATTRIBUTE_UNUSED)
+{
+ FILE *file = payload;
+ VIR_FORCE_FCLOSE(file);
+ file = NULL;
+}
+
+ATTRIBUTE_FMT_PRINTF(5, 0) static void
+libvirt_vmessage(xentoollog_logger *logger_in,
+ xentoollog_level level,
+ int errnoval,
+ const char *context,
+ const char *format,
+ va_list args)
+{
+ xentoollog_logger_libvirt *lg = (xentoollog_logger_libvirt *)logger_in;
+ FILE *logFile = lg->defaultLogFile;
+ char timestamp[VIR_TIME_STRING_BUFLEN];
+ char *message = NULL;
+ char *start, *end;
+ char ebuf[1024];
+
+ VIR_DEBUG("libvirt_vmessage: context='%s' format='%s'", context, format);
+
+ if (level < lg->minLevel)
+ return;
+
+ if (virVasprintf(&message, format, args) < 0)
+ return;
+
+ /* Should we print to a domain-specific log file? */
+ if ((start = strstr(message, ": Domain ")) &&
+ (end = strstr(start + 9, ":"))) {
+ FILE *domainLogFile;
+
+ VIR_DEBUG("Found domain log message");
+
+ start = start + 9;
+ *end = '\0';
+
+ domainLogFile = virHashLookup(lg->files, start);
+ if (domainLogFile)
+ logFile = domainLogFile;
+
+ *end = ':';
+ }
+
+ /* Do the actual print to the log file */
+ if (virTimeStringNowRaw(timestamp) < 0)
+ timestamp[0] = '\0';
+
+ fprintf(logFile, "%s: ", timestamp);
+ if (context)
+ fprintf(logFile, "%s: ", context);
+
+ fprintf(logFile, "%s", message);
+
+ if (errnoval >= 0)
+ fprintf(logFile, ": %s", virStrerror(errnoval, ebuf, sizeof(ebuf)));
+
+ fputc('\n', logFile);
+ fflush(logFile);
+
+ VIR_FREE(message);
+}
+
+static void
+libvirt_progress(xentoollog_logger *logger_in ATTRIBUTE_UNUSED,
+ const char *context ATTRIBUTE_UNUSED,
+ const char *doingwhat ATTRIBUTE_UNUSED,
+ int percent ATTRIBUTE_UNUSED,
+ unsigned long done ATTRIBUTE_UNUSED,
+ unsigned long total ATTRIBUTE_UNUSED)
+{
+ /* This function purposedly does nothing: it's no logging info */
+}
+
+static void
+libvirt_destroy(xentoollog_logger *logger_in)
+{
+ xentoollog_logger_libvirt *lg = (xentoollog_logger_libvirt*)logger_in;
+ VIR_FREE(lg);
+}
+
+
+libxlLoggerPtr libxlLoggerNew(const char *logDir,
+ virLogPriority minLevel)
+{
+ xentoollog_logger_libvirt logger;
+ libxlLoggerPtr logger_out = NULL;
+ char *path = NULL;
+
+ switch (minLevel) {
+ case VIR_LOG_DEBUG:
+ logger.minLevel = XTL_DEBUG;
+ break;
+ case VIR_LOG_INFO:
+ logger.minLevel = XTL_INFO;
+ break;
+ case VIR_LOG_WARN:
+ logger.minLevel = XTL_WARN;
+ break;
+ case VIR_LOG_ERROR:
+ logger.minLevel = XTL_ERROR;
+ break;
+ }
+ logger.logDir = logDir;
+
+ if ((logger.files = virHashCreate(3, libxlLoggerFileFree)) == NULL)
+ return NULL;
+
+ if (virAsprintf(&path, "%s/libxl-driver.log", logDir) < 0)
+ goto error;
+
+ if ((logger.defaultLogFile = fopen(path, "a")) == NULL)
+ goto error;
+
+ logger_out = XTL_NEW_LOGGER(libvirt, logger);
+
+ cleanup:
+ VIR_FREE(path);
+ return logger_out;
+
+ error:
+ virHashFree(logger.files);
+ goto cleanup;
+}
+
+void libxlLoggerFree(libxlLoggerPtr logger)
+{
+ xentoollog_logger *xtl_logger = (xentoollog_logger*)logger;
+ if (logger->defaultLogFile)
+ VIR_FORCE_FCLOSE(logger->defaultLogFile);
+ virHashFree(logger->files);
+ xtl_logger_destroy(xtl_logger);
+}
+
+void libxlLoggerOpenFile(libxlLoggerPtr logger, int id, const char *name)
+{
+ char *path = NULL;
+ FILE *logFile = NULL;
+ char *domidstr = NULL;
+ char ebuf[1024];
+
+ if (virAsprintf(&path, "%s/%s.log", logger->logDir, name) < 0 ||
+ virAsprintf(&domidstr, "%d", id) < 0)
+ goto cleanup;
+
+ if (!(logFile = fopen(path, "a"))) {
+ VIR_WARN("Failed to open log file %s: %s",
+ path, virStrerror(errno, ebuf, sizeof(ebuf)));
+ goto cleanup;
+ }
+ ignore_value(virHashAddEntry(logger->files, domidstr, logFile));
+
+ cleanup:
+ VIR_FREE(path);
+ VIR_FREE(domidstr);
+}
+
+void libxlLoggerCloseFile(libxlLoggerPtr logger, int id)
+{
+ char *domidstr = NULL;
+ if (virAsprintf(&domidstr, "%d", id) < 0)
+ return;
+
+ ignore_value(virHashRemoveEntry(logger->files, domidstr));
+
+ VIR_FREE(domidstr);
+}
diff --git a/src/libxl/libxl_logger.h b/src/libxl/libxl_logger.h
new file mode 100644
index 000000000..88c2868eb
--- /dev/null
+++ b/src/libxl/libxl_logger.h
@@ -0,0 +1,39 @@
+/*
+ * libxl_logger.h: libxl logger implementation
+ *
+ * Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Cédric Bosdonnat <cbosdonnat(a)suse.com>
+ */
+
+#ifndef __LIBXL_LOGGER_H
+# define __LIBXL_LOGGER_H
+
+# include "util/virlog.h"
+
+typedef struct xentoollog_logger_libvirt libxlLogger;
+typedef libxlLogger *libxlLoggerPtr;
+
+libxlLoggerPtr libxlLoggerNew(const char *logDir,
+ virLogPriority minLevel);
+void libxlLoggerFree(libxlLoggerPtr logger);
+
+void libxlLoggerOpenFile(libxlLoggerPtr logger, int id, const char *name);
+void libxlLoggerCloseFile(libxlLoggerPtr logger, int id);
+
+#endif /* __LIBXL_LOGGER_H */
--
2.11.0
7 years, 10 months
[libvirt] [PATCH 0/9] More event handling support
by Daniel P. Berrange
This series adds suppoort for more events
- Event when <metadata> in a domain changes
- Event when virSecret are created/deleted
- Event when virSecret value is changed
The latter two of course required wiring up the secret object
for event support, since we've not had secret events before
now.
Daniel P. Berrange (9):
Add domain event for metadata changes
Introduce secret lifecycle event APIs
conf: add secret event handling
conf: simplify internal virSecretDef handling of usage
remote: implement secret lifecycle event APIs
secret: add support for lifecycle events
examples: add secret events to event demo program
virsh: add secret lifecycle event handling
secret: add support for value change events
daemon/libvirtd.h | 2 +
daemon/remote.c | 276 ++++++++++++++++++++++++++++++++
examples/object-events/event-test.c | 107 +++++++++++++
include/libvirt/libvirt-domain.h | 20 +++
include/libvirt/libvirt-secret.h | 92 +++++++++++
src/Makefile.am | 5 +
src/access/viraccessdriverpolkit.c | 8 +-
src/bhyve/bhyve_driver.c | 7 +
src/conf/domain_event.c | 86 ++++++++++
src/conf/domain_event.h | 10 ++
src/conf/secret_conf.c | 74 ++-------
src/conf/secret_conf.h | 9 +-
src/conf/secret_event.c | 311 ++++++++++++++++++++++++++++++++++++
src/conf/secret_event.h | 65 ++++++++
src/conf/virsecretobj.c | 42 +----
src/datatypes.c | 3 +-
src/datatypes.h | 14 ++
src/driver-secret.h | 14 ++
src/libvirt-secret.c | 129 +++++++++++++++
src/libvirt_private.syms | 9 +-
src/libvirt_public.syms | 2 +
src/lxc/lxc_driver.c | 6 +
src/qemu/qemu_driver.c | 6 +
src/remote/remote_driver.c | 196 ++++++++++++++++++++++-
src/remote/remote_protocol.x | 69 +++++++-
src/remote_protocol-structs | 26 +++
src/secret/secret_driver.c | 82 +++++++++-
src/storage/storage_backend.c | 2 +-
src/test/test_driver.c | 6 +
tools/virsh-domain.c | 25 +++
tools/virsh-secret.c | 225 ++++++++++++++++++++++++++
tools/virsh.pod | 18 +++
32 files changed, 1829 insertions(+), 117 deletions(-)
create mode 100644 src/conf/secret_event.c
create mode 100644 src/conf/secret_event.h
--
2.9.3
7 years, 10 months