qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Safety of killing qemu when it is doing an fstrim
@ 2015-11-03 12:12 Richard W.M. Jones
  2015-11-03 13:01 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Richard W.M. Jones @ 2015-11-03 12:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini


I wrote a tool called virt-sparsify which runs fstrim on disks via
qemu.  My colleague asked me a good question: Is this safe if qemu is
killed (^C)?  Could it corrupt the guest?

Using 'virt-sparsify --inplace disk.img' is essentially equivalent to
doing:

  qemu-kvm \
    -kernel <recent-kernel> \
    -drive file=disk.img,discard=unmap,[virtio-scsi] \
    -drive file=appliance

And in the appliance doing:

  foreach fs in filesystems:
      mount -o discard fs /sysroot
      fstrim /sysroot
      umount /sysroot
  sync
  poweroff

I think the answer is "safe", as long as the Linux kernel and qemu are
written carefully, but it would be good to get an expert opinion.

It looks like fstrim just sends discard requests.  And mount/umount
should be safe by the usual rules of journalling.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] Safety of killing qemu when it is doing an fstrim
  2015-11-03 12:12 [Qemu-devel] Safety of killing qemu when it is doing an fstrim Richard W.M. Jones
@ 2015-11-03 13:01 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2015-11-03 13:01 UTC (permalink / raw)
  To: Richard W.M. Jones, qemu-devel



On 03/11/2015 13:12, Richard W.M. Jones wrote:
> 
> I wrote a tool called virt-sparsify which runs fstrim on disks via
> qemu.  My colleague asked me a good question: Is this safe if qemu is
> killed (^C)?  Could it corrupt the guest?
> 
> Using 'virt-sparsify --inplace disk.img' is essentially equivalent to
> doing:
> 
>   qemu-kvm \
>     -kernel <recent-kernel> \
>     -drive file=disk.img,discard=unmap,[virtio-scsi] \
>     -drive file=appliance
> 
> And in the appliance doing:
> 
>   foreach fs in filesystems:
>       mount -o discard fs /sysroot
>       fstrim /sysroot
>       umount /sysroot
>   sync
>   poweroff
> 
> I think the answer is "safe", as long as the Linux kernel and qemu are
> written carefully, but it would be good to get an expert opinion.
> 
> It looks like fstrim just sends discard requests.  And mount/umount
> should be safe by the usual rules of journalling.

Yes, this is correct.

Paolo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-03 13:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-03 12:12 [Qemu-devel] Safety of killing qemu when it is doing an fstrim Richard W.M. Jones
2015-11-03 13:01 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).