From nobody Tue Feb 10 16:22:48 2026 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@gnu.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@gnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15069584247281020.7124039037288; Mon, 2 Oct 2017 08:33:44 -0700 (PDT) Received: from localhost ([::1]:52850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz2iw-0005aB-UE for importer@patchew.org; Mon, 02 Oct 2017 11:33:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz2bf-00080k-U1 for qemu-devel@nongnu.org; Mon, 02 Oct 2017 11:26:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz2bd-0007zT-H4 for qemu-devel@nongnu.org; Mon, 02 Oct 2017 11:26:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dz2bd-0007yg-6m for qemu-devel@nongnu.org; Mon, 02 Oct 2017 11:26:05 -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 2C3D38046E; Mon, 2 Oct 2017 15:26:04 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-91.ams2.redhat.com [10.36.116.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5790C5D725; Mon, 2 Oct 2017 15:26:02 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EF16B11562F3; Mon, 2 Oct 2017 17:25:52 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2C3D38046E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=armbru@redhat.com From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 2 Oct 2017 17:25:52 +0200 Message-Id: <20171002152552.27999-33-armbru@redhat.com> In-Reply-To: <20171002152552.27999-1-armbru@redhat.com> References: <20171002152552.27999-1-armbru@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.28]); Mon, 02 Oct 2017 15:26:04 +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] [RFC PATCH 32/32] qapi/options: QAPIfy --add-fd argument type X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.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" Signed-off-by: Markus Armbruster --- qapi/options.json | 2 +- vl.c | 70 +++++++++++++--------------------------------------= ---- 2 files changed, 17 insertions(+), 55 deletions(-) diff --git a/qapi/options.json b/qapi/options.json index d55c6bfa81..c46c3deb10 100644 --- a/qapi/options.json +++ b/qapi/options.json @@ -285,7 +285,7 @@ # !end texinfo ## { 'option': '--add-fd', - 'data': 'str', # FIXME QAPIfy qemu_add_fd_opts + 'data': { 'fd': 'int', 'set': 'int', '*opaque': 'str' }, 'help': [ "-add-fd fd=3Dfd,set=3Dset[,opaque=3Dopaque]", " Add 'fd' to fd 'set'"] } diff --git a/vl.c b/vl.c index 32f4b5fef3..e769796c11 100644 --- a/vl.c +++ b/vl.c @@ -371,27 +371,6 @@ static QemuOptsList qemu_boot_opts =3D { }, }; =20 -static QemuOptsList qemu_add_fd_opts =3D { - .name =3D "add-fd", - .head =3D QTAILQ_HEAD_INITIALIZER(qemu_add_fd_opts.head), - .desc =3D { - { - .name =3D "fd", - .type =3D QEMU_OPT_NUMBER, - .help =3D "file descriptor of which a duplicate is added to fd= set", - },{ - .name =3D "set", - .type =3D QEMU_OPT_NUMBER, - .help =3D "ID of the fd set to add fd to", - },{ - .name =3D "opaque", - .type =3D QEMU_OPT_STRING, - .help =3D "free-form string used to describe fd", - }, - { /* end of list */ } - }, -}; - static QemuOptsList qemu_object_opts =3D { .name =3D "object", .implied_opt_name =3D "qom-type", @@ -1148,19 +1127,13 @@ bool defaults_enabled(void) } =20 #ifndef _WIN32 -static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp) +static int do_add_fd(int fd, int64_t fdset_id, const char *fd_opaque) { - int fd, dupfd, flags; - int64_t fdset_id; - const char *fd_opaque =3D NULL; + int dupfd, flags; AddfdInfo *fdinfo; =20 - fd =3D qemu_opt_get_number(opts, "fd", -1); - fdset_id =3D qemu_opt_get_number(opts, "set", -1); - fd_opaque =3D qemu_opt_get(opts, "opaque"); - if (fd < 0) { - error_report("fd option is required and must be non-negative"); + error_report("fd option must be non-negative"); return -1; } =20 @@ -1180,7 +1153,7 @@ static int parse_add_fd(void *opaque, QemuOpts *opts,= Error **errp) } =20 if (fdset_id < 0) { - error_report("set option is required and must be non-negative"); + error_report("set option must be non-negative"); return -1; } =20 @@ -1204,16 +1177,6 @@ static int parse_add_fd(void *opaque, QemuOpts *opts= , Error **errp) =20 return 0; } - -static int cleanup_add_fd(void *opaque, QemuOpts *opts, Error **errp) -{ - int fd; - - fd =3D qemu_opt_get_number(opts, "fd", -1); - close(fd); - - return 0; -} #endif =20 /***********************************************************/ @@ -3120,7 +3083,6 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_smp_opts); qemu_add_opts(&qemu_boot_opts); qemu_add_opts(&qemu_sandbox_opts); - qemu_add_opts(&qemu_add_fd_opts); qemu_add_opts(&qemu_object_opts); qemu_add_opts(&qemu_tpmdev_opts); qemu_add_opts(&qemu_realtime_opts); @@ -4126,11 +4088,7 @@ int main(int argc, char **argv, char **envp) break; case QAPI_OPTION_KIND_ADD_FD: #ifndef _WIN32 - opts =3D qemu_opts_parse_noisily(qemu_find_opts("add-fd"), - qopt[i].u.add_fd.data, fals= e); - if (!opts) { - exit(1); - } + /* nothing to do */ #else error_report("File descriptor passing is disabled on this " "platform"); @@ -4219,14 +4177,18 @@ int main(int argc, char **argv, char **envp) } =20 #ifndef _WIN32 - if (qemu_opts_foreach(qemu_find_opts("add-fd"), - parse_add_fd, NULL, NULL)) { - exit(1); + for (i =3D 0; qopt[i].cnt; i++) { + if (qopt[i].type =3D=3D QAPI_OPTION_KIND_ADD_FD) { + if (do_add_fd(qopt[i].u.add_fd.fd, qopt[i].u.add_fd.set, + qopt[i].u.add_fd.opaque) < 0) { + exit(1); + } + } } - - if (qemu_opts_foreach(qemu_find_opts("add-fd"), - cleanup_add_fd, NULL, NULL)) { - exit(1); + for (i =3D 0; qopt[i].cnt; i++) { + if (qopt[i].type =3D=3D QAPI_OPTION_KIND_ADD_FD) { + close(qopt[i].u.add_fd.fd); + } } #endif =20 --=20 2.13.6