From nobody Fri May 3 06:29:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501861577365614.1967006783701; Fri, 4 Aug 2017 08:46:17 -0700 (PDT) Received: from localhost ([::1]:48687 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddenn-00087M-T0 for importer@patchew.org; Fri, 04 Aug 2017 11:46:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60257) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ddduo-0000MF-F9 for qemu-devel@nongnu.org; Fri, 04 Aug 2017 10:49:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ddduP-0000Qa-Fl for qemu-devel@nongnu.org; Fri, 04 Aug 2017 10:49:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44304) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dddpc-0004nE-LC; Fri, 04 Aug 2017 10:44:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 919538125F; Fri, 4 Aug 2017 14:44:03 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-22.ams2.redhat.com [10.36.117.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 616EB8BE5C; Fri, 4 Aug 2017 14:44:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 919538125F Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 4 Aug 2017 16:43:54 +0200 Message-Id: <20170804144354.21985-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 04 Aug 2017 14:44:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] block/null: Remove 'filename' option 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, armbru@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This option was only added to allow 'null-co://' and 'null-aio://' as filenames, its value never served any actual purpose and was ignored. Nevertheless it was accepted as '-drive driver=3Dnull,filename=3Dfoo'. The correct way to enable the protocol prefixes (and that without adding a useless -drive option) is implementing .bdrv_parse_filename. This is what this patch does. Technically, this is an incompatible change, but the null block driver is only used for benchmarking, testing and debugging, and an option without effect isn't likely to be used by anyone anyway, so no bad effects are to be expected. Reported-by: Markus Armbruster Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Jeff Cody Reviewed-by: Stefan Hajnoczi --- block/null.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/block/null.c b/block/null.c index 876f90965b..dd9c13f9ba 100644 --- a/block/null.c +++ b/block/null.c @@ -30,11 +30,6 @@ static QemuOptsList runtime_opts =3D { .head =3D QTAILQ_HEAD_INITIALIZER(runtime_opts.head), .desc =3D { { - .name =3D "filename", - .type =3D QEMU_OPT_STRING, - .help =3D "", - }, - { .name =3D BLOCK_OPT_SIZE, .type =3D QEMU_OPT_SIZE, .help =3D "size of the null block", @@ -54,6 +49,30 @@ static QemuOptsList runtime_opts =3D { }, }; =20 +static void null_co_parse_filename(const char *filename, QDict *options, + Error **errp) +{ + /* This functions only exists so that a null-co:// filename is accepted + * with the null-co driver. */ + if (strcmp(filename, "null-co://")) { + error_setg(errp, "The only allowed filename for this driver is " + "'null-co://'"); + return; + } +} + +static void null_aio_parse_filename(const char *filename, QDict *options, + Error **errp) +{ + /* This functions only exists so that a null-aio:// filename is accept= ed + * with the null-aio driver. */ + if (strcmp(filename, "null-aio://")) { + error_setg(errp, "The only allowed filename for this driver is " + "'null-aio://'"); + return; + } +} + static int null_file_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { @@ -242,6 +261,7 @@ static BlockDriver bdrv_null_co =3D { .instance_size =3D sizeof(BDRVNullState), =20 .bdrv_file_open =3D null_file_open, + .bdrv_parse_filename =3D null_co_parse_filename, .bdrv_close =3D null_close, .bdrv_getlength =3D null_getlength, =20 @@ -261,6 +281,7 @@ static BlockDriver bdrv_null_aio =3D { .instance_size =3D sizeof(BDRVNullState), =20 .bdrv_file_open =3D null_file_open, + .bdrv_parse_filename =3D null_aio_parse_filename, .bdrv_close =3D null_close, .bdrv_getlength =3D null_getlength, =20 --=20 2.13.3