From patchwork Tue Jun 7 14:26:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9161557 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 42E7660801 for ; Tue, 7 Jun 2016 14:31:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 346E425D91 for ; Tue, 7 Jun 2016 14:31:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 295BD269A3; Tue, 7 Jun 2016 14:31:37 +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 D941125D91 for ; Tue, 7 Jun 2016 14:31:36 +0000 (UTC) Received: from localhost ([::1]:50226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAI2a-00072w-0C for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Jun 2016 10:31:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48319) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAHxo-0002yA-37 for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:26:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAHxi-0006ZB-0y for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:26:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45699) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAHxh-0006Z6-R3 for qemu-devel@nongnu.org; Tue, 07 Jun 2016 10:26:33 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 7718185542; Tue, 7 Jun 2016 14:26:33 +0000 (UTC) Received: from localhost (ovpn-112-74.ams2.redhat.com [10.36.112.74]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u57EQWxA024587; Tue, 7 Jun 2016 10:26:32 -0400 From: Stefan Hajnoczi To: Date: Tue, 7 Jun 2016 15:26:15 +0100 Message-Id: <1465309585-31551-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1465309585-31551-1-git-send-email-stefanha@redhat.com> References: <1465309585-31551-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 07 Jun 2016 14:26:33 +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] [PULL 02/12] 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: Peter Maydell , Fam Zheng , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Fam Zheng This allows backing up to a BDS that has not been attached to any BB. Signed-off-by: Fam Zheng Message-id: 1463969978-24970-2-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi --- blockdev.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index 717785e..ea7f397 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3335,7 +3335,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; @@ -3366,18 +3366,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_set_aio_context(target_bs, aio_context); backup_start(bs, target_bs, speed, sync, NULL, on_source_error, on_target_error, block_job_cb, bs, txn, &local_err);