Bug 1537956

Summary: RFE: qemu-img amend should list the true supported options
Product: Red Hat Enterprise Linux 7 Reporter: Ping Li <pingl>
Component: qemu-kvm-rhevAssignee: Hanna Czenczek <hreitz>
Status: CLOSED ERRATA QA Contact: Tingting Mao <timao>
Severity: low Docs Contact:
Priority: low    
Version: 7.5CC: chayang, juzhang, knoel, michen, mtessun, ngu, pingl, virt-maint
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-rhev-2.12.0-6.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-11-01 11:04:08 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 Ping Li 2018-01-24 07:36:39 UTC
Description of problem:
qemu-img supports to get an overview of the options[1] supported by raw and luks for subcommand amend. However, the specific options cannot be amended with the corresponding image format[2]. 
If we plan to support these options, we should have a bug track it. If we don't intend to support them, we should not show them and give a meaningful error message when try to amend it(such as "Format driver '%s' does not support any options to amend", because all the listed options are not supported).
After check the source code, found qemu-img uses create options for subcommand amend(raw: raw_create_opts, luks: block_crypto_create_opts_luks). The options could be used for create and convert. But we should not use them for amend.

[1] Get supported options
# qemu-img amend -f raw -o ?
Supported options:
size             Virtual disk size

# qemu-img amend -f luks -o ?
Supported options:
size             Virtual disk size
key-secret       ID of the secret that provides the keyslot passphrase
cipher-alg       Name of encryption cipher algorithm
cipher-mode      Name of encryption cipher mode
ivgen-alg        Name of IV generator algorithm
ivgen-hash-alg   Name of IV generator hash algorithm
hash-alg         Name of encryption hash algorithm
iter-time        Time to spend in PBKDF in milliseconds

[2] Try to amend the supported options
1. raw format 
1.1 Option size
# qemu-img create -f raw test.img 1G
# qemu-img amend -f raw -o size=2G test.img 
qemu-img: Error while amending options: Operation not supported

2. luks format
2.1 Options size
# qemu-img create -f luks --object secret,id=sec0,data=test -o key-secret=sec0 test.luks 1G
# qemu-img amend --object secret,id=sec0,data=test --image-opts driver=luks,key-secret=sec0,file.filename=test.luks -o size=2G
qemu-img: Error while amending options: Operation not supported

2.2 Option key-secret
# qemu-img amend --object secret,id=sec0,data=test --object secret,id=sec1,data=new --image-opts driver=luks,key-secret=sec0,file.filename=test.luks -o key-secret=sec1
qemu-img: Error while amending options: Operation not supported

3. qcow2 format
3.1 Option size
# qemu-img create -f qcow2 test.qcow2 1G
Formatting 'test.qcow2', fmt=qcow2 size=1073741824 cluster_size=65536 lazy_refcounts=off refcount_bits=16
# qemu-img resize test.qcow2 +1G
Image resized.



Version-Release number of selected component (if applicable):
qemu-kvm-rhev-2.10.0-18.el7

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 4 Hanna Czenczek 2018-04-21 17:42:18 UTC
Sent an upstream series:
http://lists.nongnu.org/archive/html/qemu-block/2018-04/msg00456.html

Comment 6 Miroslav Rezanina 2018-07-01 03:16:00 UTC
Fix included in qemu-kvm-rhev-2.12.0-6.el7

Comment 7 Ping Li 2018-07-02 06:25:15 UTC
Based on my testing, encryption, cluster_size, and preallocation couldn't be changed for qcow2 image but it is indeed listed for qemu-img amend. Although I think these options should be removed and some information should be corrected, but I think it still could be accepted according to Max's commit logs.
Set the bug as verified. Thanks Max.

Packages tested:
kernel-3.10.0-916.el7
qemu-kvm-rhev-2.12.0-6.el7

Test steps:
1. Get supported options for qemu-img amend
1) raw format
# qemu-img amend -f raw -o ?
qemu-img: Format driver 'raw' does not support option amendment

2) luks format
# qemu-img amend -f luks -o ?
qemu-img: Format driver 'luks' does not support option amendment

3) qcow2 format
# qemu-img amend -f qcow2 -o ?
Creation options for 'qcow2': ----> This should be Amendment options
size             Virtual disk size
compat           Compatibility level (0.10 or 1.1)
backing_file     File name of a base image
backing_fmt      Image format of the base image
encryption       Encrypt the image with format 'aes'. (Deprecated in favor of encrypt.format=aes)
encrypt.format   Encrypt the image, format choices: 'aes', 'luks'
encrypt.key-secret ID of secret providing qcow AES key or LUKS passphrase
encrypt.cipher-alg Name of encryption cipher algorithm
encrypt.cipher-mode Name of encryption cipher mode
encrypt.ivgen-alg Name of IV generator algorithm
encrypt.ivgen-hash-alg Name of IV generator hash algorithm
encrypt.hash-alg Name of encryption hash algorithm
encrypt.iter-time Time to spend in PBKDF in milliseconds
cluster_size     qcow2 cluster size
preallocation    Preallocation mode (allowed values: off, metadata, falloc, full)
lazy_refcounts   Postpone refcount updates
refcount_bits    Width of a reference count entry in bits

Note that not all of these options may be amendable. ---> this should be useful

2. Changed the options
1) encryption
# qemu-img amend --object secret,id=sec0,data=base -f qcow2 -o encrypt.format=luks,encrypt.key-secret=sec0 base.qcow2 
qemu-img: Changing the encryption format is not supported

2) cluster_size
# qemu-img amend -f qcow2 -o cluster_size=2M base.qcow2
qemu-img: Changing the cluster size is not supported

3) preallocation mode
# qemu-img amend -f qcow2 -o preallocation=full base.qcow2 
qemu-img: Cannot change preallocation mode

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