From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S336f-00053v-A1 for qemu-devel@nongnu.org; Thu, 01 Mar 2012 05:19:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S336Y-0000Gy-W1 for qemu-devel@nongnu.org; Thu, 01 Mar 2012 05:19:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53758) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S336Y-0000Gk-N0 for qemu-devel@nongnu.org; Thu, 01 Mar 2012 05:19:22 -0500 Message-ID: <4F4F4DF9.4020603@redhat.com> Date: Thu, 01 Mar 2012 11:22:49 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1330522650-15357-1-git-send-email-pbonzini@redhat.com> <1330522650-15357-5-git-send-email-pbonzini@redhat.com> <4F4E738E.8000706@redhat.com> In-Reply-To: <4F4E738E.8000706@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/6] add reuse field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Paolo Bonzini , fsimonce@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com 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 >> --- >> 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