From patchwork Mon May 23 02:19:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 9131115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0675360760 for ; Mon, 23 May 2016 02:45:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDBF6281A2 for ; Mon, 23 May 2016 02:45:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E29E6281EB; Mon, 23 May 2016 02:45:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9417C281A2 for ; Mon, 23 May 2016 02:45:22 +0000 (UTC) Received: from localhost ([::1]:45358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4frt-0008FB-Of for patchwork-qemu-devel@patchwork.kernel.org; Sun, 22 May 2016 22:45:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4fSo-0003tU-Nk for qemu-devel@nongnu.org; Sun, 22 May 2016 22:19:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4fSm-0003qq-Oi for qemu-devel@nongnu.org; Sun, 22 May 2016 22:19:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4fSj-0003qN-KP; Sun, 22 May 2016 22:19:21 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35D957DCC5; Mon, 23 May 2016 02:19:21 +0000 (UTC) Received: from lemon.redhat.com (vpn1-7-186.pek2.redhat.com [10.72.7.186]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4N2JDgK010152; Sun, 22 May 2016 22:19:18 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Mon, 23 May 2016 10:19:35 +0800 Message-Id: <1463969978-24970-2-git-send-email-famz@redhat.com> In-Reply-To: <1463969978-24970-1-git-send-email-famz@redhat.com> References: <1463969978-24970-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 23 May 2016 02:19:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/4] blockdev-backup: Use bdrv_lookup_bs on target X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, "Michael S. Tsirkin" , Markus Armbruster , Max Reitz , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This allows backing up to a BDS that has not been attached to any BB. Signed-off-by: Fam Zheng --- blockdev.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index 40e4e6f..026ead0 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3346,7 +3346,7 @@ void do_blockdev_backup(const char *device, const char *target, BlockdevOnError on_target_error, BlockJobTxn *txn, Error **errp) { - BlockBackend *blk, *target_blk; + BlockBackend *blk; BlockDriverState *bs; BlockDriverState *target_bs; Error *local_err = NULL; @@ -3377,18 +3377,11 @@ void do_blockdev_backup(const char *device, const char *target, } bs = blk_bs(blk); - target_blk = blk_by_name(target); - if (!target_blk) { - error_setg(errp, "Device '%s' not found", target); + target_bs = bdrv_lookup_bs(target, target, errp); + if (!target_bs) { goto out; } - if (!blk_is_available(target_blk)) { - error_setg(errp, "Device '%s' has no medium", target); - goto out; - } - target_bs = blk_bs(target_blk); - bdrv_ref(target_bs); bdrv_set_aio_context(target_bs, aio_context); backup_start(bs, target_bs, speed, sync, NULL, on_source_error,