qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rjones@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com
Subject: [Qemu-devel] Safety of killing qemu when it is doing an fstrim
Date: Tue, 3 Nov 2015 12:12:57 +0000	[thread overview]
Message-ID: <20151103121257.GA28428@redhat.com> (raw)


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

             reply	other threads:[~2015-11-03 12:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03 12:12 Richard W.M. Jones [this message]
2015-11-03 13:01 ` [Qemu-devel] Safety of killing qemu when it is doing an fstrim Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151103121257.GA28428@redhat.com \
    --to=rjones@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).