Bug 1532224

Summary: Resume=/dev/sdaX can't be updated to resume=/dev/vdaX in rhel7 guest's grub file after v2v conversion
Product: Red Hat Enterprise Linux 7 Reporter: mxie <mxie>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.5CC: juzhou, mzhan, ptoscano, tzheng, xiaodwan
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.38.1-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 07:45:24 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:
Bug Depends On: 1551055    
Bug Blocks:    
Attachments:
Description Flags
rhel7-resume.log none

Description mxie@redhat.com 2018-01-08 12:23:02 UTC
Created attachment 1378509 [details]
rhel7-resume.log

Description of problem:
Resume=/dev/sdaX can't be updated to resume=/dev/vdaX in rhel7 guest's grub file after v2v conversion


Version-Release number of selected component (if applicable):
virt-v2v-1.36.10-4.el7.x86_64
libguestfs-1.36.10-4.el7.x86_64
libvirt-3.9.0-7.el7.x86_64
qemu-kvm-rhev-2.10.0-15.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1.Prepare a rhel7 guest which has swap partition
1.1 # lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   10G  0 disk 
├─sda1   8:1    0  7.8G  0 part /
└─sda2   8:2    0  2.2G  0 part [SWAP]


1.2 # cat /etc/fstab 
....
UUID=d5ca8ffb-720a-42da-9ecc-f562bd26b115 /                       ext4    defaults        1 1
/dev/sda2	swap                    swap    defaults        0 0


2.Add resume info into /etc/default/grub 
# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sda2"

3.Use v2v to convert the guest to rhv and there is no error during conversion
# virt-v2v rhel7.5-resume -o rhv -os 10.73.131.93:/home/nfs_export
[   0.0] Opening the source -i libvirt rhel7.5-resume
[   0.0] Creating an overlay to protect the source from being modified
[   0.7] Initializing the target -o rhv -os 10.73.131.93:/home/nfs_export
[   1.7] Opening the overlay
[   4.4] Inspecting the overlay
[ 138.0] Checking for sufficient free disk space in the guest
[ 138.0] Estimating space required on target for each disk
[ 138.0] Converting Red Hat Enterprise Linux Server 7.5 Beta (Maipo) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 265.8] Mapping filesystem data to avoid copying unused and blank areas
[ 267.5] Closing the overlay
[ 270.2] Checking if the guest needs BIOS or UEFI to boot
[ 270.2] Assigning disks to buses
[ 270.2] Copying disk 1/1 to /tmp/v2v.wC8SS8/a2f71361-0af3-41db-bfa2-6438e1558cbd/images/e1d3e537-cbec-47b5-9c09-5a077d6ea28f/220a16e3-4872-426e-af46-85170dcb633b (qcow2)
    (100.00/100%)
[ 473.5] Creating output metadata
[ 473.6] Finishing off

4.Check resume info in /boot/grub2/grub.cfg for converted guest at rhv after finishing conversion
4.1 # lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 1024M  0 rom  
vda    253:0    0   10G  0 disk 
├─vda1 253:1    0  7.8G  0 part /
└─vda2 253:2    0  2.2G  0 part [SWAP]

4.2 # cat /boot/grub2/device.map
# this device map was generated by anaconda
(hd0)      /dev/vda
(hd1)      /dev/vda

4.3 # cat /etc/fstab
....
UUID=d5ca8ffb-720a-42da-9ecc-f562bd26b115 /                       ext4    defaults        1 1
/dev/vda2	swap                    swap    defaults        0 0


4.4 # cat /boot/grub2/grub.cfg 
....
menuentry 'Red Hat Enterprise Linux Server (3.10.0-823.el7.x86_64) 7.5 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-823.el7.x86_64-advanced-d5ca8ffb-720a-42da-9ecc-f562bd26b115' {
	....
	linux16 /boot/vmlinuz-3.10.0-823.el7.x86_64 root=UUID=d5ca8ffb-720a-42da-9ecc-f562bd26b115 ro crashkernel=auto rhgb quiet resume=/dev/sda2
	initrd16 /boot/initramfs-3.10.0-823.el7.x86_64.img
}
menuentry 'Red Hat Enterprise Linux Server (0-rescue-acd9b2fd1f8f4842b7b98344a756997d) 7.5 (Maipo)' --class red --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-acd9b2fd1f8f4842b7b98344a756997d-advanced-d5ca8ffb-720a-42da-9ecc-f562bd26b115' {
	...
	linux16 /boot/vmlinuz-0-rescue-acd9b2fd1f8f4842b7b98344a756997d root=UUID=d5ca8ffb-720a-42da-9ecc-f562bd26b115 ro crashkernel=auto rhgb quiet resume=/dev/sda2
	initrd16 /boot/initramfs-0-rescue-acd9b2fd1f8f4842b7b98344a756997d.img
}
....

Actual results:
As above description

Expected results:
Resume=/dev/sdaX can be updated to resume=/dev/vdaX in rhel7 guest's grub file after v2v conversion

Additional info:
Resume=/dev/sdaX can be updated to resume=/dev/vdaX in rhel6 guest's grub file after v2v conversion

Comment 2 Richard W.M. Jones 2018-01-08 12:38:08 UTC
We need to call ‘shell_unquote’ at some point.  However the fix
is not very simple because whether parameters need unquoting
depends on the context of the file they are being read from.
More details here:

https://bugzilla.redhat.com/show_bug.cgi?id=1494555#c22

Comment 3 Pino Toscano 2018-04-11 16:16:08 UTC
New attempt in fixing this properly:
https://www.redhat.com/archives/libguestfs/2018-April/msg00115.html

Comment 4 Pino Toscano 2018-04-20 11:29:58 UTC
Hopefully fixed upstream with
https://github.com/libguestfs/libguestfs/commit/f2bd817bbc79d543ed6621e75acc9357631b6069
which is in libguestfs >= 1.39.3.

Comment 5 Pino Toscano 2018-05-02 11:20:36 UTC
Fix backported in 1.38.1.

Comment 7 mxie@redhat.com 2018-06-06 10:48:25 UTC
Verify the bug with below builds:
virt-v2v-1.38.2-3.el7.x86_64
libguestfs-1.38.2-3.el7.x86_64
libvirt-4.3.0-1.el7.x86_64
qemu-kvm-rhev-2.12.0-3.el7.x86_64


Steps:
1.Prepare a rhel7 guest which has swap partition
1.1 # lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   10G  0 disk 
├─sda1   8:1    0  7.8G  0 part /
└─sda2   8:2    0  2.2G  0 part [SWAP]


1.2 # cat /etc/fstab 
....
UUID=d5ca8ffb-720a-42da-9ecc-f562bd26b115 /     ext4    defaults        1 1
/dev/sda2	               swap             swap    defaults        0 0


2.Add resume info into /etc/default/grub 
# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sda2"

3.Use v2v to convert the guest to rhv and there is no error during conversion
# virt-v2v rhel7.5-resume -o rhv -os 10.66.144.40:/home/nfs_export
[   0.0] Opening the source -i libvirt rhel7.5-resume
[   0.1] Creating an overlay to protect the source from being modified
[   1.2] Initializing the target -o rhv -os 10.66.144.40:/home/nfs_export
[   4.5] Opening the overlay
[ 261.4] Inspecting the overlay
[ 332.2] Checking for sufficient free disk space in the guest
[ 332.2] Estimating space required on target for each disk
[ 332.2] Converting Red Hat Enterprise Linux Server 7.5 (Maipo) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 449.3] Mapping filesystem data to avoid copying unused and blank areas
[ 449.6] Closing the overlay
[ 450.0] Checking if the guest needs BIOS or UEFI to boot
[ 450.0] Assigning disks to buses
[ 450.0] Copying disk 1/1 to /tmp/v2v.B2LqMX/ea9cb06f-8bf9-4fc8-a247-478e754d898a/images/65b8c564-404f-493d-8ea8-bcb0bd37bec7/45fe9ed0-d9a3-43af-927c-01e1463d1e69 (qcow2)
    (100.00/100%)
[ 528.3] Creating output metadata
[ 528.6] Finishing off

4.Check resume info in converted guest on rhv4.2 after finishing conversion

4.1 # lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 1024M  0 rom  
vda    253:0    0   10G  0 disk 
├─vda1 253:1    0  7.8G  0 part /
└─vda2 253:2    0  2.2G  0 part [SWAP]

4.2 # cat /boot/grub2/device.map
# this device map was generated by anaconda
(hd0)      /dev/vda
(hd1)      /dev/vda

4.3 # cat /etc/fstab
....
UUID=d5ca8ffb-720a-42da-9ecc-f562bd26b115 /                       ext4    defaults        1 1
/dev/vda2	swap                    swap    defaults        0 0


4.4 # cat /boot/grub2/grub.cfg 
.....
	linux16 /boot/vmlinuz-3.10.0-862.el7.x86_64 root=UUID=003b9a4d-5375-4e56-996e-c1d80176bb7e ro crashkernel=auto rhgb quiet resume=/dev/vda2
	initrd16 /boot/initramfs-3.10.0-862.el7.x86_64.img
.....


Result:
    Resume=/dev/sdaX can be updated to resume=/dev/vdaX in rhel7 guest's grub file after v2v conversion,so move the bug from ON_QA to VERIFIED

Comment 9 errata-xmlrpc 2018-10-30 07:45:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2018:3021