From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaSV-0002aI-MM for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:13:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtaSS-0006h3-8n for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:13:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43172) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtaSS-0006gs-40 for qemu-devel@nongnu.org; Tue, 03 Nov 2015 07:13:00 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 356BAC100448 for ; Tue, 3 Nov 2015 12:12:59 +0000 (UTC) Date: Tue, 3 Nov 2015 12:12:57 +0000 From: "Richard W.M. Jones" Message-ID: <20151103121257.GA28428@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] Safety of killing qemu when it is doing an fstrim List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com 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 \ -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