RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1980035 - RFE: Enable compress filter so we can create new, compressed qcow2 files via qemu-nbd
Summary: RFE: Enable compress filter so we can create new, compressed qcow2 files via ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: qemu-kvm
Version: 9.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 9.0
Assignee: Eric Blake
QA Contact: Tingting Mao
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-07-07 16:02 UTC by Richard W.M. Jones
Modified: 2022-05-17 12:25 UTC (History)
9 users (show)

Fixed In Version: qemu-kvm-6.1.0-7.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-17 12:23:27 UTC
Type: Feature Request
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2022:2307 0 None None None 2022-05-17 12:23:56 UTC

Description Richard W.M. Jones 2021-07-07 16:02:12 UTC
Description of problem:

virt-v2v has a --compressed option which traditionally
enabled the underlying qemu-img -c option to generate
a compressed qcow2 file.

virt-v2v "2.0" [1][2] will do everything with disk image pipelines,
necessitating that we create and write the qcow2 file via qemu-nbd.
We believe this command is sufficient:

qemu-nbd --image-opts driver=compress,file.driver=qcow2,file.file.driver=file,file.file.filename=new.qcow2

We will always write each cluster at most once.

However to do this means that we must enable the compress
filter in qemu-kvm in RHEL 9.

The back-up plan if we cannot enable this will be to remove
the --compressed feature from virt-v2v.

Version-Release number of selected component (if applicable):

qemu-kvm-6.0.0-1.el9.x86_64

Additional info:

[1] https://listman.redhat.com/archives/libguestfs/2020-November/msg00022.html
[2] https://github.com/rwmjones/virt-v2v/commits/2021-virt-v2v-split

https://bugzilla.redhat.com/show_bug.cgi?id=1957782#c6

Comment 3 Klaus Heinrich Kiwi 2021-08-11 19:21:44 UTC
Eric, care to take a look and update?

Comment 4 Klaus Heinrich Kiwi 2021-10-28 11:53:50 UTC
(In reply to Klaus Heinrich Kiwi from comment #3)
> Eric, care to take a look and update?

Eric,

 any updates? How likely is it for us to have this in 9.0-GA?

Comment 5 Eric Blake 2021-11-11 18:00:01 UTC
This should be doable for 9.0-GA. filter-compress has been in upstream qemu since 5.0.  Either the compress filter is already on the list of active block drivers, or it should be a simple patch to the downstream patch to add it.  But right now I need to figure out which downstream patch implements our current whitelist to definitively answer that.

Comment 6 Eric Blake 2021-11-11 22:23:56 UTC
The configure line in the current .distro/qemu-kvm.spec.template file for rhel 9 mentions only:
%global block_drivers_rw_list qcow2,raw,file,host_device,nbd,iscsi,rbd,blkdebug,luks,null-co,nvme,copy-on-read,throttle

which does not mention compress by name. But it also does not reject compress.  A quick build of the spec file and testing the just-built qemu-nbd with driver=compress in the command line worked for me, so it does appear to be built in.  Otherwise, it's a one-line patch to explicitly add it to our rw_list.

Comment 11 Tingting Mao 2021-11-22 03:28:46 UTC
Hi Eric,

Could you please help to check whether the verifying steps are okay/enought? Thanks.


Tested with:
qemu-kvm-6.1.0-7.el9
kernel-5.14.0-15.el9.x86_64


Steps:
1. Create a compressed qcow2 image via qemu-img.
# qemu-img create -f qcow2 new.qcow2 2G
# qemu-io -c 'write -P 1 0 1G' new.qcow2
# qemu-img convert -f qcow2 -O qcow2 -c new.qcow2 new.compressed.qcow2 -p

2. Export the compressed image via qemu-nbd
# qemu-nbd --image-opts driver=compress,file.driver=qcow2,file.file.driver=file,file.file.filename=new.compressed.qcow2 -t &

3. Check the image info
# qemu-img info nbd://localhost:10809
image: nbd://localhost:10809
file format: raw
virtual size: 2 GiB (2147483648 bytes)
disk size: unavailable



BTW, the steps are also works in qemu-kvm-6.1.0-1.el9.
# qemu-img --version
qemu-img version 6.1.0 (qemu-kvm-6.1.0-1.el9)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers

# qemu-nbd --image-opts driver=compress,file.driver=qcow2,file.file.driver=file,file.file.filename=new.compressed.qcow2 -t &
[1] 162472
# qemu-img info nbd://localhost:10809
image: nbd://localhost:10809
file format: raw
virtual size: 2 GiB (2147483648 bytes)
disk size: unavailable

Comment 12 Eric Blake 2021-11-22 15:00:09 UTC
(In reply to Tingting Mao from comment #11)
> Hi Eric,
> 
> Could you please help to check whether the verifying steps are okay/enought?
> Thanks.
> 
> 
> Tested with:
> qemu-kvm-6.1.0-7.el9
> kernel-5.14.0-15.el9.x86_64
> 
> 
> Steps:
> 1. Create a compressed qcow2 image via qemu-img.
> # qemu-img create -f qcow2 new.qcow2 2G
> # qemu-io -c 'write -P 1 0 1G' new.qcow2
> # qemu-img convert -f qcow2 -O qcow2 -c new.qcow2 new.compressed.qcow2 -p
> 
> 2. Export the compressed image via qemu-nbd
> # qemu-nbd --image-opts
> driver=compress,file.driver=qcow2,file.file.driver=file,file.file.
> filename=new.compressed.qcow2 -t &
> 
> 3. Check the image info
> # qemu-img info nbd://localhost:10809
> image: nbd://localhost:10809
> file format: raw
> virtual size: 2 GiB (2147483648 bytes)
> disk size: unavailable

The compress driver only makes a difference on writes.  We can read a compressed qcow2 image even without the compress driver in the mix, so you merely proved that the driver loaded, but not that it made a difference.  What you really want to test (to match what v2v actually needs to be available) is that you can pre-create an empty qcow2 image, then do a one-pass write into that image through the compress driver, and that the resulting qcow2 file is compressed yet equivalent contents to the original.  This is what I tested:

1. Create an non-empty qcow2 source image, and an empty destination
# qemu-img create -f qcow2 src.qcow2 2G
# qemu-io -f qcow2 -c 'write -P 1 0 1G' src.qcow2
# qemu-img create -f qcow2 dst.qcow2 2G

2. Export the destination wrapped by the compress driver, so that writes get compressed
# qemu-nbd --image-opts driver=compress,file.driver=qcow2,file.file.driver=file,file.file.filename=dst.qcow2 -t &

3. Copy into the destination, then end qemu-nbd
# qemu-img convert -f qcow2 -O raw -n --target-is-zero src.qcow2 nbd://localhost:10809
# kill $!

4. Check that the resulting image reads identically but is indeed compressed
# ls -l src.qcow2 dst.qcow2 
-rw-r--r--. 1 eblake eblake    1687607 Nov 22 08:47 dst.qcow2
-rw-r--r--. 1 eblake eblake 1074135040 Nov 22 08:44 src.qcow2
# qemu-img compare -f qcow2 -F qcow2 src.qcow2 dst.qcow2
Images are identical.

> 
> 
> 
> BTW, the steps are also works in qemu-kvm-6.1.0-1.el9.

Yes, by luck.  In that build, our code base was not explicitly mentioning whether to include or exclude the compress driver, but it happened to be enabled (that may or may not be an upstream bug that when we have an explicit accept list, drivers that were not explicitly mentioned still end up being available rather than on the exclude list - but addressing that is not the goal of this bug).  The change in this patch is that the compress driver is now explicit, rather than relying on luck for whatever the code base chooses as a default.  Adding the test ensures that we avoid future regressions for v2v's needs, even if we can't prove a change in behavior of luckily-on vs. explicitly-on.

You could _also_ test that:
$ qemu-img --help | grep 'Supported formats'
includes the 'compress' driver (it must be present if this patch is working).  I don't know if there is a way to make qemu-kvm cough up its list of enabled drivers, and that's somewhat unfortunate since the list of supported drivers may differ between qemu-img and qemu-kvm (v2v only cares that tools like qemu-img and qemu-nbd support the format; whether qemu-kvm must also support compress is a different question).

Comment 13 Tingting Mao 2021-11-23 02:35:59 UTC
Thanks for Eric's info. And tried again.


Tested with:
qemu-kvm-6.1.0-7.el9
kernel-5.14.0-15.el9.x86_64


Steps:
1. Create an non-empty qcow2 source image, and an empty destination
# qemu-img create -f qcow2 src.qcow2 2G
# qemu-io -f qcow2 -c 'write -P 1 0 1G' src.qcow2
# qemu-img create -f qcow2 dst.qcow2 2G

2. Export the destination wrapped by the compress driver, so that writes get compressed
# qemu-nbd --image-opts driver=compress,file.driver=qcow2,file.file.driver=file,file.file.filename=dst.qcow2 -t &

3. Copy into the destination, then end qemu-nbd
# qemu-img convert -f qcow2 -O raw -n --target-is-zero src.qcow2 nbd://localhost:10809
# kill $!

4. Check that the resulting image reads identically but is indeed compressed
# ls -la src.qcow2 dst.qcow2 
-rw-r--r-- 1 root root    1687607 Nov 22 20:59 dst.qcow2
-rw-r--r-- 1 root root 1074135040 Nov 22 20:58 src.qcow2

5. Compare the source and target images, they are identical.
# qemu-img compare -f qcow2 -F qcow2 src.qcow2 dst.qcow2 
Images are identical.

6. Check the help doc for supported formats of qemu-img
# qemu-img --help| grep -i 'supported formats'
  '-h' with or without a command shows this help and lists the supported formats
Supported formats: blkdebug blklogwrites blkverify compress copy-on-read file ftp ftps host_cdrom host_device http https luks nbd null-aio null-co nvme preallocate qcow2 quorum raw rbd ssh throttle vdi vhdx vmdk vpc
                                                   ^^^^^^^^ 


Also, all the steps are work in qemu-kvm-6.1.0-1.el9 including the checked info of qemu-img:
# qemu-img --version
qemu-img version 6.1.0 (qemu-kvm-6.1.0-1.el9)
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers

# qemu-img --help | grep -i 'supported formats'
  '-h' with or without a command shows this help and lists the supported formats
Supported formats: blkdebug blklogwrites blkverify compress copy-on-read file ftp ftps host_cdrom host_device http https luks nbd null-aio null-co nvme preallocate qcow2 quorum raw rbd ssh throttle vhdx vmdk vpc
                                                    ^^^^^^^

Comment 14 Yanan Fu 2021-11-24 02:28:25 UTC
QE bot(pre verify): Set 'Verified:Tested,SanityOnly' as gating/tier1 test pass.

Comment 17 Tingting Mao 2021-11-24 03:30:43 UTC
According to Comment 13, set this bug as verified.

Comment 19 errata-xmlrpc 2022-05-17 12:23:27 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 (new packages: qemu-kvm), 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-2022:2307


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