From patchwork Fri Jul 29 04:49:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Nakamura X-Patchwork-Id: 107329 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 861C0B6F64 for ; Fri, 29 Jul 2011 14:50:48 +1000 (EST) Received: from localhost ([::1]:60487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmf22-0001m6-Ch for incoming@patchwork.ozlabs.org; Fri, 29 Jul 2011 00:50:42 -0400 Received: from eggs.gnu.org ([140.186.70.92]:41281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmf1f-0001Xf-QL for qemu-devel@nongnu.org; Fri, 29 Jul 2011 00:50:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qmf1e-0000P5-O9 for qemu-devel@nongnu.org; Fri, 29 Jul 2011 00:50:19 -0400 Received: from mail-iy0-f173.google.com ([209.85.210.173]:46817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmf1e-0000NN-Kp for qemu-devel@nongnu.org; Fri, 29 Jul 2011 00:50:18 -0400 Received: by mail-iy0-f173.google.com with SMTP id 39so4186308iyb.4 for ; Thu, 28 Jul 2011 21:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=FmOArFh6sCQ59J1lCaG88LJ8w09H368g8h5TldEmIU4=; b=FLlB+FyVq07FRiYXo3bzutEwDlpu8kWLtEjVLxI9ePob1Bpk7uvvXDC3HofRopyjF1 rZsMvl6DRMaHjPUDCgVusaM3gNMOfUiupEtjhNnYLW0q5FGCgvYf60SMYQVGI6u2sw4T W7UxlBQgtI9i4Yum0KIwTwXNkn6jFIV5/hYm4= Received: by 10.231.114.96 with SMTP id d32mr556761ibq.118.1311915018199; Thu, 28 Jul 2011 21:50:18 -0700 (PDT) Received: from localhost.localdomain (d72-39-252-38.home1.cgocable.net [72.39.252.38]) by mx.google.com with ESMTPS id v16sm1109424ibf.25.2011.07.28.21.50.16 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jul 2011 21:50:17 -0700 (PDT) From: Devin Nakamura To: qemu-devel@nongnu.org Date: Fri, 29 Jul 2011 00:49:33 -0400 Message-Id: <1311914994-20482-4-git-send-email-devin122@gmail.com> X-Mailer: git-send-email 1.7.6.rc1 In-Reply-To: <1311914994-20482-1-git-send-email-devin122@gmail.com> References: <1311914994-20482-1-git-send-email-devin122@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.173 Cc: kwolf@redhat.com, Devin Nakamura Subject: [Qemu-devel] [RFC 03/24] block: add bdrv_open_conversion_target() 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 Conflicts: block.h Signed-off-by: Devin Nakamura --- block.c | 32 ++++++++++++++++++++++++++++++++ block.h | 4 ++++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 4503b7b..9530577 100644 --- a/block.c +++ b/block.c @@ -3038,6 +3038,38 @@ out: return ret; } +int bdrv_open_conversion_target(BlockDriverState **bs, BlockDriverState *file, + BlockConversionOptions *drv_options, + QEMUOptionParameter *usr_options, + const char *target_fmt) +{ + BlockDriver *drv; + BlockDriverState *bss; + + drv = bdrv_find_format(target_fmt); + if (!drv) { + return -ENOENT; + } + + if (!drv->bdrv_open_conversion_target) { + return -ENOTSUP; + } + + *bs = bdrv_new(""); + bss = *bs; + bss->file = file; + bss->total_sectors = drv_options->image_size >> BDRV_SECTOR_BITS; + bss->encrypted = 0; + bss->valid_key = 0; + bss->open_flags = 0; + /* buffer_alignment defaulted to 512, drivers can change this value */ + bss->buffer_alignment = 512; + bss->opaque = qemu_mallocz(drv->instance_size); + bss->drv = drv; + return drv->bdrv_open_conversion_target(bss, drv_options, usr_options); + +} + int bdrv_get_conversion_options(BlockDriverState *bs, BlockConversionOptions *options) { diff --git a/block.h b/block.h index ad7e5ea..662bae7 100644 --- a/block.h +++ b/block.h @@ -255,6 +255,10 @@ typedef struct BlockConversionOptions BlockConversionOptions; int bdrv_get_conversion_options(BlockDriverState *bs, BlockConversionOptions *options); +int bdrv_open_conversion_target(BlockDriverState **bs, BlockDriverState *file, + BlockConversionOptions *drv_options, + QEMUOptionParameter *usr_options, + const char *target_fmt); typedef enum { BLKDBG_L1_UPDATE,