From nobody Sun Apr 28 07:36:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677740892; cv=none; d=zohomail.com; s=zohoarc; b=TnUpJBANQhk2hmNozpkoVzGDuIK5nZZ6zwcjAkYT+SkLk6i463SEc0/GUrvIsqQmOdXvUcqHnRpPSrob4mpE1PYTABiFVXj7zLygYi0sdsL9TV1bhEwB6ksEsbxCAfefL4qZwdRy+TAAjjmGL3gTOyKfFSLNNtdsg8/m4nRUTpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677740892; 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=ANQjlRaq4vQYioAcyRImwl/RWb73DqBd2Kh2Xk2HLqc=; b=LLzgso3TSHsmABdvKR1y9cKPM99+90q7pJB4CHdz7IfnPn3RyJh4LRKBpf+XWX+xOltaPm62HbSoQX30eIdFe4IzFrjSf7jCmQBZw+FonsdHi1/uE+hQt0VQPOoudKVp18CUlgBnu3QjE8x58DpF0mzwiauSEvGIE1hrNJEI04Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167774089251292.76574695597651; Wed, 1 Mar 2023 23:08:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXd20-0002iz-Om; Thu, 02 Mar 2023 02:07:13 -0500 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 1pXd1x-0002gS-5b for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXd1v-0005TG-Km for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:08 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-597-hPyL4I23OraF1bofFaAoog-1; Thu, 02 Mar 2023 02:07:01 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D3463C0DDCA; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 34C6D140EBF4; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 094BA21E6A23; Thu, 2 Mar 2023 08:07:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677740826; 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=ANQjlRaq4vQYioAcyRImwl/RWb73DqBd2Kh2Xk2HLqc=; b=Uoo5iO5U5kCJXWe2/pqb8Sa1wavYA7/eHgYCng8hPtsS/5656P3WOKlo9qKsXcnx2vBmWu e8PDDHprl6py9YIaHMWML7ffBE/MpGFPYyH3NoKl2Te0ZA9Xnz7cWxImy/NSRUX9XlEuu0 imZa9DgWAnu7Zjkxjtnfvz8i7THfaXA= X-MC-Unique: hPyL4I23OraF1bofFaAoog-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Dongli Zhang , Joe Jin , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth Subject: [PULL 1/5] readline: fix hmp completion issue Date: Thu, 2 Mar 2023 08:06:56 +0100 Message-Id: <20230302070700.2998086-2-armbru@redhat.com> In-Reply-To: <20230302070700.2998086-1-armbru@redhat.com> References: <20230302070700.2998086-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677740894133100001 From: Dongli Zhang The auto completion does not work in some cases. Case 1. 1. (qemu) info reg 2. Press 'Tab'. 3. It does not auto complete. Case 2. 1. (qemu) block_resize flo 2. Press 'Tab'. 3. It does not auto complete 'floppy0'. Since the readline_add_completion_of() may add any completion when strlen(pfx) is zero, we remove the check with (name[0] =3D=3D '\0') because strlen() always returns zero in that case. Fixes: 52f50b1e9f8f ("readline: Extract readline_add_completion_of() from m= onitor") Cc: Joe Jin Signed-off-by: Dongli Zhang Message-Id: <20230207045241.8843-1-dongli.zhang@oracle.com> Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Markus Armbruster Tested-by: Thomas Huth Signed-off-by: Markus Armbruster --- monitor/hmp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/monitor/hmp.c b/monitor/hmp.c index 2aa85d3982..fee410362f 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1189,9 +1189,7 @@ static void cmd_completion(MonitorHMP *mon, const cha= r *name, const char *list) } memcpy(cmd, pstart, len); cmd[len] =3D '\0'; - if (name[0] =3D=3D '\0') { - readline_add_completion_of(mon->rs, name, cmd); - } + readline_add_completion_of(mon->rs, name, cmd); if (*p =3D=3D '\0') { break; } @@ -1335,9 +1333,7 @@ static void monitor_find_completion_by_table(MonitorH= MP *mon, /* block device name completion */ readline_set_completion_index(mon->rs, strlen(str)); while ((blk =3D blk_next(blk)) !=3D NULL) { - if (str[0] =3D=3D '\0') { - readline_add_completion_of(mon->rs, str, blk_name(blk)= ); - } + readline_add_completion_of(mon->rs, str, blk_name(blk)); } break; case 's': --=20 2.39.0 From nobody Sun Apr 28 07:36:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677740907; cv=none; d=zohomail.com; s=zohoarc; b=hJGFeaECwAmZRI4NAgX9ic7PFjxsopQVzE+lRuZfscdMr63hk33dC3R0BPEr3NV4wvpcEwVNb55weAv3drpalhYwgdWrHYitePh20ZVpQoGvs6c9Eb49/8BadqyjyEDCPPrH2ssBkJ2Xo79F/E44fam23QvGnriQgt3e+03pVgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677740907; 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=3EEBtnp00yhEK2jIM7VFnQf5ieeLElGwuTQ0thfuo8Q=; b=SGrwJ0nDmN00mO2UjRLuwbATrpRI7odDZvvT7mZtn8agKOtY35GTNznbHdCUA8LBLUMN2OslnAtmBaNbUzjJ0/JkM5uAhV5XV8AfHz8xXfqew5THqHpOUyk5MMnFDyhMX7RoXsBOgEPYlLdhk4uHMeKGYz7xUGyIGHWdo2Zr8rM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677740907489381.0822766411794; Wed, 1 Mar 2023 23:08:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXd20-0002hF-4l; Thu, 02 Mar 2023 02:07:12 -0500 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 1pXd1v-0002gO-Tg for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXd1s-0005Sf-G1 for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:06 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-213-neJ1GJ_qNTKT6MJ2yKI67Q-1; Thu, 02 Mar 2023 02:07:02 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 59BE1101AA5F; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 353641121315; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0BE8F21E6A24; Thu, 2 Mar 2023 08:07:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677740823; 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=3EEBtnp00yhEK2jIM7VFnQf5ieeLElGwuTQ0thfuo8Q=; b=fmJ6DBqxDmNaMqU5MuFhGkr03pQYDWzFgcjFfBCF3//ogxQa9m3me47oiVoENp0xXkUmqQ eu9Qz+dh9YC+Qmxr5PkibcHYu+bIrF0qKKIDRd733FZsnfpuJi6cwHOWtbvc/27pURRtCX cfh9xEYCiK84n/lkGJcFOWNR3tHoS5k= X-MC-Unique: neJ1GJ_qNTKT6MJ2yKI67Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 2/5] target/arm: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 2 Mar 2023 08:06:57 +0100 Message-Id: <20230302070700.2998086-3-armbru@redhat.com> In-Reply-To: <20230302070700.2998086-1-armbru@redhat.com> References: <20230302070700.2998086-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677740908204100005 From: Philippe Mathieu-Daud=C3=A9 Since commit a0e61807a3 ("qapi: Remove QMP events and commands from user-mode builds") we don't generate the "qapi-commands-machine.h" header in a user-emulation-only build. Move the QMP functions from helper.c (which is always compiled) to monitor.c (which is only compiled when system-emulation is selected). Rename monitor.c to arm-qmp-cmds.c. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20230223155540.30370-2-philmd@linaro.org> Signed-off-by: Markus Armbruster [Straightforward conflict with commit 9def656e7a2 resolved] --- target/arm/{monitor.c =3D> arm-qmp-cmds.c} | 28 +++++++++++++++++++++++ target/arm/helper.c | 29 ------------------------ target/arm/meson.build | 2 +- 3 files changed, 29 insertions(+), 30 deletions(-) rename target/arm/{monitor.c =3D> arm-qmp-cmds.c} (90%) diff --git a/target/arm/monitor.c b/target/arm/arm-qmp-cmds.c similarity index 90% rename from target/arm/monitor.c rename to target/arm/arm-qmp-cmds.c index ecdd5ee817..c8fa524002 100644 --- a/target/arm/monitor.c +++ b/target/arm/arm-qmp-cmds.c @@ -227,3 +227,31 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(C= puModelExpansionType type, =20 return expansion_info; } + +static void arm_cpu_add_definition(gpointer data, gpointer user_data) +{ + ObjectClass *oc =3D data; + CpuDefinitionInfoList **cpu_list =3D user_data; + CpuDefinitionInfo *info; + const char *typename; + + typename =3D object_class_get_name(oc); + info =3D g_malloc0(sizeof(*info)); + info->name =3D g_strndup(typename, + strlen(typename) - strlen("-" TYPE_ARM_CPU)); + info->q_typename =3D g_strdup(typename); + + QAPI_LIST_PREPEND(*cpu_list, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list =3D NULL; + GSList *list; + + list =3D object_class_get_list(TYPE_ARM_CPU, false); + g_slist_foreach(list, arm_cpu_add_definition, &cpu_list); + g_slist_free(list); + + return cpu_list; +} diff --git a/target/arm/helper.c b/target/arm/helper.c index 14af7ba095..82c546f11a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -23,7 +23,6 @@ #include "sysemu/cpu-timers.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" -#include "qapi/qapi-commands-machine-target.h" #include "qapi/error.h" #include "qemu/guest-random.h" #ifdef CONFIG_TCG @@ -9188,34 +9187,6 @@ void arm_cpu_list(void) g_slist_free(list); } =20 -static void arm_cpu_add_definition(gpointer data, gpointer user_data) -{ - ObjectClass *oc =3D data; - CpuDefinitionInfoList **cpu_list =3D user_data; - CpuDefinitionInfo *info; - const char *typename; - - typename =3D object_class_get_name(oc); - info =3D g_malloc0(sizeof(*info)); - info->name =3D g_strndup(typename, - strlen(typename) - strlen("-" TYPE_ARM_CPU)); - info->q_typename =3D g_strdup(typename); - - QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - CpuDefinitionInfoList *cpu_list =3D NULL; - GSList *list; - - list =3D object_class_get_list(TYPE_ARM_CPU, false); - g_slist_foreach(list, arm_cpu_add_definition, &cpu_list); - g_slist_free(list); - - return cpu_list; -} - /* * Private utility function for define_one_arm_cp_reg_with_opaque(): * add a single reginfo struct to the hash table. diff --git a/target/arm/meson.build b/target/arm/meson.build index a5191b57e1..6226098ad5 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -20,8 +20,8 @@ arm_softmmu_ss =3D ss.source_set() arm_softmmu_ss.add(files( 'arch_dump.c', 'arm-powerctl.c', + 'arm-qmp-cmds.c', 'machine.c', - 'monitor.c', 'ptw.c', )) =20 --=20 2.39.0 From nobody Sun Apr 28 07:36:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677740857; cv=none; d=zohomail.com; s=zohoarc; b=fqDcrGYab5QRWpAQ7sk7qNs0qenNgkOdOgfUViuf4fufFPKzvYlc64JGN3olFWZQaeETzRRIvXb8WKfO40msjJu1mesTGMeHlbibZPGBJrBMJ92E5v+nlMGp1c0QeMEf4yAEsFR1qXx72yslCcORPFUhpScuZy7s14zfn/SoP20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677740857; 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=7DUkvCHWMbAxRC85L+fGwovCF77gB87XXBtw4uBMXwc=; b=cbfEyf3+lFLzOiA/rnKlFMZF2sBXSseEN36HCmmQ2owwcjlCm5VtfW0ilsoRWdFjz0TaSpFiES6HnzNAxtV7Ur6kQbfRq55uhLYro/eC9v0CTXrmc1E6VJ2VzCTs6vLLFgMMrjgjCwSgllamGwR/4B/VgglG/zfhQgHoIepPFgU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677740857974133.4826136025315; Wed, 1 Mar 2023 23:07:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXd23-0002qC-JL; Thu, 02 Mar 2023 02:07:15 -0500 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 1pXd1v-0002gP-Tt for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXd1s-0005Sc-HF for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:07 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-18-PLk8ul2_Ohapqs62oNvOzQ-1; Thu, 02 Mar 2023 02:07:01 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A5D4101AA63; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3102A400EA93; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0E1F621E6A25; Thu, 2 Mar 2023 08:07:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677740823; 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=7DUkvCHWMbAxRC85L+fGwovCF77gB87XXBtw4uBMXwc=; b=QO4R14HZPPDEOcQrIKgGJtYt9jnZNB+lqEoChLAPjGcWawuOeSer6rpWzr0vaXauQKAJBo rAAvPj/bEjM7B/Qfo0fRmz6MslhcwELV9t6JaIZHlh5/l8KMTN/s1h5vQM7F8N9Naj1OEz LnNt/d7pgLhBZMHnY7S6aXtDPzxq+38= X-MC-Unique: PLk8ul2_Ohapqs62oNvOzQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 3/5] target/i386: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 2 Mar 2023 08:06:58 +0100 Message-Id: <20230302070700.2998086-4-armbru@redhat.com> In-Reply-To: <20230302070700.2998086-1-armbru@redhat.com> References: <20230302070700.2998086-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677740859847100001 From: Philippe Mathieu-Daud=C3=A9 Since commit a0e61807a3 ("qapi: Remove QMP events and commands from user-mode builds") we don't generate the "qapi-commands-machine.h" header in a user-emulation-only build. Guard qmp_query_cpu_definitions() within CONFIG_USER_ONLY; move x86_cpu_class_check_missing_features() closer since it is only used by this QMP command handler. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20230223155540.30370-3-philmd@linaro.org> Signed-off-by: Markus Armbruster --- target/i386/cpu.c | 74 +++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4bad3d41d3..4d508624e1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -31,11 +31,11 @@ #include "qapi/error.h" #include "qapi/qapi-visit-machine.h" #include "qapi/qmp/qerror.h" -#include "qapi/qapi-commands-machine-target.h" #include "standard-headers/asm-x86/kvm_para.h" #include "hw/qdev-properties.h" #include "hw/i386/topology.h" #ifndef CONFIG_USER_ONLY +#include "qapi/qapi-commands-machine-target.h" #include "exec/address-spaces.h" #include "hw/boards.h" #include "hw/i386/sgx-epc.h" @@ -4843,40 +4843,6 @@ static void x86_cpu_get_unavailable_features(Object = *obj, Visitor *v, visit_type_strList(v, "unavailable-features", &result, errp); } =20 -/* Check for missing features that may prevent the CPU class from - * running using the current machine and accelerator. - */ -static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, - strList **list) -{ - strList **tail =3D list; - X86CPU *xc; - Error *err =3D NULL; - - if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { - QAPI_LIST_APPEND(tail, g_strdup("kvm")); - return; - } - - xc =3D X86_CPU(object_new_with_class(OBJECT_CLASS(xcc))); - - x86_cpu_expand_features(xc, &err); - if (err) { - /* Errors at x86_cpu_expand_features should never happen, - * but in case it does, just report the model as not - * runnable at all using the "type" property. - */ - QAPI_LIST_APPEND(tail, g_strdup("type")); - error_free(err); - } - - x86_cpu_filter_features(xc, false); - - x86_cpu_list_feature_names(xc->filtered_features, tail); - - object_unref(OBJECT(xc)); -} - /* Print all cpuid feature names in featureset */ static void listflags(GList *features) @@ -5005,6 +4971,42 @@ void x86_cpu_list(void) g_list_free(names); } =20 +#ifndef CONFIG_USER_ONLY + +/* Check for missing features that may prevent the CPU class from + * running using the current machine and accelerator. + */ +static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, + strList **list) +{ + strList **tail =3D list; + X86CPU *xc; + Error *err =3D NULL; + + if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { + QAPI_LIST_APPEND(tail, g_strdup("kvm")); + return; + } + + xc =3D X86_CPU(object_new_with_class(OBJECT_CLASS(xcc))); + + x86_cpu_expand_features(xc, &err); + if (err) { + /* Errors at x86_cpu_expand_features should never happen, + * but in case it does, just report the model as not + * runnable at all using the "type" property. + */ + QAPI_LIST_APPEND(tail, g_strdup("type")); + error_free(err); + } + + x86_cpu_filter_features(xc, false); + + x86_cpu_list_feature_names(xc->filtered_features, tail); + + object_unref(OBJECT(xc)); +} + static void x86_cpu_definition_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; @@ -5045,6 +5047,8 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Erro= r **errp) return cpu_list; } =20 +#endif /* !CONFIG_USER_ONLY */ + uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, bool migratable_only) { --=20 2.39.0 From nobody Sun Apr 28 07:36:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677740854; cv=none; d=zohomail.com; s=zohoarc; b=HpOspgAmJumdaULzeEXDxra8XpQGHq2zUdjGa0zVkcBrfpRucVJdrYF7W7rvy2TGD0PFyUWaWxoiqZYQDe3R9QtepajC/Et9WjJZql2GB7cbGOYnodLKA/fPk6jR2baCjG8czPSch10/eDoJNsHBFI/nzUPM/X3R3GLllEw0k0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677740854; 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=kgbSASuu3cV58gv0lhM4uGISQfJUfz8H+7nE1VuVk8I=; b=JJ3KU9RhDYwgU6hFy9+cMIP8Fo52/UfzdSBPUtSeROoZouzB7RRpfPTeaxjSt2M5SCHl6R/vdbT7pheiEwoTjTl7y0q1aA2nEnmIGtLfpo0jO46olr2XqmFleWQjQ6qV21jz/ICJW1blUCg/D5Gxl5lLBvah0tQzcwDgNvdXMZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677740854313337.81936690025043; Wed, 1 Mar 2023 23:07:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXd1y-0002gm-0c; Thu, 02 Mar 2023 02:07:10 -0500 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 1pXd1u-0002fx-IT for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXd1s-0005Se-Gi for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:06 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-597-fPXZQWpwMOObhqlUO276nA-1; Thu, 02 Mar 2023 02:07:01 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5AAF12823806; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30B892166B26; Thu, 2 Mar 2023 07:07:01 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 10AB721E6A26; Thu, 2 Mar 2023 08:07:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677740823; 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=kgbSASuu3cV58gv0lhM4uGISQfJUfz8H+7nE1VuVk8I=; b=YabQficHFCwXCBJLg/le7MiSSmKouMUdP7eONKQB7ay7M/3DWzOQlf8zKTzne20tpMa3uZ cSpapBbjn5c3vMjibdWqv1Ii4+XXAdpoL/Uh2f+C+vh8wbLr4wYeJrjO1vvwTbA5BH0yNj hp0o8TJ3divAGD47YXG2KtdYK1D2kRs= X-MC-Unique: fPXZQWpwMOObhqlUO276nA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 4/5] target/loongarch: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 2 Mar 2023 08:06:59 +0100 Message-Id: <20230302070700.2998086-5-armbru@redhat.com> In-Reply-To: <20230302070700.2998086-1-armbru@redhat.com> References: <20230302070700.2998086-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677740856900100003 From: Philippe Mathieu-Daud=C3=A9 Since commit a0e61807a3 ("qapi: Remove QMP events and commands from user-mode builds") we don't generate the "qapi-commands-machine.h" header in a user-emulation-only build. Extract the QMP functions from cpu.c (which is always compiled) to the new 'loongarch-qmp-cmds.c' unit (which is only compiled when system emulation is selected). Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230223155540.30370-4-philmd@linaro.org> Signed-off-by: Markus Armbruster --- target/loongarch/cpu.c | 27 ------------------- target/loongarch/loongarch-qmp-cmds.c | 37 +++++++++++++++++++++++++++ target/loongarch/meson.build | 1 + 3 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 target/loongarch/loongarch-qmp-cmds.c diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 290ab4d526..4e845ba29b 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -12,7 +12,6 @@ #include "qemu/module.h" #include "sysemu/qtest.h" #include "exec/exec-all.h" -#include "qapi/qapi-commands-machine-target.h" #include "cpu.h" #include "internals.h" #include "fpu/softfloat-helpers.h" @@ -748,29 +747,3 @@ static const TypeInfo loongarch_cpu_type_infos[] =3D { }; =20 DEFINE_TYPES(loongarch_cpu_type_infos) - -static void loongarch_cpu_add_definition(gpointer data, gpointer user_data) -{ - ObjectClass *oc =3D data; - CpuDefinitionInfoList **cpu_list =3D user_data; - CpuDefinitionInfo *info =3D g_new0(CpuDefinitionInfo, 1); - const char *typename =3D object_class_get_name(oc); - - info->name =3D g_strndup(typename, - strlen(typename) - strlen("-" TYPE_LOONGARCH_CP= U)); - info->q_typename =3D g_strdup(typename); - - QAPI_LIST_PREPEND(*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - CpuDefinitionInfoList *cpu_list =3D NULL; - GSList *list; - - list =3D object_class_get_list(TYPE_LOONGARCH_CPU, false); - g_slist_foreach(list, loongarch_cpu_add_definition, &cpu_list); - g_slist_free(list); - - return cpu_list; -} diff --git a/target/loongarch/loongarch-qmp-cmds.c b/target/loongarch/loong= arch-qmp-cmds.c new file mode 100644 index 0000000000..6c25957881 --- /dev/null +++ b/target/loongarch/loongarch-qmp-cmds.c @@ -0,0 +1,37 @@ +/* + * QEMU LoongArch CPU (monitor definitions) + * + * SPDX-FileCopyrightText: 2021 Loongson Technology Corporation Limited + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-commands-machine-target.h" +#include "cpu.h" + +static void loongarch_cpu_add_definition(gpointer data, gpointer user_data) +{ + ObjectClass *oc =3D data; + CpuDefinitionInfoList **cpu_list =3D user_data; + CpuDefinitionInfo *info =3D g_new0(CpuDefinitionInfo, 1); + const char *typename =3D object_class_get_name(oc); + + info->name =3D g_strndup(typename, + strlen(typename) - strlen("-" TYPE_LOONGARCH_CP= U)); + info->q_typename =3D g_strdup(typename); + + QAPI_LIST_PREPEND(*cpu_list, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list =3D NULL; + GSList *list; + + list =3D object_class_get_list(TYPE_LOONGARCH_CPU, false); + g_slist_foreach(list, loongarch_cpu_add_definition, &cpu_list); + g_slist_free(list); + + return cpu_list; +} diff --git a/target/loongarch/meson.build b/target/loongarch/meson.build index 690633969f..9293a8ab78 100644 --- a/target/loongarch/meson.build +++ b/target/loongarch/meson.build @@ -16,6 +16,7 @@ loongarch_tcg_ss.add(zlib) =20 loongarch_softmmu_ss =3D ss.source_set() loongarch_softmmu_ss.add(files( + 'loongarch-qmp-cmds.c', 'machine.c', 'tlb_helper.c', 'constant_timer.c', --=20 2.39.0 From nobody Sun Apr 28 07:36:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1677740913; cv=none; d=zohomail.com; s=zohoarc; b=QeZITPqVpdwHWAzt8bmgmOh3S5XsLIBR0HPJXAEiVhtomnIyseEpn/063JcA0oAfdMFV4XmNhZvYcV1hAyI7R2m1gWneX0fdR2NdDcqdaKumAQrbighKol4D7PDCaxvqcdd8WzVMv5oPxyHe2ctF0rVmzG+faUx4fDZ2Qt+gyto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677740913; 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=Ns2NdRrri0S6YoBrgBtjeueKfArjbP8KbgSUPCbyk8M=; b=LTSP3m5yHK0Zo+urQF2XvU/1POfA5/xPK2uIHGOLaul9GMqeC6uaRCyBwsxN56dk++eUk9MtdcqNFnxeXIjm36SsrP47X14s3I2UAf/zrikvvTBB/zg1hTIj8RMvZvsAXU8DGo+Ve3DRRP5T5QieiytivkduNXI0LkdPWeZJl5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677740913052576.6178889684192; Wed, 1 Mar 2023 23:08:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXd25-0002uC-KZ; Thu, 02 Mar 2023 02:07:17 -0500 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 1pXd1x-0002gl-Rs for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXd1w-0005TQ-2O for qemu-devel@nongnu.org; Thu, 02 Mar 2023 02:07:09 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-204-F-pACq2QOXCQV4764u6BvA-1; Thu, 02 Mar 2023 02:07:03 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C8E8485CCE4; Thu, 2 Mar 2023 07:07:02 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.193.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 89C55C16027; Thu, 2 Mar 2023 07:07:02 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1336A21E6A28; Thu, 2 Mar 2023 08:07:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677740827; 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=Ns2NdRrri0S6YoBrgBtjeueKfArjbP8KbgSUPCbyk8M=; b=GO3FueyAK4ZO5m0kz66oFWP9rO7fu8eRI/yrFfNoGLpv4EBVOXDlh3ScIX1sp4eFC2D1EY 0CtA10vNddceLhmbdirM0YOWgPPkaREgaTZQwFu3KtTW0qLphePW2lStZLn97f/iA2ZptE M5tARJEdeAThwFF7SsYg5/gkkgfWclk= X-MC-Unique: F-pACq2QOXCQV4764u6BvA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 5/5] target/ppc: Restrict 'qapi-commands-machine.h' to system emulation Date: Thu, 2 Mar 2023 08:07:00 +0100 Message-Id: <20230302070700.2998086-6-armbru@redhat.com> In-Reply-To: <20230302070700.2998086-1-armbru@redhat.com> References: <20230302070700.2998086-1-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.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, 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_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677740914330100001 From: Philippe Mathieu-Daud=C3=A9 Since commit a0e61807a3 ("qapi: Remove QMP events and commands from user-mode builds") we don't generate the "qapi-commands-machine.h" header in a user-emulation-only build. Move the QMP functions from cpu_init.c (which is always compiled) to monitor.c (which is only compiled when system-emulation is selected). Rename monitor.c to arm-qmp-cmds.c. Note ppc_cpu_class_by_name() is used by both file units, so we expose its prototype in "cpu-qom.h". Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Reviewed-by: C=C3=A9dric Le Goater Message-Id: <20230223155540.30370-5-philmd@linaro.org> Signed-off-by: Markus Armbruster --- target/ppc/cpu-qom.h | 2 + target/ppc/cpu_init.c | 48 +---------------------- target/ppc/{monitor.c =3D> ppc-qmp-cmds.c} | 50 +++++++++++++++++++++++- target/ppc/meson.build | 2 +- 4 files changed, 53 insertions(+), 49 deletions(-) rename target/ppc/{monitor.c =3D> ppc-qmp-cmds.c} (78%) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 0fbd8b7246..9666f54f65 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -31,6 +31,8 @@ =20 OBJECT_DECLARE_CPU_TYPE(PowerPCCPU, PowerPCCPUClass, POWERPC_CPU) =20 +ObjectClass *ppc_cpu_class_by_name(const char *name); + typedef struct CPUArchState CPUPPCState; typedef struct ppc_tb_t ppc_tb_t; typedef struct ppc_dcr_t ppc_dcr_t; diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index abee71d407..d62ffe8a6f 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -40,7 +40,6 @@ #include "qemu/cutils.h" #include "disas/capstone.h" #include "fpu/softfloat.h" -#include "qapi/qapi-commands-machine-target.h" =20 #include "helper_regs.h" #include "internal.h" @@ -6841,7 +6840,7 @@ static const char *ppc_cpu_lookup_alias(const char *a= lias) return NULL; } =20 -static ObjectClass *ppc_cpu_class_by_name(const char *name) +ObjectClass *ppc_cpu_class_by_name(const char *name) { char *cpu_model, *typename; ObjectClass *oc; @@ -6981,51 +6980,6 @@ void ppc_cpu_list(void) #endif } =20 -static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) -{ - ObjectClass *oc =3D data; - CpuDefinitionInfoList **first =3D user_data; - const char *typename; - CpuDefinitionInfo *info; - - typename =3D object_class_get_name(oc); - info =3D g_malloc0(sizeof(*info)); - info->name =3D g_strndup(typename, - strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFF= IX)); - - QAPI_LIST_PREPEND(*first, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) -{ - CpuDefinitionInfoList *cpu_list =3D NULL; - GSList *list; - int i; - - list =3D object_class_get_list(TYPE_POWERPC_CPU, false); - g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list); - g_slist_free(list); - - for (i =3D 0; ppc_cpu_aliases[i].alias !=3D NULL; i++) { - PowerPCCPUAlias *alias =3D &ppc_cpu_aliases[i]; - ObjectClass *oc; - CpuDefinitionInfo *info; - - oc =3D ppc_cpu_class_by_name(alias->model); - if (oc =3D=3D NULL) { - continue; - } - - info =3D g_malloc0(sizeof(*info)); - info->name =3D g_strdup(alias->alias); - info->q_typename =3D g_strdup(object_class_get_name(oc)); - - QAPI_LIST_PREPEND(cpu_list, info); - } - - return cpu_list; -} - static void ppc_cpu_set_pc(CPUState *cs, vaddr value) { PowerPCCPU *cpu =3D POWERPC_CPU(cs); diff --git a/target/ppc/monitor.c b/target/ppc/ppc-qmp-cmds.c similarity index 78% rename from target/ppc/monitor.c rename to target/ppc/ppc-qmp-cmds.c index 8250b1304e..36e5b5eff8 100644 --- a/target/ppc/monitor.c +++ b/target/ppc/ppc-qmp-cmds.c @@ -1,5 +1,5 @@ /* - * QEMU monitor + * QEMU PPC (monitor definitions) * * Copyright (c) 2003-2004 Fabrice Bellard * @@ -28,6 +28,9 @@ #include "qemu/ctype.h" #include "monitor/hmp-target.h" #include "monitor/hmp.h" +#include "qapi/qapi-commands-machine-target.h" +#include "cpu-models.h" +#include "cpu-qom.h" =20 static target_long monitor_get_ccr(Monitor *mon, const struct MonitorDef *= md, int val) @@ -172,3 +175,48 @@ int target_get_monitor_def(CPUState *cs, const char *n= ame, uint64_t *pval) =20 return -EINVAL; } + +static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) +{ + ObjectClass *oc =3D data; + CpuDefinitionInfoList **first =3D user_data; + const char *typename; + CpuDefinitionInfo *info; + + typename =3D object_class_get_name(oc); + info =3D g_malloc0(sizeof(*info)); + info->name =3D g_strndup(typename, + strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFF= IX)); + + QAPI_LIST_PREPEND(*first, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + CpuDefinitionInfoList *cpu_list =3D NULL; + GSList *list; + int i; + + list =3D object_class_get_list(TYPE_POWERPC_CPU, false); + g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list); + g_slist_free(list); + + for (i =3D 0; ppc_cpu_aliases[i].alias !=3D NULL; i++) { + PowerPCCPUAlias *alias =3D &ppc_cpu_aliases[i]; + ObjectClass *oc; + CpuDefinitionInfo *info; + + oc =3D ppc_cpu_class_by_name(alias->model); + if (oc =3D=3D NULL) { + continue; + } + + info =3D g_malloc0(sizeof(*info)); + info->name =3D g_strdup(alias->alias); + info->q_typename =3D g_strdup(object_class_get_name(oc)); + + QAPI_LIST_PREPEND(cpu_list, info); + } + + return cpu_list; +} diff --git a/target/ppc/meson.build b/target/ppc/meson.build index 79beaff147..7929de8360 100644 --- a/target/ppc/meson.build +++ b/target/ppc/meson.build @@ -39,7 +39,7 @@ ppc_softmmu_ss.add(files( 'machine.c', 'mmu-hash32.c', 'mmu_common.c', - 'monitor.c', + 'ppc-qmp-cmds.c', )) ppc_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( 'mmu_helper.c', --=20 2.39.0