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 1159735 - fail to do thinly-provisioned testing with windows guest using scsi-hd/scsi-block interface under PC machine type
Summary: fail to do thinly-provisioned testing with windows guest using scsi-hd/scsi-b...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.1
Hardware: Unspecified
OS: Unspecified
high
urgent
Target Milestone: rc
: ---
Assignee: Paolo Bonzini
QA Contact: Virtualization Bugs
URL:
Whiteboard:
: 1253722 (view as bug list)
Depends On: 1056379
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-03 08:51 UTC by Sibiao Luo
Modified: 2015-08-29 13:44 UTC (History)
13 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1056379
Environment:
Last Closed: 2014-12-12 13:24:16 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Comment 1 Sibiao Luo 2014-11-03 08:52:14 UTC
host info:
# uname -r && rpm -q qemu-kvm-rhev
3.10.0-191.el7.x86_64
qemu-kvm-rhev-2.1.2-5.el7.x86_64

e.g:...-drive file=my-data-disk.qcow2,if=none,id=drive-data-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop,discard=on -device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x7 -device scsi-hd,drive=drive-data-disk,id=data-disk,bus=scsi1.0

after copy a file into the disk to take up the space in guest
host ]# stat my-data-disk.qcow2 | grep Blocks
  Size: 100401152 	Blocks: 195992     IO Block: 4096   regular file

after remove the file in guest.
host ]# stat my-data-disk.qcow2 | grep Blocks
  Size: 126287872 	Blocks: 246552     IO Block: 4096   regular file

after use the the 'Windows Optimize Drives Utility'("disk management"--->"Properties"--->"tool"--->"disk defragementation").
host ]# stat my-data-disk.qcow2 | grep Blocks
  Size: 137691136 	Blocks: 268824     IO Block: 4096   regular file

Comment 2 juzhang 2014-11-13 04:32:52 UTC
Hi Paolo,

Would you have a look this bz? According to sluo's option, this bz blocks qe run thin provision functional testing by using window guests.

Best Regards,
Junyi

Comment 3 Paolo Bonzini 2014-12-02 12:12:38 UTC
This works for me (I only tried scsi-hd for now).  Steps:

1) create a new Windows 2012R2 virtual machine (e.g. win2012r2-64.qcow2) with virtio-scsi storage.

2) create a new qcow2 file using win2012r2-64.qcow2 as the backing file; make it a bit larger, for example:

$ qemu-img info ~/win2012r2-test.qcow2 
image: /home/pbonzini/win2012r2-test.qcow2
file format: qcow2
virtual size: 30G (32212254720 bytes)
disk size: 8.1G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    corrupt: false

$ qemu-img create -f qcow2 -obacking_file=win2012-64r2.qcow2,backing_fmt=qcow2 win2012r2-test.qcow2 35G

2) start the virtual machine:

$ /usr/libexec/qemu-kvm --enable-kvm -m 1024 -device virtio-scsi-pci \
    -drive if=none,id=hd,file=$HOME/win2012r2-test.qcow2,discard=unmap \
    -device scsi-disk,drive=hd -usb -usbdevice tablet

3) pick Computer Management from the Start screen ("Apps by name").  Go to Disk Management and format a new partition in the unallocated space.  Choose 1500 MB as the size and (important!) *disable* "Perform a quick format".  Leave everything to the default and proceed until the disk is formatted.

4) on the host:

$ du -h ~/win2012r2-test.qcow2 
2,0G	/home/pbonzini/win2012r2-test.qcow2

5) from "This PC" select "New Volume (E:)", Drive Tools (in the title bar), Optimize.  You should see a new window with.

Drive             Media type               Last run         Current status
OS_Install (C:)   Thin provisioned drive   Never run        OK
New Volume (E:)   Thin provisioned drive   Never run        OK

6) Click "Optimize" and wait a minute or so.  Current status will go through "Analyzing allocations...", "Enumerating slabs: xx%", "xx% slab-consolidated", "xx% trimmed", "OK (100% space efficiency)".

7) on the host:

$ du -h ~/win2012r2-test.qcow2 
595M	/home/pbonzini/win2012r2-test.qcow2

Comment 4 Sibiao Luo 2014-12-09 08:37:20 UTC
(In reply to Paolo Bonzini from comment #3)
> This works for me (I only tried scsi-hd for now).  Steps:
> 
> 1) create a new Windows 2012R2 virtual machine (e.g. win2012r2-64.qcow2)
> with virtio-scsi storage.
> 
> 2) create a new qcow2 file using win2012r2-64.qcow2 as the backing file;
> make it a bit larger, for example:
> 
> $ qemu-img info ~/win2012r2-test.qcow2 
> image: /home/pbonzini/win2012r2-test.qcow2
> file format: qcow2
> virtual size: 30G (32212254720 bytes)
> disk size: 8.1G
> cluster_size: 65536
> Format specific information:
>     compat: 1.1
>     lazy refcounts: false
>     corrupt: false
> 
> $ qemu-img create -f qcow2
> -obacking_file=win2012-64r2.qcow2,backing_fmt=qcow2 win2012r2-test.qcow2 35G
> 
> 2) start the virtual machine:
> 
> $ /usr/libexec/qemu-kvm --enable-kvm -m 1024 -device virtio-scsi-pci \
>     -drive if=none,id=hd,file=$HOME/win2012r2-test.qcow2,discard=unmap \
>     -device scsi-disk,drive=hd -usb -usbdevice tablet
> 
> 3) pick Computer Management from the Start screen ("Apps by name").  Go to
> Disk Management and format a new partition in the unallocated space.  Choose
> 1500 MB as the size and (important!) *disable* "Perform a quick format". 
> Leave everything to the default and proceed until the disk is formatted.
> 
> 4) on the host:
> 
> $ du -h ~/win2012r2-test.qcow2 
> 2,0G	/home/pbonzini/win2012r2-test.qcow2
> 
> 5) from "This PC" select "New Volume (E:)", Drive Tools (in the title bar),
> Optimize.  You should see a new window with.
> 
> Drive             Media type               Last run         Current status
> OS_Install (C:)   Thin provisioned drive   Never run        OK
> New Volume (E:)   Thin provisioned drive   Never run        OK
> 
> 6) Click "Optimize" and wait a minute or so.  Current status will go through
> "Analyzing allocations...", "Enumerating slabs: xx%", "xx%
> slab-consolidated", "xx% trimmed", "OK (100% space efficiency)".
> 
> 7) on the host:
> 
> $ du -h ~/win2012r2-test.qcow2 
> 595M	/home/pbonzini/win2012r2-test.qcow2

Thanks for Paolo Bonzini's kindly instruction, I also tried it with your steps which can discard the free space from 2.3G to 460M.

Before click "Optimize".
# stat /home/win2012R2-snapshot.qcow2 | grep Blocks
  Size: 2210070528	Blocks: 4315792    IO Block: 4096   regular file
# du -h /home/win2012R2-snapshot.qcow2 
2.1G	/home/win2012R2-snapshot.qcow2

After click "Optimize".
# stat /home/win2012R2-snapshot.qcow2 | grep Blocks
  Size: 2246049792	Blocks: 629392     IO Block: 4096   regular file
# du -h /home/win2012R2-snapshot.qcow2 
308M	/home/win2012R2-snapshot.qcow2

But i did not see the 'Thin provisioned drive' 'Media type', it was 'Hard disk drive' 'Media type' for me.

BTW, does it must to use the snapshot for windows to try the discard=on/unmap function? How about using the disk/image directly (like comment #1) ?

Best Regards,
sluo

Comment 5 Paolo Bonzini 2014-12-12 13:24:16 UTC
You could use the disk or disk image directly, but using the snapshot makes it much easier to understand what is going on.

Comment 6 Sibiao Luo 2014-12-15 02:42:06 UTC
(In reply to Paolo Bonzini from comment #5)
> You could use the disk or disk image directly, but using the snapshot makes
> it much easier to understand what is going on.

OK, thanks for your kindly reminds, i will update it to our TCMS.

Comment 9 Karen Noel 2015-08-29 13:44:42 UTC
*** Bug 1253722 has been marked as a duplicate of this bug. ***


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