Skip to content
Snippets Groups Projects
Commit ec2fd52a authored by Guido Günther's avatar Guido Günther
Browse files

drop patches merged upstream

parent 85f4ad48
No related branches found
No related tags found
No related merge requests found
From: =?utf-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Tue, 14 Apr 2009 18:08:16 +0200
Subject: [PATCH] increase buffer on ERANGE
---
qemud/qemud.c | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/qemud/qemud.c b/qemud/qemud.c
index 4f04355..461c612 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -2529,6 +2529,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
char *unix_sock_ro_perms = NULL;
char *unix_sock_rw_perms = NULL;
char *unix_sock_group = NULL;
+ char *buf = NULL;
#if HAVE_POLKIT
/* Change the default back to no auth for non-root */
@@ -2574,13 +2575,34 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
if (getuid() != 0) {
VIR_WARN0(_("Cannot set group when not running as root"));
} else {
- char buf[1024];
+ int ret;
struct group grpdata, *grp;
- if (getgrnam_r(unix_sock_group, &grpdata, buf, sizeof(buf), &grp) != 0 || !grp) {
+ size_t maxbuf = sysconf(_SC_GETGR_R_SIZE_MAX);
+
+ if (maxbuf == -1)
+ maxbuf = 1024;
+
+ if (VIR_ALLOC_N(buf, maxbuf) < 0) {
+ VIR_ERROR("%s", _("Failed to allocate memory for buffer"));
+ goto free_and_fail;
+ }
+
+ while ((ret = getgrnam_r(unix_sock_group, &grpdata,
+ buf, maxbuf,
+ &grp)) == ERANGE) {
+ maxbuf *= 2;
+ if (VIR_REALLOC_N(buf, maxbuf) < 0) {
+ VIR_ERROR("%s", _("Failed to reallocate memory for buffer"));
+ goto free_and_fail;
+ }
+ }
+
+ if (ret != 0 || !grp) {
VIR_ERROR(_("Failed to lookup group '%s'"), unix_sock_group);
goto free_and_fail;
}
unix_sock_gid = grp->gr_gid;
+ VIR_FREE (buf);
}
free (unix_sock_group);
unix_sock_group = NULL;
@@ -2643,6 +2665,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
free (unix_sock_ro_perms);
free (unix_sock_rw_perms);
free (unix_sock_group);
+ VIR_FREE (buf);
/* Don't bother trying to free listen_addr, tcp_port, tls_port, key_file,
cert_file, ca_file, or crl_file, since they are initialized to
--
From: =?utf-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Thu, 16 Apr 2009 14:08:33 +0200
Subject: [PATCH] only log qemu monitor commands if default log priority is VIR_LOG_DEBUG
---
src/libvirt_debug.syms | 1 +
src/logging.c | 9 +++++++++
src/logging.h | 2 ++
src/qemu_driver.c | 27 +++++++++++++++------------
4 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/src/libvirt_debug.syms b/src/libvirt_debug.syms
index 1742a0b..e2e0dbd 100644
--- a/src/libvirt_debug.syms
+++ b/src/libvirt_debug.syms
@@ -10,6 +10,7 @@ debugFlag;
# logging.h
virLogMessage;
virLogSetDefaultPriority;
+virLogGetDefaultPriority;
virLogDefineFilter;
virLogDefineOutput;
virLogParseFilters;
diff --git a/src/logging.c b/src/logging.c
index 9c8b0b9..c96c8d5 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -326,6 +326,15 @@ int virLogSetDefaultPriority(int priority) {
}
/**
+ * virLogGetDefaultPriority:
+ *
+ * Get the default priority level.
+ */
+int virLogGetDefaultPriority() {
+ return virLogDefaultPriority;
+}
+
+/**
* virLogResetFilters:
*
* Removes the set of logging filters defined.
diff --git a/src/logging.h b/src/logging.h
index 7ea8935..614aefb 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -111,6 +111,7 @@ typedef void (*virLogCloseFunc) (void *data);
#ifdef ENABLE_DEBUG
extern int virLogSetDefaultPriority(int priority);
+extern int virLogGetDefaultPriority(void);
extern int virLogDefineFilter(const char *match, int priority, int flags);
extern int virLogDefineOutput(virLogOutputFunc f, virLogCloseFunc c,
void *data, int priority, int flags);
@@ -131,6 +132,7 @@ extern void virLogMessage(const char *category, int priority,
#else /* ENABLE_DEBUG */
#define virLogSetDefaultPriority(p)
+#define virLogGetDefaultPriority()
#define virLogDefineFilter(m, p, f)
#define virLogDefineOutput(func, c, d, p, f)
#define virLogStartup()
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 79ee072..d8cd4ee 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -1711,25 +1711,28 @@ qemudMonitorCommandExtra(const virDomainObjPtr vm,
}
}
- /* Log, but ignore failures to write logfile for VM */
- if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
- char ebuf[1024];
- VIR_WARN(_("Unable to log VM console data: %s\n"),
- virStrerror(errno, ebuf, sizeof ebuf));
+ if (virLogGetDefaultPriority() <= VIR_LOG_DEBUG) {
+ /* Log, but ignore failures to write logfile for VM */
+ if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
+ char ebuf[1024];
+ VIR_WARN(_("Unable to log VM console data: %s\n"),
+ virStrerror(errno, ebuf, sizeof ebuf));
+ }
}
-
*reply = buf;
return 0;
error:
if (buf) {
- /* Log, but ignore failures to write logfile for VM */
- if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
- char ebuf[1024];
- VIR_WARN(_("Unable to log VM console data: %s\n"),
- virStrerror(errno, ebuf, sizeof ebuf));
+ if (virLogGetDefaultPriority() <= VIR_LOG_WARN) {
+ /* Log, but ignore failures to write logfile for VM */
+ if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
+ char ebuf[1024];
+ VIR_WARN(_("Unable to log VM console data: %s\n"),
+ virStrerror(errno, ebuf, sizeof ebuf));
+ }
+ VIR_FREE(buf);
}
- VIR_FREE(buf);
}
return -1;
}
--
......@@ -2,5 +2,3 @@
0002-qemu-disable-network.diff.patch
0003-allow-libvirt-group-to-access-the-socket.patch
0004-fix-Debian-specific-path-to-hvm-loader.patch
0005-increase-buffer-on-ERANGE.patch
0006-only-log-qemu-monitor-commands-if-default-log-priori.patch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment