qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] qcow2 not cleaning up during image create failure


From: Eric Blake
Subject: Re: [Qemu-devel] qcow2 not cleaning up during image create failure
Date: Fri, 14 Jul 2017 07:07:48 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/14/2017 06:57 AM, Fam Zheng wrote:
> On Fri, 07/14 12:00, Daniel P. Berrange wrote:
>> I've just been looking at the qcow2 image creation code, and found that
>> if any method in qcow2_create2() returns an error, then we'll report that,
>> but leave the newly created image file on disk in some partially initialized
>> state. A user may unwittingly use this file later with undefined behaviour.
>> This is particularly bad if we fail to setup encryption, because the user
>> is left with a file with no encryption enabled.
>>
>> So I'm wondering how is the best way to clean up after failure ?
>>
>> Naively I would like to just unlink(filename), but IIUC, filename is
>> not guaranteed to refer to a local file, and AFAIK, there is not
>> bdrv_delete() method todo this portably.
>>
>> If we can't delete a file (because its a block device or network
>> volume), then we must at least blank out the just-written qcow2
>> header with zeros.
>>
>> Ideas / suggestions.
> 
> Or just write the header as the last step?

Or even keep the current steps where we write portions of the header
early, but ensure that all the early writes do NOT set the magic number,
and only the final write to the file puts QFI\xfb into place.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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