From patchwork Thu Oct 20 13:57:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 9386999 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 5423160487 for ; Thu, 20 Oct 2016 14:53:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44BC4297BB for ; Thu, 20 Oct 2016 14:53:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3962B297FC; Thu, 20 Oct 2016 14:53:17 +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 7B9EA297BB for ; Thu, 20 Oct 2016 14:53:16 +0000 (UTC) Received: from localhost ([::1]:55316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxEiZ-0006FG-3r for patchwork-qemu-devel@patchwork.kernel.org; Thu, 20 Oct 2016 10:53:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxDsJ-0003UT-JA for qemu-devel@nongnu.org; Thu, 20 Oct 2016 09:59:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxDsF-0000fv-LY for qemu-devel@nongnu.org; Thu, 20 Oct 2016 09:59:15 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:47274) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1bxDsE-0000ap-Qq; Thu, 20 Oct 2016 09:59:11 -0400 Received: from 172.24.1.60 (EHLO szxeml433-hub.china.huawei.com) ([172.24.1.60]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DTR31884; Thu, 20 Oct 2016 21:58:31 +0800 (CST) Received: from localhost (10.177.24.212) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.235.1; Thu, 20 Oct 2016 21:58:22 +0800 From: zhanghailiang To: , Date: Thu, 20 Oct 2016 21:57:40 +0800 Message-ID: <1476971860-20860-8-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 In-Reply-To: <1476971860-20860-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1476971860-20860-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.24.212] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Subject: [Qemu-devel] [PATCH RFC 7/7] nbd/replication: implement .bdrv_get_info() for nbd and replication driver 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: kwolf@redhat.com, xiecl.fnst@cn.fujitsu.com, zhanghailiang , mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Without this callback, there will be an error reports in the primary side: "qemu-system-x86_64: Couldn't determine the cluster size of the target image, which has no backing file: Operation not supported Aborting, since this may create an unusable destination image" For nbd driver, it doesn't have cluster size, so here we return a fake value for it. Signed-off-by: zhanghailiang Signed-off-by: Wen Congyang --- block/nbd.c | 12 ++++++++++++ block/replication.c | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index 6bc06d6..96d7023 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -40,6 +40,8 @@ #define EN_OPTSTR ":exportname=" +#define NBD_FAKE_CLUSTER_SIZE 512 + typedef struct BDRVNBDState { NbdClientSession client; @@ -483,6 +485,13 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options) bs->full_open_options = opts; } +static int nbd_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + bdi->cluster_size = NBD_FAKE_CLUSTER_SIZE; + + return 0; +} + static BlockDriver bdrv_nbd = { .format_name = "nbd", .protocol_name = "nbd", @@ -499,6 +508,7 @@ static BlockDriver bdrv_nbd = { .bdrv_detach_aio_context = nbd_detach_aio_context, .bdrv_attach_aio_context = nbd_attach_aio_context, .bdrv_refresh_filename = nbd_refresh_filename, + .bdrv_get_info = nbd_get_info, }; static BlockDriver bdrv_nbd_tcp = { @@ -517,6 +527,7 @@ static BlockDriver bdrv_nbd_tcp = { .bdrv_detach_aio_context = nbd_detach_aio_context, .bdrv_attach_aio_context = nbd_attach_aio_context, .bdrv_refresh_filename = nbd_refresh_filename, + .bdrv_get_info = nbd_get_info, }; static BlockDriver bdrv_nbd_unix = { @@ -535,6 +546,7 @@ static BlockDriver bdrv_nbd_unix = { .bdrv_detach_aio_context = nbd_detach_aio_context, .bdrv_attach_aio_context = nbd_attach_aio_context, .bdrv_refresh_filename = nbd_refresh_filename, + .bdrv_get_info = nbd_get_info, }; static void bdrv_nbd_init(void) diff --git a/block/replication.c b/block/replication.c index e66b1ca..14c718e 100644 --- a/block/replication.c +++ b/block/replication.c @@ -707,6 +707,11 @@ static void replication_stop(ReplicationState *rs, bool failover, Error **errp) aio_context_release(aio_context); } +static int replication_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + return bdrv_get_info(bs->file->bs, bdi); +} + BlockDriver bdrv_replication = { .format_name = "replication", .protocol_name = "replication", @@ -719,6 +724,7 @@ BlockDriver bdrv_replication = { .bdrv_co_readv = replication_co_readv, .bdrv_co_writev = replication_co_writev, + .bdrv_get_info = replication_get_info, .is_filter = true, .bdrv_recurse_is_first_non_filter = replication_recurse_is_first_non_filter,