mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
qemu-ns: Detect /dev/* mount point duplicates better
https://bugzilla.redhat.com/show_bug.cgi?id=1495511 When creating new /dev for domain ran in namespace we try to preserve all sub-mounts of /dev. Well, not quite all. For instance if /dev/foo/bar and /dev/foo are both mount points, only /dev/foo needs preserving. /dev/foo/bar is preserved with it too. Now, to identify such cases like this one STRPREFIX() is used. That is not good enough. While it works for [/dev/foo/bar; /dev/foo] case, it fails for [/dev/prefix; /dev/prefix2] where the strings share the same prefix but are in fact two different paths. The solution is to use STRSKIP(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
eebfdcb41e
commit
4f15707202
@ -8222,7 +8222,9 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr cfg,
|
|||||||
for (i = 1; i < nmounts; i++) {
|
for (i = 1; i < nmounts; i++) {
|
||||||
j = i + 1;
|
j = i + 1;
|
||||||
while (j < nmounts) {
|
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_DEBUG("Dropping path %s because of %s", mounts[j], mounts[i]);
|
||||||
VIR_DELETE_ELEMENT(mounts, j, nmounts);
|
VIR_DELETE_ELEMENT(mounts, j, nmounts);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user