diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 23b9c6c1387e101a1dd6fcb8ad9d5a9f4473b6d7..8c361058957eae92d1c0818d9d3d1bcfa77ec4de 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8222,7 +8222,9 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr cfg,
     for (i = 1; i < nmounts; i++) {
         j = i + 1;
         while (j < nmounts) {
-            if (STRPREFIX(mounts[j], mounts[i])) {
+            char *c = STRSKIP(mounts[j], mounts[i]);
+
+            if (c && *c == '/') {
                 VIR_DEBUG("Dropping path %s because of %s", mounts[j], mounts[i]);
                 VIR_DELETE_ELEMENT(mounts, j, nmounts);
             } else {