[libvirt] [PATCH] qemu-ns: Detect /dev/* mount point duplicates even better

Michal Privoznik posted 1 patch 6 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/262e3d77e46564bbd7ac73297fa4839422703e79.1510153797.git.mprivozn@redhat.com
src/qemu/qemu_domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] qemu-ns: Detect /dev/* mount point duplicates even better
Posted by Michal Privoznik 6 years, 5 months ago
In 4f1570720218302 I've tried to make duplicates detection for
nested /dev mount better. However, I've missed the obvious case
when there are two same mount points. For instance if:

  # mount --bind /dev/blah /dev/blah
  # mount --bind /dev/blah /dev/blah

Yeah, very unlikely but possible.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 702463547..61d28337b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8352,7 +8352,7 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr cfg,
         while (j < nmounts) {
             char *c = STRSKIP(mounts[j], mounts[i]);
 
-            if (c && *c == '/') {
+            if (c && (*c == '/' || *c == '\0')) {
                 VIR_DEBUG("Dropping path %s because of %s", mounts[j], mounts[i]);
                 VIR_DELETE_ELEMENT(mounts, j, nmounts);
             } else {
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu-ns: Detect /dev/* mount point duplicates even better
Posted by Daniel P. Berrange 6 years, 5 months ago
On Wed, Nov 08, 2017 at 04:09:57PM +0100, Michal Privoznik wrote:
> In 4f1570720218302 I've tried to make duplicates detection for
> nested /dev mount better. However, I've missed the obvious case
> when there are two same mount points. For instance if:
> 
>   # mount --bind /dev/blah /dev/blah
>   # mount --bind /dev/blah /dev/blah
> 
> Yeah, very unlikely but possible.

It isn't all that unlikely - libvirt itself sets up mounts just like
that for LXC containers it spawns :-)

> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_domain.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 702463547..61d28337b 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -8352,7 +8352,7 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr cfg,
>          while (j < nmounts) {
>              char *c = STRSKIP(mounts[j], mounts[i]);
>  
> -            if (c && *c == '/') {
> +            if (c && (*c == '/' || *c == '\0')) {
>                  VIR_DEBUG("Dropping path %s because of %s", mounts[j], mounts[i]);
>                  VIR_DELETE_ELEMENT(mounts, j, nmounts);
>              } else {
> -- 
> 2.13.6
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu-ns: Detect /dev/* mount point duplicates even better
Posted by Ján Tomko 6 years, 5 months ago
On Wed, Nov 08, 2017 at 04:09:57PM +0100, Michal Privoznik wrote:
>In 4f1570720218302 I've tried to make duplicates detection for
>nested /dev mount better. However, I've missed the obvious case
>when there are two same mount points. For instance if:
>
>  # mount --bind /dev/blah /dev/blah
>  # mount --bind /dev/blah /dev/blah
>
>Yeah, very unlikely but possible.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/qemu/qemu_domain.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>

ACK with the likeliness comment removed from the commit message

Jan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list