Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1364347

Summary: virt-sparsify --in-place failed with UEFI system
Product: Red Hat Enterprise Linux 7 Reporter: Xianghua Chen <xchen>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: ptoscano, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.32.6-5.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:03:18 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
log.virt-sparsify.uefi.x86_64 none

Description Xianghua Chen 2016-08-05 07:16:25 UTC
Created attachment 1187786 [details]
log.virt-sparsify.uefi.x86_64

Description of problem:
virt-sparsify --in-place failed with UEFI system
You can see the full log with -v -x in the attachment.

Version-Release number of selected component (if applicable):
libguestfs-tools-c-1.33.46-1.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Prepare an UEFI guest image: rhel7.2-uefi-x86_64.qcow2
2.
#  virt-sparsify --in-place rhel7.2-uefi-x86_64.qcow2
[   2.1] Trimming /dev/rhel/root
[   2.4] Clearing Linux swap on /dev/rhel/swap
[   2.4] Trimming /dev/sda1
virt-sparsify: error: libguestfs error: fstrim: fstrim: /sysroot/: the
discard operation is not supported

If reporting bugs, run virt-sparsify with debugging enabled and include the
complete output:

  virt-sparsify -v -x [...]


Actual results:
As above output.

Expected results:
The command should finished successfully.

Additional info:
The command also failed with:
  rhel7.2-uefi-aarch64.qcow2
  coreos
  reactos/windows(That may be alright because the filesystem is vfat,etc.)

Comment 1 Richard W.M. Jones 2016-08-05 10:02:08 UTC
A one-line reproducer is:

$ guestfish -N fs:vfat exit && virt-sparsify --in-place test1.img
[   3.5] Trimming /dev/sda1
virt-sparsify: error: libguestfs error: fstrim: fstrim: /sysroot/: the 
discard operation is not supported

A more interesting reproducer is:

$ guestfish -N bootroot:vfat:ext4 exit && virt-sparsify --in-place test1.img
[   3.3] Trimming /dev/sda1
virt-sparsify: error: libguestfs error: fstrim: fstrim: /sysroot/: the 
discard operation is not supported

The difference between the two reproducers is that the first one
creates a test disk containing only a single vfat partitions.  The
second one creates something which looks more like our UEFI situation:
two partitions, vfat & ext4.

In the first test case you could argue that virt-sparsify should fail
(because nothing could be sparsified).

In the second case you could argue that virt-sparsify should issue a
warning, but try to sparsify as much as it can, since the ext4 partition
can be sparsified (but isn't).

Comment 2 Richard W.M. Jones 2016-08-05 11:23:38 UTC
Patches posted upstream:

https://www.redhat.com/archives/libguestfs/2016-August/msg00029.html

These only add a warning.  It's complicated to add an error
as described in comment 1.

Comment 4 Xianghua Chen 2016-08-08 05:24:26 UTC
Verified with packages:
libguestfs-1.32.6-5.el7.x86_64

Verify steps:
1. # guestfish -N bootroot:vfat:ext4 exit && virt-sparsify --in-place test1.img
[   1.5] Trimming /dev/sda1
virt-sparsify: warning: fstrim operation is not supported on /dev/sda1 
(vfat).  Suppress this warning using '--ignore /dev/sda1', or use copying 
mode instead.
[   1.6] Trimming /dev/sda2
[   2.1] Sparsify in-place operation completed with no errors

There is a warning for vfat filesystem.And the size of the test1.img is sparsified.


2. # guestfish -N bootroot:vfat:ext4 exit && virt-sparsify --in-place test1.img --ignore /dev/sda1
[   1.5] Trimming /dev/sda2
[   2.0] Sparsify in-place operation completed with no errors

No error occurred. And the size of the test1.img is sparsified.

So verified.

Comment 6 errata-xmlrpc 2016-11-03 18:03:18 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/RHSA-2016-2576.html