From patchwork Thu Jun 16 14:08:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 636495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rVmSW6j1Cz9sxb for ; Fri, 17 Jun 2016 00:47:23 +1000 (AEST) Received: from localhost ([::1]:49831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDYZl-0003XA-RZ for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2016 10:47:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDXz8-0008I9-Nr for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:09:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDXz7-0000jy-L9 for qemu-devel@nongnu.org; Thu, 16 Jun 2016 10:09:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37907) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDXyv-0000cp-F4; Thu, 16 Jun 2016 10:09:17 -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 23CC58E900; Thu, 16 Jun 2016 14:09:17 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5GE8XUW003905; Thu, 16 Jun 2016 10:09:16 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 16 Jun 2016 16:08:25 +0200 Message-Id: <1466086108-24868-37-git-send-email-kwolf@redhat.com> In-Reply-To: <1466086108-24868-1-git-send-email-kwolf@redhat.com> References: <1466086108-24868-1-git-send-email-kwolf@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.26]); Thu, 16 Jun 2016 14:09:17 +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 36/39] block/null: Implement bdrv_refresh_filename() 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, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz The null block driver ignores any filename used for creating its BDSs, which allows creating such BDSs even without any filename at all. In that case, we currently construct a JSON filename when queried instead of a plain "null-co://" or "null-aio://". This patch implements bdrv_refresh_filename() to remedy this behavior. Signed-off-by: Max Reitz Message-id: 20160610185750.30956-4-mreitz@redhat.com [mreitz@redhat.com: Added commit message] Signed-off-by: Max Reitz --- block/null.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/block/null.c b/block/null.c index 396500b..b511010 100644 --- a/block/null.c +++ b/block/null.c @@ -12,6 +12,8 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qstring.h" #include "block/block_int.h" #define NULL_OPT_LATENCY "latency-ns" @@ -223,6 +225,20 @@ static int64_t coroutine_fn null_co_get_block_status(BlockDriverState *bs, } } +static void null_refresh_filename(BlockDriverState *bs, QDict *opts) +{ + QINCREF(opts); + qdict_del(opts, "filename"); + + if (!qdict_size(opts)) { + snprintf(bs->exact_filename, sizeof(bs->exact_filename), "%s://", + bs->drv->format_name); + } + + qdict_put(opts, "driver", qstring_from_str(bs->drv->format_name)); + bs->full_open_options = opts; +} + static BlockDriver bdrv_null_co = { .format_name = "null-co", .protocol_name = "null-co", @@ -238,6 +254,8 @@ static BlockDriver bdrv_null_co = { .bdrv_reopen_prepare = null_reopen_prepare, .bdrv_co_get_block_status = null_co_get_block_status, + + .bdrv_refresh_filename = null_refresh_filename, }; static BlockDriver bdrv_null_aio = { @@ -255,6 +273,8 @@ static BlockDriver bdrv_null_aio = { .bdrv_reopen_prepare = null_reopen_prepare, .bdrv_co_get_block_status = null_co_get_block_status, + + .bdrv_refresh_filename = null_refresh_filename, }; static void bdrv_null_init(void)