Bug 1168144

Summary: warning: fstrim: fstrim: /sysroot/: FITRIM ioctl failed: Operation not supported (ignored) when convert win2003 guest from xen server
Product: Red Hat Enterprise Linux 7 Reporter: zhoujunqin <juzhou>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, mbooth, mzhan, ptoscano, tzheng
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: V2V
Fixed In Version: libguestfs-1.28.1-1.28.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:58:00 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
-v -x details log message xen-hvm-win2003-x86_64_debug_log none

Description zhoujunqin 2014-11-26 09:22:46 UTC
Created attachment 961544 [details]
-v -x details log message xen-hvm-win2003-x86_64_debug_log

Description of problem:
warning: fstrim: fstrim: /sysroot/: FITRIM ioctl failed:  Operation not supported (ignored) when convert win2003 guest from xen server

Version-Release number of selected component (if applicable):
virt-v2v-1.28.1-1.13.el7.x86_64
libguestfs-1.28.1-1.13.el7.x86_64
qemu-kvm-rhev-2.1.2-8.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Setup ssh-agent access to xen host.

2. Use virt-v2v convert a win2003 guest from xen host to localhost
# virt-v2v -ic xen+ssh://10.66.106.64 xen-hvm-win2003-x86_64   -of raw
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.66.106.64 xen-hvm-win2003-x86_64
[   1.0] Creating an overlay to protect the source from being modified
[   1.0] Opening the overlay
[   7.0] Initializing the target -o libvirt -os default
[   7.0] Inspecting the overlay
[  16.0] Checking for sufficient free disk space in the guest
[  16.0] Estimating space required on target for each disk
[  16.0] Converting Microsoft Windows Server 2003 to run on KVM
virt-v2v: This guest has virtio drivers installed.
[  17.0] Mapping filesystem data to avoid copying unused and blank areas
virt-v2v: warning: fstrim: fstrim: /sysroot/: FITRIM ioctl failed:
Operation not supported (ignored)
[  17.0] Closing the overlay
[  17.0] Copying disk 1/1 to /var/lib/libvirt/images/xen-hvm-win2003-x86_64-sda (raw)
    (100.00/100%)
[ 338.0] Creating output metadata
Pool default refreshed

Domain xen-hvm-win2003-x86_64 defined from /tmp/v2vlibvirt47d4d4.xml

[ 338.0] Finishing off

3. Guest can boot up.

Actual results:
As $step2, a warning message showing:
virt-v2v: warning: fstrim: fstrim: /sysroot/: FITRIM ioctl failed:
Operation not supported (ignored)

Expected results:
No such warning message during conversion.

Additional info:
1. Can reproduce this issue with guest: xen-hvm-win2003-i386 & xen-hvm-win2003-x86_64
2. I will attach detail log.

Comment 2 Richard W.M. Jones 2014-11-26 10:31:20 UTC
This warning is expected for Windows guests older than ~ 2008.

The reason it happens is that the ntfs-3g fstrim operation that I
wrote doesn't work unless the partition containing the ntfs-3g
filesystem is aligned sufficiently.  For guests older than ~ 2008
the partition was placed starting at sector 63, so it's not aligned
at all.  For newer guests it is aligned on a 1 MB boundary, so
everything is fine.

Try doing:

  virt-alignment-scan -a /var/lib/libvirt/images/xen-hvm-win2003-x86_64-sda

You are probably hitting the error
"fstrim: backing device is not aligned for discards" here:
http://sourceforge.net/p/ntfs-3g/ntfs-3g/ci/edge/tree/libntfs-3g/ioctl.c
although unfortunately those useful log messages require a special
build of ntfs-3g to enable.

I don't know what you want to do about this bug.  It seems
unlikely I'm going to add this to ntfs-3g since discarding non-
aligned blocks is very tricky, and if we get the calculations
wrong, it would end up deleting data which would not be a good
outcome.

Comment 3 tingting zheng 2014-11-26 10:41:28 UTC
(In reply to Richard W.M. Jones from comment #2)
> This warning is expected for Windows guests older than ~ 2008.
> 
> The reason it happens is that the ntfs-3g fstrim operation that I
> wrote doesn't work unless the partition containing the ntfs-3g
> filesystem is aligned sufficiently.  For guests older than ~ 2008
> the partition was placed starting at sector 63, so it's not aligned
> at all.  For newer guests it is aligned on a 1 MB boundary, so
> everything is fine.
> 
> Try doing:
> 
>   virt-alignment-scan -a /var/lib/libvirt/images/xen-hvm-win2003-x86_64-sda
> 
> You are probably hitting the error
> "fstrim: backing device is not aligned for discards" here:
> http://sourceforge.net/p/ntfs-3g/ntfs-3g/ci/edge/tree/libntfs-3g/ioctl.c
> although unfortunately those useful log messages require a special
> build of ntfs-3g to enable.
> 
> I don't know what you want to do about this bug.  It seems
> unlikely I'm going to add this to ntfs-3g since discarding non-
> aligned blocks is very tricky, and if we get the calculations
> wrong, it would end up deleting data which would not be a good
> outcome.

Maybe a more clear and user friendly warning info is perferred.

Comment 4 Richard W.M. Jones 2014-11-26 13:45:26 UTC
As this is cosmetic, moving to 7.2.

Comment 6 Richard W.M. Jones 2015-04-20 12:17:09 UTC
The warning is now only emitted when debugging:
https://github.com/libguestfs/libguestfs/commit/0576fdd0b6bafaeaa3d69bf6fc6fef0d0a1254d1

Comment 8 tingting zheng 2015-04-27 09:00:40 UTC
Tested with:
libguestfs-1.28.1-1.29.el7.x86_64
virt-v2v-1.28.1-1.29.el7.x86_64

When use virt-v2v to convert win2003 guest,there is no such warning as described.
# virt-v2v -ic xen+ssh://10.66.106.64 xen-hvm-win2003-x86_64   -of raw
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.66.106.64 xen-hvm-win2003-x86_64
[   1.0] Creating an overlay to protect the source from being modified
[   2.0] Opening the overlay
[   8.0] Initializing the target -o libvirt -os default
[   8.0] Inspecting the overlay
[  14.0] Checking for sufficient free disk space in the guest
[  14.0] Estimating space required on target for each disk
[  14.0] Converting Microsoft Windows Server 2003 to run on KVM
virt-v2v: This guest has virtio drivers installed.
[  15.0] Mapping filesystem data to avoid copying unused and blank areas
[  16.0] Closing the overlay
[  16.0] Copying disk 1/1 to /var/lib/libvirt/images/xen-hvm-win2003-x86_64-sda (raw)
    (100.00/100%)
[ 365.0] Creating output metadata
Pool default refreshed

Domain xen-hvm-win2003-x86_64 defined from /tmp/v2vlibvirt5fcbd4.xml

[ 366.0] Finishing off

Refer to the above comments,move the bug to VERIFIED.

Comment 10 errata-xmlrpc 2015-11-19 06:58:00 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://rhn.redhat.com/errata/RHBA-2015-2183.html

Comment 11 Richard W.M. Jones 2016-08-12 09:39:13 UTC
Note this fix is proposed to be reverted.  See:
https://bugzilla.redhat.com/show_bug.cgi?id=1366456#c5

Comment 12 tingting zheng 2016-09-19 10:16:49 UTC
The current output for converting windows 2003 from xen server is as below:
#  virt-v2v -ic xen+ssh://10.73.3.21  xen-hvm-win2003-x86_64   -of raw -os default
[   0.0] Opening the source -i libvirt -ic xen+ssh://10.73.3.21 xen-hvm-win2003-x86_64
[   1.0] Creating an overlay to protect the source from being modified
[   1.6] Initializing the target -o libvirt -os default
[   1.6] Opening the overlay
[   6.5] Inspecting the overlay
[  18.5] Checking for sufficient free disk space in the guest
[  18.5] Estimating space required on target for each disk
[  18.5] Converting Microsoft Windows Server 2003 to run on KVM
virt-v2v: warning: there is no QXL driver for this version of Windows (5.2 
x86_64).  virt-v2v looks for this driver in /usr/share/virtio-win

The guest will be configured to use a basic VGA display driver.
virt-v2v: warning: this guest has Windows Group Policy Objects (GPO) and a 
new virtio block device driver was installed.  In some circumstances, Group 
Policy may prevent new drivers from working (resulting in a 7B boot error). 
 If this happens, try disabling Group Policy before doing the conversion.
virt-v2v: This guest has virtio drivers installed.
[  20.5] Mapping filesystem data to avoid copying unused and blank areas
virt-v2v: warning: fstrim on guest filesystem /dev/sda1 failed.  Usually 
you can ignore this message.  To find out more read "Trimming" in 
virt-v2v(1).

Original message: fstrim: fstrim: /sysroot/: the discard operation is not 
supported
[  20.6] Closing the overlay
[  20.7] Checking if the guest needs BIOS or UEFI to boot
[  20.7] Assigning disks to buses
[  20.7] Copying disk 1/1 to /var/lib/libvirt/images/xen-hvm-win2003-x86_64-sda (raw)
    (100.00/100%)
[ 577.0] Creating output metadata
Pool default refreshed

Domain xen-hvm-win2003-x86_64 defined from /tmp/v2vlibvirtc98422.xml

[ 577.2] Finishing off