[guestfs-tools PATCH 0/3] test "/dev/mapper/VG-LV" with "--key"
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506 This small set covers the new /dev/mapper/VG-LV "--key" ID format in the LUKS-on-LVM virt-inspector test. Thanks, Laszlo Laszlo Ersek (3): update common submodule inspector: rename VGs and LVs in LUKS-on-LVM test inspector: test /dev/mapper/VG-LV translation in LUKS-on-LVM test common | 2 +- inspector/test-virt-inspector-luks-on-lvm.sh | 22 ++++++++++---- test-data/phony-guests/make-fedora-img.pl | 30 +++++++++++--------- 3 files changed, 35 insertions(+), 19 deletions(-) base-commit: 67647b883e1373623212d6b9fae5098135fd5efe
Laszlo Ersek (2): options/keys: key_store_import_key(): un-constify "key" parameter options/keys: introduce unescape_device_mapper_lvm() Richard W.M. Jones (1): mlcustomize/SELinux_relabel.ml: Use Array.mem Roman Kagan (1): mlcustomize: skip SELinux relabeling if it's disabled Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common b/common index 70c10a079a30..b636c3f20a1b 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 70c10a079a30ff3a84f38596d725a6c5d46e2470 +Subproject commit b636c3f20a1b8d1a6a75f33dcb1fd931c95c5e00
In preparation for a subsequent patch, rename "VG" to "Volume-Group", and "LV<n>" to "Logical-Volume-<n>", in the LUKS-on-LVM virt-inspector test. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- inspector/test-virt-inspector-luks-on-lvm.sh | 11 +++---- test-data/phony-guests/make-fedora-img.pl | 30 +++++++++++--------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/inspector/test-virt-inspector-luks-on-lvm.sh b/inspector/test-virt-inspector-luks-on-lvm.sh index b9989433da85..35454e630d3d 100755 --- a/inspector/test-virt-inspector-luks-on-lvm.sh +++ b/inspector/test-virt-inspector-luks-on-lvm.sh @@ -36,14 +36,15 @@ if [ "$(guestfish version | grep minor | awk '{print $2}')" -lt 47 ]; then fi f=../test-data/phony-guests/fedora-luks-on-lvm.img -keys=(--key /dev/VG/Root:key:FEDORA-Root - --key /dev/VG/LV1:key:FEDORA-LV1 - --key /dev/VG/LV2:key:FEDORA-LV2 - --key /dev/VG/LV3:key:FEDORA-LV3) +keys=(--key /dev/Volume-Group/Root:key:FEDORA-Root + --key /dev/Volume-Group/Logical-Volume-1:key:FEDORA-LV1 + --key /dev/Volume-Group/Logical-Volume-2:key:FEDORA-LV2 + --key /dev/Volume-Group/Logical-Volume-3:key:FEDORA-LV3) # Ignore zero-sized file. if [ -s "$f" ]; then - uuid_root=$(guestfish --ro -i -a "$f" "${keys[@]}" luks-uuid /dev/VG/Root) + uuid_root=$(guestfish --ro -i -a "$f" "${keys[@]}" \ + luks-uuid /dev/Volume-Group/Root) b=$(basename "$f") $VG virt-inspector "${keys[@]}" --format=raw -a "$f" > "actual-$b.xml" # Check the generated output validate the schema. diff --git a/test-data/phony-guests/make-fedora-img.pl b/test-data/phony-guests/make-fedora-img.pl index ffa7e0f100bf..9721ce4a9dc9 100755 --- a/test-data/phony-guests/make-fedora-img.pl +++ b/test-data/phony-guests/make-fedora-img.pl @@ -224,23 +224,27 @@ EOF # Create the Volume Group on /dev/sda2. $g->pvcreate ('/dev/sda2'); - $g->vgcreate ('VG', ['/dev/sda2']); - $g->lvcreate ('Root', 'VG', 256); - $g->lvcreate ('LV1', 'VG', 32); - $g->lvcreate ('LV2', 'VG', 32); - $g->lvcreate ('LV3', 'VG', 64); + $g->vgcreate ('Volume-Group', ['/dev/sda2']); + $g->lvcreate ('Root', 'Volume-Group', 256); + $g->lvcreate ('Logical-Volume-1', 'Volume-Group', 32); + $g->lvcreate ('Logical-Volume-2', 'Volume-Group', 32); + $g->lvcreate ('Logical-Volume-3', 'Volume-Group', 64); # Format each Logical Group as a LUKS device, with a different password. - $g->luks_format ('/dev/VG/Root', 'FEDORA-Root', 0); - $g->luks_format ('/dev/VG/LV1', 'FEDORA-LV1', 0); - $g->luks_format ('/dev/VG/LV2', 'FEDORA-LV2', 0); - $g->luks_format ('/dev/VG/LV3', 'FEDORA-LV3', 0); + $g->luks_format ('/dev/Volume-Group/Root', 'FEDORA-Root', 0); + $g->luks_format ('/dev/Volume-Group/Logical-Volume-1', 'FEDORA-LV1', 0); + $g->luks_format ('/dev/Volume-Group/Logical-Volume-2', 'FEDORA-LV2', 0); + $g->luks_format ('/dev/Volume-Group/Logical-Volume-3', 'FEDORA-LV3', 0); # Open the LUKS devices. This creates nodes like /dev/mapper/*-luks. - $g->cryptsetup_open ('/dev/VG/Root', 'FEDORA-Root', 'Root-luks'); - $g->cryptsetup_open ('/dev/VG/LV1', 'FEDORA-LV1', 'LV1-luks'); - $g->cryptsetup_open ('/dev/VG/LV2', 'FEDORA-LV2', 'LV2-luks'); - $g->cryptsetup_open ('/dev/VG/LV3', 'FEDORA-LV3', 'LV3-luks'); + $g->cryptsetup_open ('/dev/Volume-Group/Root', + 'FEDORA-Root', 'Root-luks'); + $g->cryptsetup_open ('/dev/Volume-Group/Logical-Volume-1', + 'FEDORA-LV1', 'LV1-luks'); + $g->cryptsetup_open ('/dev/Volume-Group/Logical-Volume-2', + 'FEDORA-LV2', 'LV2-luks'); + $g->cryptsetup_open ('/dev/Volume-Group/Logical-Volume-3', + 'FEDORA-LV3', 'LV3-luks'); # Phony root filesystem. $g->mkfs ('ext2', '/dev/mapper/Root-luks', blocksize => 4096, label => 'ROOT');
In the LUKS-on-LVM virt-inspector test, run virt-inspector one more time, now with such "--key" options that exercise the recent "/dev/mapper/VG-LV" -> "/dev/VG/LV" translation (unescaping) from libguestfs-common. Verify that virt-inspector outputs the same XML as it did when we passed it the "/dev/VG/LV" format "--key" options. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168506 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- Notes: context:-U6 inspector/test-virt-inspector-luks-on-lvm.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/inspector/test-virt-inspector-luks-on-lvm.sh b/inspector/test-virt-inspector-luks-on-lvm.sh index 35454e630d3d..13b25e338a87 100755 --- a/inspector/test-virt-inspector-luks-on-lvm.sh +++ b/inspector/test-virt-inspector-luks-on-lvm.sh @@ -38,19 +38,30 @@ fi f=../test-data/phony-guests/fedora-luks-on-lvm.img keys=(--key /dev/Volume-Group/Root:key:FEDORA-Root --key /dev/Volume-Group/Logical-Volume-1:key:FEDORA-LV1 --key /dev/Volume-Group/Logical-Volume-2:key:FEDORA-LV2 --key /dev/Volume-Group/Logical-Volume-3:key:FEDORA-LV3) +keys_mapper=(--key /dev/mapper/Volume--Group-Root:key:FEDORA-Root + --key /dev/mapper/Volume--Group-Logical--Volume--1:key:FEDORA-LV1 + --key /dev/mapper/Volume--Group-Logical--Volume--2:key:FEDORA-LV2 + --key /dev/mapper/Volume--Group-Logical--Volume--3:key:FEDORA-LV3) + # Ignore zero-sized file. if [ -s "$f" ]; then uuid_root=$(guestfish --ro -i -a "$f" "${keys[@]}" \ luks-uuid /dev/Volume-Group/Root) b=$(basename "$f") $VG virt-inspector "${keys[@]}" --format=raw -a "$f" > "actual-$b.xml" # Check the generated output validate the schema. $XMLLINT --noout --relaxng "$srcdir/virt-inspector.rng" "actual-$b.xml" # This 'diff' command will fail (because of -e option) if there # are any differences. sed -e "s/ROOTUUID/$uuid_root/" < "$srcdir/expected-$b.xml" \ | diff -u - "actual-$b.xml" + + # Re-run virt-inspector with keys using the /dev/mapper/VG-LV format; verify + # only that the XML output matches the output from the previous + # virt-inspector invocation (which used the /dev/VG/LV format). + $VG virt-inspector "${keys_mapper[@]}" --format=raw -a "$f" \ + | diff -u "actual-$b.xml" - fi
For the series: Reviewed-by: Richard W.M. Jones <rjones@redhat.com> BTW it's usually possible to cherry pick across git repos, eg: $ git fetch ../libguestfs $ git cherry-pick -x <hash> Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
On 5/19/23 18:31, Richard W.M. Jones wrote:
For the series:
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Thanks! Commit range 67647b883e13..569bd1dd29da.
BTW it's usually possible to cherry pick across git repos, eg:
$ git fetch ../libguestfs $ git cherry-pick -x <hash>
Hm, good to know, thanks! I didn't know you could use git fetch this directly. Minimally I would have expected having to add a file:// scheme remote, before the fetch. In retrospect, the third paragraph of the git-fetch manual mentions "URL", and then the "GIT URLS" section mentions the example "/path/to/repo.git/". Too much documentation to read! :) Regarding the cherry-pick -- I wonder how helpful it could have been. Sometimes it is surprisingly clever, in resolving conflicts. This time I copied "make-fedora-img.pl" from the already modified project(s) to the next project, and used "git add -p" to review and stage the changes I wanted. And then I compared the candidate patch to the actual commit in the other (already modified) project(s), effectively looking at "interdiff"s. There was at least one surprise that way: see virt-v2v commit fd7cd0c0fd22 / guestfs-tools commit 21e051c0c846. We don't have the same in libguestfs (in fact I'd not been aware of guestfs-tools commit 21e051c0c846!), and now I didn't want to change the size of the Root LV -- there seemed to be no justification for that. Laszlo
On Mon, May 22, 2023 at 02:46:34PM +0200, Laszlo Ersek wrote:
On 5/19/23 18:31, Richard W.M. Jones wrote:
For the series:
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Thanks!
Commit range 67647b883e13..569bd1dd29da.
BTW it's usually possible to cherry pick across git repos, eg:
$ git fetch ../libguestfs $ git cherry-pick -x <hash>
Hm, good to know, thanks! I didn't know you could use git fetch this directly. Minimally I would have expected having to add a file:// scheme remote, before the fetch. In retrospect, the third paragraph of the git-fetch manual mentions "URL", and then the "GIT URLS" section mentions the example "/path/to/repo.git/". Too much documentation to read! :)
Regarding the cherry-pick -- I wonder how helpful it could have been. Sometimes it is surprisingly clever, in resolving conflicts. This time I copied "make-fedora-img.pl" from the already modified project(s) to the next project, and used "git add -p" to review and stage the changes I wanted. And then I compared the candidate patch to the actual commit in the other (already modified) project(s), effectively looking at "interdiff"s. There was at least one surprise that way: see virt-v2v commit fd7cd0c0fd22 / guestfs-tools commit 21e051c0c846. We don't have the same in libguestfs (in fact I'd not been aware of guestfs-tools commit 21e051c0c846!), and now I didn't want to change the size of the Root LV -- there seemed to be no justification for that.
Yes it definitely depends on the number of separate changes that have been made, and also whether previous changes were cherry picked in the same order (or at all). You can get two files that should supposedly be the same getting so out of synch that simply copying the files and reviewing the changes is better. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com nbdkit - Flexible, fast NBD server with plugins https://gitlab.com/nbdkit/nbdkit
participants (2)
-
Laszlo Ersek -
Richard W.M. Jones