From nobody Tue Oct 28 04:11:07 2025 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515016308204318.1893491620474; Wed, 3 Jan 2018 13:51:48 -0800 (PST) Received: from localhost ([::1]:38411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWqws-00026c-EB for importer@patchew.org; Wed, 03 Jan 2018 16:51:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWqup-0000gl-6u for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWqun-0003oc-R8 for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:39 -0500 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:46729) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWqun-0003oH-Ls for qemu-devel@nongnu.org; Wed, 03 Jan 2018 16:49:37 -0500 Received: by mail-qk0-x242.google.com with SMTP id b132so3325037qkc.13 for ; Wed, 03 Jan 2018 13:49:37 -0800 (PST) Received: from x1.lan ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id l80sm1237566qki.96.2018.01.03.13.49.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 13:49:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NfMG68vXxpxUyyWS6o5oWMAME+jPMdrNzSUeuMGlZzc=; b=iPeCv2G78Hy7ThVwbmFOuphV6PBCyxC5LtRY1YvZMAWHo+ghEjGRW8MARJud4p/ZGY blp8NSDYCNzTxjGA8iFXq1q++SOzoZN9nvnOQvpH1hE5eytYRaPggsTXCITdhd35MLO7 bwrwNWzSWFp/EvXJoRsiDBTcDJJGKCCyA6sxBF3C74sTU6HBLt21sq0sO50L8FrLKrE5 2DrcQArxbK/izXVmBG+Zc4lcSyfcFpcSTRJfZw9oygRL7LKjwJN0MGy8Df9MpiWnqgs5 o2Vn4rOsngQUT8ZeDZtDFy54hObalQTYuJsVlOBpKWdEhifhSlNxkKWL26gLV8EvfQay UzDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=NfMG68vXxpxUyyWS6o5oWMAME+jPMdrNzSUeuMGlZzc=; b=alGlLkK5QBuszVaXa/h7lXicwSQRUIrX7k0uxDerRYlZtnUjfeZJpvFpNELAuxDSxG Y08ri1UGMPSIP3xPCwsXCreJQMe2jJGS7yb2xSgzjs6liT/PAun1M78bvZzRllizXiHF lD2ZSEuF0RzpTDRvFtAUjiu9IYt4PLstE2OFm96PNoGibZc+Ou2nsuPIhkebfvKgbXXT p4cfBsdZKnbK46g92687ILKQTMe0lxFjR3b6KGHSkSu/ppz3aOry4w1a5jq0hhrsTiAM Dwk/k5MrWu3wRo+ZJGG+6Ss8G+hipTLEfBMAlYsbJFK0Pt5/rKhJS2pBXmY8FjLe+ah1 SU/Q== X-Gm-Message-State: AKGB3mIKCjdlyGX2cJ/NqhRbL++ZlIE/uY1Nu2uvENl7yBQqproFkk1a Ugq7oHr6AQxx/SaotuVb2Fw= X-Google-Smtp-Source: ACJfBourNIpXlyc7+Rc5FliqZq6Eu1l6f9xRaSS3Yj5VWgrAZjy9X2cFpUltGk/Q5wF/6/v+/jmDLw== X-Received: by 10.55.99.75 with SMTP id x72mr3672467qkb.258.1515016177034; Wed, 03 Jan 2018 13:49:37 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , Peter Maydell , Eric Blake , Paolo Bonzini , Kevin Wolf , Eduardo Habkost , "Daniel P . Berrange" , Stefan Hajnoczi Date: Wed, 3 Jan 2018 18:49:22 -0300 Message-Id: <20180103214925.16677-2-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180103214925.16677-1-f4bug@amsat.org> References: <20180103214925.16677-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH v2 1/4] sdbus: add a QMP command to access a SDBus 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: "Edgar E . Iglesias" , Thomas Huth , qemu-devel@nongnu.org, Markus Armbruster , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Use Base64 to serialize the binary blobs in JSON. So far at most 512 bytes will be transfered, which result in a 684 bytes payload. Since this command is intented for qtesting, it is acceptable. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi --- qapi-schema.json | 41 +++++++++++++++++++++++++++++++++ hw/sd/sdbus-qmp.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ stubs/qmp_sdbus.c | 12 ++++++++++ hw/sd/Makefile.objs | 2 +- stubs/Makefile.objs | 1 + 5 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 hw/sd/sdbus-qmp.c create mode 100644 stubs/qmp_sdbus.c diff --git a/qapi-schema.json b/qapi-schema.json index 18457954a8..be26e8cd34 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3200,3 +3200,44 @@ # Since: 2.11 ## { 'command': 'watchdog-set-action', 'data' : {'action': 'WatchdogAction'} } + +## +# @SDBusCommandResponse: +# +# SD Bus command response. +# +# @base64: the command response encoded as a Base64 string, if any (option= al) +# +# Since: 2.11 +## +{ 'struct': 'SDBusCommandResponse', 'data': {'*base64': 'str'} } + +## +# @x-debug-sdbus-command: +# +# Execute a command on a SD Bus return the response (if any). +# +# @qom-path: the SD Bus path +# @command: the SD protocol command to execute in the bus +# @arg: a 64-bit command argument (optional) +# @crc: the command/argument CRC (optional) +# +# Returns: the response of the command encoded as a Base64 string +# +# Since: 2.11 +# +# -> { "execute": "x-debug-sdbus-command", +# "arguments": { "qom-path": "/machine/unattached/device[32]/sd.0", +# "command": 0x01 +# } +# } +# <- { "return": {'base64': 'A=3D'} } +# +## +{ 'command': 'x-debug-sdbus-command', + 'data': { 'qom-path': 'str', + 'command': 'uint8', + '*arg': 'uint64', + '*crc': 'uint16' }, + 'returns': 'SDBusCommandResponse' +} diff --git a/hw/sd/sdbus-qmp.c b/hw/sd/sdbus-qmp.c new file mode 100644 index 0000000000..8c4b6f2aee --- /dev/null +++ b/hw/sd/sdbus-qmp.c @@ -0,0 +1,65 @@ +/* + * SD card bus QMP debugging interface (for QTesting). + * + * Copyright (c) 2017 ? + * + * Author: + * Philippe Mathieu-Daud=C3=A9 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ +#include "qemu/osdep.h" +#include "hw/sd/sd.h" +#include "qmp-commands.h" + +SDBusCommandResponse *qmp_x_debug_sdbus_command(const char *qom_path, + uint8_t command, + bool has_arg, uint64_t arg, + bool has_crc, uint16_t crc, + Error **errp) +{ + uint8_t response[16 + 1]; + SDBusCommandResponse *res; + bool ambiguous =3D false; + Object *obj; + SDBus *sdbus; + int sz; + + obj =3D object_resolve_path(qom_path, &ambiguous); + if (obj =3D=3D NULL) { + if (ambiguous) { + error_setg(errp, "Path '%s' is ambiguous", qom_path); + } else { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", qom_path); + } + return NULL; + } + sdbus =3D (SDBus *)object_dynamic_cast(obj, TYPE_SD_BUS); + if (sdbus =3D=3D NULL) { + error_set(errp, ERROR_CLASS_GENERIC_ERROR, + "Device '%s' not a sd-bus", qom_path); + return NULL; + } + + res =3D g_new0(SDBusCommandResponse, 1); + sz =3D sdbus_do_command(sdbus, + &(SDRequest){ command, arg, has_crc ? crc : -1 }, + response); + if (sz > 0) { + res->has_base64 =3D true; + res->base64 =3D g_base64_encode(response, sz); + } + + return res; +} diff --git a/stubs/qmp_sdbus.c b/stubs/qmp_sdbus.c new file mode 100644 index 0000000000..d9bd75ec71 --- /dev/null +++ b/stubs/qmp_sdbus.c @@ -0,0 +1,12 @@ +#include "qemu/osdep.h" +#include "qmp-commands.h" +#include "hw/sd/sd.h" + +SDBusCommandResponse *qmp_x_debug_sdbus_command(const char *qom_path, + uint8_t command, + bool has_arg, uint64_t arg, + bool has_crc, uint16_t crc, + Error **errp) +{ + return NULL; +} diff --git a/hw/sd/Makefile.objs b/hw/sd/Makefile.objs index c2b7664264..3a70477bba 100644 --- a/hw/sd/Makefile.objs +++ b/hw/sd/Makefile.objs @@ -1,6 +1,6 @@ common-obj-$(CONFIG_PL181) +=3D pl181.o common-obj-$(CONFIG_SSI_SD) +=3D ssi-sd.o -common-obj-$(CONFIG_SD) +=3D sd.o core.o +common-obj-$(CONFIG_SD) +=3D sd.o core.o sdbus-qmp.o common-obj-$(CONFIG_SDHCI) +=3D sdhci.o =20 obj-$(CONFIG_MILKYMIST) +=3D milkymist-memcard.o diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 8cfe34328a..a46cb3b992 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -35,6 +35,7 @@ stub-obj-y +=3D vm-stop.o stub-obj-y +=3D vmstate.o stub-obj-$(CONFIG_WIN32) +=3D fd-register.o stub-obj-y +=3D qmp_pc_dimm.o +stub-obj-y +=3D qmp_sdbus.o stub-obj-y +=3D target-monitor-defs.o stub-obj-y +=3D target-get-monitor-def.o stub-obj-y +=3D pc_madt_cpu_entry.o --=20 2.15.1