[Libguestfs] [v2v PATCH] convert/linux_kernels: fix virtio-socket check

Laszlo Ersek lersek at redhat.com
Thu Mar 31 13:38:30 UTC 2022


On 03/31/22 15:16, Richard W.M. Jones wrote:
> On Thu, Mar 31, 2022 at 12:57:39PM +0200, Laszlo Ersek wrote:
>> The virtio-vsock support check from commit 05f780c16f01 ("v2v: support
>> configuration of viosock driver", 2021-02-26) is wrong; it looks for one
>> of two things:
>> - a module called "virtio_socket",
>> - a kernel config item called VIRTIO_SOCKET.
>>
>> In reality, we need:
>> - the "vmw_vsock_virtio_transport" module,
>> - or the kernel config item VIRTIO_VSOCKETS.
>>
>> Refer to Linux commit 304ba62fd4e6 ("VSOCK: Add Makefile and Kconfig",
>> 2016-08-02).
>>
>> Fix the parameters of the related "kernel_supports" call.
>>
>> The same virt-v2v commit also missed extending the "print_kernel_info"
>> function; do that now as well.
>>
>> I tested this patch by converting a RHEL-8.5 guest from libvirt to libvirt
>> (originally creating the guest with virt-builder). Relevant differences
>> between the "before" and "after" conversion logs:
>>
>>>  installed kernel packages in this guest:
>>>  * kernel-core 4.18.0-348.el8.x86_64 (x86_64)
>>>         /boot/vmlinuz-4.18.0-348.el8.x86_64
>>>         /boot/initramfs-4.18.0-348.el8.x86_64.img
>>>         /boot/config-4.18.0-348.el8.x86_64
>>>         /lib/modules/4.18.0-348.el8.x86_64
>>>         2580 modules found
>>>         virtio: blk=true net=true rng=true balloon=true
>>> -       pvpanic=true xen=false debug=false
>>> +       pvpanic=true vsock=true xen=false debug=false
>>
>> and
>>
>>>  kernels offered by the bootloader in this guest (first in list is default):
>>>  * kernel-core 4.18.0-348.el8.x86_64 (x86_64)
>>>         /boot/vmlinuz-4.18.0-348.el8.x86_64
>>>         /boot/initramfs-4.18.0-348.el8.x86_64.img
>>>         /boot/config-4.18.0-348.el8.x86_64
>>>         /lib/modules/4.18.0-348.el8.x86_64
>>>         2580 modules found
>>>         virtio: blk=true net=true rng=true balloon=true
>>> -       pvpanic=true xen=false debug=false
>>> +       pvpanic=true vsock=true xen=false debug=false
>>>  * kernel-core 4.18.0-348.el8.x86_64 (x86_64)
>>>         /boot/vmlinuz-4.18.0-348.el8.x86_64
>>>         /boot/initramfs-4.18.0-348.el8.x86_64.img
>>>         /boot/config-4.18.0-348.el8.x86_64
>>>         /lib/modules/4.18.0-348.el8.x86_64
>>>         2580 modules found
>>>         virtio: blk=true net=true rng=true balloon=true
>>> -       pvpanic=true xen=false debug=false
>>> +       pvpanic=true vsock=true xen=false debug=false
>>
>> and
>>
>>>  best kernel for this guest:
>>>  * kernel-core 4.18.0-348.el8.x86_64 (x86_64)
>>>         /boot/vmlinuz-4.18.0-348.el8.x86_64
>>>         /boot/initramfs-4.18.0-348.el8.x86_64.img
>>>         /boot/config-4.18.0-348.el8.x86_64
>>>         /lib/modules/4.18.0-348.el8.x86_64
>>>         2580 modules found
>>>         virtio: blk=true net=true rng=true balloon=true
>>> -       pvpanic=true xen=false debug=false
>>> +       pvpanic=true vsock=true xen=false debug=false
>>
>> and
>>
>>>  gcaps_block_bus = virtio-blk
>>>  gcaps_net_bus = virtio-net
>>>  gcaps_virtio_rng = true
>>>  gcaps_virtio_balloon = true
>>>  gcaps_isa_pvpanic = true
>>> -gcaps_virtio_socket = false
>>> +gcaps_virtio_socket = true
>>>  gcaps_machine = q35
>>>  gcaps_arch = x86_64
>>>  gcaps_acpi = true
>>>  gcaps_virtio_1_0 = true
>>
>> and
>>
>>>  resulting XML for libvirt:
>>>  <?xml version='1.0' encoding='utf-8'?>
>>>  <domain type='kvm'>
>>>    <!-- generated by virt-v2v 2.0.1 -->
>>>    <name>converted</name>
>>>    <metadata>
>>>      <libosinfo:libosinfo
>>>      xmlns:libosinfo='http://libosinfo.org/xmlns/libvirt/domain/1.0'>
>>>        <libosinfo:os id='http://redhat.com/rhel/8.5'/>
>>>      </libosinfo:libosinfo>
>>>    </metadata>
>>>    <memory unit='KiB'>2097152</memory>
>>>    <currentMemory unit='KiB'>2097152</currentMemory>
>>>    <vcpu>2</vcpu>
>>>    <features>
>>>      <acpi/>
>>>      <apic/>
>>>    </features>
>>>    <os>
>>>      <type arch='x86_64' machine='q35'>hvm</type>
>>>    </os>
>>>    <on_poweroff>destroy</on_poweroff>
>>>    <on_reboot>restart</on_reboot>
>>>    <on_crash>restart</on_crash>
>>>    <devices>
>>>      <disk type='volume' device='disk'>
>>>        <driver name='qemu' type='raw'/>
>>>        <source pool='default' volume='converted-sda'/>
>>>        <target dev='vda' bus='virtio'/>
>>>      </disk>
>>>      <interface type='bridge'>
>>>        <source bridge='virbr0'/>
>>>        <model type='virtio'/>
>>>        <mac address='52:54:00:5c:cc:f8'/>
>>>      </interface>
>>>      <video>
>>>        <model type='vga' vram='16384' heads='1'/>
>>>      </video>
>>>      <graphics type='spice' autoport='yes'/>
>>>      <sound model='ich6'/>
>>>      <rng model='virtio'>
>>>        <backend model='random'>/dev/urandom</backend>
>>>      </rng>
>>>      <memballoon model='virtio'/>
>>>      <panic model='isa'>
>>>        <address type='isa' iobase='0x505'/>
>>>      </panic>
>>> +    <vsock model='virtio'/>
>>>      <input type='tablet' bus='usb'/>
>>>      <input type='mouse' bus='ps2'/>
>>>      <console type='pty'/>
>>>    </devices>
>>>  </domain>
>>
>> I also checked the device with "lspci", and the module with "lsmod", in
>> the converted domain.
>>
>> Fixes: 05f780c16f0135c657615520c2245b42de1efc3e
>> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2070186
>> Signed-off-by: Laszlo Ersek <lersek at redhat.com>
>> ---
>>  convert/linux_kernels.ml | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/convert/linux_kernels.ml b/convert/linux_kernels.ml
>> index 6dead217ef71..307de5729e3e 100644
>> --- a/convert/linux_kernels.ml
>> +++ b/convert/linux_kernels.ml
>> @@ -61,8 +61,9 @@ let print_kernel_info chan prefix ki =
>>    fpf "virtio: blk=%b net=%b rng=%b balloon=%b\n"
>>        ki.ki_supports_virtio_blk ki.ki_supports_virtio_net
>>        ki.ki_supports_virtio_rng ki.ki_supports_virtio_balloon;
>> -  fpf "pvpanic=%b xen=%b debug=%b\n"
>> -      ki.ki_supports_isa_pvpanic ki.ki_is_xen_pv_only_kernel ki.ki_is_debug
>> +  fpf "pvpanic=%b vsock=%b xen=%b debug=%b\n"
>> +      ki.ki_supports_isa_pvpanic ki.ki_supports_virtio_socket
>> +      ki.ki_is_xen_pv_only_kernel ki.ki_is_debug
>>  
>>  let rex_ko = PCRE.compile "\\.k?o(?:\\.xz)?$"
>>  let rex_ko_extract = PCRE.compile "/([^/]+)\\.k?o(?:\\.xz)?$"
>> @@ -248,7 +249,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader =
>>             let supports_isa_pvpanic =
>>               kernel_supports "pvpanic" "PVPANIC" in
>>             let supports_virtio_socket =
>> -               kernel_supports "virtio_socket" "VIRTIO_SOCKET" in
>> +               kernel_supports "vmw_vsock_virtio_transport" "VIRTIO_VSOCKETS" in
>>             let is_xen_pv_only_kernel =
>>               check_config "X86_XEN" config_file ||
>>               check_config "X86_64_XEN" config_file in
> 
> Reviewed-by: Richard W.M. Jones <rjones at redhat.com>
> 
> Thanks for fixing this mess :-/
> 
> Rich.
> 

Thank you for the quick reviews!
Laszlo


More information about the Libguestfs mailing list