From patchwork Tue Apr 26 21:32:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 8945851 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3466F9F441 for ; Tue, 26 Apr 2016 21:37:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B399201EC for ; Tue, 26 Apr 2016 21:37:10 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 5344D201BB for ; Tue, 26 Apr 2016 21:37:09 +0000 (UTC) Received: from localhost ([::1]:39734 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avAfM-00078O-KM for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Apr 2016 17:37:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avAaz-0006hQ-5n for qemu-devel@nongnu.org; Tue, 26 Apr 2016 17:32:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avAax-0003ug-KD for qemu-devel@nongnu.org; Tue, 26 Apr 2016 17:32:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48450) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avAav-0003tY-D9; Tue, 26 Apr 2016 17:32:33 -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 0E09D3455AE; Tue, 26 Apr 2016 21:32:33 +0000 (UTC) Received: from localhost (ovpn-116-92.ams2.redhat.com [10.36.116.92]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3QLWVU8000715 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 26 Apr 2016 17:32:32 -0400 From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 26 Apr 2016 23:32:04 +0200 Message-Id: <1461706338-20219-6-git-send-email-mreitz@redhat.com> In-Reply-To: <1461706338-20219-1-git-send-email-mreitz@redhat.com> References: <1461706338-20219-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 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] [PATCH 05/19] block: Add bdrv_default_refresh_protocol_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: Kevin Wolf , Alberto Garcia , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Split off the default code for protocol BDS from bdrv_refresh_filename() into an own function, just as it has been done for format BDS. Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia --- block.c | 58 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/block.c b/block.c index 447468c..511a0b1 100644 --- a/block.c +++ b/block.c @@ -3922,6 +3922,38 @@ static void bdrv_default_refresh_format_filename(BlockDriverState *bs) } } +static void bdrv_default_refresh_protocol_filename(BlockDriverState *bs) +{ + BlockDriver *drv = bs->drv; + QDict *opts; + + /* There is no underlying file BDS (at least referenced by BDS.file), + * so the full options QDict should be equal to the options given + * specifically for this block device when it was opened (plus the + * driver specification). + * Because those options don't change, there is no need to update + * full_open_options when it's already set. */ + + opts = qdict_new(); + append_open_options(opts, bs); + qdict_put_obj(opts, "driver", + QOBJECT(qstring_from_str(drv->format_name))); + + if (bs->exact_filename[0]) { + /* This may not work for all block protocol drivers (some may + * require this filename to be parsed), but we have to find some + * default solution here, so just include it. If some block driver + * does not support pure options without any filename at all or + * needs some special format of the options QDict, it needs to + * implement the driver-specific bdrv_refresh_filename() function. + */ + qdict_put_obj(opts, "filename", + QOBJECT(qstring_from_str(bs->exact_filename))); + } + + bs->full_open_options = opts; +} + /* Updates the following BDS fields: * - exact_filename: A filename which may be used for opening a block device * which (mostly) equals the given BDS (even without any @@ -3967,31 +3999,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) /* Try to reconstruct valid information from the underlying file */ bdrv_default_refresh_format_filename(bs); } else if (!bs->full_open_options && qdict_size(bs->options)) { - /* There is no underlying file BDS (at least referenced by BDS.file), - * so the full options QDict should be equal to the options given - * specifically for this block device when it was opened (plus the - * driver specification). - * Because those options don't change, there is no need to update - * full_open_options when it's already set. */ - - opts = qdict_new(); - append_open_options(opts, bs); - qdict_put_obj(opts, "driver", - QOBJECT(qstring_from_str(drv->format_name))); - - if (bs->exact_filename[0]) { - /* This may not work for all block protocol drivers (some may - * require this filename to be parsed), but we have to find some - * default solution here, so just include it. If some block driver - * does not support pure options without any filename at all or - * needs some special format of the options QDict, it needs to - * implement the driver-specific bdrv_refresh_filename() function. - */ - qdict_put_obj(opts, "filename", - QOBJECT(qstring_from_str(bs->exact_filename))); - } - - bs->full_open_options = opts; + bdrv_default_refresh_protocol_filename(bs); } if (bs->exact_filename[0]) {