From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXU1O-0004XR-46 for qemu-devel@nongnu.org; Tue, 08 Apr 2014 07:17:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXU1H-0006Qh-An for qemu-devel@nongnu.org; Tue, 08 Apr 2014 07:16:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22003) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXU1H-0006QX-2m for qemu-devel@nongnu.org; Tue, 08 Apr 2014 07:16:47 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s38BGjbt018995 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 8 Apr 2014 07:16:46 -0400 Message-ID: <5343DA97.3060402@redhat.com> Date: Tue, 08 Apr 2014 13:16:39 +0200 From: Max Reitz MIME-Version: 1.0 References: <1396891800-8627-1-git-send-email-mreitz@redhat.com> <1396891800-8627-4-git-send-email-mreitz@redhat.com> <5342F836.3060600@redhat.com> <5342FC77.9060105@redhat.com> <8761mk2u52.fsf@blackfin.pond.sub.org> In-Reply-To: <8761mk2u52.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/4] qemu-img: Implement commit like QMP List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi On 08.04.2014 08:49, Markus Armbruster wrote: > Max Reitz writes: > >> On 07.04.2014 21:10, Eric Blake wrote: >>> On 04/07/2014 11:29 AM, Max Reitz wrote: >>>> qemu-img should use QMP commands whenever possible in order to ensure >>>> feature completeness of both online and offline image operations. As >>>> qemu-img itself has no access to QMP (since this would basically require >>>> just everything being linked into qemu-img), imitate QMP's >>>> implementation of block-commit by using commit_active_start() and then >>>> waiting for the block job to finish. >>>> >>>> This new implementation does not empty the snapshot image, as opposed to >>>> the old implementation using bdrv_commit(). However, as QMP's >>>> block-commit apparently never did this and as qcow2 (which is probably >>>> qemu's standard image format) does not even implement the required >>>> function (bdrv_make_empty()), it does not seem necessary. >>>> >>>> Signed-off-by: Max Reitz >>>> --- >>>> block/Makefile.objs | 2 +- >>>> qemu-img.c | 68 ++++++++++++++++++++++++++++++++++++++--------------- >>>> 2 files changed, 50 insertions(+), 20 deletions(-) >>>> >>>> @@ -728,29 +755,32 @@ static int img_commit(int argc, char **argv) >>>> if (!bs) { >>>> return 1; >>>> } >>>> + >>>> + base_bs = bdrv_find_base(bs); >>>> + if (!base_bs) { >>>> + error_set(&local_err, QERR_BASE_NOT_FOUND, "NULL"); >>>> + goto done; >>>> + } >>> Is it worth adding an optional '-b base' image to allow qemu-img to >>> commit across multiple images? That is, QMP can shorten from 'a <- b <- >>> c' all the way to 'a'; but qemu-img has to be called twice (once to 'a >>> <- b' and second to 'a'). Separate commit, of course. >> Sounds interesting, I'll have a look. >> >>>> + >>>> + commit_active_start(bs, base_bs, 0, COMMIT_BUF_SECTORS << >>>> BDRV_SECTOR_BITS, >>>> + BLOCKDEV_ON_ERROR_REPORT, dummy_block_job_cb, bs, >>>> + &local_err); >>>> + if (error_is_set(&local_err)) { >>> No new uses of error_is_set if we can help it. This can be 'if >>> (local_err)'. >> Okay, seems like I missed something. > Yes :) > > commit 84d18f065fb041a1c0d78d20320d740ae0673c8a > Author: Markus Armbruster > Date: Thu Jan 30 15:07:28 2014 +0100 > > Use error_is_set() only when necessary > > error_is_set(&var) is the same as var != NULL, but it takes > whole-program analysis to figure that out. Unnecessarily hard for > optimizers, static checkers, and human readers. Dumb it down to > obvious. > > Gets rid of several dozen Coverity false positives. > > Note that the obvious form is already used in many places. > > [...] Thank you for the reference. Seems like I did not miss it, but worse, I forgot about it. Max