Hi,

I've noticed a couple of issues in the block script check_sharing
function.  Right now, loopback file can be assigned multiple times to
multiple VMs.

The first issue is `stat -c '%D'` is used to get the device number of
the file in hexadecimal, but losetup prints the device number as
decimal.

$ sudo losetup /dev/loop1
/dev/loop1: [64770]:84856 (/svr/raw.img)
$ stat -c %d /svr/raw.img
64770
$ stat -c %D /svr/raw.img
fd02

I found this on CentOS7, but it looks like losetup has returned
decimal since 2011.
https://github.com/karelzak/util-linux/commits/39fde1373d9f888b686fc8f780c05ba4091c70bd
changed from show_loop_fd using PRIx64 to printf_loopdev with "%04d".

The second I'm not sure how to correct.  Hence this email instead of a patch.

When a loop device is created, the loopdev's major:minor is stored
into the physical-device node.  When check_sharing iterates through
the physical-device nodes, it is using the file's major:minor.  So
even though /dev/loop0 already exists pointing to a given file, it
doesn't get matched.  It seems like files should be handled in terms
of block-device & filepath/inode separately from the blockdevice
major:minor.  Maybe check_sharing needs to match the losetup output
against the files paths when creating devmm?

Regards,
Jason

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to