]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu_namespace: Fix detection of nested mount points
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 3 Jan 2023 14:51:42 +0000 (15:51 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 5 Jan 2023 11:57:56 +0000 (12:57 +0100)
When deciding whether to bind mount a path in domain's namespace,
we look at the QEMU mount table (/proc/$pid/mounts) and try to
match prefix of given path with one of mount points. Well, we
do that in a bit clumsy way. For instance, if there's
"/dev/hugepages" already mounted inside the namespace and we are
deciding whether to bind mount "/dev/hugepages1G/..." we decide
to skip over the path and NOT bind mount it. This is because
plain STRPREFIX() is used and yes, the former is prefix of the
latter. What we need to check also is whether the next character
after the prefix is slash.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_namespace.c

index fb79460109151c6e58f3819d2d54fe043fe9eb39..fc348c043edd2189e8d21d2ed6c1abfac6836173 100644 (file)
@@ -1264,9 +1264,11 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData *data,
             bool found = false;
 
             for (n = devMountsPath; n && *n; n++) {
+                const char *p;
+
                 if (STREQ(*n, "/dev"))
                     continue;
-                if (STRPREFIX(item.file, *n)) {
+                if ((p = STRSKIP(item.file, *n)) && *p == '/') {
                     found = true;
                     break;
                 }