From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538742689246791.3521507038491; Fri, 5 Oct 2018 05:31:29 -0700 (PDT) Received: from localhost ([::1]:34919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PGR-0001GE-Vb for importer@patchew.org; Fri, 05 Oct 2018 08:31:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PEV-0007wL-Rr for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PEU-0005YI-VO for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43682) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PEU-0005Wo-N5 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08419307D922; Fri, 5 Oct 2018 12:29:26 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED1906246B; Fri, 5 Oct 2018 12:29:22 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:28:59 +0400 Message-Id: <20181005122910.11745-2-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 05 Oct 2018 12:29:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 01/12] qdev-monitor: print help to stdout 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" qdev_device_help() is used from command line "-device help", or from HMP "device_add". If used from command line, print help to stdout (it is only printed on explicit demand). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- include/monitor/monitor.h | 3 +++ monitor.c | 16 +++++++++++++--- qdev-monitor.c | 32 +++++++++++++++++++------------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 2ef5e04b37..6fd2c53b09 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -47,4 +47,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd= ); void monitor_fdset_dup_fd_remove(int dup_fd); int monitor_fdset_dup_fd_find(int dup_fd); =20 +void monitor_vfprintf(FILE *stream, + const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); + #endif /* MONITOR_H */ diff --git a/monitor.c b/monitor.c index c4677b502b..b9258a7438 100644 --- a/monitor.c +++ b/monitor.c @@ -4493,19 +4493,29 @@ static void monitor_readline_flush(void *opaque) } =20 /* - * Print to current monitor if we have one, else to stderr. + * Print to current monitor if we have one, else to stream. * TODO should return int, so callers can calculate width, but that * requires surgery to monitor_vprintf(). Left for another day. */ -void error_vprintf(const char *fmt, va_list ap) +void monitor_vfprintf(FILE *stream, const char *fmt, va_list ap) { if (cur_mon && !monitor_cur_is_qmp()) { monitor_vprintf(cur_mon, fmt, ap); } else { - vfprintf(stderr, fmt, ap); + vfprintf(stream, fmt, ap); } } =20 +/* + * Print to current monitor if we have one, else to stderr. + * TODO should return int, so callers can calculate width, but that + * requires surgery to monitor_vprintf(). Left for another day. + */ +void error_vprintf(const char *fmt, va_list ap) +{ + monitor_vfprintf(stderr, fmt, ap); +} + void error_vprintf_unless_qmp(const char *fmt, va_list ap) { if (cur_mon && !monitor_cur_is_qmp()) { diff --git a/qdev-monitor.c b/qdev-monitor.c index 61e0300991..802c18a74e 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -104,22 +104,31 @@ static bool qdev_class_has_alias(DeviceClass *dc) return (qdev_class_get_alias(dc) !=3D NULL); } =20 +static void out_printf(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + monitor_vfprintf(stdout, fmt, ap); + va_end(ap); +} + static void qdev_print_devinfo(DeviceClass *dc) { - error_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); + out_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); if (dc->bus_type) { - error_printf(", bus %s", dc->bus_type); + out_printf(", bus %s", dc->bus_type); } if (qdev_class_has_alias(dc)) { - error_printf(", alias \"%s\"", qdev_class_get_alias(dc)); + out_printf(", alias \"%s\"", qdev_class_get_alias(dc)); } if (dc->desc) { - error_printf(", desc \"%s\"", dc->desc); + out_printf(", desc \"%s\"", dc->desc); } if (!dc->user_creatable) { - error_printf(", no-user"); + out_printf(", no-user"); } - error_printf("\n"); + out_printf("\n"); } =20 static void qdev_print_devinfos(bool show_no_user) @@ -155,8 +164,7 @@ static void qdev_print_devinfos(bool show_no_user) continue; } if (!cat_printed) { - error_printf("%s%s devices:\n", i ? "\n" : "", - cat_name[i]); + out_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]); cat_printed =3D true; } qdev_print_devinfo(dc); @@ -278,13 +286,11 @@ int qdev_device_help(QemuOpts *opts) } =20 for (prop =3D prop_list; prop; prop =3D prop->next) { - error_printf("%s.%s=3D%s", driver, - prop->value->name, - prop->value->type); + out_printf("%s.%s=3D%s", driver, prop->value->name, prop->value->t= ype); if (prop->value->has_description) { - error_printf(" (%s)\n", prop->value->description); + out_printf(" (%s)\n", prop->value->description); } else { - error_printf("\n"); + out_printf("\n"); } } =20 --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538742888146740.0114769276663; Fri, 5 Oct 2018 05:34:48 -0700 (PDT) Received: from localhost ([::1]:34930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PJb-0004Yd-Mt for importer@patchew.org; Fri, 05 Oct 2018 08:34:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PEf-00086L-Sf for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PEc-0005go-Hw for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53224) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PEc-0005gC-Aa for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B04CA8830A; Fri, 5 Oct 2018 12:29:33 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9ECC46A75E; Fri, 5 Oct 2018 12:29:30 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:00 +0400 Message-Id: <20181005122910.11745-3-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 05 Oct 2018 12:29:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 02/12] cutils: add qemu_pstrcmp0() 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" A char** variant of g_strcmp0(). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth --- include/qemu/cutils.h | 12 ++++++++++++ util/cutils.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 47aaa3b0b9..7071bfe2d4 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -169,4 +169,16 @@ bool test_buffer_is_zero_next_accel(void); int uleb128_encode_small(uint8_t *out, uint32_t n); int uleb128_decode_small(const uint8_t *in, uint32_t *n); =20 +/** + * qemu_pstrcmp0: + * @str1: a non-NULL pointer to a C string (*str1 can be NULL) + * @str2: a non-NULL pointer to a C string (*str2 can be NULL) + * + * Compares *str1 and *str2 with g_strcmp0(). + * + * Returns: an integer less than, equal to, or greater than zero, if + * *str1 is <, =3D=3D or > than *str2. + */ +int qemu_pstrcmp0(const char **str1, const char **str2); + #endif diff --git a/util/cutils.c b/util/cutils.c index 9205e09031..698bd315bd 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -769,3 +769,8 @@ char *size_to_str(uint64_t val) =20 return g_strdup_printf("%0.3g %sB", (double)val / div, suffixes[i]); } + +int qemu_pstrcmp0(const char **str1, const char **str2) +{ + return g_strcmp0(*str1, *str2); +} --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538743068087101.08983521621303; Fri, 5 Oct 2018 05:37:48 -0700 (PDT) Received: from localhost ([::1]:34950 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PMQ-0006ed-L7 for importer@patchew.org; Fri, 05 Oct 2018 08:37:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58697) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PEp-0000OG-OJ for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PEm-0005sn-Gf for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37832) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PEm-0005rz-8Y for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F7F631500B8; Fri, 5 Oct 2018 12:29:43 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5381104C53C; Fri, 5 Oct 2018 12:29:37 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:01 +0400 Message-Id: <20181005122910.11745-4-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 05 Oct 2018 12:29:43 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 03/12] qemu-option: add help fallback to print the list of options 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" QDev options accept 'help' (or '?', but that's problematic with shell globbing) in the list of parameters, which is handy to list the available options. Unfortunately, this isn't built in QemuOpts. qemu_opts_parse_noisily() seems to be the common path for command line options, so place a fallback to print help, listing the available options. This is quite handy, for example with qemu "-spice help". Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- util/qemu-option.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 01886efe90..557b6c6626 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -486,7 +486,7 @@ int qemu_opt_unset(QemuOpts *opts, const char *name) } =20 static void opt_set(QemuOpts *opts, const char *name, char *value, - bool prepend, Error **errp) + bool prepend, bool *invalidp, Error **errp) { QemuOpt *opt; const QemuOptDesc *desc; @@ -496,6 +496,9 @@ static void opt_set(QemuOpts *opts, const char *name, c= har *value, if (!desc && !opts_accepts_any(opts)) { g_free(value); error_setg(errp, QERR_INVALID_PARAMETER, name); + if (invalidp) { + *invalidp =3D true; + } return; } =20 @@ -519,7 +522,7 @@ static void opt_set(QemuOpts *opts, const char *name, c= har *value, void qemu_opt_set(QemuOpts *opts, const char *name, const char *value, Error **errp) { - opt_set(opts, name, g_strdup(value), false, errp); + opt_set(opts, name, g_strdup(value), false, NULL, errp); } =20 void qemu_opt_set_bool(QemuOpts *opts, const char *name, bool val, @@ -750,7 +753,8 @@ void qemu_opts_print(QemuOpts *opts, const char *separa= tor) } =20 static void opts_do_parse(QemuOpts *opts, const char *params, - const char *firstname, bool prepend, Error **err= p) + const char *firstname, bool prepend, + bool *invalidp, Error **errp) { char *option =3D NULL; char *value =3D NULL; @@ -785,7 +789,7 @@ static void opts_do_parse(QemuOpts *opts, const char *p= arams, } if (strcmp(option, "id") !=3D 0) { /* store and parse */ - opt_set(opts, option, value, prepend, &local_err); + opt_set(opts, option, value, prepend, invalidp, &local_err); value =3D NULL; if (local_err) { error_propagate(errp, local_err); @@ -814,11 +818,12 @@ static void opts_do_parse(QemuOpts *opts, const char = *params, void qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname, Error **errp) { - opts_do_parse(opts, params, firstname, false, errp); + opts_do_parse(opts, params, firstname, false, NULL, errp); } =20 static QemuOpts *opts_parse(QemuOptsList *list, const char *params, - bool permit_abbrev, bool defaults, Error **err= p) + bool permit_abbrev, bool defaults, + bool *invalidp, Error **errp) { const char *firstname; char *id =3D NULL; @@ -850,7 +855,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const c= har *params, return NULL; } =20 - opts_do_parse(opts, params, firstname, defaults, &local_err); + opts_do_parse(opts, params, firstname, defaults, invalidp, &local_err); if (local_err) { error_propagate(errp, local_err); qemu_opts_del(opts); @@ -870,7 +875,7 @@ static QemuOpts *opts_parse(QemuOptsList *list, const c= har *params, QemuOpts *qemu_opts_parse(QemuOptsList *list, const char *params, bool permit_abbrev, Error **errp) { - return opts_parse(list, params, permit_abbrev, false, errp); + return opts_parse(list, params, permit_abbrev, false, NULL, errp); } =20 /** @@ -886,10 +891,16 @@ QemuOpts *qemu_opts_parse_noisily(QemuOptsList *list,= const char *params, { Error *err =3D NULL; QemuOpts *opts; + bool invalidp =3D false; =20 - opts =3D opts_parse(list, params, permit_abbrev, false, &err); + opts =3D opts_parse(list, params, permit_abbrev, false, &invalidp, &er= r); if (err) { - error_report_err(err); + if (invalidp && has_help_option(params)) { + qemu_opts_print_help(list); + error_free(err); + } else { + error_report_err(err); + } } return opts; } @@ -899,7 +910,7 @@ void qemu_opts_set_defaults(QemuOptsList *list, const c= har *params, { QemuOpts *opts; =20 - opts =3D opts_parse(list, params, permit_abbrev, true, NULL); + opts =3D opts_parse(list, params, permit_abbrev, true, NULL, NULL); assert(opts); } =20 --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538743050359949.5953361175551; Fri, 5 Oct 2018 05:37:30 -0700 (PDT) Received: from localhost ([::1]:34949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PMG-0006X4-2D for importer@patchew.org; Fri, 05 Oct 2018 08:37:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PEu-0000UQ-Qq for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PEt-0005wq-W6 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43802) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PEt-0005wL-OK for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:51 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 200F6307D922; Fri, 5 Oct 2018 12:29:51 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02A4C68DA1; Fri, 5 Oct 2018 12:29:47 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:02 +0400 Message-Id: <20181005122910.11745-5-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 05 Oct 2018 12:29:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 04/12] qemu-option: improve qemu_opts_print_help() output 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Modify qemu_opts_print_help(): - to print expected argument type - skip description if not available - sort lines - prefix with the list name (like qdev, to avoid confusion) - drop 16-chars alignment, use a '-' as seperator for option name and description For ex, "-spice help" output is changed from: port No description available tls-port No description available addr No description available [...] gl No description available rendernode No description available to: spice.addr=3Dstr spice.agent-mouse=3Dbool (on/off) spice.disable-agent-file-xfer=3Dbool (on/off) [...] spice.x509-key-password=3Dstr spice.zlib-glz-wan-compression=3Dstr "qemu-img create -f qcow2 -o help", changed from: size Virtual disk size compat Compatibility level (0.10 or 1.1) backing_file File name of a base image [...] lazy_refcounts Postpone refcount updates refcount_bits Width of a reference count entry in bits to: backing_file=3Dstr - File name of a base image backing_fmt=3Dstr - Image format of the base image cluster_size=3Dsize - qcow2 cluster size [...] refcount_bits=3Dnum - Width of a reference count entry in bits size=3Dsize - Virtual disk size Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- util/qemu-option.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/util/qemu-option.c b/util/qemu-option.c index 557b6c6626..9a5f263294 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -208,17 +208,51 @@ out: return result; } =20 +static const char *opt_type_to_string(enum QemuOptType type) +{ + switch (type) { + case QEMU_OPT_STRING: + return "str"; + case QEMU_OPT_BOOL: + return "bool (on/off)"; + case QEMU_OPT_NUMBER: + return "num"; + case QEMU_OPT_SIZE: + return "size"; + } + + g_assert_not_reached(); +} + void qemu_opts_print_help(QemuOptsList *list) { QemuOptDesc *desc; + int i; + GPtrArray *array =3D g_ptr_array_new(); =20 assert(list); desc =3D list->desc; while (desc && desc->name) { - printf("%-16s %s\n", desc->name, - desc->help ? desc->help : "No description available"); + GString *str =3D g_string_new(NULL); + if (list->name) { + g_string_append_printf(str, "%s.", list->name); + } + g_string_append_printf(str, "%s=3D%s", desc->name, + opt_type_to_string(desc->type)); + if (desc->help) { + g_string_append_printf(str, " - %s", desc->help); + } + g_ptr_array_add(array, g_string_free(str, false)); desc++; } + + g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); + for (i =3D 0; i < array->len; i++) { + printf("%s\n", (char *)array->pdata[i]); + } + g_ptr_array_set_free_func(array, g_free); + g_ptr_array_free(array, true); + } /* ------------------------------------------------------------------ */ =20 --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153874319186862.15376897108388; Fri, 5 Oct 2018 05:39:51 -0700 (PDT) Received: from localhost ([::1]:34959 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8POY-0008Lk-RL for importer@patchew.org; Fri, 05 Oct 2018 08:39:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PF4-0000ay-Cc for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PF1-00062y-4a for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PF0-00062B-V8 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:29:59 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B57D31649A4; Fri, 5 Oct 2018 12:29:58 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 375C3206F369; Fri, 5 Oct 2018 12:29:54 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:03 +0400 Message-Id: <20181005122910.11745-6-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 05 Oct 2018 12:29:58 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 05/12] qom/object: fix iterating properties over a class 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" object_class_property_iter_init() starts from the given class, so the next class should continue with the parent class. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Paolo Bonzini --- qom/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qom/object.c b/qom/object.c index 9222b23172..9eaf08a53c 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1115,7 +1115,7 @@ void object_class_property_iter_init(ObjectPropertyIt= erator *iter, ObjectClass *klass) { g_hash_table_iter_init(&iter->iter, klass->properties); - iter->nextclass =3D klass; + iter->nextclass =3D object_class_get_parent(klass); } =20 ObjectProperty *object_class_property_find(ObjectClass *klass, const char = *name, --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538742775879482.9757533727526; Fri, 5 Oct 2018 05:32:55 -0700 (PDT) Received: from localhost ([::1]:34923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PHp-0002Rl-KR for importer@patchew.org; Fri, 05 Oct 2018 08:32:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PFU-00011c-Mj for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PFR-0006P4-EH for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38752) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PFP-0006L2-CS for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:24 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D7FF30A3ACB; Fri, 5 Oct 2018 12:30:21 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64858308BDA4; Fri, 5 Oct 2018 12:30:02 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:04 +0400 Message-Id: <20181005122910.11745-7-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 05 Oct 2018 12:30:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 06/12] qom/object: register 'type' property as class property 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Let's save a few byte in each object instance. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Paolo Bonzini --- qom/object.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qom/object.c b/qom/object.c index 9eaf08a53c..547dcf97c3 100644 --- a/qom/object.c +++ b/qom/object.c @@ -2430,9 +2430,10 @@ void object_class_property_set_description(ObjectCla= ss *klass, op->description =3D g_strdup(description); } =20 -static void object_instance_init(Object *obj) +static void object_class_init(ObjectClass *klass, void *data) { - object_property_add_str(obj, "type", qdev_get_type, NULL, NULL); + object_class_property_add_str(klass, "type", qdev_get_type, + NULL, &error_abort); } =20 static void register_types(void) @@ -2446,7 +2447,7 @@ static void register_types(void) static TypeInfo object_info =3D { .name =3D TYPE_OBJECT, .instance_size =3D sizeof(Object), - .instance_init =3D object_instance_init, + .class_init =3D object_class_init, .abstract =3D true, }; =20 --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538743001923468.4318185467383; Fri, 5 Oct 2018 05:36:41 -0700 (PDT) Received: from localhost ([::1]:34948 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PLS-0005v7-Ir for importer@patchew.org; Fri, 05 Oct 2018 08:36:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59013) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PFc-00018K-2f for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PFY-0006Wt-RL for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PFX-0006Vo-0z for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:31 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2D7E51F1A; Fri, 5 Oct 2018 12:30:29 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD8666A75A; Fri, 5 Oct 2018 12:30:25 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:05 +0400 Message-Id: <20181005122910.11745-8-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 05 Oct 2018 12:30:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 07/12] tests/qom-proplist: check duplicate "bv" property registration failed 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" "bv" is already a class property. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Paolo Bonzini --- tests/check-qom-proplist.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 92898e1520..0f6d9c1ce3 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -125,10 +125,13 @@ static char *dummy_get_sv(Object *obj, =20 static void dummy_init(Object *obj) { + Error *err =3D NULL; + object_property_add_bool(obj, "bv", dummy_get_bv, dummy_set_bv, - NULL); + &err); + error_free_or_abort(&err); } =20 =20 --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538743203463276.86764789764686; Fri, 5 Oct 2018 05:40:03 -0700 (PDT) Received: from localhost ([::1]:34960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8POk-0008V6-6I for importer@patchew.org; Fri, 05 Oct 2018 08:40:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PFe-0001Bm-UX for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PFe-0006bk-34 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50190) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PFd-0006at-Rj for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3330B30CF68E; Fri, 5 Oct 2018 12:30:37 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 163126246B; Fri, 5 Oct 2018 12:30:33 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:06 +0400 Message-Id: <20181005122910.11745-9-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 05 Oct 2018 12:30:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 08/12] tests/qom-proplist: check properties are not listed multiple times 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" And factor out a common function used by the follow class properties iterator test. Fix uninitialized "seentype" variable. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Paolo Bonzini --- tests/check-qom-proplist.c | 44 +++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 0f6d9c1ce3..2c07719607 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -520,32 +520,19 @@ static void test_dummy_getenum(void) } =20 =20 -static void test_dummy_iterator(void) +static void test_dummy_prop_iterator(ObjectPropertyIterator *iter) { - Object *parent =3D object_get_objects_root(); - DummyObject *dobj =3D DUMMY_OBJECT( - object_new_with_props(TYPE_DUMMY, - parent, - "dummy0", - &error_abort, - "bv", "yes", - "sv", "Hiss hiss hiss", - "av", "platypus", - NULL)); - + bool seenbv =3D false, seensv =3D false, seenav =3D false, seentype = =3D false; ObjectProperty *prop; - ObjectPropertyIterator iter; - bool seenbv =3D false, seensv =3D false, seenav =3D false, seentype; =20 - object_property_iter_init(&iter, OBJECT(dobj)); - while ((prop =3D object_property_iter_next(&iter))) { - if (g_str_equal(prop->name, "bv")) { + while ((prop =3D object_property_iter_next(iter))) { + if (!seenbv && g_str_equal(prop->name, "bv")) { seenbv =3D true; - } else if (g_str_equal(prop->name, "sv")) { + } else if (!seensv && g_str_equal(prop->name, "sv")) { seensv =3D true; - } else if (g_str_equal(prop->name, "av")) { + } else if (!seenav && g_str_equal(prop->name, "av")) { seenav =3D true; - } else if (g_str_equal(prop->name, "type")) { + } else if (!seentype && g_str_equal(prop->name, "type")) { /* This prop comes from the base Object class */ seentype =3D true; } else { @@ -557,7 +544,24 @@ static void test_dummy_iterator(void) g_assert(seenav); g_assert(seensv); g_assert(seentype); +} =20 +static void test_dummy_iterator(void) +{ + Object *parent =3D object_get_objects_root(); + DummyObject *dobj =3D DUMMY_OBJECT( + object_new_with_props(TYPE_DUMMY, + parent, + "dummy0", + &error_abort, + "bv", "yes", + "sv", "Hiss hiss hiss", + "av", "platypus", + NULL)); + ObjectPropertyIterator iter; + + object_property_iter_init(&iter, OBJECT(dobj)); + test_dummy_prop_iterator(&iter); object_unparent(OBJECT(dobj)); } =20 --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538743304327384.2173535239815; Fri, 5 Oct 2018 05:41:44 -0700 (PDT) Received: from localhost ([::1]:34971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PQN-0001Nz-7N for importer@patchew.org; Fri, 05 Oct 2018 08:41:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PFn-0001Io-Mt for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PFj-0006fD-8U for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38098) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PFj-0006ex-1S for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 528C93167E49; Fri, 5 Oct 2018 12:30:42 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F6026246B; Fri, 5 Oct 2018 12:30:40 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:07 +0400 Message-Id: <20181005122910.11745-10-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 05 Oct 2018 12:30:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 09/12] tests/qom-proplist: check class properties iterator 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This test failed before "fix iterating properties over a class". Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Paolo Bonzini --- tests/check-qom-proplist.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index 2c07719607..a8b2958e6e 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -565,6 +565,14 @@ static void test_dummy_iterator(void) object_unparent(OBJECT(dobj)); } =20 +static void test_dummy_class_iterator(void) +{ + ObjectPropertyIterator iter; + ObjectClass *klass =3D object_class_by_name(TYPE_DUMMY); + + object_class_property_iter_init(&iter, klass); + test_dummy_prop_iterator(&iter); +} =20 static void test_dummy_delchild(void) { @@ -636,6 +644,7 @@ int main(int argc, char **argv) g_test_add_func("/qom/proplist/badenum", test_dummy_badenum); g_test_add_func("/qom/proplist/getenum", test_dummy_getenum); g_test_add_func("/qom/proplist/iterator", test_dummy_iterator); + g_test_add_func("/qom/proplist/class_iterator", test_dummy_class_itera= tor); g_test_add_func("/qom/proplist/delchild", test_dummy_delchild); g_test_add_func("/qom/resolve/partial", test_qom_partial_path); =20 --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538743312568639.4586734848278; Fri, 5 Oct 2018 05:41:52 -0700 (PDT) Received: from localhost ([::1]:34972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PQV-0001UA-BH for importer@patchew.org; Fri, 05 Oct 2018 08:41:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PFz-0001Uq-EU for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:31:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PFv-0006me-IH for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59692) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PFt-0006kX-HF for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:30:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53CE181DE7; Fri, 5 Oct 2018 12:30:51 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1755A18C4C; Fri, 5 Oct 2018 12:30:46 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:08 +0400 Message-Id: <20181005122910.11745-11-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 05 Oct 2018 12:30:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 10/12] vl: handle -object help 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" List the user creatable objects. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Paolo Bonzini --- vl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vl.c b/vl.c index a867c9c4d9..f254b99bdb 100644 --- a/vl.c +++ b/vl.c @@ -2698,6 +2698,19 @@ static int machine_set_property(void *opaque, */ static bool object_create_initial(const char *type) { + if (is_help_option(type)) { + GSList *l, *list; + + printf("List of user creatable objects:\n"); + list =3D object_class_get_list_sorted(TYPE_USER_CREATABLE, false); + for (l =3D list; l !=3D NULL; l =3D l->next) { + ObjectClass *oc =3D OBJECT_CLASS(l->data); + printf("%s\n", object_class_get_name(oc)); + } + g_slist_free(list); + exit(0); + } + if (g_str_equal(type, "rng-egd") || g_str_has_prefix(type, "pr-manager-")) { return false; --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153874314711478.80534976113813; Fri, 5 Oct 2018 05:39:07 -0700 (PDT) Received: from localhost ([::1]:34958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PNp-0007jx-UN for importer@patchew.org; Fri, 05 Oct 2018 08:39:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PG2-0001Wy-S9 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:31:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PG2-0006s3-30 for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:31:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PG1-0006q6-NF for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:31:02 -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 E97543164983; Fri, 5 Oct 2018 12:30:59 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE1FD5D9C8; Fri, 5 Oct 2018 12:30:55 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:09 +0400 Message-Id: <20181005122910.11745-12-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 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.41]); Fri, 05 Oct 2018 12:30:59 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 11/12] hostmem: add some properties description 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Paolo Bonzini --- backends/hostmem-memfd.c | 9 +++++++++ backends/hostmem.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 3800bd07b6..b6836b28e5 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -145,16 +145,25 @@ memfd_backend_class_init(ObjectClass *oc, void *data) memfd_backend_get_hugetlb, memfd_backend_set_hugetlb, &error_abort); + object_class_property_set_description(oc, "hugetlb", + "Use huge pages", + &error_abort); object_class_property_add(oc, "hugetlbsize", "int", memfd_backend_get_hugetlbsize, memfd_backend_set_hugetlbsize, NULL, NULL, &error_abort); + object_class_property_set_description(oc, "hugetlbsize", + "Huge pages size (ex: 2M, 1G= )", + &error_abort); } if (qemu_memfd_check(MFD_ALLOW_SEALING)) { object_class_property_add_bool(oc, "seal", memfd_backend_get_seal, memfd_backend_set_seal, &error_abort); + object_class_property_set_description(oc, "seal", + "Seal growing & shrinking", + &error_abort); } } =20 diff --git a/backends/hostmem.c b/backends/hostmem.c index 4908946cd3..1a89342039 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -397,27 +397,41 @@ host_memory_backend_class_init(ObjectClass *oc, void = *data) object_class_property_add_bool(oc, "merge", host_memory_backend_get_merge, host_memory_backend_set_merge, &error_abort); + object_class_property_set_description(oc, "merge", + "Mark memory as mergeable", &error_abort); object_class_property_add_bool(oc, "dump", host_memory_backend_get_dump, host_memory_backend_set_dump, &error_abort); + object_class_property_set_description(oc, "dump", + "Set to 'off' to exclude from core dump", &error_abort); object_class_property_add_bool(oc, "prealloc", host_memory_backend_get_prealloc, host_memory_backend_set_prealloc, &error_abort); + object_class_property_set_description(oc, "prealloc", + "Preallocate memory", &error_abort); object_class_property_add(oc, "size", "int", host_memory_backend_get_size, host_memory_backend_set_size, NULL, NULL, &error_abort); + object_class_property_set_description(oc, "size", + "Size of the memory region (ex: 500M)", &error_abort); object_class_property_add(oc, "host-nodes", "int", host_memory_backend_get_host_nodes, host_memory_backend_set_host_nodes, NULL, NULL, &error_abort); + object_class_property_set_description(oc, "host-nodes", + "Binds memory to the list of NUMA host nodes", &error_abort); object_class_property_add_enum(oc, "policy", "HostMemPolicy", &HostMemPolicy_lookup, host_memory_backend_get_policy, host_memory_backend_set_policy, &error_abort); + object_class_property_set_description(oc, "policy", + "Set the NUMA policy", &error_abort); object_class_property_add_bool(oc, "share", host_memory_backend_get_share, host_memory_backend_set_share, &error_abort); + object_class_property_set_description(oc, "share", + "Mark the memory as private to QEMU or shared", &error_abort); } =20 static const TypeInfo host_memory_backend_info =3D { --=20 2.19.0.271.gfe8321ec05 From nobody Sat May 18 05:53:11 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538743397448863.8481004000917; Fri, 5 Oct 2018 05:43:17 -0700 (PDT) Received: from localhost ([::1]:34983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PRn-0002UL-Ax for importer@patchew.org; Fri, 05 Oct 2018 08:43:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8PGD-0001dK-Iy for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:31:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8PGC-00070o-9S for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:31:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58950) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g8PGC-0006z1-1m for qemu-devel@nongnu.org; Fri, 05 Oct 2018 08:31:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF940300177F; Fri, 5 Oct 2018 12:31:09 +0000 (UTC) Received: from localhost (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8736968DA1; Fri, 5 Oct 2018 12:31:04 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 16:29:10 +0400 Message-Id: <20181005122910.11745-13-marcandre.lureau@redhat.com> In-Reply-To: <20181005122910.11745-1-marcandre.lureau@redhat.com> References: <20181005122910.11745-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 05 Oct 2018 12:31:09 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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 v2 12/12] vl: list user creatable properties when 'help' is argument 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@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Iterate over the writable class properties, sort and print them out with the description if available. Ex: qemu -object memory-backend-file,help memory-backend-file.align=3Dint memory-backend-file.discard-data=3Dbool memory-backend-file.dump=3Dbool - Set to 'off' to exclude from core dump memory-backend-file.host-nodes=3Dint - Binds memory to the list of NUMA hos= t nodes memory-backend-file.mem-path=3Dstring memory-backend-file.merge=3Dbool - Mark memory as mergeable memory-backend-file.pmem=3Dbool memory-backend-file.policy=3DHostMemPolicy - Set the NUMA policy memory-backend-file.prealloc=3Dbool - Preallocate memory memory-backend-file.share=3Dbool - Mark the memory as private to QEMU or sh= ared memory-backend-file.size=3Dint - Size of the memory region (ex: 500M) Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini --- qom/object_interfaces.c | 6 +++--- vl.c | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index 72b97a8bed..941fd63afd 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -141,14 +141,14 @@ Object *user_creatable_add_opts(QemuOpts *opts, Error= **errp) =20 int user_creatable_add_opts_foreach(void *opaque, QemuOpts *opts, Error **= errp) { - bool (*type_predicate)(const char *) =3D opaque; + bool (*type_opt_predicate)(const char *, QemuOpts *) =3D opaque; Object *obj =3D NULL; Error *err =3D NULL; const char *type; =20 type =3D qemu_opt_get(opts, "qom-type"); - if (type && type_predicate && - !type_predicate(type)) { + if (type && type_opt_predicate && + !type_opt_predicate(type, opts)) { return 0; } =20 diff --git a/vl.c b/vl.c index f254b99bdb..4e25c78bff 100644 --- a/vl.c +++ b/vl.c @@ -2696,8 +2696,10 @@ static int machine_set_property(void *opaque, * cannot be created here, as it depends on the chardev * already existing. */ -static bool object_create_initial(const char *type) +static bool object_create_initial(const char *type, QemuOpts *opts) { + ObjectClass *klass; + if (is_help_option(type)) { GSList *l, *list; =20 @@ -2711,6 +2713,38 @@ static bool object_create_initial(const char *type) exit(0); } =20 + klass =3D object_class_by_name(type); + if (klass && qemu_opt_has_help_opt(opts)) { + ObjectPropertyIterator iter; + ObjectProperty *prop; + GPtrArray *array =3D g_ptr_array_new(); + int i; + + object_class_property_iter_init(&iter, klass); + while ((prop =3D object_property_iter_next(&iter))) { + GString *str; + + if (!prop->set) { + continue; + } + + str =3D g_string_new(NULL); + g_string_append_printf(str, "%s.%s=3D%s", type, + prop->name, prop->type); + if (prop->description) { + g_string_append_printf(str, " - %s", prop->description); + } + g_ptr_array_add(array, g_string_free(str, false)); + } + g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); + for (i =3D 0; i < array->len; i++) { + printf("%s\n", (char *)array->pdata[i]); + } + g_ptr_array_set_free_func(array, g_free); + g_ptr_array_free(array, true); + exit(0); + } + if (g_str_equal(type, "rng-egd") || g_str_has_prefix(type, "pr-manager-")) { return false; @@ -2757,9 +2791,9 @@ static bool object_create_initial(const char *type) * The remainder of object creation happens after the * creation of chardev, fsdev, net clients and device data types. */ -static bool object_create_delayed(const char *type) +static bool object_create_delayed(const char *type, QemuOpts *opts) { - return !object_create_initial(type); + return !object_create_initial(type, opts); } =20 =20 --=20 2.19.0.271.gfe8321ec05