[libvirt] [PATCH] util: fix mount issue by moving NULL value to "none" in syscall.

Julio Faracco jcfaracco at gmail.com
Tue Jun 26 03:18:21 UTC 2018


After running libvirt daemon with valgrind tools, some errors are
appearing when you try to start a domain. One example:

==18012== Syscall param mount(type) points to unaddressable byte(s)
==18012==    at 0x6FEE3CA: mount (syscall-template.S:78)
==18012==    by 0x531344D: virFileMoveMount (virfile.c:3828)
==18012==    by 0x27FE7675: qemuDomainBuildNamespace (qemu_domain.c:11501)
==18012==    by 0x2800C44E: qemuProcessHook (qemu_process.c:2870)
==18012==    by 0x52F7E1D: virExec (vircommand.c:726)
==18012==    by 0x52F7E1D: virCommandRunAsync (vircommand.c:2477)
==18012==    by 0x52F4EDD: virCommandRun (vircommand.c:2309)
==18012==    by 0x2800A731: qemuProcessLaunch (qemu_process.c:6235)
==18012==    by 0x2800D6B4: qemuProcessStart (qemu_process.c:6569)
==18012==    by 0x28074876: qemuDomainObjStart (qemu_driver.c:7314)
==18012==    by 0x280522EB: qemuDomainCreateWithFlags (qemu_driver.c:7367)
==18012==    by 0x55484BF: virDomainCreate (libvirt-domain.c:6531)
==18012==    by 0x12CDBD: remoteDispatchDomainCreate (remote_daemon_dispatch_stubs.h:4350)
==18012==    by 0x12CDBD: remoteDispatchDomainCreateHelper (remote_daemon_dispatch_stubs.h:4326)
==18012==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

Some documentation recommends to use "none" when you don't have a
filesystem type to use. Specially, for bind and move actions.

Signed-off-by: Julio Faracco <jcfaracco at gmail.com>
---
 src/util/virfile.c    | 2 +-
 src/util/virprocess.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index 9296ccbe2a..378d03ecf0 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -3825,7 +3825,7 @@ virFileMoveMount(const char *src,
 {
     const unsigned long mount_flags = MS_MOVE;
 
-    if (mount(src, dst, NULL, mount_flags, NULL) < 0) {
+    if (mount(src, dst, "none", mount_flags, NULL) < 0) {
         virReportSystemError(errno,
                              _("Unable to move %s mount to %s"),
                              src, dst);
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 1fbbbb3a27..f92b0dce37 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -1181,7 +1181,7 @@ virProcessSetupPrivateMountNS(void)
         goto cleanup;
     }
 
-    if (mount("", "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) {
+    if (mount("", "/", "none", MS_SLAVE|MS_REC, NULL) < 0) {
         virReportSystemError(errno, "%s",
                              _("Failed to switch root mount into slave mode"));
         goto cleanup;
-- 
2.17.1




More information about the libvir-list mailing list