On Wed, Jun 08, 2022 at 05:49:01PM +0100, Richard W.M. Jones wrote:
+# Virt-v2v also needs a kernel, initrd and modules path.
+$g->touch ("/boot/vmlinuz-$kver");
+$g->touch ("/boot/initramfs-$kver.img");
+$g->mkdir_p ("/lib/modules/$kver/kernel/drivers/block");
+$g->upload ($ENV{SRCDIR}.'/../binaries/bin-x86_64-dynamic',
+ "/lib/modules/$kver/kernel/drivers/block/virtio_blk.ko");
Surprisingly this works even on !x86-64. I just tested it on aarch64.
Here:
https://github.com/libguestfs/virt-v2v/blob/0d1b2ec1b733db1ca0bebf2e4a9e8...
we use guestfs_file_architecture on a kernel module to determine the
architecture of the kernel. Because we uploaded an x86-64 binary this
means we detect the kernel as being x86_64:
installed kernel packages in this guest:
* kernel 5.19.0-0.rc1.14.fc37.x86_64 (x86_64) <------- ki_arch
/boot/vmlinuz-5.19.0-0.rc1.14.fc37.x86_64
/boot/initramfs-5.19.0-0.rc1.14.fc37.x86_64.img
no config
/lib/modules/5.19.0-0.rc1.14.fc37.x86_64
1 modules found
virtio: blk=true net=false rng=false balloon=false
pvpanic=false vsock=false xen=false debug=false
Then we run dracut, which would fail on a real guest if the host is
aarch64, but succeeds here because the phony dracut binary is aarch64:
libguestfs: trace: v2v: command "/sbin/dracut --verbose --add-drivers virtio_blk
/boot/initramfs-5.19.0-0.rc1.14.fc37.x86_64.img 5.19.0-0.rc1.14.fc37.x86_64"
Later:
gcaps_block_bus = virtio-blk
gcaps_net_bus = e1000
gcaps_virtio_rng = false
gcaps_virtio_balloon = false
gcaps_isa_pvpanic = false
gcaps_virtio_socket = false
gcaps_machine = i440fx
gcaps_arch = x86_64 <---------
gcaps_acpi = true
gcaps_virtio_1_0 = false
gcaps_default_cpu = true
Anyway this is kind of a bug in virt-v2v (because it should reject
conversion of a !hostarch guest), and also in this test, but this is a
fairly obscure corner case so I guess I'll leave it for now.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org