Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1528523

Summary: v2v should update the grub2 configuration and give guest a valid grub2 configuration
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: kuwei <kuwei>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: jsuchane, juzhou, mxie, mzhan, ptoscano, rjones, tzheng, xiaodwan
Target Milestone: rc   
Target Release: 8.1   
Hardware: x86_64   
OS: Linux   
Whiteboard: V2V
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-01-23 10:30:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description kuwei@redhat.com 2017-12-22 02:54:35 UTC
Description of problem:
v2v should update the grub2 configuration and give guest a valid grub2 configuration

Version-Release number of selected component (if applicable):
virt-v2v-1.36.10-3.el7.x86_64
libguestfs-1.36.10-3.el7.x86_64
libvirt-3.9.0-5.el7.x86_64
qemu-kvm-rhev-2.10.0-11.el7.x86_64
libguestfs-winsupport-7.2-2.el7.x86_64
virtio-win-1.9.3-1.el7.noarch


How reproducible:
100%

Steps to Reproduce:
Scenario 1:
1.Prepare a rhel7.4 guest with multi kernels on kvm server,and edit the guest's "boot/grub2/grub.cfg/" file, remove all the available kernel message

2.Use virt-v2v to convert the guest to RHVM.

3.The conversion should be finished without error and the guest can start normally,it's "grub2.cfg" has updated to a valid grub2 configuration.

Scenario 2:
1.Prepare a rhel7.4 guest with one kernel on kvm server, edit the guest's "boot/grub2/grub.cfg/" file delete the default kernel info.

2.Use virt-v2v to convert the guest to RHVM.

3.The conversion should be finished without error and the guest can start normally,it's "grub2.cfg" has updated to a valid grub2 configuration.

Scenario 3:
1.Prepare a rhel7.4 guest on kvm server, edit the guest's "boot/grub2/grub.cfg/" file delete the default kernel info and add a bogus kernel info.

2.Use virt-v2v to convert the guest to RHVM.

3.The conversion should be finished without error and the guest can start normally,it's "grub2.cfg" has updated to a valid grub2 configuration,the bogus kernel info should be cleared away



Actual results:


Expected results:
As above

Additional info:

Comment 2 kuwei@redhat.com 2017-12-22 08:10:54 UTC
Grub.cfg file content:
Scenario 1:
Prepare a rhel7.4 guest with multi kernels on kvm server,and edit the guest's "boot/grub2/grub.cfg/" file, remove all the available kernel message :
Original grub.cfg:
#cat /boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
*************************************************
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Red Hat Enterprise Linux Server (3.10.0-799.el7.x86_64) 7.5 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-799.el7.x86_64-advanced-99c4e8f2-d986-4ff9-8dd0-3859dfe9120f'
'
'
************************************************
menuentry 'Red Hat Enterprise Linux Server (3.10.0-693.el7.x86_64) 7.4 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-703f78ca-75e8-48c5-97be-b726e63d224e'
'
'
************************************************
### END /etc/grub.d/10_linux ###



Modify the grub.cfg, delete all the kernels info:

#cat /boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
*************************************************
### BEGIN /etc/grub.d/10_linux ###

### END /etc/grub.d/10_linux ###

Comment 3 kuwei@redhat.com 2017-12-22 08:19:13 UTC
Grub.cfg file content:
Scenario 2:
Prepare a rhel7.4 guest with one kernel on kvm server,and edit the guest's "boot/grub2/grub.cfg/" file, remove the available kernel message :

After modify:
grub.cfg
#cat /boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
*************************************************
### BEGIN /etc/grub.d/10_linux ###

### END /etc/grub.d/10_linux ###
'
'
Scenario 3:
Prepare a rhel7.4 guest with one kernel on kvm server as Scenario 2, edit the guest's "boot/grub2/grub.cfg/" file delete the default kernel info and add a bogus kernel info.

After modify:
#cat /boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
*************************************************
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Red Hat Enterprise Linux Server (3.10.0-XXXXX.el7.x86_64) 7.4 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-XXX.el7.x86_64-advanced-703f78ca-75e8-48c5-97be-b726e63d224e'
### END /etc/grub.d/10_linux ###
'
'

Comment 4 mxie@redhat.com 2018-02-01 06:31:29 UTC
Reproduce this bug with below builds:
virt-v2v-1.36.10-6.el7.x86_64
libguestfs-1.36.10-6.el7.x86_64
libvirt-3.9.0-10.virtcov.el7.x86_64
qemu-kvm-rhev-2.10.0-18.el7.x86_64


Steps:

Scenario1:
1.1 Prepare a rhel7 guest, delete grub.cfg file in /boot/grub2 and keep  ,then power off the guest

#ls /boot/grub2
device.map  fonts   grubenv  i386-pc  locale

#ls /boot
...
initramfs-0-rescue-1fbb2558d52640e0b194403c838bb9d2.img 
initramfs-3.10.0-823.el7.x86_64.img 
vmlinuz-3.10.0-823.el7.x86_64
vmlinuz-0-rescue-1fbb2558d52640e0b194403c838bb9d2


1.2 Convert this guest by virt-v2v
# virt-v2v no-grub -o null
[   0.0] Opening the source -i libvirt no-grub
[   0.0] Creating an overlay to protect the source from being modified
[   0.4] Initializing the target -o null
[   0.4] Opening the overlay
[   4.2] Inspecting the overlay
[  28.3] Checking for sufficient free disk space in the guest
[  28.3] Estimating space required on target for each disk
[  28.3] Converting Red Hat Enterprise Linux Server 7.5 Beta (Maipo) to run on KVM
virt-v2v: error: no bootloader detected

If reporting bugs, run virt-v2v with debugging enabled and include the 
complete output:

  virt-v2v -v -x [...]

Result1:
  V2V can't find bootloader which is expected result



Scenario2:
2.1 Prepare a rhel7 guest and modify grub.cfg file as bug (delete all kernel info ),then power off the guest

#cat /boot/grub2/grub.cfg
....
### BEGIN /etc/grub.d/10_linux ###
### END /etc/grub.d/10_linux ###
....

#ls /boot
...
initramfs-0-rescue-1fbb2558d52640e0b194403c838bb9d2.img 
initramfs-3.10.0-823.el7.x86_64.img 
vmlinuz-3.10.0-823.el7.x86_64
vmlinuz-0-rescue-1fbb2558d52640e0b194403c838bb9d2

2.2 Convert this guest by virt-v2v
# virt-v2v no-kernel-info -on no-kernel-info-v2v
[   0.0] Opening the source -i libvirt no-kernel-info
[   0.0] Creating an overlay to protect the source from being modified
[   0.6] Initializing the target -o libvirt -os default
[   0.8] Opening the overlay
[   5.0] Inspecting the overlay
[  25.7] Checking for sufficient free disk space in the guest
[  25.7] Estimating space required on target for each disk
[  25.7] Converting Red Hat Enterprise Linux Server 7.5 Beta (Maipo) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 100.7] Mapping filesystem data to avoid copying unused and blank areas
[ 100.8] Closing the overlay
[ 101.1] Checking if the guest needs BIOS or UEFI to boot
[ 101.1] Assigning disks to buses
[ 101.1] Copying disk 1/1 to /var/lib/libvirt/images/no-kernel-info-v2v-sda (qcow2)
    (100.00/100%)
[ 214.9] Creating output metadata
Pool default refreshed

Domain no-kernel-info-v2v defined from /tmp/v2vlibvirta92fff.xml

[ 217.7] Finishing off

2.3 Converted guest can't boot into os after powering on 


Result2:
   There is no error during converting a no-kernel rhel7 guest which is not a expected result.

Hi Pino,
   I have some query about fixed method of sceanrio2,according to https://bugzilla.redhat.com/show_bug.cgi?id=1519204#c16, maybe the fixed method for this bug is "v2v could always update the grub2 configuration by grub2-mkconfig. But rjones said in https://bugzilla.redhat.com/show_bug.cgi?id=1492633#c4, virt-v2v runs grub2-mkconfig
only if it changes a device name in either /etc/fstab, device.map.... 
   Do you think it is possible v2v could always update the grub2 configuration by grub2-mkconfig? If yes, does it mean the guest which has no grub.cfg file (sceanrio1 )also could be converted by v2v ?Thanks!



Sceanrio3:
3.1 Prepare a rhel7 guest and add a bogus kernel in grub.cfg
#cat /boot/grub2/grub.cfg
....
menuentry 'Red Hat Enterprise Linux Server (3.10.0-838.el7.x86_64) 7.5 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-838.el7.x86_64-advanced-b25fc065-f6f9-4a9c-a37c-90579aabfa92' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_msdos
	insmod xfs
	set root='hd0,msdos1'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  1136e534-47b0-4c6f-b89f-1de5949ca14b
	else
	  search --no-floppy --fs-uuid --set=root 1136e534-47b0-4c6f-b89f-1de5949ca14b
	fi
	linux16 /vmlinuz-3.10.0-838.el7.x86_64 root=/dev/mapper/rhel-root ro crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet 
	initrd16 /initramfs-3.10.0-838.el7.x86_64.img
}
menuentry 'Red Hat Enterprise Linux Server (3.10.0-00.el7.x86_64) 7.5 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-00.el7.x86_64-advanced-b25fc065-f6f9-4a9c-a37c-90579aabfa92' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_msdos
	insmod xfs
	set root='hd0,msdos1'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  1136e534-47b0-4c6f-b89f-1de5949ca14b
	else
	  search --no-floppy --fs-uuid --set=root 1136e534-47b0-4c6f-b89f-1de5949ca14b
	fi
	linux16 /vmlinuz-3.10.0-00.el7.x86_64 root=/dev/mapper/rhel-root ro crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet 
	initrd16 /initramfs-3.10.0-00.el7.x86_64.img
}
.....

#ls /boot
....
initramfs-0-rescue-5db1f88ad1494fd294632635f22d75d8.img
initramfs-3.10.0-838.el7.x86_64.img
vmlinuz-0-rescue-5db1f88ad1494fd294632635f22d75d8
vmlinuz-3.10.0-838.el7.x86_64

3.2 Convert this guest by virt-v2v
# virt-v2v rhel7.5-bogus -on rhel7-bogus-v2v
[   0.0] Opening the source -i libvirt rhel7.5-bogus
[   0.0] Creating an overlay to protect the source from being modified
[   0.4] Initializing the target -o libvirt -os default
[   0.4] Opening the overlay
[   3.6] Inspecting the overlay
[  26.0] Checking for sufficient free disk space in the guest
[  26.0] Estimating space required on target for each disk
[  26.0] Converting Red Hat Enterprise Linux Server 7.5 Beta (Maipo) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[  94.3] Mapping filesystem data to avoid copying unused and blank areas
[  94.5] Closing the overlay
[  94.6] Checking if the guest needs BIOS or UEFI to boot
[  94.6] Assigning disks to buses
[  94.6] Copying disk 1/1 to /var/lib/libvirt/images/rhel7-bogus-v2v-sda (qcow2)
    (100.00/100%)
[ 205.6] Creating output metadata
Pool default refreshed

Domain rhel7-bogus-v2v defined from /tmp/v2vlibvirt8abbdd.xml

[ 206.8] Finishing off


3.4 Check guest after finishing conversion,guest could boot into os normally and there is no change in grub.cfg 

Result3
   There is no error or warning during conversion

Hi Pino,
   Because v2v will pop up warning about bogus kernel if convert a rhel6 guest which has bogus kernel, but v2v will not pop up warning as scenario3, do you think it is necessary to fix this problem?

Comment 5 Pino Toscano 2018-02-01 12:19:08 UTC
Please note that scenario1 is not related to this bug: since there is no
bootloader configuration, v2v does not detect any bootloader, and thus
it cannot convert the guest.  It is a good scenario, but should not be
part of the testing for this bug.

(In reply to mxie from comment #4)
> Scenario2:
> 2.1 Prepare a rhel7 guest and modify grub.cfg file as bug (delete all kernel
> info ),then power off the guest
> ....
> Result2:
>    There is no error during converting a no-kernel rhel7 guest which is not
> a expected result.
> 
> Hi Pino,
>    I have some query about fixed method of sceanrio2,according to
> https://bugzilla.redhat.com/show_bug.cgi?id=1519204#c16, maybe the fixed
> method for this bug is "v2v could always update the grub2 configuration by
> grub2-mkconfig.

Yes, this was a possible idea about what v2v could do when convering
guests that use grub2 as bootloader.

> But rjones said in
> https://bugzilla.redhat.com/show_bug.cgi?id=1492633#c4, virt-v2v runs
> grub2-mkconfig
> only if it changes a device name in either /etc/fstab, device.map.... 

Yes, the grub2 configuration is updated (using grub2-mkconfig) only when
there are changes needed.  Converting a guest that already runs on KVM
most probably will not require any change.

>    Do you think it is possible v2v could always update the grub2
> configuration by grub2-mkconfig?

This is what bug 1519204 comment 16 suggested, and what this bug is about.
We need to check whether updating the grub2 configuration in all the cases
is a good idea (with no bad side effects).

> If yes, does it mean the guest which has no
> grub.cfg file (sceanrio1 )also could be converted by v2v ?

No, because to update the grub2 configuration v2v needs to detect grub2
is used, and you cannot detect that grub2 is used without a grub2
configuration.

> Sceanrio3:
> 3.1 Prepare a rhel7 guest and add a bogus kernel in grub.cfg
> #cat /boot/grub2/grub.cfg
> ....
> Result3
>    There is no error or warning during conversion
> 
> Hi Pino,
>    Because v2v will pop up warning about bogus kernel if convert a rhel6
> guest which has bogus kernel, but v2v will not pop up warning as scenario3,
> do you think it is necessary to fix this problem?

v2v uses the grub configuration with grub1 (used in RHEL 6), so
wrong entries give warnings.
With grub2 (used in RHEL 7), v2v does not read the grub2 configuration
at all, so bogus entries will be silently ignored.

Comment 6 Jaroslav Suchanek 2020-01-23 10:30:10 UTC
All three scenarios in comment 0 are not bugs. There is nothing v2v should fix.