[libvirt] [PATCH 0/5] Couple of LXC fixes & improvements

*** BLURB HERE *** Michal Prívozník (5): lxc: Refresh capabilities on virConnectGetCapabilities lxc: Report supported huge pages lxc: Enable under valgrind again lxc: Don't leak @veths in virLXCProcessStart lxc: Don't mangle @cfg refs in virLXCProcessBuildControllerCmd src/lxc/lxc_conf.c | 4 ++++ src/lxc/lxc_driver.c | 13 +------------ src/lxc/lxc_process.c | 15 +++++++++------ 3 files changed, 14 insertions(+), 18 deletions(-) -- 2.16.4

While not as critical as in qemu driver, there are still some runtime information we report in capabilities XML that might change throughout time. For instance, onlined CPUs (which affects reported L3 cache sizes). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 9b329269a9..6969dddcab 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -205,7 +205,7 @@ static char *lxcConnectGetCapabilities(virConnectPtr conn) { if (virConnectGetCapabilitiesEnsureACL(conn) < 0) return NULL; - if (!(caps = virLXCDriverGetCapabilities(driver, false))) + if (!(caps = virLXCDriverGetCapabilities(driver, true))) return NULL; xml = virCapabilitiesFormatXML(caps); -- 2.16.4

On Wed, Jul 25, 2018 at 03:02:07PM +0200, Michal Privoznik wrote:
While not as critical as in qemu driver, there are still some runtime information we report in capabilities XML that might change throughout time. For instance, onlined CPUs (which affects reported L3 cache sizes).
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 9b329269a9..6969dddcab 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -205,7 +205,7 @@ static char *lxcConnectGetCapabilities(virConnectPtr conn) { if (virConnectGetCapabilitiesEnsureACL(conn) < 0) return NULL;
- if (!(caps = virLXCDriverGetCapabilities(driver, false))) + if (!(caps = virLXCDriverGetCapabilities(driver, true)))
I'm curious why we don't need to refresh the capabilities for stateReload as well, but we don't do that for QEMU either. The patch is fine, but if someone could educate me here, I'd be glad. Reviewed-by: Erik Skultety <eskultet@redhat.com>

There are two places where we report supported sizes of huge pages: /capabilities/host/cpu/pages /capabilities/host/topology/cells/cell/pages The former aggregates sizes over all NUMA nodes while the latter reports supported sizes only for given node. While we are reporting per NUMA node sizes we are not reporting the aggregated sizes. I've noticed this when wondering why doesn't allocpages completer work. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_conf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 5cd6f231dd..949bfe246a 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -86,6 +86,10 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) if (driver && virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0) VIR_WARN("Failed to get host power management capabilities"); + /* Add huge pages info */ + if (virCapabilitiesInitPages(caps) < 0) + VIR_WARN("Failed to get pages info"); + if (virGetHostUUID(caps->host.host_uuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot get the host uuid")); -- 2.16.4

On Wed, Jul 25, 2018 at 03:02:08PM +0200, Michal Privoznik wrote:
There are two places where we report supported sizes of huge pages:
/capabilities/host/cpu/pages /capabilities/host/topology/cells/cell/pages
The former aggregates sizes over all NUMA nodes while the latter reports supported sizes only for given node. While we are reporting per NUMA node sizes we are not reporting the aggregated sizes. I've noticed this when wondering why doesn't allocpages completer work.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_conf.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 5cd6f231dd..949bfe246a 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -86,6 +86,10 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver) if (driver && virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0) VIR_WARN("Failed to get host power management capabilities");
+ /* Add huge pages info */ + if (virCapabilitiesInitPages(caps) < 0) + VIR_WARN("Failed to get pages info"); + if (virGetHostUUID(caps->host.host_uuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot get the host uuid"));
Reviewed-by: Erik Skultety <eskultet@redhat.com>

So we originally disabled LXC driver when libvirtd is running under valgrind back in 05436ab7ff087 (which dates to beginning of 2009) as it was causing valgrind to crash. It's not the case anymore. Valgrind works with LXC happily. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_driver.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 6969dddcab..8867645cdc 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1550,19 +1550,8 @@ static int lxcStateInitialize(bool privileged, void *opaque ATTRIBUTE_UNUSED) { virCapsPtr caps = NULL; - const char *ld; virLXCDriverConfigPtr cfg = NULL; - /* Valgrind gets very annoyed when we clone containers, so - * disable LXC when under valgrind - * XXX remove this when valgrind is fixed - */ - ld = virGetEnvBlockSUID("LD_PRELOAD"); - if (ld && strstr(ld, "vgpreload")) { - VIR_INFO("Running under valgrind, disabling driver"); - return 0; - } - /* Check that the user is root, silently disable if not */ if (!privileged) { VIR_INFO("Not running privileged, disabling driver"); -- 2.16.4

On Wed, Jul 25, 2018 at 03:02:09PM +0200, Michal Privoznik wrote:
So we originally disabled LXC driver when libvirtd is running under valgrind back in 05436ab7ff087 (which dates to beginning of 2009) as it was causing valgrind to crash. It's not the case anymore. Valgrind works with LXC happily.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- Reviewed-by: Erik Skultety <eskultet@redhat.com>

The individual strings are freed, but the array is never freed. 8 bytes in 1 blocks are definitely lost in loss record 28 of 1,098 at 0x4C2CE3F: malloc (vg_replace_malloc.c:298) by 0x4C2F1BF: realloc (vg_replace_malloc.c:785) by 0x52C9C92: virReallocN (viralloc.c:245) by 0x52C9D88: virExpandN (viralloc.c:294) by 0x23414D99: virLXCProcessSetupInterfaces (lxc_process.c:552) by 0x23417457: virLXCProcessStart (lxc_process.c:1356) by 0x2341F71C: lxcDomainCreateWithFiles (lxc_driver.c:1088) by 0x2341F805: lxcDomainCreate (lxc_driver.c:1123) by 0x55917EB: virDomainCreate (libvirt-domain.c:6534) by 0x1367D1: remoteDispatchDomainCreate (remote_daemon_dispatch_stubs.h:4434) by 0x1366EA: remoteDispatchDomainCreateHelper (remote_daemon_dispatch_stubs.h:4410) by 0x546FDF1: virNetServerProgramDispatchCall (virnetserverprogram.c:437) Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_process.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 14502e12fe..3e44da1aaf 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1559,6 +1559,7 @@ int virLXCProcessStart(virConnectPtr conn, virCommandFree(cmd); for (i = 0; i < nveths; i++) VIR_FREE(veths[i]); + VIR_FREE(veths); for (i = 0; i < nttyFDs; i++) VIR_FORCE_CLOSE(ttyFDs[i]); VIR_FREE(ttyFDs); -- 2.16.4

On Wed, Jul 25, 2018 at 03:02:10PM +0200, Michal Privoznik wrote:
The individual strings are freed, but the array is never freed.
8 bytes in 1 blocks are definitely lost in loss record 28 of 1,098 at 0x4C2CE3F: malloc (vg_replace_malloc.c:298) by 0x4C2F1BF: realloc (vg_replace_malloc.c:785) by 0x52C9C92: virReallocN (viralloc.c:245) by 0x52C9D88: virExpandN (viralloc.c:294) by 0x23414D99: virLXCProcessSetupInterfaces (lxc_process.c:552) by 0x23417457: virLXCProcessStart (lxc_process.c:1356) by 0x2341F71C: lxcDomainCreateWithFiles (lxc_driver.c:1088) by 0x2341F805: lxcDomainCreate (lxc_driver.c:1123) by 0x55917EB: virDomainCreate (libvirt-domain.c:6534) by 0x1367D1: remoteDispatchDomainCreate (remote_daemon_dispatch_stubs.h:4434) by 0x1366EA: remoteDispatchDomainCreateHelper (remote_daemon_dispatch_stubs.h:4410) by 0x546FDF1: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_process.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 14502e12fe..3e44da1aaf 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1559,6 +1559,7 @@ int virLXCProcessStart(virConnectPtr conn, virCommandFree(cmd); for (i = 0; i < nveths; i++) VIR_FREE(veths[i]); + VIR_FREE(veths);
Hmm, I'll use this patch to promote the recent (ongoing) work on __attribute__(cleanup), would you mind converting veths into a NULL-terminated list so that we could use VIR_AUTOPTR(virString) veths = NULL and thus drop the manual cleanup? Bonus points if you add a follow-up patch. Reviewed-by: Erik Skultety <eskultet@redhat.com>

The config object is refed but unrefed only on error which leaves refcount unbalanced on successful return. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/lxc/lxc_process.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 3e44da1aaf..d021a890f7 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -931,7 +931,7 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver, filterstr = virLogGetFilters(); if (!filterstr) { virReportOOMError(); - goto cleanup; + goto error; } virCommandAddEnvPair(cmd, "LIBVIRT_LOG_FILTERS", filterstr); @@ -943,7 +943,7 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver, outputstr = virLogGetOutputs(); if (!outputstr) { virReportOOMError(); - goto cleanup; + goto error; } virCommandAddEnvPair(cmd, "LIBVIRT_LOG_OUTPUTS", outputstr); @@ -973,7 +973,7 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver, char *tmp = NULL; if (virAsprintf(&tmp, "--share-%s", nsInfoLocal[i]) < 0) - goto cleanup; + goto error; virCommandAddArg(cmd, tmp); virCommandAddArgFormat(cmd, "%d", nsInheritFDs[i]); virCommandPassFD(cmd, nsInheritFDs[i], 0); @@ -999,11 +999,13 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver, * write the live domain status XML with the PID */ virCommandRequireHandshake(cmd); + cleanup: + virObjectUnref(cfg); return cmd; - cleanup: + error: virCommandFree(cmd); - virObjectUnref(cfg); - return NULL; + cmd = NULL; + goto cleanup; } -- 2.16.4

On Wed, Jul 25, 2018 at 03:02:11PM +0200, Michal Privoznik wrote:
The config object is refed but unrefed only on error which leaves refcount unbalanced on successful return.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- Reviewed-by: Erik Skultety <eskultet@redhat.com>
participants (2)
-
Erik Skultety
-
Michal Privoznik