From nobody Sun Feb 8 09:37:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589987525; cv=none; d=zohomail.com; s=zohoarc; b=fIUeEiKyrB2wEbVHOPq5LMdIRsdOfr6hcxFcFS62vh0yds/Q6KvLbLZBOcRRT0JjeADw9KqLiqAraqaXQCXA2eZyOSDGuEiu0H8eyWReLyc7EousYh7JMdyxdu2TF2fpl3vOqiJTq7r6GUN+13SYoZ/DeTqTmUb/+zf+00A5pYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589987525; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xwkUiDsMKfDa5Zgki/Byh7RKqDufhpguITNHwaV82bA=; b=etn9DFb8ZLU6mk77wYoW9Ac3vUhylPybagH6s32JRPkJznPWrclhUpuUBFa87J0fL20gUS3Zpv/h6W4ngUokQhzEJ/L/JxYq+OJJU7v+Qo17b0wVqLasOaI/Mf8Z9zNiJ7l1GpAESqf5NBkKmzOFOLZaNdDh3RA9jPUZ16X5jSI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158998752527272.38254679281522; Wed, 20 May 2020 08:12:05 -0700 (PDT) Received: from localhost ([::1]:54374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbQO3-00005i-I3 for importer@patchew.org; Wed, 20 May 2020 11:12:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbQNL-0007ek-40 for qemu-devel@nongnu.org; Wed, 20 May 2020 11:11:19 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:25333 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jbQNJ-0000O7-Pz for qemu-devel@nongnu.org; Wed, 20 May 2020 11:11:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-354-6C0rikraOuipj08i-2Zilw-1; Wed, 20 May 2020 11:11:14 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 554BB107ACCA; Wed, 20 May 2020 15:11:13 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-114-169.ams2.redhat.com [10.36.114.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DF386F93C; Wed, 20 May 2020 15:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589987476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xwkUiDsMKfDa5Zgki/Byh7RKqDufhpguITNHwaV82bA=; b=EwSPEFHSGuEuLqIveXj28PobKiueMgYuf03DjcjTI7zBScroMi/qLWHkXh5wENI/p/UQp4 XT66TVo4kVELChVBBt3M8lTtuIKM54WtGRo4qlAk5VD+VLNPU19J+LBgRkNtCYEXR+MHnG hCNFcukfFudKfoakjC4fHAgOhzK7U/s= X-MC-Unique: 6C0rikraOuipj08i-2Zilw-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, armbru@redhat.com Subject: [PATCH 1/2] hmp: Implement qom-get HMP command Date: Wed, 20 May 2020 16:11:07 +0100 Message-Id: <20200520151108.160598-2-dgilbert@redhat.com> In-Reply-To: <20200520151108.160598-1-dgilbert@redhat.com> References: <20200520151108.160598-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=205.139.110.61; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/20 02:22:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, T_HK_NAME_DR=0.01 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com, clg@kaod.org, afaerber@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Dr. David Alan Gilbert" This started off as Andreas F=C3=A4rber's implementation from March 2015, but after feedback from Paolo and Markus it morphed into using the json output which handles structs reasonably. Use with qom-list to find the members of an object. (qemu) qom-get /backend/console[0]/device/vga.rom[0] size 65536 (qemu) qom-get /machine smm "auto" (qemu) qom-get /machine rtc-time { "tm_year": 120, "tm_sec": 51, "tm_hour": 9, "tm_min": 50, "tm_mon": 4, "tm_mday": 20 } (qemu) qom-get /machine frob Error: Property '.frob' not found Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hmp-commands.hx | 14 ++++++++++++++ include/monitor/hmp.h | 1 + qom/qom-hmp-cmds.c | 18 ++++++++++++++++++ tests/qtest/test-hmp.c | 1 + 4 files changed, 34 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 7f0f3974ad..250ddae54d 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1790,6 +1790,20 @@ SRST Print QOM properties of object at location *path* ERST =20 + { + .name =3D "qom-get", + .args_type =3D "path:s,property:s", + .params =3D "path property", + .help =3D "print QOM property", + .cmd =3D hmp_qom_get, + .flags =3D "p", + }, + +SRST +``qom-get`` *path* *property* + Print QOM property *property* of object at location *path* +ERST + { .name =3D "qom-set", .args_type =3D "path:s,property:s,value:s", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index e33ca5a911..c986cfd28b 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -96,6 +96,7 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict); void hmp_info_numa(Monitor *mon, const QDict *qdict); void hmp_info_memory_devices(Monitor *mon, const QDict *qdict); void hmp_qom_list(Monitor *mon, const QDict *qdict); +void hmp_qom_get(Monitor *mon, const QDict *qdict); void hmp_qom_set(Monitor *mon, const QDict *qdict); void hmp_info_qom_tree(Monitor *mon, const QDict *dict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str= ); diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c index cd08233a4c..a8b0a080c7 100644 --- a/qom/qom-hmp-cmds.c +++ b/qom/qom-hmp-cmds.c @@ -12,6 +12,8 @@ #include "qapi/error.h" #include "qapi/qapi-commands-qom.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qstring.h" #include "qom/object.h" =20 void hmp_qom_list(Monitor *mon, const QDict *qdict) @@ -62,6 +64,22 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } =20 +void hmp_qom_get(Monitor *mon, const QDict *qdict) +{ + const char *path =3D qdict_get_str(qdict, "path"); + const char *property =3D qdict_get_str(qdict, "property"); + Error *err =3D NULL; + QObject *obj =3D qmp_qom_get(path, property, &err); + + if (err =3D=3D NULL) { + QString *str =3D qobject_to_json_pretty(obj); + monitor_printf(mon, "%s\n", qstring_get_str(str)); + qobject_unref(str); + } + + hmp_handle_error(mon, err); +} + typedef struct QOMCompositionState { Monitor *mon; int indent; diff --git a/tests/qtest/test-hmp.c b/tests/qtest/test-hmp.c index f8aa5f92c5..b8b1271b9e 100644 --- a/tests/qtest/test-hmp.c +++ b/tests/qtest/test-hmp.c @@ -61,6 +61,7 @@ static const char *hmp_cmds[] =3D { "p $pc + 8", "qom-list /", "qom-set /machine initrd test", + "qom-get /machine initrd", "screendump /dev/null", "sendkey x", "singlestep on", --=20 2.26.2 From nobody Sun Feb 8 09:37:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589987584; cv=none; d=zohomail.com; s=zohoarc; b=K6Up00C7lbi0xt0QWHCUxBozXoaM9OyBMMkaTfOVDEERD8FU1HQ6NGghiMTxm2X5SxEnOO8COJFuZXhLFgy4X2SsiskyxQk92h5pwiQxXbNvLOLvzDHK20AFyj0RhxTWF38kD+EpWEYgY6jRZPoDfMZVvmfYRHRhsqZDrSM6Utw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589987584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J5fJyh2HhKoNPQVu+TCSyESaN/JTCbbZTvUVBwjtNAM=; b=DmL0yTrxx0Y4kSSSYLGLJT9IDDs4tOH+2hzGI6N5eryqs4U+Z0rCmiDbXeJFAbYtUja5GoNCN6aZYuDVBtR2EZnfjNUTNTRVJZC3nHMXebXjOo2Q34u+xYKc04IsyMAPRzR9pywWu4tlQD1MwlL/PZj8zosyBlYN4aMVZ/NbVZE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589987584294569.9245885790697; Wed, 20 May 2020 08:13:04 -0700 (PDT) Received: from localhost ([::1]:57674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jbQP1-0001bu-02 for importer@patchew.org; Wed, 20 May 2020 11:13:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbQNM-0007fF-Su for qemu-devel@nongnu.org; Wed, 20 May 2020 11:11:20 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:47153 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jbQNL-0000OF-68 for qemu-devel@nongnu.org; Wed, 20 May 2020 11:11:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-411-6PWOuDTJNYyWAxrO-T6muQ-1; Wed, 20 May 2020 11:11:16 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id E62991005512; Wed, 20 May 2020 15:11:14 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-114-169.ams2.redhat.com [10.36.114.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7F636F93C; Wed, 20 May 2020 15:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589987478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J5fJyh2HhKoNPQVu+TCSyESaN/JTCbbZTvUVBwjtNAM=; b=TAlXPdYc1MTr5dfcm+MqdKGhaMrPy/GSVuI6x2sj2AgYCLxDTKQBQdBqIcU8HaPhSN5PnH iLaBWx943s9bz3OXayw/+pe9DynJ+JudPx3z0+ZFa7tTa87u03oBMTonNbmUeU+g11foCx 6Scps0iVgBRreHe7cwJ4UXEuj6ubqNw= X-MC-Unique: 6PWOuDTJNYyWAxrO-T6muQ-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, armbru@redhat.com Subject: [PATCH 2/2] hmp: Simplify qom_set Date: Wed, 20 May 2020 16:11:08 +0100 Message-Id: <20200520151108.160598-3-dgilbert@redhat.com> In-Reply-To: <20200520151108.160598-1-dgilbert@redhat.com> References: <20200520151108.160598-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=207.211.31.120; envelope-from=dgilbert@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/20 01:34:51 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, T_HK_NAME_DR=0.01 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com, clg@kaod.org, afaerber@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Simplify qom_set by making it use qmp_qom_set and the JSON parser. Note that qom-set likes JSON strings quoted with ' not ", e.g.: (qemu) qom-get /machine smm "auto" (qemu) qom-set /machine smm 'auto' Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- qom/qom-hmp-cmds.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c index a8b0a080c7..f704b6949a 100644 --- a/qom/qom-hmp-cmds.c +++ b/qom/qom-hmp-cmds.c @@ -48,19 +48,13 @@ void hmp_qom_set(Monitor *mon, const QDict *qdict) const char *property =3D qdict_get_str(qdict, "property"); const char *value =3D qdict_get_str(qdict, "value"); Error *err =3D NULL; - bool ambiguous =3D false; - Object *obj; + QObject *obj; =20 - obj =3D object_resolve_path(path, &ambiguous); - if (obj =3D=3D NULL) { - error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND, - "Device '%s' not found", path); - } else { - if (ambiguous) { - monitor_printf(mon, "Warning: Path '%s' is ambiguous\n", path); - } - object_property_parse(obj, value, property, &err); + obj =3D qobject_from_json(value, &err); + if (err =3D=3D NULL) { + qmp_qom_set(path, property, obj, &err); } + hmp_handle_error(mon, err); } =20 --=20 2.26.2