qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Safety of killing qemu when it is doing an fstrim


From: Paolo Bonzini
Subject: Re: [Qemu-devel] Safety of killing qemu when it is doing an fstrim
Date: Tue, 3 Nov 2015 14:01:57 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0


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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]