« Previous | Next » 

Revision eab5fd59

IDeab5fd5989a1ac48d123ccaec7346ce325b9ee77

Added by Paolo Bonzini over 8 years ago

qemu-ga: add guest-fstrim command

FITRIM is a mounted filesystem feature to discard (or "trim") blocks which
are not in use by the filesystem. This is useful for solid-state drives
(SSDs) and thinly-provisioned storage. Provide access to the feature
from the host so that filesystems can be trimmed periodically or before
migration.

Here is an example using scsi_debug:

  1. modprobe scsi_debug lbpu=1 lbpws=1
  2. sg_vpd -p0xb2 /dev/sdb
    Logical block provisioning VPD page (SBC):
    Unmap command supported (LBPU): 1
    Write same (16) with unmap bit supported (LBWS): 1
    Write same (10) with unmap bit supported (LBWS10): 0
  3. mke2fs /dev/sdb
  4. cat /sys/bus/pseudo/drivers/scsi_debug/map
    1-616,16257-16383
  5. mount /dev/sdb /run/media/pbonzini/test
  6. dd if=/dev/zero of=/run/media/pbonzini/test/file
  7. cat map
    1-616,645-1588,1599-4026,4029-16383
  8. rm /run/media/pbonzini/test/file
  9. ./qemu-ga /dev/fd/0 {"execute":"guest-fstrim"} {"return": {}}
  10. cat map
    1-612

Signed-off-by: Paolo Bonzini <>
Reviewed-by: Luiz Capitulino <>
Reviewed-by: Michal Privoznik <>
Signed-off-by: Michael Roth <>

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences