From patchwork Tue Nov 12 11:30:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Lopez X-Patchwork-Id: 11239113 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92BF618B6 for ; Tue, 12 Nov 2019 11:34:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67F1C21783 for ; Tue, 12 Nov 2019 11:34:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OAndAIb2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 67F1C21783 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUUR2-0000au-K8 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Nov 2019 06:34:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35573) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUUP2-0007G9-82 for qemu-devel@nongnu.org; Tue, 12 Nov 2019 06:32:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUUOy-00019c-AQ for qemu-devel@nongnu.org; Tue, 12 Nov 2019 06:32:08 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20320 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iUUOy-00018K-0E for qemu-devel@nongnu.org; Tue, 12 Nov 2019 06:32:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573558321; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wbvPC0j2Q4yaXtsYW/Ngr7jfFhiP1PPYm5HSHEmn2Q0=; b=OAndAIb2R7B1D681Jw+jGWUiQvtjkiBbzygPAdRdgOfYrvx7xcUwIZJuPD7Bo3uo3uv6+j eeIgvv6Y6vLh/FG3qUws0ZQe7HANwrWjpuTIDWshIGjMZld+3vG4cdvvN3YP9Kn64jaH0i Om8jiItZYFl4WoSRtI8bJQh79S5HVcc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-9-9tauDOo0MqibY3ubE9t7Rw-1; Tue, 12 Nov 2019 06:30:32 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 780B3DC20; Tue, 12 Nov 2019 11:30:31 +0000 (UTC) Received: from dritchie.redhat.com (unknown [10.33.36.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id D864D6090D; Tue, 12 Nov 2019 11:30:29 +0000 (UTC) From: Sergio Lopez To: qemu-devel@nongnu.org Subject: [PATCH v3 6/8] blockdev: place blockdev_backup_prepare with the other related transaction helpers Date: Tue, 12 Nov 2019 12:30:10 +0100 Message-Id: <20191112113012.71136-7-slp@redhat.com> In-Reply-To: <20191112113012.71136-1-slp@redhat.com> References: <20191112113012.71136-1-slp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 9tauDOo0MqibY3ubE9t7Rw-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Sergio Lopez , Markus Armbruster , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Move blockdev_backup_prepare() to be side by side with the other related transaction helper functions. Signed-off-by: Sergio Lopez --- blockdev.c | 70 +++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/blockdev.c b/blockdev.c index 128707cdc6..f94aaa98f0 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1940,6 +1940,41 @@ typedef struct BlockdevBackupState { BlockJob *job; } BlockdevBackupState; +static void blockdev_backup_prepare(BlkActionState *common, Error **errp) +{ + BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); + BlockdevBackup *backup; + BlockDriverState *bs; + BlockDriverState *target_bs; + AioContext *aio_context; + + assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); + backup = common->action->u.blockdev_backup.data; + + bs = bdrv_lookup_bs(backup->device, backup->device, errp); + if (!bs) { + return; + } + + target_bs = bdrv_lookup_bs(backup->target, backup->target, errp); + if (!target_bs) { + return; + } + + aio_context = bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); + state->bs = bs; + + /* Paired with .clean() */ + bdrv_drained_begin(state->bs); + + state->job = do_backup_common(qapi_BlockdevBackup_base(backup), + bs, target_bs, aio_context, + common->block_job_txn, errp); + + aio_context_release(aio_context); +} + static void blockdev_backup_commit(BlkActionState *common) { BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); @@ -3654,41 +3689,6 @@ XDbgBlockGraph *qmp_x_debug_query_block_graph(Error **errp) return bdrv_get_xdbg_block_graph(errp); } -static void blockdev_backup_prepare(BlkActionState *common, Error **errp) -{ - BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); - BlockdevBackup *backup; - BlockDriverState *bs; - BlockDriverState *target_bs; - AioContext *aio_context; - - assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); - backup = common->action->u.blockdev_backup.data; - - bs = bdrv_lookup_bs(backup->device, backup->device, errp); - if (!bs) { - return; - } - - target_bs = bdrv_lookup_bs(backup->target, backup->target, errp); - if (!target_bs) { - return; - } - - aio_context = bdrv_get_aio_context(bs); - aio_context_acquire(aio_context); - state->bs = bs; - - /* Paired with .clean() */ - bdrv_drained_begin(state->bs); - - state->job = do_backup_common(qapi_BlockdevBackup_base(backup), - bs, target_bs, aio_context, - common->block_job_txn, errp); - - aio_context_release(aio_context); -} - void qmp_blockdev_backup(BlockdevBackup *arg, Error **errp) { BlockJob *job;