From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtbE1-0002vp-5P for qemu-devel@nongnu.org; Tue, 03 Nov 2015 08:02:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtbDx-0003RO-Vs for qemu-devel@nongnu.org; Tue, 03 Nov 2015 08:02:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54587) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtbDx-0003RK-Qb for qemu-devel@nongnu.org; Tue, 03 Nov 2015 08:02:05 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5A259C100450 for ; Tue, 3 Nov 2015 13:02:04 +0000 (UTC) References: <20151103121257.GA28428@redhat.com> From: Paolo Bonzini Message-ID: <5638B045.3030906@redhat.com> Date: Tue, 3 Nov 2015 14:01:57 +0100 MIME-Version: 1.0 In-Reply-To: <20151103121257.GA28428@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [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: "Richard W.M. Jones" , qemu-devel@nongnu.org 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 \ > -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