From nobody Mon Nov 10 19:43:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1558118419; cv=none; d=zoho.com; s=zohoarc; b=gvQUEogMTjG0wiibQYCBkV8AYI63vMvJUpJyUOYFczSOAZBSIIGF4wKhtHjkRE8ucb8gBoh0i/S8aKYsTDD7Y/9Zt4zCfgth8u4tzsgrQ4KD1D0ojXXjXWZgdyhAC9klytaggaGA5OS0Ns4W7V0uOOE8ICP+PpFTXbjYSrv6/k4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558118419; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=kSP09rXvK5idVzDCV4IYtHZSDd3Rz+oSDfaQVwSOI+Y=; b=Ro+M41Zw1U2kKJdKKw8j9JeyokfY7//oiA5h+DvVzPAW5utfZbW0nM3AN6iKleLi6PPxfZiK+teAdefr++Jn1TW23KhjCZ6oCgZtNhzecGHTmdE3aTeONf7mxXGDR1XFyV72hoXM0w734SZwsVBKvZNApubt+r9pBqwTdMaYUgM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1558118419340575.3860523716393; Fri, 17 May 2019 11:40:19 -0700 (PDT) Received: from localhost ([127.0.0.1]:52365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRhm3-0000sq-5Z for importer@patchew.org; Fri, 17 May 2019 14:40:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRhfE-00046X-E3 for qemu-devel@nongnu.org; Fri, 17 May 2019 14:33:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRhfD-0006H9-8O for qemu-devel@nongnu.org; Fri, 17 May 2019 14:33:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38060 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRhfD-0006GG-3V for qemu-devel@nongnu.org; Fri, 17 May 2019 14:33:03 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4HINoG9072969 for ; Fri, 17 May 2019 14:33:01 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2shyuswkfk-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 May 2019 14:33:00 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 May 2019 19:32:59 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 May 2019 19:32:57 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4HIWunC49676306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 May 2019 18:32:56 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C96F052065; Fri, 17 May 2019 18:32:56 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id A5E8452050; Fri, 17 May 2019 18:32:56 +0000 (GMT) Received: from bahia.ibmuc.com (sig-9-145-156-103.de.ibm.com [9.145.156.103]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 3F3BD2203F3; Fri, 17 May 2019 20:32:56 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 17 May 2019 20:32:38 +0200 X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190517183240.689188-1-groug@kaod.org> References: <20190517183240.689188-1-groug@kaod.org> X-TM-AS-GCONF: 00 x-cbid: 19051718-4275-0000-0000-00000335EB45 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051718-4276-0000-0000-0000384577DC Message-Id: <20190517183240.689188-5-groug@kaod.org> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-17_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905170108 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL 4/6] fsdev: Error out when unsupported option is passed 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: Peter Maydell , Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Each fsdriver only supports a subset of the options that can be passed to -fsdev. Unsupported options are simply ignored. This could cause the user to erroneously think QEMU has a bug. Enforce strict checking of supported options for all fsdrivers. This shouldn't impact libvirt, since it doesn't know about the synth and proxy fsdrivers. Signed-off-by: Greg Kurz Reviewed-by: Eric Blake --- fsdev/qemu-fsdev.c | 74 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c index e972bd698cf5..077a8c4e2bca 100644 --- a/fsdev/qemu-fsdev.c +++ b/fsdev/qemu-fsdev.c @@ -34,6 +34,7 @@ typedef struct FsDriverTable { const char *name; FileOperations *ops; + const char **opts; } FsDriverTable; =20 typedef struct FsDriverListEntry { @@ -44,12 +45,75 @@ typedef struct FsDriverListEntry { static QTAILQ_HEAD(, FsDriverListEntry) fsdriver_entries =3D QTAILQ_HEAD_INITIALIZER(fsdriver_entries); =20 +#define COMMON_FS_DRIVER_OPTIONS "id", "fsdriver", "readonly" + static FsDriverTable FsDrivers[] =3D { - { .name =3D "local", .ops =3D &local_ops}, - { .name =3D "synth", .ops =3D &synth_ops}, - { .name =3D "proxy", .ops =3D &proxy_ops}, + { + .name =3D "local", + .ops =3D &local_ops, + .opts =3D (const char * []) { + COMMON_FS_DRIVER_OPTIONS, + "security_model", + "path", + "writeout", + "fmode", + "dmode", + "throttling.bps-total", + "throttling.bps-read", + "throttling.bps-write", + "throttling.iops-total", + "throttling.iops-read", + "throttling.iops-write", + "throttling.bps-total-max", + "throttling.bps-read-max", + "throttling.bps-write-max", + "throttling.iops-total-max", + "throttling.iops-read-max", + "throttling.iops-write-max", + "throttling.bps-total-max-length", + "throttling.bps-read-max-length", + "throttling.bps-write-max-length", + "throttling.iops-total-max-length", + "throttling.iops-read-max-length", + "throttling.iops-write-max-length", + "throttling.iops-size", + }, + }, + { + .name =3D "synth", + .ops =3D &synth_ops, + .opts =3D (const char * []) { + COMMON_FS_DRIVER_OPTIONS, + }, + }, + { + .name =3D "proxy", + .ops =3D &proxy_ops, + .opts =3D (const char * []) { + COMMON_FS_DRIVER_OPTIONS, + "socket", + "sock_fd", + "writeout", + }, + }, }; =20 +static int validate_opt(void *opaque, const char *name, const char *value, + Error **errp) +{ + FsDriverTable *drv =3D opaque; + const char **opt; + + for (opt =3D drv->opts; *opt; opt++) { + if (!strcmp(*opt, name)) { + return 0; + } + } + + error_setg(errp, "'%s' is invalid for fsdriver '%s'", name, drv->name); + return -1; +} + int qemu_fsdev_add(QemuOpts *opts, Error **errp) { int i; @@ -80,6 +144,10 @@ int qemu_fsdev_add(QemuOpts *opts, Error **errp) return -1; } =20 + if (qemu_opt_foreach(opts, validate_opt, &FsDrivers[i], errp)) { + return -1; + } + fsle =3D g_malloc0(sizeof(*fsle)); fsle->fse.fsdev_id =3D g_strdup(fsdev_id); fsle->fse.ops =3D FsDrivers[i].ops; --=20 2.17.2