? propos: https://listman.redhat.com/archives/libguestfs/2022-June/029134.html Port the corresponging commits from guestfs-tools to virt-v2v. Thanks Laszlo Laszlo Ersek (2): tests: rename "luks" to "lvm-on-luks" tests: add LUKS-on-LVM test Richard W.M. Jones (1): test-data: Replace deprecated luks_open with cryptsetup_open. .gitignore | 3 +- test-data/phony-guests/Makefile.am | 15 +++-- test-data/phony-guests/guests.xml.in | 22 ++++++- test-data/phony-guests/make-fedora-img.pl | 64 ++++++++++++++++++-- tests/Makefile.am | 6 +- tests/{test-v2v-fedora-luks-conversion.sh => test-v2v-fedora-luks-on-lvm-conversion.sh} | 10 ++- tests/{test-v2v-fedora-luks-conversion.sh => test-v2v-fedora-lvm-on-luks-conversion.sh} | 2 +- 7 files changed, 104 insertions(+), 18 deletions(-) copy tests/{test-v2v-fedora-luks-conversion.sh => test-v2v-fedora-luks-on-lvm-conversion.sh} (77%) rename tests/{test-v2v-fedora-luks-conversion.sh => test-v2v-fedora-lvm-on-luks-conversion.sh} (95%) -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2022-Jun-14 11:27 UTC
[Libguestfs] [v2v PATCH 1/3] test-data: Replace deprecated luks_open with cryptsetup_open.
From: "Richard W.M. Jones" <rjones at redhat.com> The two calls are identical, so this simply avoids a deprecation warning. (Picked from guestfs-tools commit 9a27f19269f5 ("test-data: Replace deprecated luks_open with cryptsetup_open.", 2022-02-28).) Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- test-data/phony-guests/make-fedora-img.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-data/phony-guests/make-fedora-img.pl b/test-data/phony-guests/make-fedora-img.pl index ad30960fa349..488a7d89963c 100755 --- a/test-data/phony-guests/make-fedora-img.pl +++ b/test-data/phony-guests/make-fedora-img.pl @@ -195,7 +195,7 @@ EOF # Put LUKS on the second partition. $g->luks_format ('/dev/sda2', 'FEDORA', 0); - $g->luks_open ('/dev/sda2', 'FEDORA', 'luks'); + $g->cryptsetup_open ('/dev/sda2', 'FEDORA', 'luks'); init_lvm_root ('/dev/mapper/luks'); } -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2022-Jun-14 11:27 UTC
[Libguestfs] [v2v PATCH 2/3] tests: rename "luks" to "lvm-on-luks"
Clarify that our current usage of "luks" stands for "lvm-on-luks" (IOW, that the decrypted LUKS devices are Physical Volumes for LVM). (This is a port of libguestfs patch 'tests: rename "luks" to "lvm-on-luks"' -- commit 39a5bb6fda4d. See also guestfs-tools commit 8f2bbc3d50d8 -- 'inspector: rename "luks" to "lvm-on-luks"', 2022-02-28.) Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- test-data/phony-guests/Makefile.am | 8 ++++---- tests/Makefile.am | 4 ++-- .gitignore | 2 +- test-data/phony-guests/guests.xml.in | 4 ++-- test-data/phony-guests/make-fedora-img.pl | 8 ++++---- tests/{test-v2v-fedora-luks-conversion.sh => test-v2v-fedora-lvm-on-luks-conversion.sh} | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test-data/phony-guests/Makefile.am b/test-data/phony-guests/Makefile.am index c45ddc1123e0..6d7db3da8043 100644 --- a/test-data/phony-guests/Makefile.am +++ b/test-data/phony-guests/Makefile.am @@ -49,7 +49,7 @@ disk_images = \ fedora-md1.img \ fedora-md2.img \ fedora-btrfs.img \ - fedora-luks.img \ + fedora-lvm-on-luks.img \ ubuntu.img \ archlinux.img \ coreos.img \ @@ -99,12 +99,12 @@ fedora-btrfs.img: make-fedora-img.pl \ fedora-static-bin SRCDIR=$(srcdir) LAYOUT=btrfs $(top_builddir)/run --test ./$< -# Make a (dummy) Fedora image with LVM encrypted with LUKS. -fedora-luks.img: make-fedora-img.pl \ +# Make a (dummy) Fedora image with LVM-on-LUKS. +fedora-lvm-on-luks.img: make-fedora-img.pl \ fedora-journal.tar.xz \ fedora.db \ fedora-static-bin - SRCDIR=$(srcdir) LAYOUT=lvm-luks $(top_builddir)/run --test ./$< + SRCDIR=$(srcdir) LAYOUT=lvm-on-luks $(top_builddir)/run --test ./$< # Make a (dummy) Debian image. debian.img: make-debian-img.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 63e654a3d148..75a05874094d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -98,7 +98,7 @@ TESTS = \ test-v2v-virtio-win-iso.sh \ test-v2v-fedora-conversion.sh \ test-v2v-fedora-btrfs-conversion.sh \ - test-v2v-fedora-luks-conversion.sh \ + test-v2v-fedora-lvm-on-luks-conversion.sh \ test-v2v-fedora-md-conversion.sh \ test-v2v-windows-conversion.sh \ rhbz1232192.sh \ @@ -177,7 +177,7 @@ EXTRA_DIST += \ test-v2v-cdrom.sh \ test-v2v-fedora-conversion.sh \ test-v2v-fedora-btrfs-conversion.sh \ - test-v2v-fedora-luks-conversion.sh \ + test-v2v-fedora-lvm-on-luks-conversion.sh \ test-v2v-fedora-md-conversion.sh \ test-v2v-floppy.expected \ test-v2v-floppy.sh \ diff --git a/.gitignore b/.gitignore index 04ab847dcd7f..cf96c1af29be 100644 --- a/.gitignore +++ b/.gitignore @@ -114,7 +114,7 @@ Makefile.in /test-data/phony-guests/debian.img /test-data/phony-guests/fedora.img /test-data/phony-guests/fedora-btrfs.img -/test-data/phony-guests/fedora-luks.img +/test-data/phony-guests/fedora-lvm-on-luks.img /test-data/phony-guests/fedora-md1.img /test-data/phony-guests/fedora-md2.img /test-data/phony-guests/fedora-static-bin diff --git a/test-data/phony-guests/guests.xml.in b/test-data/phony-guests/guests.xml.in index 9f64c35cd80f..339a6f7de839 100644 --- a/test-data/phony-guests/guests.xml.in +++ b/test-data/phony-guests/guests.xml.in @@ -185,7 +185,7 @@ <!-- LUKS password is 'FEDORA' --> <domain type='test'> - <name>fedora-luks</name> + <name>fedora-lvm-on-luks</name> <memory>1048576</memory> <os> <type>hvm</type> @@ -194,7 +194,7 @@ <devices> <disk type='file' device='disk'> <driver name='qemu' type='raw'/> - <source file='@abs_builddir@/fedora-luks.img'/> + <source file='@abs_builddir@/fedora-lvm-on-luks.img'/> <target dev='vda' bus='virtio'/> </disk> </devices> diff --git a/test-data/phony-guests/make-fedora-img.pl b/test-data/phony-guests/make-fedora-img.pl index 488a7d89963c..0d886bdf1af6 100755 --- a/test-data/phony-guests/make-fedora-img.pl +++ b/test-data/phony-guests/make-fedora-img.pl @@ -171,8 +171,8 @@ EOF } } -elsif ($ENV{LAYOUT} eq 'lvm-luks') { - push (@images, "fedora-luks.img-t"); +elsif ($ENV{LAYOUT} eq 'lvm-on-luks') { + push (@images, "fedora-lvm-on-luks.img-t"); open (my $fstab, '>', "fedora.fstab") or die; print $fstab <<EOF; @@ -183,9 +183,9 @@ EOF $bootdev = '/dev/sda1'; - $g->disk_create ("fedora-luks.img-t", "raw", $IMAGE_SIZE); + $g->disk_create ("fedora-lvm-on-luks.img-t", "raw", $IMAGE_SIZE); - $g->add_drive ("fedora-luks.img-t", format => "raw"); + $g->add_drive ("fedora-lvm-on-luks.img-t", format => "raw"); $g->launch (); $g->part_init ('/dev/sda', 'mbr'); diff --git a/tests/test-v2v-fedora-luks-conversion.sh b/tests/test-v2v-fedora-lvm-on-luks-conversion.sh similarity index 95% rename from tests/test-v2v-fedora-luks-conversion.sh rename to tests/test-v2v-fedora-lvm-on-luks-conversion.sh index 2922c31da13c..e3e70e8c66e1 100755 --- a/tests/test-v2v-fedora-luks-conversion.sh +++ b/tests/test-v2v-fedora-lvm-on-luks-conversion.sh @@ -25,7 +25,7 @@ set -e set -x skip_if_skipped -f=../test-data/phony-guests/fedora-luks.img +f=../test-data/phony-guests/fedora-lvm-on-luks.img requires test -f $f # The disk is encrypted with password "FEDORA". -- 2.19.1.3.g30247aa5d201
Laszlo Ersek
2022-Jun-14 11:27 UTC
[Libguestfs] [v2v PATCH 3/3] tests: add LUKS-on-LVM test
Port guestfs-tools commit 27da4b0c4991 ("inspector: add LUKS-on-LVM test", 2022-02-28) to virt-v2v. While at it, account for virt-v2v commit fd7cd0c0fd22 ("test-data/phony-guests: Increase size of root filesystem", 2022-06-08). Signed-off-by: Laszlo Ersek <lersek at redhat.com> --- test-data/phony-guests/Makefile.am | 7 +++ tests/Makefile.am | 2 + .gitignore | 1 + test-data/phony-guests/guests.xml.in | 18 +++++++ test-data/phony-guests/make-fedora-img.pl | 54 ++++++++++++++++++++ tests/test-v2v-fedora-luks-on-lvm-conversion.sh | 36 +++++++++++++ 6 files changed, 118 insertions(+) diff --git a/test-data/phony-guests/Makefile.am b/test-data/phony-guests/Makefile.am index 6d7db3da8043..29dbd4d0f9f2 100644 --- a/test-data/phony-guests/Makefile.am +++ b/test-data/phony-guests/Makefile.am @@ -49,6 +49,7 @@ disk_images = \ fedora-md1.img \ fedora-md2.img \ fedora-btrfs.img \ + fedora-luks-on-lvm.img \ fedora-lvm-on-luks.img \ ubuntu.img \ archlinux.img \ @@ -99,6 +100,12 @@ fedora-btrfs.img: make-fedora-img.pl \ fedora-static-bin SRCDIR=$(srcdir) LAYOUT=btrfs $(top_builddir)/run --test ./$< +# Make a (dummy) Fedora image with LUKS-on-LVM. +fedora-luks-on-lvm.img: make-fedora-img.pl \ + fedora-journal.tar.xz \ + fedora.db + SRCDIR=$(srcdir) LAYOUT=luks-on-lvm $(top_builddir)/run --test ./$< + # Make a (dummy) Fedora image with LVM-on-LUKS. fedora-lvm-on-luks.img: make-fedora-img.pl \ fedora-journal.tar.xz \ diff --git a/tests/Makefile.am b/tests/Makefile.am index 75a05874094d..ebc433ae5e89 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -98,6 +98,7 @@ TESTS = \ test-v2v-virtio-win-iso.sh \ test-v2v-fedora-conversion.sh \ test-v2v-fedora-btrfs-conversion.sh \ + test-v2v-fedora-luks-on-lvm-conversion.sh \ test-v2v-fedora-lvm-on-luks-conversion.sh \ test-v2v-fedora-md-conversion.sh \ test-v2v-windows-conversion.sh \ @@ -177,6 +178,7 @@ EXTRA_DIST += \ test-v2v-cdrom.sh \ test-v2v-fedora-conversion.sh \ test-v2v-fedora-btrfs-conversion.sh \ + test-v2v-fedora-luks-on-lvm-conversion.sh \ test-v2v-fedora-lvm-on-luks-conversion.sh \ test-v2v-fedora-md-conversion.sh \ test-v2v-floppy.expected \ diff --git a/.gitignore b/.gitignore index cf96c1af29be..62541b898020 100644 --- a/.gitignore +++ b/.gitignore @@ -114,6 +114,7 @@ Makefile.in /test-data/phony-guests/debian.img /test-data/phony-guests/fedora.img /test-data/phony-guests/fedora-btrfs.img +/test-data/phony-guests/fedora-luks-on-lvm.img /test-data/phony-guests/fedora-lvm-on-luks.img /test-data/phony-guests/fedora-md1.img /test-data/phony-guests/fedora-md2.img diff --git a/test-data/phony-guests/guests.xml.in b/test-data/phony-guests/guests.xml.in index 339a6f7de839..4391c9b4466a 100644 --- a/test-data/phony-guests/guests.xml.in +++ b/test-data/phony-guests/guests.xml.in @@ -183,6 +183,24 @@ </devices> </domain> + <!-- LUKS passwords are 'FEDORA-Root', 'FEDORA-LV1', 'FEDORA-LV2', + 'FEDORA-LV3' --> + <domain type='test'> + <name>fedora-luks-on-lvm</name> + <memory>1048576</memory> + <os> + <type>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <disk type='file' device='disk'> + <driver name='qemu' type='raw'/> + <source file='@abs_builddir@/fedora-luks-on-lvm.img'/> + <target dev='vda' bus='virtio'/> + </disk> + </devices> + </domain> + <!-- LUKS password is 'FEDORA' --> <domain type='test'> <name>fedora-lvm-on-luks</name> diff --git a/test-data/phony-guests/make-fedora-img.pl b/test-data/phony-guests/make-fedora-img.pl index 0d886bdf1af6..c30c0b53a775 100755 --- a/test-data/phony-guests/make-fedora-img.pl +++ b/test-data/phony-guests/make-fedora-img.pl @@ -200,6 +200,60 @@ EOF init_lvm_root ('/dev/mapper/luks'); } +elsif ($ENV{LAYOUT} eq 'luks-on-lvm') { + push (@images, "fedora-luks-on-lvm.img-t"); + + open (my $fstab, '>', "fedora.fstab") or die; + print $fstab <<EOF; +LABEL=BOOT /boot ext2 default 0 0 +LABEL=ROOT / ext2 default 0 0 +EOF + close ($fstab) or die; + + $bootdev = '/dev/sda1'; + + $g->disk_create ("fedora-luks-on-lvm.img-t", "raw", $IMAGE_SIZE); + + $g->add_drive ("fedora-luks-on-lvm.img-t", format => "raw"); + $g->launch (); + + $g->part_init ('/dev/sda', 'mbr'); + foreach my $p (@PARTITIONS) { + $g->part_add('/dev/sda', @$p); + } + + # 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); + + # 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); + + # 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'); + + # Phony root filesystem. + $g->mkfs ('ext2', '/dev/mapper/Root-luks', blocksize => 4096, label => 'ROOT'); + $g->set_uuid ('/dev/mapper/Root-luks', '01234567-0123-0123-0123-012345678902'); + + # Other filesystems, just for testing findfs-label. + $g->mkfs ('ext2', '/dev/mapper/LV1-luks', blocksize => 4096, label => 'LV1'); + $g->mkfs ('ext2', '/dev/mapper/LV2-luks', blocksize => 1024, label => 'LV2'); + $g->mkfs ('ext2', '/dev/mapper/LV3-luks', blocksize => 2048, label => 'LV3'); + + $g->mount ('/dev/mapper/Root-luks', '/'); +} + else { print STDERR "$0: Unknown LAYOUT: ",$ENV{LAYOUT},"\n"; exit 1; diff --git a/tests/test-v2v-fedora-luks-on-lvm-conversion.sh b/tests/test-v2v-fedora-luks-on-lvm-conversion.sh new file mode 100755 index 000000000000..1a4068cf678f --- /dev/null +++ b/tests/test-v2v-fedora-luks-on-lvm-conversion.sh @@ -0,0 +1,36 @@ +#!/bin/bash - +# libguestfs virt-v2v test script +# Copyright (C) 2014-2022 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test virt-v2v (Phony) Fedora conversion. + +set -e + +source ./functions.sh +set -e +set -x + +skip_if_skipped +f=../test-data/phony-guests/fedora-luks-on-lvm.img +requires test -f $f + +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) + +$VG virt-v2v --debug-gc -i disk $f -o null "${keys[@]}" -- 2.19.1.3.g30247aa5d201