Bug 962620

Summary: Backport qemu-ga guest-fstrim command to RHEL7 [TestOnly]
Product: Red Hat Enterprise Linux 7 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Laszlo Ersek <lersek>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: acathrow, chayang, flang, hhuang, juzhang, kwolf, lersek, michen, pbonzini, qzhang, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-1.4.0-2.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 10:43:59 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:

Description Sibiao Luo 2013-05-14 04:54:57 UTC
Description of problem:
We have backport qemu-ga guest-fstrim command to RHEL 6.x(bug 918311). We also need to backport it to rhel7 and discussed with pbonzini that we will add "discard=on|off" to the -drive option since qemu-1.5.0, so file this bug to trace it correctly.

Note: this case only support on passthrough scsi disk and use RAW format.

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


How reproducible:


Steps to Reproduce:
1.refer to:
https://bugzilla.redhat.com/show_bug.cgi?id=918311#c17
https://bugzilla.redhat.com/show_bug.cgi?id=918311#c27
2.
3.
  
Actual results:


Expected results:
It can discard (or "trim") blocks which are not in use by the filesystem using qemu-ga 'guest-fstrim' command.

Additional info:

Comment 1 Sibiao Luo 2013-05-14 05:22:09 UTC
Hi pbonzini,
  
   Does it only support on passthrough scsi disk(scsi-block) with RAW format in rhel7? How about the emulated SCSI hard disk(scsi-hd) with 'discard=on', does it support the guest-fstrim ? btw, it works well according to my test(https://bugzilla.redhat.com/show_bug.cgi?id=918311#c17).
Could you help me make a note here about what's the difference will be between rhel6.5 and rhel7 for the 'discard=on'? Thanks.

Best Regards,
sluo

Comment 2 Sibiao Luo 2013-05-14 05:24:29 UTC
(In reply to comment #1)
> Hi pbonzini,
>   
>    Does it only support on passthrough scsi disk(scsi-block) with RAW format
> in rhel7? How about the emulated SCSI hard disk(scsi-hd) with 'discard=on',
> does it support the guest-fstrim ? btw, it works well according to my
> test(https://bugzilla.redhat.com/show_bug.cgi?id=918311#c17).

> Could you help me make a note here about what's the difference will be
> between rhel6.5 and rhel7 for the 'discard=on'? Thanks.
sorry, a mistake here.
Could you help me make a note here about what's the difference will be between rhel6.5 and rhel7 for the 'guest-fstrim'? 
> Best Regards,
> sluo

Comment 3 Paolo Bonzini 2013-05-14 10:18:13 UTC
Hi sluo,

RHEL7 will support guest-fstrim also with emulated SCSI hard disks and rhel7.x.0 machine types.  It will work with both discard=on and discard=off, but it will only have an actual effect with discard=on.  With discard=off, it will be a "no-op".

Comment 4 Sibiao Luo 2013-05-15 01:58:51 UTC
(In reply to comment #3)
> Hi sluo,
> 
> RHEL7 will support guest-fstrim also with emulated SCSI hard disks and
> rhel7.x.0 machine types.  It will work with both discard=on and discard=off,
> but it will only have an actual effect with discard=on.  With discard=off,
> it will be a "no-op".
Got it, thanks for your info. We will verify this issue with the passthrough scsi disk(scsi-block) and emulated SCSI hard disk(scsi-hd) with 'discard=on' in rhel7.

Comment 5 Laszlo Ersek 2013-07-31 15:09:22 UTC
Paolo, Kevin, do we need

commit 50b05b6f2e24296b4d739a638e1e7427767ed7cd
Author: Kevin Wolf <kwolf>
Date:   Wed Jun 19 13:44:21 2013 +0200

    block: Always enable discard on the protocol level

for this bug, or can I bump it to MODIFIED?

I think we should be all set.

BTW I'd prefer if one you took the BZ, or at least gave a concise description of all the layers that can mess with UNMAP going through. (The commit messages, eg. 9e8f1835 too -- already in RHEL-7 -- imply that it can go wrong in many places.)

Thanks.

Comment 6 Kevin Wolf 2013-08-01 07:27:44 UTC
The patch will be needed for qcow2 to pass through discard requests to the
image file. We still have bug 978402 for that, this one can concentrate on the
guest agent part.

Comment 7 Laszlo Ersek 2013-08-05 07:31:58 UTC
Thanks.

Comment 9 Sibiao Luo 2014-01-21 08:57:58 UTC
Verified this issue on qemu-kvm-1.5.3-38.el7.x86_64 with the instruction of Paolo. I verified this issue with the passthrough scsi disk(scsi-block) and emulated SCSI hard disk(scsi-hd) with 'discard=on' in rhel7.

host info:
# uname -r && rpm -q qemu-kvm
3.10.0-76.el7.x86_64
qemu-kvm-1.5.3-38.el7.x86_64
guest info:
# uname -r
3.10.0-76.el7.x86_64

Steps:
1.Boot guest with /dev/sdb (generaled as setup) with virtio serial and start guest agent inside guest.
# modprobe scsi_debug lbpu=1 lbpws=1
# lsscsi
...
[9:0:0:0]    disk    Linux    scsi_debug       0004  /dev/sdb 
e.g:/usr/libexec/qemu-kvm...-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 -chardev socket,id=channel1,path=/tmp/helloworld1,server,nowait -device virtserialport,chardev=channel1,name=org.qemu.guest_agent.0,bus=virtio-serial0.0,id=port1,nr=1 -drive file=/dev/sdb,if=none,id=drive-data-disk,format=raw,cache=none,aio=native,werror=stop,rerror=stop,discard=on -device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x7 -device scsi-hd|scsi-block,drive=drive-data-disk,id=data-disk,bus=scsi1.0
2.Make file system to the disk in the guest.
# mkfs.ext4 /dev/sdb
3. On the host
# cat /sys/bus/pseudo/drivers/scsi_debug/map
4.On the guest
# mount /dev/sdb /home/test
# dd if=/dev/zero of=/home/test/file
5.cat map in host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map
6.in guest.
# rm /home/test/file
7.connect the chardev socket in host side and send  "guest-fstrim" command in the host side:
# nc -U /tmp/qga.sock
{"execute":"guest-fstrim"}
8.cat map in host.
# cat /sys/bus/pseudo/drivers/scsi_debug/map

Results:
- for scsi-hd:
1.after step 1, boot guest successfully.
2.after step 3,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-2663,16256-16383
3.after step 5,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-7379,8194-16383
4.after step 7,
{"execute":"guest-fstrim"}
{"return": {}}
5.after step 8,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-2659

- for scsi-block:
1.after step 1, boot guest successfully.
2.after step 3,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-135,640-2663,16256-16383
3.after step 5,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-135,640-2663,2688-15595,16256-16383
4.after step 7,
{"execute":"guest-fstrim"}
{"return": {}}
5.after step 8,
# cat /sys/bus/pseudo/drivers/scsi_debug/map
0-135,640-2659

Base on above, this issue has been fixed correctly, the "guest-fstrim" command worked successfully.

Best Regards,
sluo

Comment 11 Sibiao Luo 2014-01-26 03:13:27 UTC
According comment #9 and comment #10, this bug has been fixed, move it to VERIFIED status. Please correct me if any mistake, thanks in advance.

Best Regards,
sluo

Comment 12 Ludek Smid 2014-06-13 10:43:59 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.