Bug 1264332

Summary: Test that trimming in virt-v2v doesn't regress
Product: Red Hat Enterprise Linux 7 Reporter: mxie <mxie>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: juzhou, mxie, mzhan, ptoscano, rjones, tzheng, xiaodwan
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.32.5-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-06-23 09:49:52 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
Conversion logs
none
new conversion logs
none
conversion logs on qemu-kvm-2.3.0-24.zip none

Description mxie@redhat.com 2015-09-18 08:34:41 UTC
Created attachment 1074728 [details]
Conversion logs

Description of problem:
Parameter '--no-trim all' doesn't work when converting guest via virt-v2v command

Version-Release number of selected component (if applicable):
virt-v2v-1.28.1-1.55.el7.x86_64
libvirt-1.2.17-9.el7.x86_64
libguestfs-1.28.1-1.55.el7.x86_64
host:rhel7.2-x64-20150910.2(3.10.0-315.el7.x86_64)

How reproducible:
100%

Steps to Reproduce:
1. Convert a guest from Xen server to local kvm using parameter '--no-trim all'
# virt-v2v -ic xen+ssh://10.66.106.64 -b virbr0 rhel6.7-mxie -on rhel6.7-have-para --no-trim all -of raw
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.66.106.64 rhel6.7-mxie
[   0.0] Creating an overlay to protect the source from being modified
[   1.0] Opening the overlay
[   5.0] Initializing the target -o libvirt -os default
[   5.0] Inspecting the overlay
[  21.0] Checking for sufficient free disk space in the guest
[  21.0] Estimating space required on target for each disk
[  21.0] Converting Red Hat Enterprise Linux Server release 6.7 Beta (Santiago) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[  68.0] Closing the overlay
[  69.0] Checking if the guest needs BIOS or UEFI to boot
[  69.0] Copying disk 1/1 to /var/lib/libvirt/images/rhel6.7-have-para-sda (raw)
    (100.00/100%)
[ 314.0] Creating output metadata
Pool default refreshed

Domain rhel6.7-have-para defined from /tmp/v2vlibvirt5e3fe1.xml

[ 314.0] Finishing off


2. Convert a guest from Xen server to local kvm without parameter '--no-trim all'
# virt-v2v -ic xen+ssh://10.66.106.64 -b virbr0 rhel6.7-mxie -on rhel6.7-no-para -of raw
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.66.106.64 rhel6.7-mxie
[   2.0] Creating an overlay to protect the source from being modified
[   3.0] Opening the overlay
[   7.0] Initializing the target -o libvirt -os default
[   7.0] Inspecting the overlay
[  24.0] Checking for sufficient free disk space in the guest
[  24.0] Estimating space required on target for each disk
[  24.0] Converting Red Hat Enterprise Linux Server release 6.7 Beta (Santiago) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[  71.0] Mapping filesystem data to avoid copying unused and blank areas
[  72.0] Closing the overlay
[  72.0] Checking if the guest needs BIOS or UEFI to boot
[  72.0] Copying disk 1/1 to /var/lib/libvirt/images/rhel6.7-no-para-sda (raw)
    (100.00/100%)
[ 318.0] Creating output metadata
Pool default refreshed

Domain rhel6.7-no-para defined from /tmp/v2vlibvirt27579d.xml

[ 318.0] Finishing off


3. Comparing two guests'disk
# ls -lsh rhel6.7-have-para-sda 
3.2G -rw-r--r--. 1 root root 5.9G Sep 18 11:25 rhel6.7-have-para-sda
# ls -lsh rhel6.7-no-para-sda 
3.2G -rw-r--r--. 1 root root 5.9G Sep 18 11:33 rhel6.7-no-para-sda

4. We can find the parameter '--no-trim all' doesn't work when converting guest via virt-v2v command on rhel7.2



Actual results:
As above steps

Expected results:
The guest's disk converted using --no-trim all option is larger than without
--no-trim all option.

Additional info:
Verify With the packages version:
virt-v2v-1.28.1-1.18.el7.x86_64
libvirt-1.2.8-16.el7.x86_64
libguestfs-1.28.1-1.18.el7.x86_64
host:rhel7.1-x64(3.10.0-229.el7.x86_64)

1.Convert a guest from Xen server to local kvm using parameter '--no-trim all'
# virt-v2v -ic xen+ssh://10.66.106.64 -b virbr0 rhel6.7-mxie -on rhel6.7-have-para --no-trim all -of raw
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.66.106.64 rhel6.7-mxie
[   0.0] Creating an overlay to protect the source from being modified
[   1.0] Opening the overlay
[   5.0] Initializing the target -o libvirt -os default
[   5.0] Inspecting the overlay
[  22.0] Checking for sufficient free disk space in the guest
[  22.0] Estimating space required on target for each disk
[  22.0] Converting Red Hat Enterprise Linux Server release 6.7 Beta (Santiago) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[  69.0] Closing the overlay
[  69.0] Copying disk 1/1 to /var/lib/libvirt/images/rhel6.7-have-para-sda (raw)
    (100.00/100%)
[ 259.0] Creating output metadata
Pool default refreshed

Domain rhel6.7-have-para defined from /tmp/v2vlibvirt7725cc.xml

[ 259.0] Finishing off

2.Convert a guest from Xen server to local kvm without parameter '--no-trim all'
# virt-v2v -ic xen+ssh://10.66.106.64 -b virbr0 rhel6.7-mxie -on rhel6.7-no-para -of raw
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.66.106.64 rhel6.7-mxie
[   1.0] Creating an overlay to protect the source from being modified
[   1.0] Opening the overlay
[ 182.0] Initializing the target -o libvirt -os default
[ 182.0] Inspecting the overlay
[ 200.0] Checking for sufficient free disk space in the guest
[ 200.0] Estimating space required on target for each disk
[ 200.0] Converting Red Hat Enterprise Linux Server release 6.7 Beta (Santiago) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 247.0] Mapping filesystem data to avoid copying unused and blank areas
[ 248.0] Closing the overlay
[ 248.0] Copying disk 1/1 to /var/lib/libvirt/images/rhel6.7-no-para-sda (raw)
    (100.00/100%)
[ 373.0] Creating output metadata
Pool default refreshed

Domain rhel6.7-no-para defined from /tmp/v2vlibvirt044e66.xml

[ 375.0] Finishing off


3. Comparing two guests'disk
# ls -lsh rhel6.7-have-para-sda 
3.2G -rw-r--r--. 1 root root 5.9G Sep 17 23:13 rhel6.7-have-para-sda
# ls -lsh rhel6.7-no-para-sda 
2.9G -rw-r--r--. 1 root root 5.9G Sep 17 23:07 rhel6.7-no-para-sda

4. We can find the guest's disk converted using --no-trim all option is larger than without --no-trim all option.

Comment 2 Richard W.M. Jones 2015-09-18 09:17:23 UTC
I think you've attached the wrong log files for the rhel7u2
conversions, because:

$ grep "virt-v2v: error" *
convert guest without parameter --no-trim all on rhel7u2.log:virt-v2v: error: a libvirt domain called 'rhel6.7-no-para' already exists 
convert guest with parameter --no-trim all on rhel7u2.log:virt-v2v: error: a libvirt domain called 'rhel6.7-have-para' already exists

Comment 3 mxie@redhat.com 2015-09-18 09:51:13 UTC
Created attachment 1074763 [details]
new conversion logs

Comment 4 Richard W.M. Jones 2015-09-18 10:05:12 UTC
I think the issue is probably this difference between your
RHEL 7.1 and RHEL 7.2 test:

-libguestfs: qemu version 2.1
+libguestfs: qemu version 1.5

Probably old qemu didn't support discard (or maybe not in all
circumstances).  I think we need an extra test to make sure
that trimming doesn't regress.

Comment 5 mxie@redhat.com 2015-09-21 08:23:47 UTC
(In reply to Richard W.M. Jones from comment #4)
> I think the issue is probably this difference between your
> RHEL 7.1 and RHEL 7.2 test:
> 
> -libguestfs: qemu version 2.1
> +libguestfs: qemu version 1.5
> 
> Probably old qemu didn't support discard (or maybe not in all
> circumstances).  I think we need an extra test to make sure
> that trimming doesn't regress.

yes, I also think the qemu-kvm version 1.5 is not support parameter"--no-trim all"   

Verify parameter'--no-trim all' With below packages version
virt-v2v-1.28.1-1.55.el7.x86_64
libvirt-1.2.17-9.el7.x86_64
libguestfs-1.28.1-1.55.el7.x86_64
qemu-kvm-rhev-2.3.0-24.el7.x86_64

Host:rhel7.2-x64-20150917.0(3.10.0-316.el7.x86_64)

Comparing two guests'disk as below and we can find the guest's disk converted using --no-trim all option is larger than without --no-trim all option. more details pls refer to attachment log:
# ls -lsh have-parameter-sda 
3.2G -rw-r--r--. 1 root root 5.9G Sep 21 15:48 have-parameter-sda
# ls -lsh no-parameter-sda 
2.9G -rw-r--r--. 1 root root 5.9G Sep 21 15:42 no-parameter-sda

Comment 6 mxie@redhat.com 2015-09-21 08:24:37 UTC
Created attachment 1075419 [details]
conversion logs on qemu-kvm-2.3.0-24.zip

Comment 8 Richard W.M. Jones 2016-04-26 09:29:12 UTC
FWIW I've proposed that we remove the --no-trim option entirely
in RHEL 7.4.  See:
https://www.redhat.com/archives/libguestfs/2016-April/msg00178.html

Comment 9 Richard W.M. Jones 2016-04-26 12:17:05 UTC
Patch posted:
https://www.redhat.com/archives/libguestfs/2016-April/msg00184.html

Comment 11 mxie@redhat.com 2016-06-23 07:04:14 UTC
Try to reproduce the bug with builds
virt-v2v-1.28.1-1.55.el7.x86_64
libguestfs-1.28.1-1.55.el7.x86_64
qemu-kvm-1.5.3-104.el7.x86_64

Reproduce steps:
1.Convert a guest from Xen server without parameter '--no-trim all'
# virt-v2v -ic xen+ssh://10.73.3.21 -b virbr0 xen-hvm-win7-x86_64 -on no-para -of raw
2.Convert a guest from Xen server with parameter '--no-trim all' 
# virt-v2v -ic xen+ssh://10.73.3.21 -b virbr0 xen-hvm-win7-x86_64 -on have-para --no-trim all -of raw
3.Comparing two guests'disk as below, different size is about 8M 
# ls -ls have-para-sda 
7979320 -rw-r--r--. 1 root root 10485760000 Jun 23 12:07 have-para-sda
# ls -ls no-para-sda
7970748 -rw-r--r--. 1 root root 10485760000 Jun 23 12:10 no-para-sda



Try to verify the bug with builds
virt-v2v-1.32.5-5.el7.x86_64
libguestfs-1.32.5-5.el7.x86_64
qemu-kvm-1.5.3-113.el7.x86_64

Verify Steps:
1.Convert a guest from Xen server without parameter '--no-trim all'
# virt-v2v -ic xen+ssh://10.73.3.21 -b virbr0 xen-hvm-win7-x86_64 -on no-para -of raw
2.Convert a guest from Xen server with parameter '--no-trim all' 
# virt-v2v -ic xen+ssh://10.73.3.21 -b virbr0 xen-hvm-win7-x86_64 -on have-para --no-trim all -of raw
3.Comparing two guests'disk as below, different size is about 8M 
# ls -ls no-para-sda
7970720 -rw-r--r--. 1 root root 10485760000 Jun 23 10:18 no-para-sda
# ls -ls have-para-sda 
7979288 -rw-r--r--. 1 root root 10485760000 Jun 23 10:31 have-para-sda


Hi rjones

According to above reproduce result and verify result,I didn't find any change between libguestfs-1.32.5-1.el7 and libguestfs-1.28.1-1.55.el7.x86_64 for this bug, I also see the patch https://www.redhat.com/archives/libguestfs/2016-April/msg00184.html said that 
" We're expecting the image to grow a bit because of the changes made
 by conversion (I observed growth of about 9MB).  That's OK.  If it
 grows by ~ 500 + 100 MB, then that's not OK.  So choose a threshold
 of 300 MB"

But if convert a guest whose size is about 6G respectively with --no-trim all or without --no-trim all, it will have about 2MB difference in size and there also no difference between libguestfs-1.32.5-1.el7 and libguestfs-1.28.1-1.55.el7.x86_64, such as below

Using libguestfs-1.32.5-1.el7
# ls -ls rhel6.7-no-sda
3306208 -rw-r--r--. 1 root root 6291456000 Jun 22 17:28 rhel6.7-no-sda
# ls -ls rhel6.7-have-para-sda
3308112 -rw-r--r--. 1 root root 6291456000 Jun 22 17:14 rhel6.7-have-para-sda

Using libguestfs-1.28.1-1.55.el7.x86_64
# ls -ls no-sda 
3306228 -rw-r--r--. 1 root root 6291456000 Jun 23 14:57 no-sda
# ls -ls have-sda 
3314384 -rw-r--r--. 1 root root 6291456000 Jun 23 14:42 have-sda


I'm not sure whether this bug is fixed, pls give me some suggestion, thanks

Comment 12 Richard W.M. Jones 2016-06-23 08:17:13 UTC
Honestly I can't really understand what this bug is about.

However looking at the procedure in comment 11, I think you need
to use qemu-kvm-rhev.  qemu-kvm 1.5 didn't support trimming, or only
supported trimming in limited circumstances.  qemu-kvm-rhev has
full support for trimming (except over NFS).

Comment 13 mxie@redhat.com 2016-06-23 08:38:56 UTC
(In reply to Richard W.M. Jones from comment #12)
> Honestly I can't really understand what this bug is about.
> 
> However looking at the procedure in comment 11, I think you need
> to use qemu-kvm-rhev.  qemu-kvm 1.5 didn't support trimming, or only
> supported trimming in limited circumstances.  qemu-kvm-rhev has
> full support for trimming (except over NFS).

Hi rjones,

Thanks for you quickly reply, but virt-v2v is released with qemu-kvm on rhel, we need to test virt-v2v with qemu-kvm rather than qemu-kvm-rhev, if qemu-kvm 1.5 doesn't support trimming, could we remove parameter --no-trim all in virt-v2v directly?

Comment 14 Richard W.M. Jones 2016-06-23 08:49:52 UTC
Since the --no-trim option is going to be removed in RHEL 7.4
(or rather, turned into a warning and no-op), I don't think we
should spend too much time on this bug.

I've added a test upstream to ensure that trimming doesn't regress.

Comment 15 mxie@redhat.com 2016-06-23 09:19:13 UTC
Hi rjones,

Because --no-trim all parameter has no obvious effect for virt-v2v which is tested with qemu-kvm , could we move the bug to close currentrelease status, thanks

Comment 16 Richard W.M. Jones 2016-06-23 09:49:52 UTC
Closing this bug since in RHEL 7.4 the --no-trim parameter
will be turned into a warning and no-op.