qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 4/6] add reuse field


From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH 4/6] add reuse field
Date: Thu, 01 Mar 2012 11:22:49 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120209 Thunderbird/10.0.1

Am 29.02.2012 19:50, schrieb Eric Blake:
> On 02/29/2012 06:37 AM, Paolo Bonzini wrote:
>> In some cases it can be useful to use an existing file as the new image
>> in a snapshot.  Add this capability to blockdev-transaction.
>>
>> Signed-off-by: Paolo Bonzini <address@hidden>
>> ---
>>  blockdev.c       |   18 +++++++++++-------
>>  qapi-schema.json |    3 ++-
>>  qmp-commands.hx  |    7 +++++++
>>  3 files changed, 20 insertions(+), 8 deletions(-)
>> @@ -805,13 +807,15 @@ void qmp_blockdev_transaction(BlockdevActionList 
>> *dev_list,
>>          }
>>  
>>          /* create new image w/backing file */
>> -        ret = bdrv_img_create(new_image_file, format,
>> -                              states->old_bs->filename,
>> -                              states->old_bs->drv->format_name,
>> -                              NULL, -1, flags);
>> -        if (ret) {
>> -            error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
>> -            goto delete_and_fail;
>> +        if (do_snapshot) {
>> +            ret = bdrv_img_create(new_image_file, format,
>> +                                  states->old_bs->filename,
>> +                                  states->old_bs->drv->format_name,
>> +                                  NULL, -1, flags);
>> +            if (ret) {
>> +                error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
>> +                goto delete_and_fail;
>> +            }
> 
> Is there any sanity checking that we should be doing if the 'reuse' flag
> was provided, or is this a case of 'the user better be giving us the
> right information, and it's their fault if things break'?

The latter, qemu can't really perform meaningful checks here, especially
once we allow using file descriptors instead of file names.

(Would this command actually provide a hackish way for using FDs with
backing files even without -blockdev? Hm... Better forget it right now,
I never told anyone about this! :-))

>> +++ b/qapi-schema.json
>> @@ -1127,7 +1127,8 @@
>>  # @format: #optional the format of the snapshot image, default is 'qcow2'.
>>  ##
>>  { 'type': 'BlockdevSnapshot',
>> -  'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str' } }
>> +  'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str',
>> +            '*reuse': 'bool' } }
>>  
>>  ##
>>  # @BlockdevAction
>> diff --git a/qmp-commands.hx b/qmp-commands.hx
>> index ee05ec2..6728495 100644
>> --- a/qmp-commands.hx
>> +++ b/qmp-commands.hx
>> @@ -704,6 +704,10 @@ the original disks pre-snapshot attempt are used.
>>  A list of dictionaries is accepted, that contains the actions to be 
>> performed.
>>  For snapshots this is the device, the file to use for the new snapshot,
>>  and the format.  The default format, if not specified, is qcow2.
>> +Image files can be created by QEMU, or it can be created externally.
> 
> 'files' is plural, 'it' is singular.  Perhaps this wording is better?
> 
> Each new snapshot defaults to being created by QEMU (wiping any contents
> if the file already exists), but it is also possible to reuse an
> externally-created file.

And let's add a warning that you're on your own if you override qemu's
snapshot creation.

Kevin



reply via email to

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