Bug 1529666 - "qemu-img commit" reports error for luks format image
Summary: "qemu-img commit" reports error for luks format image
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.5
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Eric Blake
QA Contact: Tingting Mao
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-12-29 09:13 UTC by yilzhang
Modified: 2018-11-01 11:04 UTC (History)
14 users (show)

Fixed In Version: qemu-kvm-rhev-2.12.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-11-01 11:04:08 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description yilzhang 2017-12-29 09:13:37 UTC
Description of problem:
Use luks format image to create one snapshot with qcow2 format, then commit the changes to backing file, "qemu-img commit" will fail with error.

Power and x86 have the same issue.


Version-Release number of selected component (if applicable):
Host kernel: 3.10.0-825.el7.ppc64le
qemu-kvm:    qemu-kvm-rhev-2.10.0-13.el7

How reproducible: 100%


Steps to Reproduce:
1. Create an image with luks format
# qemu-img create -f luks --object secret,id=sec0,data=`printf %s "redhat" |base64`,format=base64 -o key-secret=sec0 base.luks 10G

2. Create a qcow2 snapshot based on this luks format image
# qemu-img create    --object secret,id=sec0,data=`printf %s "redhat" |base64`,format=base64 --object secret,id=sec1,data=snapshot    -f qcow2 -o encrypt.format=luks,encrypt.key-secret=sec1     -b 'json:{"key-secret": "sec0", "driver": "luks", "file": {"driver": "file", "filename": "base.luks"}}'     sn1.qcow2

3. Get information of the snapshot, and it should be qcow2 format
# qemu-img info  sn1.qcow2 
image: sn1.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 540K
encrypted: yes
cluster_size: 65536
backing file: json:{"key-secret": "sec0", "driver": "luks", "file": {"driver": "file", "filename": "base.luks"}}
Format specific information:
    compat: 1.1
... ...

4. Boot up the snapshot, write some files after the guest is up (optional)
-object secret,id=sec0,data=`printf %s "redhat" |base64`,format=base64 \
--object secret,id=sec1,data=snapshot \
-device virtio-scsi-pci,id=scsi0 \
-drive file=/home/sn1.qcow2,encrypt.key-secret=sec1,backing.key-secret=sec0,format=qcow2,if=none,rerror=stop,werror=stop,cache=none,id=drive_sysdisk \
-device scsi-hd,drive=drive_sysdisk,bus=scsi0.0,id=sysdisk,bootindex=0 \


5. Commit the changes to backing file
# qemu-img commit --object secret,id=sec0,data=`printf %s "redhat" |base64`,format=base64 --object secret,id=sec1,data=snapshot        --image-opts driver=qcow2,encrypt.key-secret=sec1,file.filename=sn1.qcow2,backing.key-secret=sec0


Actual results:
qemu-img: Block format 'luks' used by node '#block357' does not support reopening files
[root@dhcp-10-122 ~]# echo $?
1

Expected results:
"qemu-img commit" should succeed


Additional info:
x86 platform:
Host kernel: 3.10.0-823.el7.x86_64
qemu-kvm:    qemu-kvm-rhev-2.10.0-13.el7

Comment 3 Ping Li 2018-01-22 04:02:14 UTC
Failed to commit changes in the base luks image. Not sure it is a duplicate of this bug.

packages tested:
qemu-kvm-rhev-2.10.0-17.el7

Test steps:
1. Create an image chain as base.luks <- sn1.qcow2 <- sn2.qcow2. Boot guest with the created image and create temporary files base, sn1, and sn2 in turn. 
# qemu-img create -f luks --object secret,id=sec0,data=base -o key-secret=sec0 base.luks 20G
# qemu-img create -f qcow2 --object secret,id=sec0,data=base -b 'json:{"driver": "luks", "file": {"driver": "file", "filename": "/home/tests/nfsclient/pingl/base.luks"}, "key-secret": "sec0"}' sn1.qcow2
# qemu-img create --object secret,id=sec0,data=base -f qcow2 -b sn1.qcow2 -F qcow2 sn2.qcow2

# qemu-img info sn2.qcow2 --backing-chain
image: sn2.qcow2
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 1.0G
cluster_size: 65536
backing file: sn1.qcow2
backing file format: qcow2
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

image: sn1.qcow2
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 1.0G
cluster_size: 65536
backing file: json:{"driver": "luks", "file": {"driver": "file", "filename": "/home/tests/nfsclient/pingl/base.luks"}, "key-secret": "sec0"}
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

image: json:{"driver": "luks", "file": {"driver": "file", "filename": "/home/tests/nfsclient/pingl/base.luks"}, "key-secret": "sec0"}
file format: luks
virtual size: 20G (21474836480 bytes)
disk size: 12G
encrypted: yes
Format specific information:
    ivgen alg: plain64
    hash alg: sha256
    cipher alg: aes-256
    uuid: 11b118be-f4c3-4b04-b3c3-5f3fc073acaa
    cipher mode: xts
    slots:
        [0]:
            active: true
            iters: 499024
            key offset: 4096
            stripes: 4000
        [1]:
            active: false
            key offset: 262144
        [2]:
            active: false
            key offset: 520192
        [3]:
            active: false
            key offset: 778240
        [4]:
            active: false
            key offset: 1036288
        [5]:
            active: false
            key offset: 1294336
        [6]:
            active: false
            key offset: 1552384
        [7]:
            active: false
            key offset: 1810432
    payload offset: 2068480
    master key iters: 148945

2. Commit the changes in base image
# qemu-img commit --object secret,id=sec0,data=base -f qcow2 -b base.luks sn2.qcow2
qemu-img: Did not find 'base.luks' in the backing chain of 'sn2.qcow2'

Comment 8 Ping Li 2018-06-27 01:59:54 UTC
According to Comment 4 and Comment 5, set the bug as verified

Comment 9 errata-xmlrpc 2018-11-01 11:04:08 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-2018:3443


Note You need to log in before you can comment on or make changes to this bug.