From nobody Sun Feb 8 08:04:04 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=1591775574; cv=none; d=zohomail.com; s=zohoarc; b=VgvpsLM8RfUPAc9IBf4EFvmxcV4YCBpZCbVQG6hIU0fBXh59hMcfrZiKBPhKSoXhbmlTYdqPr5SgG7piJyFpvpzSAmyBezFiJksJekSBA4n1p1GQaVFHDOGemkbWKxT7TpuuRhOYhuE/b3mt3qOE6Dq0Hc6SxvbJoTY1Y4o311o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591775574; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=aIpvvfVXtw6BNfgMW0q0tbLusYuPMD21M3SPYqWBJ/A=; b=eAUr7rLCqQw+5yOoNENeeVqQqxac34i89vNtMRQt3fNkc+wQMpLWbjvTQdl+AJWfdh4G5mIkWa5VAVaNEFvk37EVNpPpcdYfB7my2sv5dD4oyg8cKID8pZuKM2+O1hKLB97fpLTixh3q6sK2k2P99JhvoVsfsWSK4EHAhkpUnB0= 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 159177557423580.07278704333169; Wed, 10 Jun 2020 00:52:54 -0700 (PDT) Received: from localhost ([::1]:33918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jivXZ-0000nD-3W for importer@patchew.org; Wed, 10 Jun 2020 03:52:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jivWn-0008LH-BB for qemu-devel@nongnu.org; Wed, 10 Jun 2020 03:52:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:26568 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 1jivWm-00054E-FM for qemu-devel@nongnu.org; Wed, 10 Jun 2020 03:52:05 -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-187-SANqEYvmMKOVcQCDKt0oiw-1; Wed, 10 Jun 2020 03:51:59 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C629083DA41 for ; Wed, 10 Jun 2020 07:51:58 +0000 (UTC) Received: from t480s.redhat.com (ovpn-114-42.ams2.redhat.com [10.36.114.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32ED66111F; Wed, 10 Jun 2020 07:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591775523; 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; bh=aIpvvfVXtw6BNfgMW0q0tbLusYuPMD21M3SPYqWBJ/A=; b=Z5oe4sL9hBDLoWtLNe+WhXDv9ea+QHerGsY1LYpr9RoJ6q2oBbZKFI/mmQFCMPqLZvbtJV hzJsvVMtjNLPCcDrgd0Kn6RCIlrFaycz8QZho+URHDp62snUstocirWtUNPSIiAEXI0Agg c75RftHfk+tzpBZjx7cgPnLNM8MuubE= X-MC-Unique: SANqEYvmMKOVcQCDKt0oiw-1 From: David Hildenbrand To: qemu-devel@nongnu.org Subject: [PATCH v2] hmp: Make json format optional for qom-set Date: Wed, 10 Jun 2020 09:51:53 +0200 Message-Id: <20200610075153.33892-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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=207.211.31.120; envelope-from=david@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/09 21:17:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , David Hildenbrand , Markus Armbruster , "Dr . David Alan Gilbert" , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Commit 7d2ef6dcc1cf ("hmp: Simplify qom-set") switched to the json parser, making it possible to specify complex types. However, with this change it is no longer possible to specify proper sizes (e.g., 2G, 128M), turning the interface harder to use for properties that consume sizes. Let's switch back to the previous handling and allow to specify passing json via the "-j" parameter. Cc: Philippe Mathieu-Daud=C3=A9 Cc: Markus Armbruster Cc: Dr. David Alan Gilbert Cc: Paolo Bonzini Cc: "Daniel P. Berrang=C3=A9" Cc: Eduardo Habkost Signed-off-by: David Hildenbrand Reviewed-by: Dr. David Alan Gilbert --- v1 - v2: - keep the "value:S" as correctly noted by Paolo :) --- hmp-commands.hx | 7 ++++--- qom/qom-hmp-cmds.c | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 28256209b5..5d12fbeebe 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1806,9 +1806,10 @@ ERST =20 { .name =3D "qom-set", - .args_type =3D "path:s,property:s,value:S", - .params =3D "path property value", - .help =3D "set QOM property", + .args_type =3D "json:-j,path:s,property:s,value:S", + .params =3D "[-j] path property value", + .help =3D "set QOM property.\n\t\t\t" + "-j: the property is specified in json format.", .cmd =3D hmp_qom_set, .flags =3D "p", }, diff --git a/qom/qom-hmp-cmds.c b/qom/qom-hmp-cmds.c index f704b6949a..a794e62f0b 100644 --- a/qom/qom-hmp-cmds.c +++ b/qom/qom-hmp-cmds.c @@ -44,15 +44,27 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict) =20 void hmp_qom_set(Monitor *mon, const QDict *qdict) { + const bool json =3D qdict_get_try_bool(qdict, "json", false); const char *path =3D qdict_get_str(qdict, "path"); const char *property =3D qdict_get_str(qdict, "property"); const char *value =3D qdict_get_str(qdict, "value"); Error *err =3D NULL; - QObject *obj; =20 - obj =3D qobject_from_json(value, &err); - if (err =3D=3D NULL) { - qmp_qom_set(path, property, obj, &err); + if (!json) { + Object *obj =3D object_resolve_path(path, NULL); + + if (!obj) { + error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", path); + } else { + object_property_parse(obj, value, property, &err); + } + } else { + QObject *obj =3D qobject_from_json(value, &err); + + if (!err) { + qmp_qom_set(path, property, obj, &err); + } } =20 hmp_handle_error(mon, err); --=20 2.26.2