]> xenbits.xensource.com Git - libvirt.git/commit
virDevMapperGetTargetsImpl: Check for dm major properly
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 11 Jun 2020 10:14:33 +0000 (12:14 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Jun 2020 12:50:46 +0000 (14:50 +0200)
commitd53ab9f54ea8d6cc1e5c3b04c4eb743cae9518ce
tree73cc51807518bc9ac42034b124f30660b7dea05b
parentdfa0e118f745fe3f4fe95975c6100f0fc6d788be
virDevMapperGetTargetsImpl: Check for dm major properly

In v6.4.0-rc1~143 I've introduced a check that is supposed to
return from the function early, if given path is not a dm target.
While the idea is still valid, the implementation had a flaw.
It calls stat() over given path and the uses major(sb.st_dev) to
learn the major of the device. This is then passed to
dm_is_dm_major() which returns true or false depending whether
the device is under devmapper's control or not.

The problem with this approach is in how the major of the device
is obtained - paths managed by devmapper are special files and
thus we want to be using st_rdev instead of st_dev to obtain the
major number. Well, that's what virIsDevMapperDevice() does
already so might as well us that.

Fixes: 01626c668ecfbe465d18799ac4628e6127ea1d47
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1839992

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/util/virdevmapper.c