« Previous | Next » 

Revision eab5fd59


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

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
  5. mount /dev/sdb /run/media/pbonzini/test
  6. dd if=/dev/zero of=/run/media/pbonzini/test/file
  7. cat map
  8. rm /run/media/pbonzini/test/file
  9. ./qemu-ga /dev/fd/0 {"execute":"guest-fstrim"} {"return": {}}
  10. cat map

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


  • added
  • modified
  • copied
  • renamed
  • deleted

View differences