From patchwork Mon Jun 10 17:58:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 803024 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp2066703wro; Mon, 10 Jun 2024 10:59:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUWBhIVDJ92I/suygj+Zd134aqfY9aLqlBvxelaqYmq6xd2kVUa+OHh0pndHJvg8OJCEnCe34v9KXl9ZIBRmtnX X-Google-Smtp-Source: AGHT+IEjZ6/VXcx5hfEZ4yoR0d5T++upr0w5ZzNjybd7pFkwLn5bU65gS0ZXyEA2cPE3fY8unAkA X-Received: by 2002:a05:6808:f0e:b0:3d2:1cfa:94d3 with SMTP id 5614622812f47-3d21cfa9875mr8121924b6e.47.1718042394044; Mon, 10 Jun 2024 10:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718042394; cv=none; d=google.com; s=arc-20160816; b=Z80bSN97oOA0r8vdk0ZhL0AdzWMYqEcy4JOmpSAZr5Zp3PmxvDh42BemeN647cY5qQ HvU+n4Gsx+GQSehB5LIYTpoYGv38vapFY1rp4p0EbMVMBHITO2URMIGpiDo/d0AbeySa KeifvVLAwIaogk++lyw1We0YKmLzpmaA+lNsaNUD7147cEF19t26EbpY0d6O2UEjkmrJ QhgotVR8Q4rfwIn6oPsV6s1KD21S/WZ/eroJVZxTay5CwMrg4Pkr7h1DlyRJVFlgkfWj t4poMng87Uuu1Jupx8yPkB/21VysI3//hAT6Bnk2x2vbTnX/8dFy8JTvaPPAsqUvob2A Xnrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xJyIGRy7KVzvmUcZdC1VviPw8AK09jMHFagaK3CiBV0=; fh=vy8rMnyalXYwC8r+6c5Ytj8Gcby8oePbkyeEOJGoHLo=; b=0Jvge8v1wrEKEhFP4cwQjxNL+apXbPpYdge+avvmN0g4mFFmifaU98neXOtIvm2BX+ 2/A/mo2qt+duTep5EkbH9PkabGAADyXrOiXnoQhkFCYHpC0Sk+Lx7MavYeEluVSQ98a2 tMdf+MqKMpvzhR/HbN3hggLgb6xU/AgmVSDp6mPqZOHoUJlBxvbxg9a9cNvPJTXU0hMD FcDZIx8qN/EeHk3i95WVNOwPK0U1dNzQ0ZOEZ1c34cA8Irl60Ksa7mtRMF6dv237NUhk 7JSXmQJSZkdRUL2RX7g7G1RzfrvFzuTrJ881bqXGNJ8weL3mdd6fKV35yLwAakQcEf5a AOnA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EPCNZ/3v"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44038b3ac66si114572131cf.454.2024.06.10.10.59.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jun 2024 10:59:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EPCNZ/3v"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGjIP-0005HI-SN; Mon, 10 Jun 2024 13:59:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGjIO-0005Gx-T7 for qemu-devel@nongnu.org; Mon, 10 Jun 2024 13:59:04 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGjIN-0001aI-7h for qemu-devel@nongnu.org; Mon, 10 Jun 2024 13:59:04 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-421a1b834acso11227295e9.3 for ; Mon, 10 Jun 2024 10:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718042341; x=1718647141; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xJyIGRy7KVzvmUcZdC1VviPw8AK09jMHFagaK3CiBV0=; b=EPCNZ/3v1aqrGlIwloX5WpmJDBS7PzTc2o6hx1KfFBP9z4Lc8D4I/NnHqstNzNPvlD EqG8N/Clj90o0rtWJKNoNDvarC3oiyU5SgAXd1lfE6+FNsPcINg9QcOA7AsKPKqaYg6t Pjd+KJDew3i68DyoDk+2bHc0jOWxl7GIcVziPoqijtooFJEXIiOE65S8NBZJWWCS5dv0 ZQhHYUK0qjKJ8HLRN8dWacd2Qn48NI+uFHOHHRrPbZNtFDnI4Ld/B3cUor+mcmoLVrRQ mZtCoV98LQitbbw2JvNwa2fyV7sHqRSUJhoojYzNlXYYqvSJEOYJntuST7CF7ZW2ePbM kQDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718042341; x=1718647141; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xJyIGRy7KVzvmUcZdC1VviPw8AK09jMHFagaK3CiBV0=; b=JZUZUV8K5U+OsJavxow+31pAysNB9g6TWmOw8MPQuf/Tzne214mieFRQKSqbzGzsII wpEVQTfdCq5g2rhvehpRRPYp76G2L19Ek51wmC535EdVNKVYRoHl3y5HW7+2S25Bb50z T85mXx1ScX2QcY706g64PcvBvFaZfRl/iVVL8zogH7Jj42cpbYHD97PWr2qvDcjVklG8 eFKYdpCVhJ9K4Qim7g3l5vp0PCmROd3ha9w93dA9a9qr77KDg9aWT70F7EH5oiL0AM2c FWvw6wc+vhU30chajAaana9kX5DPCq46qdT/Mp34PTEbL5APHzVvI7exGwTlA6btmVe3 UeaA== X-Forwarded-Encrypted: i=1; AJvYcCV1YpZF9F0dOEg8DIvzmn/WBmKA9qaRquIXu9vSkbGv3XRd22/cJ44fqHy8Xl4/mttv9uxjo4BmS1rOWx527uWRZtLnpAI= X-Gm-Message-State: AOJu0YwZ8vwQnuFFsxpHsML7zlOjDQyOMarulfdDanzkBmPc2pVZ4YRl YeYOaxpM0XqNVZki+yeLJ2uSmzvKzvRsEcio9lOYgYiC4rKnu5YHUE6AjRqMFmsRbDh6UImWVBn k X-Received: by 2002:a05:600c:4f93:b0:421:f441:e7e7 with SMTP id 5b1f17b1804b1-421f441eae3mr19894315e9.19.1718042341622; Mon, 10 Jun 2024 10:59:01 -0700 (PDT) Received: from m1x-phil.lan ([176.176.129.242]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4217ab6199bsm89965205e9.13.2024.06.10.10.58.59 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jun 2024 10:59:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , =?utf-8?q?Daniel_P_=2E_Berrang?= =?utf-8?q?=C3=A9?= , "Dr. David Alan Gilbert" , qemu-devel@nongnu.org Cc: Yanan Wang , Richard Henderson , Eric Farman , Thomas Huth , Eric Blake , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Christian Borntraeger , qemu-s390x@nongnu.org, Eduardo Habkost , Ilya Leoshkevich , Halil Pasic , Marcel Apfelbaum , David Hildenbrand , Paolo Bonzini Subject: [PATCH 1/3] hw/s390x: Declare target specific monitor commands in hmp-target.h Date: Mon, 10 Jun 2024 19:58:50 +0200 Message-ID: <20240610175852.21215-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240610175852.21215-1-philmd@linaro.org> References: <20240610175852.21215-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org "monitor/hmp-target.h" is meant to hold target-specific commands. Move s390x specific commands there, slightly simplifying hmp-target.c. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/s390x/storage-attributes.h | 4 ---- include/hw/s390x/storage-keys.h | 4 ---- include/monitor/hmp-target.h | 5 +++++ hw/s390x/s390-skeys.c | 2 ++ hw/s390x/s390-stattrib.c | 2 ++ monitor/hmp-target.c | 5 ----- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/hw/s390x/storage-attributes.h b/include/hw/s390x/storage-attributes.h index 8921a04d51..4916c75936 100644 --- a/include/hw/s390x/storage-attributes.h +++ b/include/hw/s390x/storage-attributes.h @@ -13,7 +13,6 @@ #define S390_STORAGE_ATTRIBUTES_H #include "hw/qdev-core.h" -#include "monitor/monitor.h" #include "qom/object.h" #define TYPE_S390_STATTRIB "s390-storage_attributes" @@ -73,7 +72,4 @@ static inline Object *kvm_s390_stattrib_create(void) } #endif -void hmp_info_cmma(Monitor *mon, const QDict *qdict); -void hmp_migrationmode(Monitor *mon, const QDict *qdict); - #endif /* S390_STORAGE_ATTRIBUTES_H */ diff --git a/include/hw/s390x/storage-keys.h b/include/hw/s390x/storage-keys.h index aa2ec2aae5..1d9b7ead44 100644 --- a/include/hw/s390x/storage-keys.h +++ b/include/hw/s390x/storage-keys.h @@ -13,7 +13,6 @@ #define S390_STORAGE_KEYS_H #include "hw/qdev-core.h" -#include "monitor/monitor.h" #include "qom/object.h" #define TYPE_S390_SKEYS "s390-skeys" @@ -114,7 +113,4 @@ void s390_skeys_init(void); S390SKeysState *s390_get_skeys_device(void); -void hmp_dump_skeys(Monitor *mon, const QDict *qdict); -void hmp_info_skeys(Monitor *mon, const QDict *qdict); - #endif /* S390_STORAGE_KEYS_H */ diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h index b679aaebbf..024cff0052 100644 --- a/include/monitor/hmp-target.h +++ b/include/monitor/hmp-target.h @@ -61,4 +61,9 @@ void hmp_gva2gpa(Monitor *mon, const QDict *qdict); void hmp_gpa2hva(Monitor *mon, const QDict *qdict); void hmp_gpa2hpa(Monitor *mon, const QDict *qdict); +void hmp_dump_skeys(Monitor *mon, const QDict *qdict); +void hmp_info_skeys(Monitor *mon, const QDict *qdict); +void hmp_info_cmma(Monitor *mon, const QDict *qdict); +void hmp_migrationmode(Monitor *mon, const QDict *qdict); + #endif /* MONITOR_HMP_TARGET_H */ diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index 5c535d483e..7b2ccb94a5 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -23,6 +23,8 @@ #include "sysemu/kvm.h" #include "migration/qemu-file-types.h" #include "migration/register.h" +#include "monitor/hmp-target.h" +#include "monitor/monitor.h" #define S390_SKEYS_BUFFER_SIZE (128 * KiB) /* Room for 128k storage keys */ #define S390_SKEYS_SAVE_FLAG_EOS 0x01 diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index c4259b5327..9b4b8d8d0c 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -19,6 +19,8 @@ #include "exec/ram_addr.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" +#include "monitor/hmp-target.h" +#include "monitor/monitor.h" #include "cpu.h" /* 512KiB cover 2GB of guest memory */ diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c index 1eb72ac1bf..0466474354 100644 --- a/monitor/hmp-target.c +++ b/monitor/hmp-target.c @@ -36,11 +36,6 @@ #include "qapi/error.h" #include "qemu/cutils.h" -#if defined(TARGET_S390X) -#include "hw/s390x/storage-keys.h" -#include "hw/s390x/storage-attributes.h" -#endif - /* Make devices configuration available for use in hmp-commands*.hx templates */ #include CONFIG_DEVICES From patchwork Mon Jun 10 17:58:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 803025 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp2066701wro; Mon, 10 Jun 2024 10:59:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVR8kv5BHMg49p5QKcta7B/moGHufkX/UF9WOUoD5gfNsypbU8gqufVpuBJpOpuPelgUXZKuWTCYjoEddsPs4Sm X-Google-Smtp-Source: AGHT+IGfPj0UpT9N46MePEIBPWqVRo+xri1bBiD1PTZqSGcYHGtMwmaOVPHb1bam+7mXfM86GYDw X-Received: by 2002:a05:620a:40d5:b0:795:5018:b1af with SMTP id af79cd13be357-7955018b3a2mr972217985a.69.1718042394053; Mon, 10 Jun 2024 10:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718042394; cv=none; d=google.com; s=arc-20160816; b=UQzUiDmuDlvPul7oTXS+1/d2itXdPoTp+D97dAXtFznLLclU+nvDQ7GqB5FwmJQH7a kV58vyRogmXfUEgjF70RI1hShy7j9Jws8jvEiLvEJOIvhNRP5xmQYc3o4vuL/7fj57/+ x1UUH2U8Xrv1Jkr6ZCb9zjERHQ/vUab1MFaytV5GqpjoFwIdZFUDVuzzysD6a4UBwBud uosCAU5ay2H4t/a8zb4K+m70vdVjhYWEL0zlL0nin4TUEwT6zlV9u7t53t9x+el2j4xC HDfHU9VzFtQLiqhm4pHtBuzogvmoPnbu++GECd6SZnkU0eJE5f2XyDoaQoeH4quYG0J0 KafA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GNte3Osrk4NBFN17tMmuMGXy/JnFYDWs3NUrv+YBw84=; fh=9TNqMz4BiFdn+yn01fGcPG/Vpc1CKix1hJCfz6CRri0=; b=d4YF9TmVZFkSwmolTxwHh862seRsM4JR5Wmdq1FxCHaj9bfxuX0ht68XoVAjLzCVFb GrpKQs2SD4G6w+OQzlvj+qbwVMUxcRhNq70xEyYKTTPUT6xGNABbNlb5Et7WORbEKgI3 JBePEsuON9g736kFkJUW/kqjR3t+evufOAZVtrN3mIAYdAxnFHRUepqnesUgEekiQDhM kE9awdtwsGPfK3IA1STwSsB7CYHTZZdavob5Ld0gZmB2DaHgnBDW+rFadfd80L7otToX en83a4CHMwGB/FPG7AtDm5hrx+CZsZ4l+/rUKRB8VWCErUMMMQN4a66NQpxsd72ZswQw Z1Rg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=evegldKY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7979c63180asi147834785a.117.2024.06.10.10.59.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jun 2024 10:59:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=evegldKY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGjIX-0005Kd-FA; Mon, 10 Jun 2024 13:59:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGjIV-0005It-Jv for qemu-devel@nongnu.org; Mon, 10 Jun 2024 13:59:11 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGjIT-0001ai-DL for qemu-devel@nongnu.org; Mon, 10 Jun 2024 13:59:11 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4223c77e4b1so1077935e9.2 for ; Mon, 10 Jun 2024 10:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718042348; x=1718647148; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GNte3Osrk4NBFN17tMmuMGXy/JnFYDWs3NUrv+YBw84=; b=evegldKYw4ZvacVCr0aic+N5Il6gMuAIdBpahAIIw4X52ow5k1Ta0Sx0Qv3PNIV0So 5q3WsSueXQ7F591r2yznR5U5p9khuY+B4/W0QWcxxyoT6psIzdrzwzltZotxAVzCI27o 8TuMSmbhw8+uVsOGlJx5AQAWY+87vowYz78+at3Uhpk+GZsDuFRr3fi7GU8xcD0kAlsT 26WWuLNY8GGlV53M5yCnEkD2JHr+aFzRpxiJ/6e3YMXJ3H+LDwNbo6ew8v/4c22IrRYX q/4xZ2UtHyzpvnZnxBuxxipvT5wXDoQF6/GIjQUdddt/i0TzpcBFUq7FqqHMZ3rM1fSn ntAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718042348; x=1718647148; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GNte3Osrk4NBFN17tMmuMGXy/JnFYDWs3NUrv+YBw84=; b=Phuxyfm52wpnvE9MHW1Fgk5fhAX24DbWak1UcHr8R1FPrmvdcaRc6SpASxzjHm0XFW GRqWDyqlX59o6cgIWDYujnj9WClCJgmL8fMhMmhS7mu7EH6glcUxCQABoPVXj+2Q53YT lJ2zglZAEbAArnwUduU6U19UUaZhBMnPFGBoEyOMvGFQBEX8IQhiONTAybN2uwoD2jLH P1ffFqUFCmUXmzoYIQcJQBlc/5OebPSk1NEEdjRJwVGUOVB1NCx9bqfN3V6vQgL82PjU n5lUGUv9h6UT1sn+7xF+8Q6YPzJOY9ZXEs833TCpaR+RlzNASUQJmbaKr5bQRrNm+7zB torQ== X-Forwarded-Encrypted: i=1; AJvYcCVswcNbQg8QQhN+Of1VfiP0a1oZcsQT4AVvvkTTOUY6M1UjWH7FsaB6+t3TVpbDeEsL7yAhWAzBy0jlmp+kT7BUxfs/GsU= X-Gm-Message-State: AOJu0YzEh8XOrrS1pd4I1shJP5feuNU7XU4WonCzTudC5HBJLKeieCZw wGcHb6plOnmcRBXIIG5rQqlPZYESV+eNfP58uUqLPB3DxBvvOMqV6Ols3XtqmqY= X-Received: by 2002:a05:600c:1907:b0:419:f241:633b with SMTP id 5b1f17b1804b1-421649ea685mr92311205e9.8.1718042347748; Mon, 10 Jun 2024 10:59:07 -0700 (PDT) Received: from m1x-phil.lan ([176.176.129.242]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4224385670fsm1523025e9.16.2024.06.10.10.59.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jun 2024 10:59:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , =?utf-8?q?Daniel_P_=2E_Berrang?= =?utf-8?q?=C3=A9?= , "Dr. David Alan Gilbert" , qemu-devel@nongnu.org Cc: Yanan Wang , Richard Henderson , Eric Farman , Thomas Huth , Eric Blake , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Christian Borntraeger , qemu-s390x@nongnu.org, Eduardo Habkost , Ilya Leoshkevich , Halil Pasic , Marcel Apfelbaum , David Hildenbrand , Paolo Bonzini Subject: [RFC PATCH 2/3] monitor: Allow passing HMP arguments to QMP HumanReadableText API Date: Mon, 10 Jun 2024 19:58:51 +0200 Message-ID: <20240610175852.21215-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240610175852.21215-1-philmd@linaro.org> References: <20240610175852.21215-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Allow HMP commands implemented using the HumanReadableText API (via the HMPCommand::cmd_info_hrt handler) to pass arguments to the QMP equivalent command. The arguments are serialized as a JSON dictionary. Signed-off-by: Philippe Mathieu-Daudé --- docs/devel/writing-monitor-commands.rst | 15 ++++++++++++++- qapi/machine.json | 24 ++++++++++++++++++++++++ include/monitor/monitor.h | 3 ++- monitor/monitor-internal.h | 2 +- accel/tcg/monitor.c | 4 ++-- hw/core/loader.c | 2 +- hw/core/machine-qmp-cmds.c | 9 +++++---- hw/usb/bus.c | 2 +- monitor/hmp-target.c | 3 ++- monitor/hmp.c | 11 +++++++---- 10 files changed, 59 insertions(+), 16 deletions(-) diff --git a/docs/devel/writing-monitor-commands.rst b/docs/devel/writing-monitor-commands.rst index 930da5cd06..843458e52c 100644 --- a/docs/devel/writing-monitor-commands.rst +++ b/docs/devel/writing-monitor-commands.rst @@ -561,6 +561,7 @@ returns a ``HumanReadableText``:: # Since: 6.2 ## { 'command': 'x-query-roms', + 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } @@ -578,7 +579,7 @@ Implementing the QMP command The QMP implementation will typically involve creating a ``GString`` object and printing formatted data into it, like this:: - HumanReadableText *qmp_x_query_roms(Error **errp) + HumanReadableText *qmp_x_query_roms(const char *json_args, Error **errp) { g_autoptr(GString) buf = g_string_new(""); Rom *rom; @@ -596,6 +597,18 @@ object and printing formatted data into it, like this:: The actual implementation emits more information. You can find it in hw/core/loader.c. +For QMP command taking (optional) parameters, these parameters are +serialized as a JSON dictionary, and can be retrieved using the QDict +API. If the previous ``x-query-roms`` command were taking a "index" +argument, it could be retrieved as:: + + HumanReadableText *qmp_x_query_roms(const char *json_args, Error **errp) + { + g_autoptr(GString) buf = g_string_new(""); + QDict *qdict = qobject_to(QDict, qobject_from_json(json_args, &error_abort)); + uint64_t index = qdict_get_int(qdict, "index"); + ... + } Implementing the HMP command ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/qapi/machine.json b/qapi/machine.json index 1283d14493..6da72f2585 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1697,6 +1697,8 @@ # # Query interrupt statistics # +# @json-args: HMP arguments encoded as JSON string (unused for this command). +# # Features: # # @unstable: This command is meant for debugging. @@ -1706,6 +1708,7 @@ # Since: 6.2 ## { 'command': 'x-query-irq', + 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } @@ -1714,6 +1717,8 @@ # # Query TCG compiler statistics # +# @json-args: HMP arguments encoded as JSON string (unused for this command). +# # Features: # # @unstable: This command is meant for debugging. @@ -1723,6 +1728,7 @@ # Since: 6.2 ## { 'command': 'x-query-jit', + 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'if': 'CONFIG_TCG', 'features': [ 'unstable' ] } @@ -1732,6 +1738,8 @@ # # Query NUMA topology information # +# @json-args: HMP arguments encoded as JSON string (unused for this command). +# # Features: # # @unstable: This command is meant for debugging. @@ -1741,6 +1749,7 @@ # Since: 6.2 ## { 'command': 'x-query-numa', + 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } @@ -1749,6 +1758,8 @@ # # Query TCG opcode counters # +# @json-args: HMP arguments encoded as JSON string (unused for this command). +# # Features: # # @unstable: This command is meant for debugging. @@ -1758,6 +1769,7 @@ # Since: 6.2 ## { 'command': 'x-query-opcount', + 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'if': 'CONFIG_TCG', 'features': [ 'unstable' ] } @@ -1767,6 +1779,8 @@ # # Query system ramblock information # +# @json-args: HMP arguments encoded as JSON string (unused for this command). +# # Features: # # @unstable: This command is meant for debugging. @@ -1776,6 +1790,7 @@ # Since: 6.2 ## { 'command': 'x-query-ramblock', + 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } @@ -1784,6 +1799,8 @@ # # Query information on the registered ROMS # +# @json-args: HMP arguments encoded as JSON string (unused for this command). +# # Features: # # @unstable: This command is meant for debugging. @@ -1793,6 +1810,7 @@ # Since: 6.2 ## { 'command': 'x-query-roms', + 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } @@ -1801,6 +1819,8 @@ # # Query information on the USB devices # +# @json-args: HMP arguments encoded as JSON string (unused for this command). +# # Features: # # @unstable: This command is meant for debugging. @@ -1810,6 +1830,7 @@ # Since: 6.2 ## { 'command': 'x-query-usb', + 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } @@ -1870,6 +1891,8 @@ # # Query information on interrupt controller devices # +# @json-args: HMP arguments encoded as JSON string (unused for this command). +# # Features: # # @unstable: This command is meant for debugging. @@ -1879,5 +1902,6 @@ # Since: 9.1 ## { 'command': 'x-query-interrupt-controllers', + 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'features': [ 'unstable' ]} diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 965f5d5450..b21c702c12 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -58,7 +58,8 @@ int64_t monitor_fdset_dup_fd_find(int dup_fd); void monitor_register_hmp(const char *name, bool info, void (*cmd)(Monitor *mon, const QDict *qdict)); void monitor_register_hmp_info_hrt(const char *name, - HumanReadableText *(*handler)(Error **errp)); + HumanReadableText *(*handler)(const char *json_args, + Error **errp)); int error_vprintf_unless_qmp(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0); int error_printf_unless_qmp(const char *fmt, ...) G_GNUC_PRINTF(1, 2); diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index 252de85681..b3aa50834b 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -81,7 +81,7 @@ typedef struct HMPCommand { * @cmd_info_hrt to the corresponding QMP handler that returns * the formatted text. */ - HumanReadableText *(*cmd_info_hrt)(Error **errp); + HumanReadableText *(*cmd_info_hrt)(const char *json_args, Error **errp); bool coroutine; /* * @sub_table is a list of 2nd level of commands. If it does not exist, diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c index 093efe9714..517c96eeb7 100644 --- a/accel/tcg/monitor.c +++ b/accel/tcg/monitor.c @@ -199,7 +199,7 @@ static void dump_exec_info(GString *buf) tcg_dump_info(buf); } -HumanReadableText *qmp_x_query_jit(Error **errp) +HumanReadableText *qmp_x_query_jit(const char *json_args, Error **errp) { g_autoptr(GString) buf = g_string_new(""); @@ -220,7 +220,7 @@ static void tcg_dump_op_count(GString *buf) g_string_append_printf(buf, "[TCG profiler not compiled]\n"); } -HumanReadableText *qmp_x_query_opcount(Error **errp) +HumanReadableText *qmp_x_query_opcount(const char *json_args, Error **errp) { g_autoptr(GString) buf = g_string_new(""); diff --git a/hw/core/loader.c b/hw/core/loader.c index 2f8105d7de..e0da5edbb3 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -1679,7 +1679,7 @@ void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t size) return cbdata.rom; } -HumanReadableText *qmp_x_query_roms(Error **errp) +HumanReadableText *qmp_x_query_roms(const char *json_args, Error **errp) { Rom *rom; g_autoptr(GString) buf = g_string_new(""); diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 130217da8f..fc79772df8 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -214,7 +214,7 @@ MemdevList *qmp_query_memdev(Error **errp) return list; } -HumanReadableText *qmp_x_query_numa(Error **errp) +HumanReadableText *qmp_x_query_numa(const char *json_args, Error **errp) { g_autoptr(GString) buf = g_string_new(""); int i, nb_numa_nodes; @@ -311,7 +311,7 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp) return mem_info; } -HumanReadableText *qmp_x_query_ramblock(Error **errp) +HumanReadableText *qmp_x_query_ramblock(const char *json_args, Error **errp) { g_autoptr(GString) buf = ram_block_format(); @@ -351,7 +351,7 @@ static int qmp_x_query_irq_foreach(Object *obj, void *opaque) return 0; } -HumanReadableText *qmp_x_query_irq(Error **errp) +HumanReadableText *qmp_x_query_irq(const char *json_args, Error **errp) { g_autoptr(GString) buf = g_string_new(""); @@ -382,7 +382,8 @@ static int qmp_x_query_intc_foreach(Object *obj, void *opaque) return 0; } -HumanReadableText *qmp_x_query_interrupt_controllers(Error **errp) +HumanReadableText *qmp_x_query_interrupt_controllers(const char *json_args, + Error **errp) { g_autoptr(GString) buf = g_string_new(""); object_child_foreach_recursive(object_get_root(), diff --git a/hw/usb/bus.c b/hw/usb/bus.c index bfab2807d7..daa3f71d47 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -598,7 +598,7 @@ static char *usb_get_fw_dev_path(DeviceState *qdev) return fw_path; } -HumanReadableText *qmp_x_query_usb(Error **errp) +HumanReadableText *qmp_x_query_usb(const char *json_args, Error **errp) { g_autoptr(GString) buf = g_string_new(""); USBBus *bus; diff --git a/monitor/hmp-target.c b/monitor/hmp-target.c index 0466474354..81e53a5767 100644 --- a/monitor/hmp-target.c +++ b/monitor/hmp-target.c @@ -157,7 +157,8 @@ void monitor_register_hmp(const char *name, bool info, } void monitor_register_hmp_info_hrt(const char *name, - HumanReadableText *(*handler)(Error **errp)) + HumanReadableText *(*handler)(const char *json_args, + Error **errp)) { HMPCommand *table = hmp_info_cmds; diff --git a/monitor/hmp.c b/monitor/hmp.c index 69c1b7e98a..7802a31412 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -29,6 +29,7 @@ #include "monitor/hmp.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qnum.h" +#include "qapi/qmp/qjson.h" #include "qemu/config-file.h" #include "qemu/ctype.h" #include "qemu/cutils.h" @@ -1082,11 +1083,13 @@ fail: return NULL; } -static void hmp_info_human_readable_text(Monitor *mon, - HumanReadableText *(*handler)(Error **)) +static void hmp_info_human_readable_text(Monitor *mon, QDict *qdict, + HumanReadableText *(*handler)(const char *, + Error **)) { Error *err = NULL; - g_autoptr(HumanReadableText) info = handler(&err); + g_autoptr(GString) ret_json = qobject_to_json(QOBJECT(qdict)); + g_autoptr(HumanReadableText) info = handler(ret_json->str, &err); if (hmp_handle_error(mon, err)) { return; @@ -1100,7 +1103,7 @@ static void handle_hmp_command_exec(Monitor *mon, QDict *qdict) { if (cmd->cmd_info_hrt) { - hmp_info_human_readable_text(mon, + hmp_info_human_readable_text(mon, qdict, cmd->cmd_info_hrt); } else { cmd->cmd(mon, qdict); From patchwork Mon Jun 10 17:58:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 803026 Delivered-To: patch@linaro.org Received: by 2002:adf:f147:0:b0:35b:5a80:51b4 with SMTP id y7csp2067038wro; Mon, 10 Jun 2024 11:00:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUQ6xP4ZtZZqkWHFh2vj5+wbGOZJZ7JbnQxGr2YXSHbVmXBYerpyGAoWX25WbGqcEp8oAzcIgUsy69sSRYjuz73 X-Google-Smtp-Source: AGHT+IHhiUZkk7/5dbrVbe0RGB++TQcdargwTG0q67de96rCXMPzSk4Pp6pz4CEZ5i2ZvHx2N7jF X-Received: by 2002:a05:6102:292c:b0:48c:470b:69ac with SMTP id ada2fe7eead31-48c470b6aecmr7261764137.30.1718042438685; Mon, 10 Jun 2024 11:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718042438; cv=none; d=google.com; s=arc-20160816; b=A/xFftZW+9qTyEWIMw2UsDDSualvl0/mLoZiCO5h/3hkJz0NRIIaRtF6BmMJ7N/8DR yZHA96u2njvf1PW92tRYTXsI5P4CSjudnrEP7Cvx8tpIO80cdOyg2vbGIFsNqcRepqf3 3+7y9Sptcd+EaqLM96Bu5pbINtt9jgJyXN9R0m+csFqynG1J9ALTLxL2yEw2HewY5h1c vYEtLt2AXAIR2Qnd5gpqhTBNpT0els1k67PL9m1xq+uzxfDkBqB26Hp/lUtRzj0EAZ4i MvK9s6ONAQVc/3MWDxez2dFTgzEgjHzTF05yAn97UJ/QCNUgLn6M9qWH+5AGWNOelrEm wjxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AyIsM5i4zPBNdNF1s0PfQtdMv+Jq8dQQMzodQt/XrZA=; fh=jFYU4X0rkvin9/Mu1nO8Epgl7H7wg/G008zfQh3Qs5E=; b=YoJ5bcCIa5FqcBFDk122ApqGVe3gPiRGsP4kJ/ffsCd0GSdlI0mAWOSHQEJenvtLRf 54XqPkmca0RmITBAdDcIWEowp0hdvde8Ic/SaZHKMdFk3k5xuXqUBjVFbR3HC0T+lx89 lCLbQVv7wFBFGbK7or5e7AyW/m0kPExhwWRPqSKcomxHng8MIT7pPMaGxpZVdsR4+3m+ uh+X0B1e5YdZA4OVrfCAS7z65VQjy2+PaLA+Rv46pEx6sDpkLDWnXcKIFiQnDin0fpb4 I479KmcZuDbrywM5tbbKeZdhdspx2EllnFLDWnBDRFzySEOCsQKkKQI1m1u5ig95Y5aC 5Csg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rQzgkOQI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-48c1a0f6502si2435419137.104.2024.06.10.11.00.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jun 2024 11:00:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rQzgkOQI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGjId-0005Mo-Nb; Mon, 10 Jun 2024 13:59:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGjIb-0005M9-U8 for qemu-devel@nongnu.org; Mon, 10 Jun 2024 13:59:17 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGjIZ-0001bB-RJ for qemu-devel@nongnu.org; Mon, 10 Jun 2024 13:59:17 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-52c4b92c09bso270760e87.1 for ; Mon, 10 Jun 2024 10:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718042354; x=1718647154; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AyIsM5i4zPBNdNF1s0PfQtdMv+Jq8dQQMzodQt/XrZA=; b=rQzgkOQIvhnNWVLlX2LhmmFsUokDfnjBmC0+ZZZI0AKFA/QfVZv+Z0APJI4EtwkSt0 jhcFi4cehtTCz0EuiDbQSdN3726MFKmJMy5Yyk2tqEvkjZBnVXYNPJ/BryYn0JeNrlhd FFRN/wC8WoxaOKhzTsSPF+aecMW0dzIQrlMDJnfZu9spn5YoV8Cm7dlf4Musb4daPTmD h8GvO5QwDbf399LpEAQDTDVTHRL5d6qXiF4o5lci2EW1idhwXpePO2a5Hu4r0o0X55Kr 8ZSeJY0qsAMiQdEPhqbLh09QHdMT5uEbZc74vHAeeKcIk+lGaGOkV0fnzODgk1EVmr0s uDMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718042354; x=1718647154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AyIsM5i4zPBNdNF1s0PfQtdMv+Jq8dQQMzodQt/XrZA=; b=dgTFC0JAWbwheeRAvIrZuNlAA8mo++pQeE2ccbdA5O3YQYMbyRDrWwNTZAcbDrN/tD ZQ8h5/I/yQLDtcMeQY/gSj6s3oGG86rVjFFfdAsTcoMHb81bsI5boSVlg2DhJ1qZ0viu vAGd7onVrvnA5aXSlpCWWqs7AucovwWrCtP5YV1nbW/obdrdnLhPOFHBA0ts4aMFN7au vss7njGmHD8F2JnoEQHlyylXAsbzGQR+RQD8agdFlTAaWx6y0GO15kzh4L6kY7EPV4Vu dv7M+uedm16EMfew6k6wEC1NjOB+AQZ6EgHs4IcaWWLCkFJlLLPZM6NxevrZDVyOAosJ jaiQ== X-Forwarded-Encrypted: i=1; AJvYcCVpXrnHMGBDoTkjRLVLNOdVGQ14TR4IFiz9Zdxa+gbMSUmttdv08Pr49IzXYrUqPrjYiGzJD9sz9Si1rVPksb2mgfRYKIw= X-Gm-Message-State: AOJu0YyCK1EEA0U0SSFvenvrGKB2VTiHjv8URmbzs7vmEUrBT0353Vf4 8NIX0O4lLSUx/cRVgTvdTkAU1amMihQ4t3wrdAlImVtcj/1t+OnueB3BYktQ+x4= X-Received: by 2002:ac2:5e62:0:b0:52c:7f8d:4888 with SMTP id 2adb3069b0e04-52c7f8d490cmr4836851e87.24.1718042353801; Mon, 10 Jun 2024 10:59:13 -0700 (PDT) Received: from m1x-phil.lan ([176.176.129.242]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-421e6f0861bsm36413705e9.4.2024.06.10.10.59.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 10 Jun 2024 10:59:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Markus Armbruster , =?utf-8?q?Daniel_P_=2E_Berrang?= =?utf-8?q?=C3=A9?= , "Dr. David Alan Gilbert" , qemu-devel@nongnu.org Cc: Yanan Wang , Richard Henderson , Eric Farman , Thomas Huth , Eric Blake , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Christian Borntraeger , qemu-s390x@nongnu.org, Eduardo Habkost , Ilya Leoshkevich , Halil Pasic , Marcel Apfelbaum , David Hildenbrand , Paolo Bonzini Subject: [RFC PATCH 3/3] hw/s390x: Introduce x-query-s390x-cmma QMP command Date: Mon, 10 Jun 2024 19:58:52 +0200 Message-ID: <20240610175852.21215-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240610175852.21215-1-philmd@linaro.org> References: <20240610175852.21215-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=philmd@linaro.org; helo=mail-lf1-x12e.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This is a counterpart to the HMP "info cmma" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Philippe Mathieu-Daudé --- qapi/machine.json | 20 ++++++++++++++++++++ hw/s390x/s390-stattrib.c | 28 ++++++++++++++++++---------- hmp-commands-info.hx | 2 +- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/qapi/machine.json b/qapi/machine.json index 6da72f2585..a56b7572b1 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1905,3 +1905,23 @@ 'data': { 'json-args': 'str'}, 'returns': 'HumanReadableText', 'features': [ 'unstable' ]} + +## +# @x-query-s390x-cmma: +# +# Query information on s390x CMMA storage attributes +# +# @json-args: HMP arguments encoded as JSON string. +# +# Features: +# +# @unstable: This command is meant for debugging. +# +# Returns: s390x CMMA storage attributes information +# +# Since: 9.1 +## +{ 'command': 'x-query-s390x-cmma', + 'data': { 'json-args': 'str'}, + 'returns': 'HumanReadableText', + 'features': [ 'unstable' ]} diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index 9b4b8d8d0c..8c2372bd71 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -19,6 +19,9 @@ #include "exec/ram_addr.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" +#include "qapi/qapi-commands-machine.h" +#include "qapi/qmp/qjson.h" +#include "qapi/type-helpers.h" #include "monitor/hmp-target.h" #include "monitor/monitor.h" #include "cpu.h" @@ -73,10 +76,12 @@ void hmp_migrationmode(Monitor *mon, const QDict *qdict) } } -void hmp_info_cmma(Monitor *mon, const QDict *qdict) +HumanReadableText *qmp_x_query_s390x_cmma(const char *json_args, Error **errp) { + g_autoptr(GString) buf = g_string_new(""); S390StAttribState *sas = s390_get_stattrib_device(); S390StAttribClass *sac = S390_STATTRIB_GET_CLASS(sas); + QDict *qdict = qobject_to(QDict, qobject_from_json(json_args, &error_abort)); uint64_t addr = qdict_get_int(qdict, "addr"); uint64_t buflen = qdict_get_try_int(qdict, "count", 8); uint8_t *vals; @@ -84,30 +89,33 @@ void hmp_info_cmma(Monitor *mon, const QDict *qdict) vals = g_try_malloc(buflen); if (!vals) { - monitor_printf(mon, "Error: %s\n", strerror(errno)); - return; + error_setg(errp, "Failed to allocate memory"); + return NULL; } len = sac->peek_stattr(sas, addr / TARGET_PAGE_SIZE, buflen, vals); if (len < 0) { - monitor_printf(mon, "Error: %s", strerror(-len)); + error_setg_errno(errp, -len, "Could not get attributes"); goto out; } - monitor_printf(mon, " CMMA attributes, " - "pages %" PRIu64 "+%d (0x%" PRIx64 "):\n", - addr / TARGET_PAGE_SIZE, len, addr & ~TARGET_PAGE_MASK); + g_string_append_printf(buf, " CMMA attributes, " + "pages %" PRIu64 "+%d (0x%" PRIx64 "):\n", + addr / TARGET_PAGE_SIZE, len, + addr & ~TARGET_PAGE_MASK); for (cx = 0; cx < len; cx++) { if (cx % 8 == 7) { - monitor_printf(mon, "%02x\n", vals[cx]); + g_string_append_printf(buf, "%02x\n", vals[cx]); } else { - monitor_printf(mon, "%02x", vals[cx]); + g_string_append_printf(buf, "%02x", vals[cx]); } } - monitor_printf(mon, "\n"); + g_string_append_c(buf, '\n'); out: + qobject_unref(qdict); g_free(vals); + return human_readable_text_from_str(buf); } /* Migration support: */ diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index cfd4ad5651..0a944e43ce 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -720,7 +720,7 @@ ERST .args_type = "addr:l,count:l?", .params = "address [count]", .help = "Display the values of the CMMA storage attributes for a range of pages", - .cmd = hmp_info_cmma, + .cmd_info_hrt = qmp_x_query_s390x_cmma, }, #endif