[libvirt] qemu-kvm spending time in do_info_migrate() during virDomainSave(); 50ms polling too fast?
by Charles Duffy
...or more particularly, in ram_bytes_remaining() called by do_info_migrate();
oddly, this is much more pronounced when running with <emulator> pointing at a
shim prepending -no-kvm-irqchip to the invoked command line.
This VM was intended to be paused for the save event (if my software was doing
its job correctly), so we shouldn't be spending time running the guest CPU and
writing updates for already-once-written blocks.
I'm seeing much more CPU time spent inside qemu-kvm than in the exec'd lzop
process compressing and writing the data stream; on attaching gdb and taking
some stack traces to sample where execution time was spent, it appeared that we
were spending our time responding to requests from the monitor.
The question then -- is the 50ms poll in qemuDomainWaitForMigrationComplete
(called from qemudDomainSave) perhaps too frequent?
Thanks!
---
Below is an exchange from IRC:
<nDuff> How often should libvirt be calling "info migrate" during a
virDomainSave (of a qemu domain)?
* nDuff is seeing his qemu-kvm spending the bulk of its time inside
ram_bytes_remaining() under do_info_migrate().
<DV> nDuff: I doubt libvirt is doing this on his own, something else is asking
for the information I would assume
<nDuff> DV, I'm not running virt-manager or such; the only management layer on
top is locally developed, and it only has a single thread that's blocked waiting
for the dom.save() call [this is using the Python bindings] to complete.
<DV> interesting
<DV> nDuff -> send this to the list, someone need to look at it, at least raise
the problem, maybe we didn't expected that to be so costly
<DV> nDuff: maybe open a bugzilla
<nDuff> it might be that it's not _usually_ so costly except that I'm hitting a
qemu/kvm bug; it only started expressing itself when I added -no-kvm-irqchip to
the commandline via a shim
<DV> nDuff: I could see how trying to extract this too often could stall the
migration process
<nDuff> ...but yes, I'll post to the list.
<DV> nDuff: maybe it's related to the capability to force migration end when the
full flush will be shorter than a user defined limit
14 years, 6 months
[libvirt] [PATCH] nwfilter: skip interfaces on filter update
by Stefan Berger
When a filter is updated, only those interfaces must have their old
rules cleared that either reference the filter directly or indirectly
through another filter. Remember between the different steps of the
instantiation of the filters which interfaces must be skipped. I am
using a hash map to remember the names of the interfaces and store a
bogus pointer to ~0 into it that need not be freed.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/conf/nwfilter_conf.c | 8 ++++
src/conf/nwfilter_conf.h | 1
src/nwfilter/nwfilter_gentech_driver.c | 66 ++++++++++++++++++++++++---------
src/nwfilter/nwfilter_gentech_driver.h | 3 +
4 files changed, 59 insertions(+), 19 deletions(-)
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -2088,8 +2088,14 @@ virNWFilterTriggerVMFilterRebuild(virCon
.conn = conn,
.err = 0,
.step = STEP_APPLY_NEW,
+ .skipInterfaces = virHashCreate(0),
};
+ if (!cb.skipInterfaces) {
+ virReportOOMError();
+ return 1;
+ }
+
for (i = 0; i < nCallbackDriver; i++) {
callbackDrvArray[i]->vmFilterRebuild(conn,
virNWFilterDomainFWUpdateCB,
@@ -2115,6 +2121,8 @@ virNWFilterTriggerVMFilterRebuild(virCon
&cb);
}
+ virHashFree(cb.skipInterfaces, NULL);
+
return err;
}
Index: libvirt-acl/src/conf/nwfilter_conf.h
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.h
+++ libvirt-acl/src/conf/nwfilter_conf.h
@@ -471,6 +471,7 @@ struct domUpdateCBStruct {
virConnectPtr conn;
enum UpdateStep step;
int err;
+ virHashTablePtr skipInterfaces;
};
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.h
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
@@ -40,7 +40,8 @@ enum instCase {
int virNWFilterInstantiateFilter(virConnectPtr conn,
const virDomainNetDefPtr net);
int virNWFilterUpdateInstantiateFilter(virConnectPtr conn,
- const virDomainNetDefPtr net);
+ const virDomainNetDefPtr net,
+ bool *skipIface);
int virNWFilterRollbackUpdateFilter(virConnectPtr conn,
const virDomainNetDefPtr net);
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
@@ -316,7 +316,7 @@ _virNWFilterInstantiateRec(virConnectPtr
virNWFilterHashTablePtr vars,
int *nEntries,
virNWFilterRuleInstPtr **insts,
- enum instCase useNewFilter, int *foundNewFilter,
+ enum instCase useNewFilter, bool *foundNewFilter,
virNWFilterDriverStatePtr driver)
{
virNWFilterPoolObjPtr obj;
@@ -381,7 +381,7 @@ _virNWFilterInstantiateRec(virConnectPtr
case INSTANTIATE_FOLLOW_NEWFILTER:
if (obj->newDef) {
next_filter = obj->newDef;
- *foundNewFilter = 1;
+ *foundNewFilter = true;
}
break;
case INSTANTIATE_ALWAYS:
@@ -562,7 +562,7 @@ virNWFilterInstantiate(virConnectPtr con
int ifindex,
const char *linkdev,
virNWFilterHashTablePtr vars,
- enum instCase useNewFilter, int *foundNewFilter,
+ enum instCase useNewFilter, bool *foundNewFilter,
bool teardownOld,
const unsigned char *macaddr,
virNWFilterDriverStatePtr driver,
@@ -693,7 +693,8 @@ __virNWFilterInstantiateFilter(virConnec
virNWFilterHashTablePtr filterparams,
enum instCase useNewFilter,
virNWFilterDriverStatePtr driver,
- bool forceWithPendingReq)
+ bool forceWithPendingReq,
+ bool *foundNewFilter)
{
int rc;
const char *drvname = EBIPTABLES_DRIVER_ID;
@@ -702,7 +703,6 @@ __virNWFilterInstantiateFilter(virConnec
virNWFilterHashTablePtr vars, vars1;
virNWFilterDefPtr filter;
char vmmacaddr[VIR_MAC_STRING_BUFLEN] = {0};
- int foundNewFilter = 0;
char *str_macaddr = NULL;
const char *ipaddr;
char *str_ipaddr = NULL;
@@ -775,7 +775,7 @@ __virNWFilterInstantiateFilter(virConnec
case INSTANTIATE_FOLLOW_NEWFILTER:
if (obj->newDef) {
filter = obj->newDef;
- foundNewFilter = 1;
+ *foundNewFilter = true;
}
break;
@@ -791,7 +791,7 @@ __virNWFilterInstantiateFilter(virConnec
ifindex,
linkdev,
vars,
- useNewFilter, &foundNewFilter,
+ useNewFilter, foundNewFilter,
teardownOld,
macaddr,
driver,
@@ -816,7 +816,8 @@ static int
_virNWFilterInstantiateFilter(virConnectPtr conn,
const virDomainNetDefPtr net,
bool teardownOld,
- enum instCase useNewFilter)
+ enum instCase useNewFilter,
+ bool *foundNewFilter)
{
const char *linkdev = (net->type == VIR_DOMAIN_NET_TYPE_DIRECT)
? net->data.direct.linkdev
@@ -837,7 +838,8 @@ _virNWFilterInstantiateFilter(virConnect
net->filterparams,
useNewFilter,
conn->nwfilterPrivateData,
- false);
+ false,
+ foundNewFilter);
}
@@ -853,6 +855,8 @@ virNWFilterInstantiateFilterLate(virConn
virNWFilterDriverStatePtr driver)
{
int rc;
+ bool foundNewFilter = false;
+
rc = __virNWFilterInstantiateFilter(conn,
1,
ifname,
@@ -864,7 +868,8 @@ virNWFilterInstantiateFilterLate(virConn
filterparams,
INSTANTIATE_ALWAYS,
driver,
- true);
+ true,
+ &foundNewFilter);
if (rc) {
//something went wrong... 'DOWN' the interface
if (ifaceCheck(false, ifname, NULL, ifindex) != 0 ||
@@ -881,19 +886,29 @@ int
virNWFilterInstantiateFilter(virConnectPtr conn,
const virDomainNetDefPtr net)
{
+ bool foundNewFilter = false;
+
return _virNWFilterInstantiateFilter(conn, net,
1,
- INSTANTIATE_ALWAYS);
+ INSTANTIATE_ALWAYS,
+ &foundNewFilter);
}
int
virNWFilterUpdateInstantiateFilter(virConnectPtr conn,
- const virDomainNetDefPtr net)
+ const virDomainNetDefPtr net,
+ bool *skipIface)
{
- return _virNWFilterInstantiateFilter(conn, net,
- 0,
- INSTANTIATE_FOLLOW_NEWFILTER);
+ bool foundNewFilter = false;
+
+ int rc = _virNWFilterInstantiateFilter(conn, net,
+ 0,
+ INSTANTIATE_FOLLOW_NEWFILTER,
+ &foundNewFilter);
+
+ *skipIface = !foundNewFilter;
+ return rc;
}
int virNWFilterRollbackUpdateFilter(virConnectPtr conn,
@@ -993,6 +1008,7 @@ virNWFilterDomainFWUpdateCB(void *payloa
virDomainDefPtr vm = obj->def;
struct domUpdateCBStruct *cb = data;
int i;
+ bool skipIface;
virDomainObjLock(obj);
@@ -1003,15 +1019,29 @@ virNWFilterDomainFWUpdateCB(void *payloa
switch (cb->step) {
case STEP_APPLY_NEW:
cb->err = virNWFilterUpdateInstantiateFilter(cb->conn,
- net);
+ net,
+ &skipIface);
+ if (cb->err == 0 && skipIface == true) {
+ // filter tree unchanged -- no update needed
+ cb->err = virHashAddEntry(cb->skipInterfaces,
+ net->ifname,
+ (void *)~0);
+ if (cb->err)
+ virReportOOMError();
+ }
break;
case STEP_TEAR_NEW:
- cb->err = virNWFilterRollbackUpdateFilter(cb->conn, net);
+ if ( !virHashLookup(cb->skipInterfaces, net->ifname)) {
+ cb->err = virNWFilterRollbackUpdateFilter(cb->conn,
+ net);
+ }
break;
case STEP_TEAR_OLD:
- cb->err = virNWFilterTearOldFilter(cb->conn, net);
+ if ( !virHashLookup(cb->skipInterfaces, net->ifname)) {
+ cb->err = virNWFilterTearOldFilter(cb->conn, net);
+ }
break;
}
if (cb->err)
14 years, 6 months
[libvirt] [PATCH] mingw: Fix two undefined symbols
by Matthias Bolte
Add an empty body for virCondWaitUntil and move virPipeReadUntilEOF
out of the '#ifndef WIN32' block, because it compiles fine with MinGW
in combination with gnulib.
---
src/util/threads-win32.c | 10 +++
src/util/util.c | 160 +++++++++++++++++++++++-----------------------
2 files changed, 90 insertions(+), 80 deletions(-)
diff --git a/src/util/threads-win32.c b/src/util/threads-win32.c
index a30bccf..e478560 100644
--- a/src/util/threads-win32.c
+++ b/src/util/threads-win32.c
@@ -157,6 +157,16 @@ int virCondWait(virCondPtr c, virMutexPtr m)
return 0;
}
+int virCondWaitUntil(virCondPtr c ATTRIBUTE_UNUSED,
+ virMutexPtr m ATTRIBUTE_UNUSED,
+ unsigned long long whenms ATTRIBUTE_UNUSED)
+{
+ /* FIXME: this function is currently only used by the QEMU driver that
+ * is not compiled on Windows, so it's okay for now to just
+ * miss an implementation */
+ return -1;
+}
+
void virCondSignal(virCondPtr c)
{
virMutexLock(&c->lock);
diff --git a/src/util/util.c b/src/util/util.c
index 3209185..e444c97 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -782,86 +782,6 @@ int virExecDaemonize(const char *const*argv,
return ret;
}
-int
-virPipeReadUntilEOF(int outfd, int errfd,
- char **outbuf, char **errbuf) {
-
- struct pollfd fds[2];
- int i;
- int finished[2];
-
- fds[0].fd = outfd;
- fds[0].events = POLLIN;
- finished[0] = 0;
- fds[1].fd = errfd;
- fds[1].events = POLLIN;
- finished[1] = 0;
-
- while(!(finished[0] && finished[1])) {
-
- if (poll(fds, ARRAY_CARDINALITY(fds), -1) < 0) {
- if ((errno == EAGAIN) || (errno == EINTR))
- continue;
- goto pollerr;
- }
-
- for (i = 0; i < ARRAY_CARDINALITY(fds); ++i) {
- char data[1024], **buf;
- int got, size;
-
- if (!(fds[i].revents))
- continue;
- else if (fds[i].revents & POLLHUP)
- finished[i] = 1;
-
- if (!(fds[i].revents & POLLIN)) {
- if (fds[i].revents & POLLHUP)
- continue;
-
- virUtilError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("Unknown poll response."));
- goto error;
- }
-
- got = read(fds[i].fd, data, sizeof(data));
-
- if (got == 0) {
- finished[i] = 1;
- continue;
- }
- if (got < 0) {
- if (errno == EINTR)
- continue;
- if (errno == EAGAIN)
- break;
- goto pollerr;
- }
-
- buf = ((fds[i].fd == outfd) ? outbuf : errbuf);
- size = (*buf ? strlen(*buf) : 0);
- if (VIR_REALLOC_N(*buf, size+got+1) < 0) {
- virReportOOMError();
- goto error;
- }
- memmove(*buf+size, data, got);
- (*buf)[size+got] = '\0';
- }
- continue;
-
- pollerr:
- virReportSystemError(errno,
- "%s", _("poll error"));
- goto error;
- }
-
- return 0;
-
-error:
- VIR_FREE(*outbuf);
- VIR_FREE(*errbuf);
- return -1;
-}
-
/**
* @argv NULL terminated argv to run
* @status optional variable to return exit status in
@@ -1008,6 +928,86 @@ virExecDaemonize(const char *const*argv ATTRIBUTE_UNUSED,
# endif /* WIN32 */
int
+virPipeReadUntilEOF(int outfd, int errfd,
+ char **outbuf, char **errbuf) {
+
+ struct pollfd fds[2];
+ int i;
+ int finished[2];
+
+ fds[0].fd = outfd;
+ fds[0].events = POLLIN;
+ finished[0] = 0;
+ fds[1].fd = errfd;
+ fds[1].events = POLLIN;
+ finished[1] = 0;
+
+ while(!(finished[0] && finished[1])) {
+
+ if (poll(fds, ARRAY_CARDINALITY(fds), -1) < 0) {
+ if ((errno == EAGAIN) || (errno == EINTR))
+ continue;
+ goto pollerr;
+ }
+
+ for (i = 0; i < ARRAY_CARDINALITY(fds); ++i) {
+ char data[1024], **buf;
+ int got, size;
+
+ if (!(fds[i].revents))
+ continue;
+ else if (fds[i].revents & POLLHUP)
+ finished[i] = 1;
+
+ if (!(fds[i].revents & POLLIN)) {
+ if (fds[i].revents & POLLHUP)
+ continue;
+
+ virUtilError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Unknown poll response."));
+ goto error;
+ }
+
+ got = read(fds[i].fd, data, sizeof(data));
+
+ if (got == 0) {
+ finished[i] = 1;
+ continue;
+ }
+ if (got < 0) {
+ if (errno == EINTR)
+ continue;
+ if (errno == EAGAIN)
+ break;
+ goto pollerr;
+ }
+
+ buf = ((fds[i].fd == outfd) ? outbuf : errbuf);
+ size = (*buf ? strlen(*buf) : 0);
+ if (VIR_REALLOC_N(*buf, size+got+1) < 0) {
+ virReportOOMError();
+ goto error;
+ }
+ memmove(*buf+size, data, got);
+ (*buf)[size+got] = '\0';
+ }
+ continue;
+
+ pollerr:
+ virReportSystemError(errno,
+ "%s", _("poll error"));
+ goto error;
+ }
+
+ return 0;
+
+error:
+ VIR_FREE(*outbuf);
+ VIR_FREE(*errbuf);
+ return -1;
+}
+
+int
virRun(const char *const*argv,
int *status) {
return virRunWithHook(argv, NULL, NULL, status);
--
1.7.0.4
14 years, 6 months
[libvirt] [PATCH] configure.ac: avoid uname, which breaks cross-compilation
by Eric Blake
Without this patch, compiling to mingw with a $build on windows
(think MSYS or cygwin) worked, but failed with a $build on Linux.
* configure.ac: Fix cross-compilation from Linux to mingw.
Reported by Matthias Bolte.
---
configure.ac | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 0fb8bd9..3225cfa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,8 +197,8 @@ if test "$prefix" = "/usr" && test "$sysconfdir" = '${prefix}/etc' ; then
fi
dnl lxc and qemu drivers require linux headers
-if test `uname -s` != "Linux"
-then
+case $host in
+ linux*)
if test "x$with_lxc" != "xyes"
then
with_lxc=no
@@ -207,7 +207,8 @@ then
then
with_qemu=no
fi
-fi
+ ;;
+esac
dnl Allow to build without Xen, QEMU/KVM, test or remote driver
AC_ARG_WITH([xen],
@@ -1970,7 +1971,11 @@ then
fi
AM_CONDITIONAL([WITH_NODE_DEVICES], [test "$with_nodedev" = "yes"])
-AM_CONDITIONAL([WITH_LINUX], [test `uname -s` = "Linux"])
+case $host in
+ linux*) with_linux=yes ;;
+ *) with_linux=no ;;
+esac
+AM_CONDITIONAL([WITH_LINUX], [test $with_linux = yes])
AC_ARG_WITH([qemu-user],
--
1.6.6.1
14 years, 6 months
[libvirt] [PATCH] build: avoid compiler warning
by Eric Blake
Necessary on cygwin, where uid_t and gid_t are 4-byte long rather
than int, causing gcc -Wformat warnings.
* src/util/util.c (virFileOperationNoFork, virDirCreateNoFork)
(virFileOperation, virDirCreate, virGetUserEnt): Cast uid_t and
gid_t before passing to printf.
* .gitignore: Ignore cygwin executables.
---
.gitignore | 1 +
src/util/util.c | 21 ++++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8c275f4..4faf384 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
*#*#
*.#*#
*.a
+*.exe
*.o
*.orig
*.rej
diff --git a/src/util/util.c b/src/util/util.c
index 3209185..0c5a22b 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -74,11 +74,14 @@
#include "util.h"
#include "memory.h"
#include "threads.h"
+#include "verify.h"
#ifndef NSIG
# define NSIG 32
#endif
+verify(sizeof (gid_t) <= sizeof (int) && sizeof (uid_t) <= sizeof (int));
+
#define VIR_FROM_THIS VIR_FROM_NONE
#define virUtilError(code, ...) \
@@ -1277,7 +1280,7 @@ static int virFileOperationNoFork(const char *path, int openflags, mode_t mode,
&& (fchown(fd, uid, gid) < 0)) {
ret = errno;
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
- path, uid, gid);
+ path, (int) uid, (int) gid);
goto error;
}
if ((flags & VIR_FILE_OP_FORCE_PERMS)
@@ -1328,7 +1331,7 @@ static int virDirCreateNoFork(const char *path, mode_t mode, uid_t uid, gid_t gi
&& (chown(path, uid, gid) < 0)) {
ret = errno;
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
- path, uid, gid);
+ path, (int) uid, (int) gid);
goto error;
}
if ((flags & VIR_DIR_CREATE_FORCE_PERMS)
@@ -1407,14 +1410,14 @@ parenterror:
ret = errno;
virReportSystemError(errno,
_("cannot set gid %u creating '%s'"),
- gid, path);
+ (int) gid, path);
goto childerror;
}
if ((uid != 0) && (setuid(uid) != 0)) {
ret = errno;
virReportSystemError(errno,
_("cannot set uid %u creating '%s'"),
- uid, path);
+ (int) uid, path);
goto childerror;
}
if ((fd = open(path, openflags, mode)) < 0) {
@@ -1436,7 +1439,7 @@ parenterror:
&& (fchown(fd, -1, gid) < 0)) {
ret = errno;
virReportSystemError(errno, _("cannot chown '%s' to (%u, %u)"),
- path, uid, gid);
+ path, (int) uid, (int) gid);
goto childerror;
}
if ((flags & VIR_FILE_OP_FORCE_PERMS)
@@ -1517,13 +1520,13 @@ parenterror:
if ((gid != 0) && (setgid(gid) != 0)) {
ret = errno;
virReportSystemError(errno, _("cannot set gid %u creating '%s'"),
- gid, path);
+ (int) gid, path);
goto childerror;
}
if ((uid != 0) && (setuid(uid) != 0)) {
ret = errno;
virReportSystemError(errno, _("cannot set uid %u creating '%s'"),
- uid, path);
+ (int) uid, path);
goto childerror;
}
if (mkdir(path, mode) < 0) {
@@ -1547,7 +1550,7 @@ parenterror:
ret = errno;
virReportSystemError(errno,
_("cannot chown '%s' to group %u"),
- path, gid);
+ path, (int) gid);
goto childerror;
}
if ((flags & VIR_DIR_CREATE_FORCE_PERMS)
@@ -2564,7 +2567,7 @@ static char *virGetUserEnt(uid_t uid,
if (getpwuid_r(uid, &pwbuf, strbuf, strbuflen, &pw) != 0 || pw == NULL) {
virReportSystemError(errno,
_("Failed to find user record for uid '%d'"),
- uid);
+ (int) uid);
VIR_FREE(strbuf);
return NULL;
}
--
1.6.6.1
14 years, 6 months
[libvirt] [PATCH] dnsmasqReload: avoid mingw link failure
by Eric Blake
* src/util/dnsmasq.c (dnsmasqReload): Mingw lacks kill, but is not
running a dnsmasq daemon either.
---
I'm not as familiar with the mingw cross-build setup, but I finally
got enough pieces installed on my F-12 machine that this was the only
remaining compilation failure that I ran into. Let me know if we need
an alternate patch that solves dnsmasq more gracefully than just
crippling one function.
src/util/dnsmasq.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/util/dnsmasq.c b/src/util/dnsmasq.c
index 1cb5f21..d6cef40 100644
--- a/src/util/dnsmasq.c
+++ b/src/util/dnsmasq.c
@@ -328,14 +328,16 @@ dnsmasqDelete(const dnsmasqContext *ctx)
* Reloads all the configurations associated to a context
*/
int
-dnsmasqReload(pid_t pid)
+dnsmasqReload(pid_t pid ATTRIBUTE_UNUSED)
{
+#ifndef __MINGW32__
if (kill(pid, SIGHUP) != 0) {
virReportSystemError(errno,
_("Failed to make dnsmasq (PID: %d) reload config files.\n"),
pid);
return -1;
}
+#endif /* __MINGW32__ */
return 0;
}
--
1.6.6.1
14 years, 6 months
[libvirt] [PATCH] nwfilter: pass info where request stems from to have rules applied
by Stefan Berger
For the decision on whether to instantiate the rules, the check for a
pending IP address learn request is not sufficient since then only the
thread could instantiate the rules. So, a boolean needs to be passed
when the thread instantiates the filter rules late and the IP address
learn request is still pending in order to override the check for the
pending learn request. If the rules are to be updated while the thread
is active, this will not be done immediately but the thread will do that
later on.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
src/nwfilter/nwfilter_gentech_driver.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
@@ -543,6 +543,8 @@ virNWFilterRuleInstancesToArray(int nEnt
* @ifname: The name of the interface to apply the rules to
* @vars: A map holding variable names and values used for instantiating
* the filter and its subfilters.
+ * @forceWithPendingReq: Ignore the check whether a pending learn request
+ * is active; 'true' only when the rules are applied late
*
* Returns 0 on success, a value otherwise.
*
@@ -563,7 +565,8 @@ virNWFilterInstantiate(virConnectPtr con
enum instCase useNewFilter, int *foundNewFilter,
bool teardownOld,
const unsigned char *macaddr,
- virNWFilterDriverStatePtr driver)
+ virNWFilterDriverStatePtr driver,
+ bool forceWithPendingReq)
{
int rc;
int j, nptrs;
@@ -610,7 +613,8 @@ virNWFilterInstantiate(virConnectPtr con
} else if (virHashSize(missing_vars->hashTable) > 1) {
rc = 1;
goto err_exit;
- } else if (virNWFilterLookupLearnReq(ifindex) == NULL) {
+ } else if (!forceWithPendingReq &&
+ virNWFilterLookupLearnReq(ifindex) != NULL) {
goto err_exit;
}
@@ -688,7 +692,8 @@ __virNWFilterInstantiateFilter(virConnec
const char *filtername,
virNWFilterHashTablePtr filterparams,
enum instCase useNewFilter,
- virNWFilterDriverStatePtr driver)
+ virNWFilterDriverStatePtr driver,
+ bool forceWithPendingReq)
{
int rc;
const char *drvname = EBIPTABLES_DRIVER_ID;
@@ -789,7 +794,8 @@ __virNWFilterInstantiateFilter(virConnec
useNewFilter, &foundNewFilter,
teardownOld,
macaddr,
- driver);
+ driver,
+ forceWithPendingReq);
virNWFilterHashTableFree(vars);
@@ -830,7 +836,8 @@ _virNWFilterInstantiateFilter(virConnect
net->filter,
net->filterparams,
useNewFilter,
- conn->nwfilterPrivateData);
+ conn->nwfilterPrivateData,
+ false);
}
@@ -856,7 +863,8 @@ virNWFilterInstantiateFilterLate(virConn
filtername,
filterparams,
INSTANTIATE_ALWAYS,
- driver);
+ driver,
+ true);
if (rc) {
//something went wrong... 'DOWN' the interface
if (ifaceCheck(false, ifname, NULL, ifindex) != 0 ||
14 years, 6 months
[libvirt] [PATCH] cgroup: Fix possible memory leak in virCgroupMakeGroup
by Ryota Ozaki
* src/util/cgroup.c: free temporal path string before breaking loop
---
src/util/cgroup.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index b649c3c..b8b2eb5 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -472,8 +472,10 @@ static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group, int creat
(i == VIR_CGROUP_CONTROLLER_CPUSET ||
STREQ(group->controllers[i].mountPoint, group->controllers[VIR_CGROUP_CONTROLLER_CPUSET].mountPoint))) {
rc = virCgroupCpuSetInherit(parent, group);
- if (rc != 0)
+ if (rc != 0) {
+ VIR_FREE(path);
break;
+ }
}
}
--
1.6.5.2
14 years, 6 months
[libvirt] [PATCH] dnsmasq.c: Fix OOM error reporting
by Matthias Bolte
Also do some indentation clean up.
---
src/util/dnsmasq.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/util/dnsmasq.c b/src/util/dnsmasq.c
index 1cb5f21..2d57884 100644
--- a/src/util/dnsmasq.c
+++ b/src/util/dnsmasq.c
@@ -84,12 +84,12 @@ hostsfileAdd(dnsmasqHostsfile *hostsfile,
if (name) {
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host, "%s,%s,%s",
- mac, ip, name) < 0) {
+ mac, ip, name) < 0) {
goto alloc_error;
}
} else {
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host, "%s,%s",
- mac, ip) < 0) {
+ mac, ip) < 0) {
goto alloc_error;
}
}
@@ -99,9 +99,8 @@ hostsfileAdd(dnsmasqHostsfile *hostsfile,
return 0;
alloc_error:
- virReportSystemError(ENOMEM,
- _("Failed to add dhcp host entry: mac=%s, ip=%s, name=%s\n"),
- mac, ip, (name ? name : "(null)"));
+ virReportOOMError();
+
return -1;
}
@@ -112,20 +111,23 @@ hostsfileNew(const char *name,
int err;
dnsmasqHostsfile *hostsfile;
- if (VIR_ALLOC(hostsfile) < 0)
+ if (VIR_ALLOC(hostsfile) < 0) {
+ virReportOOMError();
return NULL;
+ }
hostsfile->hosts = NULL;
hostsfile->nhosts = 0;
if (virAsprintf(&hostsfile->path, "%s/%s.%s", config_dir, name,
- DNSMASQ_HOSTSFILE_SUFFIX) < 0) {
+ DNSMASQ_HOSTSFILE_SUFFIX) < 0) {
+ virReportOOMError();
goto error;
}
if ((err = virFileMakePath(config_dir))) {
virReportSystemError(err, _("cannot create config directory '%s'"),
- config_dir);
+ config_dir);
goto error;
}
@@ -201,11 +203,11 @@ static int
hostsfileSave(dnsmasqHostsfile *hostsfile)
{
int err = hostsfileWrite(hostsfile->path, hostsfile->hosts,
- hostsfile->nhosts);
+ hostsfile->nhosts);
if (err < 0) {
virReportSystemError(err, _("cannot write config file '%s'"),
- hostsfile->path);
+ hostsfile->path);
return -1;
}
@@ -220,7 +222,7 @@ hostsfileDelete(dnsmasqHostsfile *hostsfile)
if (unlink(hostsfile->path) < 0) {
virReportSystemError(errno, _("cannot remove config file '%s'"),
- hostsfile->path);
+ hostsfile->path);
return -1;
}
@@ -240,8 +242,10 @@ dnsmasqContextNew(const char *network_name,
{
dnsmasqContext *ctx;
- if (VIR_ALLOC(ctx) < 0)
+ if (VIR_ALLOC(ctx) < 0) {
+ virReportOOMError();
return NULL;
+ }
if (!(ctx->hostsfile = hostsfileNew(network_name, config_dir)))
goto error;
--
1.7.0.4
14 years, 6 months
[libvirt] [PATCH] mingw: Fix symbol export
by Matthias Bolte
In commit 98fb83ce25f46e0236706fa6e0943032d921935f I changed the
version script handling. But it seems that I didn't test this properly
and broke it. The .def file is passed to the compiler directly, but it
should get passed to the linker instead.
Set VERSION_SCRIPT_FLAGS to -Wl, to pass the .def file correctly to
the linker.
This fixes the undefined symbol errors while linking virsh.
---
configure.ac | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index f25e173..6ee5b90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -78,7 +78,6 @@ AM_PROG_LD
VERSION_SCRIPT_FLAGS=-Wl,--version-script=
`$LD --help 2>&1 | grep -- --version-script >/dev/null` || \
VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
-AC_SUBST(VERSION_SCRIPT_FLAGS)
LIBVIRT_COMPILE_WARNINGS([maximum])
@@ -1824,10 +1823,11 @@ case "$host" in
# from libvirt.syms and passes libvirt.def instead of libvirt.syms to the linker
LIBVIRT_SYMBOL_FILE=libvirt.def
# mingw's ld has the --version-script parameter, but it requires a .def file
- # instead to work properly, therefore clear --version-script here
+ # instead to work properly, therefore clear --version-script here and use
+ # -Wl, to pass the .def file to the linker
# cygwin's ld has the --version-script parameter too, but for some reason
# it's working there as expected
- VERSION_SCRIPT_FLAGS=
+ VERSION_SCRIPT_FLAGS="-Wl,"
;;
esac
AC_SUBST([CYGWIN_EXTRA_LDFLAGS])
@@ -1836,6 +1836,7 @@ AC_SUBST([CYGWIN_EXTRA_PYTHON_LIBADD])
AC_SUBST([MINGW_EXTRA_LDFLAGS])
AC_SUBST([WIN32_EXTRA_CFLAGS])
AC_SUBST([LIBVIRT_SYMBOL_FILE])
+AC_SUBST([VERSION_SCRIPT_FLAGS])
dnl Look for windres to build a Windows icon resource.
--
1.7.0.4
14 years, 6 months