From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnSOO-0006oS-QS for qemu-devel@nongnu.org; Fri, 14 Jun 2013 07:42:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnSON-000694-Nw for qemu-devel@nongnu.org; Fri, 14 Jun 2013 07:42:08 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:47136) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnSOF-0005mF-3z for qemu-devel@nongnu.org; Fri, 14 Jun 2013 07:42:07 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 14 Jun 2013 21:30:33 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id D0B3F3578053 for ; Fri, 14 Jun 2013 21:41:41 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5EBR5ao27918404 for ; Fri, 14 Jun 2013 21:27:05 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5EBfe5U026294 for ; Fri, 14 Jun 2013 21:41:41 +1000 From: Wenchao Xia Date: Fri, 14 Jun 2013 19:39:48 +0800 Message-Id: <1371209999-15579-2-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1371209999-15579-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1371209999-15579-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V2 01/12] blockdev: drop redundant proto_drv check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, phrdina@redhat.com, famz@redhat.com, Wenchao Xia , armbru@redhat.com, lcapitulino@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dietmar@proxmox.com From: Stefan Hajnoczi It is not necessary to check that we can find a protocol block driver since we create or open the image file. This produces the error that we need anyway. Besides, the QERR_INVALID_BLOCK_FORMAT is inappropriate since the protocol is incorrect rather than the format. Also drop an empty line between bdrv_open() and checking its return value. This may be due to copy-pasting from earlier code that performed other operations before handling errors. Reported-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Wenchao Xia Signed-off-by: Wenchao Xia --- blockdev.c | 15 --------------- 1 files changed, 0 insertions(+), 15 deletions(-) diff --git a/blockdev.c b/blockdev.c index 9937311..e70225b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -818,7 +818,6 @@ typedef struct ExternalSnapshotStates { static void external_snapshot_prepare(BlkTransactionStates *common, Error **errp) { - BlockDriver *proto_drv; BlockDriver *drv; int flags, ret; Error *local_err = NULL; @@ -874,12 +873,6 @@ static void external_snapshot_prepare(BlkTransactionStates *common, flags = states->old_bs->open_flags; - proto_drv = bdrv_find_protocol(new_image_file); - if (!proto_drv) { - error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); - return; - } - /* create new image w/backing file */ if (mode != NEW_IMAGE_MODE_EXISTING) { bdrv_img_create(new_image_file, format, @@ -1372,7 +1365,6 @@ void qmp_drive_mirror(const char *device, const char *target, { BlockDriverState *bs; BlockDriverState *source, *target_bs; - BlockDriver *proto_drv; BlockDriver *drv = NULL; Error *local_err = NULL; int flags; @@ -1440,12 +1432,6 @@ void qmp_drive_mirror(const char *device, const char *target, sync = MIRROR_SYNC_MODE_FULL; } - proto_drv = bdrv_find_protocol(target); - if (!proto_drv) { - error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); - return; - } - bdrv_get_geometry(bs, &size); size *= 512; if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) { @@ -1480,7 +1466,6 @@ void qmp_drive_mirror(const char *device, const char *target, */ target_bs = bdrv_new(""); ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv); - if (ret < 0) { bdrv_delete(target_bs); error_set(errp, QERR_OPEN_FILE_FAILED, target); -- 1.7.1