Bug 1745922

Summary: Luks-inside-qcow2 snapshot cannot boot after 'qemu-img rebase'
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Cheng Huayu <hucheng>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
qemu-kvm sub component: General QA Contact: Virtualization Bugs <virt-bugs>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: high CC: coli, ddepaula, jinzhao, juzhang, mtessun, ngu, qzhang, timao, virt-maint, zhenyzha
Version: 8.1Keywords: Regression
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-4.1.0-12.module+el8.1.0+4292+1293ae0c Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-06 07:19:01 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:
Attachments:
Description Flags
PrtSc of the guest none

Description Cheng Huayu 2019-08-27 08:52:14 UTC
Created attachment 1608421 [details]
PrtSc of the guest

Description of problem:
First,I created a snap-chain:base->sn1。
Then,I created a new image:nbase.qcow2.And rebased sn1 on nbase that is empty.
Finally,I tried to boot up sn1,and it hit "uncompression error.system halted."


Version-Release number of selected component (if applicable):
qemu-kvm-4.1.0-4.module+el8.1.0+4020+16089f93
RHEL8.1.0-BaseOS-x86_64.iso


How reproducible:
3/3


Steps to Reproduce:
1. Create base image file
# qemu-img create -f qcow2 --object secret,id=sec0,data=base -o encrypt.format=luks,encrypt.key-secret=sec0 base.qcow2 20G

2.Install base.qcow2 with below commands.
# /usr/libexec/qemu-kvm \
        -name 'guest-rhel8.0' \
        -machine q35 \
        -nodefaults \
        -vga qxl \
	-object secret,id=sec0,data=base \
        -drive id=drive_cd1,if=none,snapshot=off,aio=threads,cache=none,media=cdrom,file=RHEL8.1.0-BaseOS-x86_64.iso  \
        -device ide-cd,id=cd1,drive=drive_cd1,bus=ide.0,unit=0 \
        -drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=qcow2,file=base.qcow2,encrypt.format=luks,encrypt.key-secret=sec0 \
        -device virtio-blk-pci,id=virtio_blk_pci0,drive=drive_image1,bus=pcie.0,addr=05,bootindex=0 \
        -vnc :1 \
        -monitor stdio \
        -m 8192 \
        -smp 8 \
        -device virtio-net-pci,mac=9a:b5:b6:b1:b2:b3,id=idMmq1jH,vectors=4,netdev=idxgXAlm,bus=pcie.0,addr=0x9  \
        -netdev tap,id=idxgXAlm \
        -chardev socket,id=qmp_id_qmpmonitor1,path=/var/tmp/hucheng/monitor-qmpmonitor1-20180220-094308-h9I6hRsI,server,nowait \
        -mon chardev=qmp_id_qmpmonitor1,mode=control  \

3.Boot guest from base.qcow2 and write a big fiel in it.
# dd if=/dev/urandom of=largebase bs=1M count=2048 ; cksum largebase

4. Create snapshot file based on the base.qcow2, and boot guest from it. And write a file in it.
# qemu-img create --object secret,id=sec0,data=base --object secret,id=sec1,data=sn1  -f qcow2 -o encrypt.format=luks,encrypt.key-secret=sec1 -b 'json:{"encrypt.key-secret": "sec0", "driver": "qcow2", "file": {"driver": "file", "filename": "base.qcow2"}}' sn1.qcow2

# /usr/libexec/qemu-kvm \
        -name 'guest-rhel8.0' \
        -machine q35 \
        -nodefaults \
        -vga qxl \
	-object secret,id=sec0,data=base \
        -object secret,id=sec1,data=sn1 \
	-object secret,id=sec4,data=nbase \
	-drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=qcow2,file=sn1.qcow2,encrypt.format=luks,encrypt.key-secret=sec1 \
        -device virtio-blk-pci,id=virtio_blk_pci0,drive=drive_image1,bus=pcie.0,addr=05,bootindex=0 \
        -vnc :0 \
        -monitor stdio \
        -m 8192 \
        -smp 8 \
        -device virtio-net-pci,mac=9a:b5:b6:b1:b2:b3,id=idMmq1jH,vectors=4,netdev=idxgXAlm,bus=pcie.0,addr=0x9  \
        -netdev tap,id=idxgXAlm \
        -chardev socket,id=qmp_id_qmpmonitor1,path=/var/tmp/hucheng/monitor-qmpmonitor1-20180220-094308-h9I6hRsI,server,nowait \
        -mon chardev=qmp_id_qmpmonitor1,mode=control  \

5.Ceate a new empty luks-inside-qcow2 image and rebase sn1.qcow2 to it.
# qemu-img create -f qcow2 --object secret,id=sec4,data=nbase -o encrypt.format=luks,encrypt.key-secret=sec4 nbase.qcow2 20G
# qemu-img rebase --object secret,id=sec0,data=base --object secret,id=sec1,data=sn1 --object secret,id=sec4,data=nbase -b 'json:{"encrypt.key-secret": "sec4", "driver": "qcow2", "file": {"driver": "file", "filename": "nbase.qcow2"}}'  -f qcow2 -F qcow2 'json:{"encrypt.key-secret": "sec1", "driver": "qcow2", "file": {"driver": "file", "filename": "sn1.qcow2"}}'

6. Check snapshot file, there is no error.
# qemu-img check --object secret,id=sec1,data=sn1 --object secret,id=sec4,data=nbase 'json:{"encrypt.key-secret": "sec1", "driver": "qcow2", "file": {"driver": "file", "filename": "sn1.qcow2"}}'
No errors were found on the image.
124810/327680 = 38.09% allocated, 1.41% fragmented, 0.00% compressed clusters
Image end offset: 8183480320

7. Boot from sn3.qcow2
# /usr/libexec/qemu-kvm \
        -name 'guest-rhel8.0' \
        -machine q35 \
        -nodefaults \
        -vga qxl \
	-object secret,id=sec0,data=base \
        -object secret,id=sec1,data=sn1 \
	-object secret,id=sec4,data=nbase \
	-drive id=drive_image1,if=none,snapshot=off,aio=threads,cache=none,format=qcow2,file=sn1.qcow2,encrypt.format=luks,encrypt.key-secret=sec1 \
        -device virtio-blk-pci,id=virtio_blk_pci0,drive=drive_image1,bus=pcie.0,addr=05,bootindex=0 \
        -vnc :0 \
        -monitor stdio \
        -m 8192 \
        -smp 8 \
        -device virtio-net-pci,mac=9a:b5:b6:b1:b2:b3,id=idMmq1jH,vectors=4,netdev=idxgXAlm,bus=pcie.0,addr=0x9  \
        -netdev tap,id=idxgXAlm \
        -chardev socket,id=qmp_id_qmpmonitor1,path=/var/tmp/hucheng/monitor-qmpmonitor1-20180220-094308-h9I6hRsI,server,nowait \
        -mon chardev=qmp_id_qmpmonitor1,mode=control  \

8.Used the vncviewer connect to the guest and saw an error msg.


Actual results:
In step8,after I select the os,it hit an error.And the screenshot is in attachment.


Expected results:
Boot successfully and enter the os.


Additional info:
ALL IMAGE FORMAT IS LUKS-INSIDE-QCOW2。And for normal qcow2 without encrytion, there is no the bug.

Comment 1 Cheng Huayu 2019-08-27 09:24:59 UTC
Tried on 'qemu-kvm-4.0.0-6.module+el8.1.0+3736+a2aefea3', there is no the bug. So mark this bug as regression. Thanks.

Comment 2 Rick Barry 2019-08-27 19:08:00 UTC
Note: Priority is set to High and ITR is 8.1.0 since this was marked a regression.

Comment 4 Maxim Levitsky 2019-09-06 17:47:11 UTC
This is a real corruption, introduced in 4.1 with threaded luks
encryption code (commit 8ac0f15f335)

I had just sent patch upstream which fixes it.

https://lists.gnu.org/archive/html/qemu-devel/2019-09/msg01244.html

Comment 5 John Ferlan 2019-09-11 19:55:20 UTC
Setting exception? based on Virt team meeting from Sep 11 for bz's w/ ITR 8.1.0. It's a qemu-4.1 regression.

Comment 16 Tingting Mao 2019-09-26 06:56:08 UTC
Reproduced this bug in 'qemu-kvm-4.1.0-11.module+el8.1.0+4250+4f5fbfdc'. And in latest 'qemu-kvm-4.1.0-12.module+el8.1.0+4292+1293ae0c', did not hit this bug. 


Tested with:
kernel-4.18.0-145.el8
qemu-kvm-4.1.0-12.module+el8.1.0+4292+1293ae0c


Steps:
The same as the ones in Comment 0.


Result:
After step8, guest booted up normally. And all the files created before were still existing.

Comment 18 errata-xmlrpc 2019-11-06 07:19:01 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/RHBA-2019:3723