From patchwork Sat Jun 8 06:57:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 249921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 611462C0182 for ; Sat, 8 Jun 2013 17:01:29 +1000 (EST) Received: from localhost ([::1]:41559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlD9T-0003Vd-Hc for incoming@patchwork.ozlabs.org; Sat, 08 Jun 2013 03:01:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlD94-0003R5-No for qemu-devel@nongnu.org; Sat, 08 Jun 2013 03:01:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UlD93-0000Ue-Oj for qemu-devel@nongnu.org; Sat, 08 Jun 2013 03:01:02 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:34491) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlD93-0000UY-5f for qemu-devel@nongnu.org; Sat, 08 Jun 2013 03:01:01 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 8 Jun 2013 16:49:59 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 8 Jun 2013 16:49:56 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 81B9D2CE804A for ; Sat, 8 Jun 2013 17:00:52 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5870i9T32374876 for ; Sat, 8 Jun 2013 17:00:44 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5870pAj025765 for ; Sat, 8 Jun 2013 17:00:51 +1000 Received: from RH63Wenchao.localdomain ([9.125.31.72]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r586w9It018747; Sat, 8 Jun 2013 17:00:48 +1000 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Sat, 8 Jun 2013 14:57:57 +0800 Message-Id: <1370674687-13849-2-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1370674687-13849-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1370674687-13849-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13060806-0260-0000-0000-0000031F220D X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.140 Cc: kwolf@redhat.com, phrdina@redhat.com, armbru@redhat.com, lcapitulino@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dietmar@proxmox.com Subject: [Qemu-devel] [PATCH 01/11] blockdev: drop redundant proto_drv check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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);