From patchwork Thu Jun 16 08:31:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644197 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=c/q79U1a; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwX63qycz9sG0 for ; Thu, 16 Jun 2022 18:37:10 +1000 (AEST) Received: from localhost ([::1]:54422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1l00-0004Ry-BJ for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:37:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvM-0001aF-Jq for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvJ-0002lc-QD for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368337; 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=nG7mO5/STv/cms3snyKEtibZkMqcmz4MRzv4kL+ciUM=; b=c/q79U1ahKIByNHQO1+oST8DbmiDFKyHXDf9S9XHF06wDb6zd7dRX6BCqlPd9nKQxtEP6o 6kIQ6RFovSu9GpvIlVp8hjw2fqunXk7t45OMGkFr8Ogk04Cli2CYKjg7qcB3z8U8jhOBs9 PV9DCwinAVjSx+YbakwQSG1To57MoN0= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-FokAdfEtOR6aK2SP6mHVVg-1; Thu, 16 Jun 2022 04:32:16 -0400 X-MC-Unique: FokAdfEtOR6aK2SP6mHVVg-1 Received: by mail-ed1-f69.google.com with SMTP id i20-20020a50fd14000000b0042dd305d0f7so751107eds.18 for ; Thu, 16 Jun 2022 01:32:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nG7mO5/STv/cms3snyKEtibZkMqcmz4MRzv4kL+ciUM=; b=6qqRNdBdaZSp6kNpMWlo9BYIqlGu4H0EN0NPzouXHQ5HvuOFHo89Oycitbq/SKLZcX IAuV0Vd4rJKu0qS1PGZp7YFwdHqCdtrUbMiNfs+3LNCxAYQcns99p7gQ8mdjQhOji7c7 3oP+LNhUOV1eGUyTThdOPhvVbAU28e7lyui5gtXR74gbekIQ9NvmcYpaB7nHWj0BEowG vvTmekoMyiovhuYiTQtCfYtV4mT1mEz0deUL2IQFQ2Nkz0EfXeOouFX8DbmD2PUg8eB4 d8VMzMqkI8qj8JOmvxh6wsPU44rDNgnM1SfztDLicbNlenz6iv1oMmDpdPD64eNsvRQt DfVQ== X-Gm-Message-State: AJIora+MxaHFNbYRAbLJT8unCGiqHgge8yXMXGU63lLF1GT79oFaAugJ +rUb4t+g7ke48+jAB8eE+QoTiQiDwM7f5hoAOVxXcQ9JDzid0+ttXNJP4d3wcVsbhFfiZEOhkRb ZzsOPN8sCJsWwQLiq8ubikYjjXjSTUD6GfF7GepxtNm899LU5MQZqYjrv6/YY09b2qcU= X-Received: by 2002:a17:907:1c97:b0:6f5:22ae:7024 with SMTP id nb23-20020a1709071c9700b006f522ae7024mr3484717ejc.570.1655368334250; Thu, 16 Jun 2022 01:32:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1usmntfHi/ujoJ+LLA/x16U1jPuNUWl4dT8NUCYF4ISN89lDmBqvhm25PpSEx+U8lMnEwivNQ== X-Received: by 2002:a17:907:1c97:b0:6f5:22ae:7024 with SMTP id nb23-20020a1709071c9700b006f522ae7024mr3484681ejc.570.1655368333550; Thu, 16 Jun 2022 01:32:13 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id u9-20020a1709061da900b006fef557bb7asm487380ejh.80.2022.06.16.01.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Mark Kanda , Markus Armbruster Subject: [PULL 01/21] qmp: Support for querying stats Date: Thu, 16 Jun 2022 10:31:49 +0200 Message-Id: <20220616083209.117397-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Kanda Gathering statistics is important for development, for monitoring and for performance measurement. There are tools such as kvm_stat that do this and they rely on the _user_ knowing the interesting data points rather than the tool (which can treat them as opaque). The commands introduced in this commit introduce QMP support for querying stats; the goal is to take the capabilities of these tools and making them available throughout the whole virtualization stack, so that one can observe, monitor and measure virtual machines without having shell access + root on the host that runs them. query-stats returns a list of all stats per target type (only VM and vCPU to start); future commits add extra options for specifying stat names, vCPU qom paths, and providers. All these are used by the HMP command "info stats". Because of the development usecases around statistics, a good HMP interface is important. query-stats-schemas returns a list of stats included in each target type, with an option for specifying the provider. The concepts in the schema are based on the KVM binary stats' own introspection data, just translated to QAPI. There are two reasons to have a separate schema that is not tied to the QAPI schema. The first is the contents of the schemas: the new introspection data provides different information than the QAPI data, namely unit of measurement, how the numbers are gathered and change (peak/instant/cumulative/histogram), and histogram bucket sizes. There's really no reason to have this kind of metadata in the QAPI introspection schema (except possibly for the unit of measure, but there's a very weak justification). Another reason is the dynamicity of the schema. The QAPI introspection data is very much static; and while QOM is somewhat more dynamic, generally we consider that to be a bug rather than a feature these days. On the other hand, the statistics that are exposed by QEMU might be passed through from another source, such as KVM, and the disadvantages of manually updating the QAPI schema for outweight the benefits from vetting the statistics and filtering out anything that seems "too unstable". Running old QEMU with new kernel is a supported usecase; if old QEMU cannot expose statistics from a new kernel, or if a kernel developer needs to change QEMU before gathering new info from the new kernel, then that is a poor user interface. The framework provides a method to register callbacks for these QMP commands. Most of the work in fact is done by the callbacks, and a large majority of this patch is new QAPI structs and commands. Examples (with KVM stats): - Query all VM stats: { "execute": "query-stats", "arguments" : { "target": "vm" } } { "return": [ { "provider": "kvm", "stats": [ { "name": "max_mmu_page_hash_collisions", "value": 0 }, { "name": "max_mmu_rmap_size", "value": 0 }, { "name": "nx_lpage_splits", "value": 148 }, ... ] }, { "provider": "xyz", "stats": [ ... ] } ] } - Query all vCPU stats: { "execute": "query-stats", "arguments" : { "target": "vcpu" } } { "return": [ { "provider": "kvm", "qom_path": "/machine/unattached/device[0]" "stats": [ { "name": "guest_mode", "value": 0 }, { "name": "directed_yield_successful", "value": 0 }, { "name": "directed_yield_attempted", "value": 106 }, ... ] }, { "provider": "kvm", "qom_path": "/machine/unattached/device[1]" "stats": [ { "name": "guest_mode", "value": 0 }, { "name": "directed_yield_successful", "value": 0 }, { "name": "directed_yield_attempted", "value": 106 }, ... ] }, ] } - Retrieve the schemas: { "execute": "query-stats-schemas" } { "return": [ { "provider": "kvm", "target": "vcpu", "stats": [ { "name": "guest_mode", "unit": "none", "base": 10, "exponent": 0, "type": "instant" }, { "name": "directed_yield_successful", "unit": "none", "base": 10, "exponent": 0, "type": "cumulative" }, ... ] }, { "provider": "kvm", "target": "vm", "stats": [ { "name": "max_mmu_page_hash_collisions", "unit": "none", "base": 10, "exponent": 0, "type": "peak" }, ... ] }, { "provider": "xyz", "target": "vm", "stats": [ ... ] } ] } Signed-off-by: Mark Kanda Reviewed-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/monitor/stats.h | 34 +++++++ monitor/qmp-cmds.c | 95 ++++++++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + qapi/stats.json | 216 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 347 insertions(+) create mode 100644 include/monitor/stats.h create mode 100644 qapi/stats.json diff --git a/include/monitor/stats.h b/include/monitor/stats.h new file mode 100644 index 0000000000..912eeadb2f --- /dev/null +++ b/include/monitor/stats.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#ifndef STATS_H +#define STATS_H + +#include "qapi/qapi-types-stats.h" + +typedef void StatRetrieveFunc(StatsResultList **result, StatsTarget target, + Error **errp); +typedef void SchemaRetrieveFunc(StatsSchemaList **result, Error **errp); + +/* + * Register callbacks for the QMP query-stats command. + * + * @stats_fn: routine to query stats: + * @schema_fn: routine to query stat schemas: + */ +void add_stats_callbacks(StatRetrieveFunc *stats_fn, + SchemaRetrieveFunc *schemas_fn); + +/* + * Helper routines for adding stats entries to the results lists. + */ +void add_stats_entry(StatsResultList **, StatsProvider, const char *id, + StatsList *stats_list); +void add_stats_schema(StatsSchemaList **, StatsProvider, StatsTarget, + StatsSchemaValueList *); + +#endif /* STATS_H */ diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 1ebb89f46c..a6ac8d7473 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -35,6 +35,7 @@ #include "qapi/qapi-commands-control.h" #include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-stats.h" #include "qapi/qapi-commands-ui.h" #include "qapi/type-helpers.h" #include "qapi/qmp/qerror.h" @@ -43,6 +44,7 @@ #include "hw/acpi/acpi_dev_interface.h" #include "hw/intc/intc.h" #include "hw/rdma/rdma.h" +#include "monitor/stats.h" NameInfo *qmp_query_name(Error **errp) { @@ -441,3 +443,96 @@ HumanReadableText *qmp_x_query_irq(Error **errp) return human_readable_text_from_str(buf); } + +typedef struct StatsCallbacks { + StatRetrieveFunc *stats_cb; + SchemaRetrieveFunc *schemas_cb; + QTAILQ_ENTRY(StatsCallbacks) next; +} StatsCallbacks; + +static QTAILQ_HEAD(, StatsCallbacks) stats_callbacks = + QTAILQ_HEAD_INITIALIZER(stats_callbacks); + +void add_stats_callbacks(StatRetrieveFunc *stats_fn, + SchemaRetrieveFunc *schemas_fn) +{ + StatsCallbacks *entry = g_new(StatsCallbacks, 1); + entry->stats_cb = stats_fn; + entry->schemas_cb = schemas_fn; + + QTAILQ_INSERT_TAIL(&stats_callbacks, entry, next); +} + +static bool invoke_stats_cb(StatsCallbacks *entry, + StatsResultList **stats_results, + StatsFilter *filter, + Error **errp) +{ + ERRP_GUARD(); + + entry->stats_cb(stats_results, filter->target, errp); + if (*errp) { + qapi_free_StatsResultList(*stats_results); + *stats_results = NULL; + return false; + } + return true; +} + +StatsResultList *qmp_query_stats(StatsFilter *filter, Error **errp) +{ + StatsResultList *stats_results = NULL; + StatsCallbacks *entry; + + QTAILQ_FOREACH(entry, &stats_callbacks, next) { + if (!invoke_stats_cb(entry, &stats_results, filter, errp)) { + break; + } + } + + return stats_results; +} + +StatsSchemaList *qmp_query_stats_schemas(Error **errp) +{ + StatsSchemaList *stats_results = NULL; + StatsCallbacks *entry; + ERRP_GUARD(); + + QTAILQ_FOREACH(entry, &stats_callbacks, next) { + entry->schemas_cb(&stats_results, errp); + if (*errp) { + qapi_free_StatsSchemaList(stats_results); + return NULL; + } + } + + return stats_results; +} + +void add_stats_entry(StatsResultList **stats_results, StatsProvider provider, + const char *qom_path, StatsList *stats_list) +{ + StatsResult *entry = g_new0(StatsResult, 1); + + entry->provider = provider; + if (qom_path) { + entry->has_qom_path = true; + entry->qom_path = g_strdup(qom_path); + } + entry->stats = stats_list; + + QAPI_LIST_PREPEND(*stats_results, entry); +} + +void add_stats_schema(StatsSchemaList **schema_results, + StatsProvider provider, StatsTarget target, + StatsSchemaValueList *stats_list) +{ + StatsSchema *entry = g_new0(StatsSchema, 1); + + entry->provider = provider; + entry->target = target; + entry->stats = stats_list; + QAPI_LIST_PREPEND(*schema_results, entry); +} diff --git a/qapi/meson.build b/qapi/meson.build index 656ef0e039..fd5c93d643 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -46,6 +46,7 @@ qapi_all_modules = [ 'replay', 'run-state', 'sockets', + 'stats', 'trace', 'transaction', 'yank', diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 4912b9744e..92d7ecc52c 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -93,3 +93,4 @@ { 'include': 'audio.json' } { 'include': 'acpi.json' } { 'include': 'pci.json' } +{ 'include': 'stats.json' } diff --git a/qapi/stats.json b/qapi/stats.json new file mode 100644 index 0000000000..ada0fbf26f --- /dev/null +++ b/qapi/stats.json @@ -0,0 +1,216 @@ +# -*- Mode: Python -*- +# vim: filetype=python +# +# Copyright (c) 2022 Oracle and/or its affiliates. +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +## +# = Statistics +## + +## +# @StatsType: +# +# Enumeration of statistics types +# +# @cumulative: stat is cumulative; value can only increase. +# @instant: stat is instantaneous; value can increase or decrease. +# @peak: stat is the peak value; value can only increase. +# @linear-histogram: stat is a linear histogram. +# @log2-histogram: stat is a logarithmic histogram, with one bucket +# for each power of two. +# +# Since: 7.1 +## +{ 'enum' : 'StatsType', + 'data' : [ 'cumulative', 'instant', 'peak', 'linear-histogram', + 'log2-histogram' ] } + +## +# @StatsUnit: +# +# Enumeration of unit of measurement for statistics +# +# @bytes: stat reported in bytes. +# @seconds: stat reported in seconds. +# @cycles: stat reported in clock cycles. +# +# Since: 7.1 +## +{ 'enum' : 'StatsUnit', + 'data' : [ 'bytes', 'seconds', 'cycles' ] } + +## +# @StatsProvider: +# +# Enumeration of statistics providers. +# +# Since: 7.1 +## +{ 'enum': 'StatsProvider', + 'data': [ ] } + +## +# @StatsTarget: +# +# The kinds of objects on which one can request statistics. +# +# @vm: statistics that apply to the entire virtual machine or +# the entire QEMU process. +# +# @vcpu: statistics that apply to a single virtual CPU. +# +# Since: 7.1 +## +{ 'enum': 'StatsTarget', + 'data': [ 'vm', 'vcpu' ] } + +## +# @StatsFilter: +# +# The arguments to the query-stats command; specifies a target for which to +# request statistics. +# +# Since: 7.1 +## +{ 'struct': 'StatsFilter', + 'data': { 'target': 'StatsTarget' } } + +## +# @StatsValue: +# +# @scalar: single unsigned 64-bit integers. +# @list: list of unsigned 64-bit integers (used for histograms). +# +# Since: 7.1 +## +{ 'alternate': 'StatsValue', + 'data': { 'scalar': 'uint64', + 'list': [ 'uint64' ] } } + +## +# @Stats: +# +# @name: name of stat. +# @value: stat value. +# +# Since: 7.1 +## +{ 'struct': 'Stats', + 'data': { 'name': 'str', + 'value' : 'StatsValue' } } + +## +# @StatsResult: +# +# @provider: provider for this set of statistics. +# +# @qom-path: Path to the object for which the statistics are returned, +# if the object is exposed in the QOM tree +# +# @stats: list of statistics. +# +# Since: 7.1 +## +{ 'struct': 'StatsResult', + 'data': { 'provider': 'StatsProvider', + '*qom-path': 'str', + 'stats': [ 'Stats' ] } } + +## +# @query-stats: +# +# Return runtime-collected statistics for objects such as the +# VM or its vCPUs. +# +# The arguments are a StatsFilter and specify the provider and objects +# to return statistics about. +# +# Returns: a list of StatsResult, one for each provider and object +# (e.g., for each vCPU). +# +# Since: 7.1 +## +{ 'command': 'query-stats', + 'data': 'StatsFilter', + 'boxed': true, + 'returns': [ 'StatsResult' ] } + +## +# @StatsSchemaValue: +# +# Schema for a single statistic. +# +# @name: name of the statistic; each element of the schema is uniquely +# identified by a target, a provider (both available in @StatsSchema) +# and the name. +# +# @type: kind of statistic. +# +# @unit: basic unit of measure for the statistic; if missing, the statistic +# is a simple number or counter. +# +# @base: base for the multiple of @unit in which the statistic is measured. +# Only present if @exponent is non-zero; @base and @exponent together +# form a SI prefix (e.g., _nano-_ for ``base=10`` and ``exponent=-9``) +# or IEC binary prefix (e.g. _kibi-_ for ``base=2`` and ``exponent=10``) +# +# @exponent: exponent for the multiple of @unit in which the statistic is +# expressed, or 0 for the basic unit +# +# @bucket-size: Present when @type is "linear-histogram", contains the width +# of each bucket of the histogram. +# +# Since: 7.1 +## +{ 'struct': 'StatsSchemaValue', + 'data': { 'name': 'str', + 'type': 'StatsType', + '*unit': 'StatsUnit', + '*base': 'int8', + 'exponent': 'int16', + '*bucket-size': 'uint32' } } + +## +# @StatsSchema: +# +# Schema for all available statistics for a provider and target. +# +# @provider: provider for this set of statistics. +# +# @target: the kind of object that can be queried through the provider. +# +# @stats: list of statistics. +# +# Since: 7.1 +## +{ 'struct': 'StatsSchema', + 'data': { 'provider': 'StatsProvider', + 'target': 'StatsTarget', + 'stats': [ 'StatsSchemaValue' ] } } + +## +# @query-stats-schemas: +# +# Return the schema for all available runtime-collected statistics. +# +# Note: runtime-collected statistics and their names fall outside QEMU's usual +# deprecation policies. QEMU will try to keep the set of available deport 0. Such +# changes, however, are expected to be rare. +# +# Since: 7.1 +## +{ 'command': 'query-stats-schemas', + 'data': { }, + 'returns': [ 'StatsSchema' ] } -- 2.36.1 From patchwork Thu Jun 16 08:31:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gqi2tvJB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwgG3S6Pz9sG0 for ; Thu, 16 Jun 2022 18:43:22 +1000 (AEST) Received: from localhost ([::1]:39288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1l60-0005QW-Aj for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:43:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvO-0001aL-Of for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvL-0002mc-JT for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368339; 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=sbq4y/Uq4UU32oaY8kPADTiD4d/5TcWI3vybct7qkRc=; b=gqi2tvJB8q4XpCetGOyCE3GVvuvJ5CQ9/XC5O6UTQydqTH9yqrFUr5xpG2TNmhAnG/5D6n E7bxaPuNDAuwTDcaP4T0VmI6EOzoHBYxEYt8A69QU6kl+0LzfQklvou9Wb5TMlfy+afhUa GH+yXxM4efLwDIWYDpzMRx/t9BZkRWA= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-Pp49Z13OMOapuWqyIEC0jw-1; Thu, 16 Jun 2022 04:32:17 -0400 X-MC-Unique: Pp49Z13OMOapuWqyIEC0jw-1 Received: by mail-ed1-f70.google.com with SMTP id o2-20020a056402438200b00434ec3efc03so765820edc.9 for ; Thu, 16 Jun 2022 01:32:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sbq4y/Uq4UU32oaY8kPADTiD4d/5TcWI3vybct7qkRc=; b=KrkrUSF48InLP60J6U5WQxnxlt0pGmylGJHJWL68w0E/kwegAU09DLsTikEWmj/yMO yGVe6X2ZY7L1tHGJ+fIyyYWmSJJOZPjFvypjq6kjvL86VEex+kw1nhvyyZTL3x6DLAxP PU2a+bmKyaumZfxij9T67viwzWYmeVQzbEsy6edrx5BdCkY8Fck9CeoueYIza0ahJedp SWBWktBnyvc36oBArJ20iYcvXk+Q6ZgdL2Coevrg/3G+TJFoVLQCVIfx1qcm/Jxc3rek vma+gsfftzVOLQz3fruVWh8iuGmYFzvc9vfmOFVXkuvFPXTXi2XlAqYRk67e3inaL+qa rFQA== X-Gm-Message-State: AJIora8qhsSVB745Ay3DbqlQVrH3YyyuoQbgP8pPs5hZuGEF3yNxAGqC ymQN08UroMST+8J6I7ppgU/8jllbJCc9Uz5a0pU7bTqlACgHk7Y8svWvEB8X/ptBHtYGPEPaKaI RYv/mS4Nmvkp92HPYm4ezTGQ/xz0pXS84HUCLYnG0WJ3BRRfCcOmT+kh20IAyVgFTsNM= X-Received: by 2002:a05:6402:430f:b0:42e:2a86:abaf with SMTP id m15-20020a056402430f00b0042e2a86abafmr4839941edc.194.1655368335924; Thu, 16 Jun 2022 01:32:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s5XsncGEafQUQJGQ1vnGYg3OS7UQ8V/OtZlNbuaP3PxcqFM3/EpXFxaOSCGr3S33/CEsGx2Q== X-Received: by 2002:a05:6402:430f:b0:42e:2a86:abaf with SMTP id m15-20020a056402430f00b0042e2a86abafmr4839910edc.194.1655368335521; Thu, 16 Jun 2022 01:32:15 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id w9-20020a170906b18900b006fec27575f1sm480970ejy.123.2022.06.16.01.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Mark Kanda Subject: [PULL 02/21] kvm: Support for querying fd-based stats Date: Thu, 16 Jun 2022 10:31:50 +0200 Message-Id: <20220616083209.117397-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Kanda Add support for querying fd-based KVM stats - as introduced by Linux kernel commit: cb082bfab59a ("KVM: stats: Add fd-based API to read binary stats data") This allows the user to analyze the behavior of the VM without access to debugfs. Signed-off-by: Mark Kanda Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 392 ++++++++++++++++++++++++++++++++++++++++++++ qapi/stats.json | 2 +- 2 files changed, 393 insertions(+), 1 deletion(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index a4c4863f53..7cc9e33bab 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -47,6 +47,7 @@ #include "kvm-cpus.h" #include "hw/boards.h" +#include "monitor/stats.h" /* This check must be after config-host.h is included */ #ifdef CONFIG_EVENTFD @@ -2310,6 +2311,9 @@ bool kvm_dirty_ring_enabled(void) return kvm_state->kvm_dirty_ring_size ? true : false; } +static void query_stats_cb(StatsResultList **result, StatsTarget target, Error **errp); +static void query_stats_schemas_cb(StatsSchemaList **result, Error **errp); + static int kvm_init(MachineState *ms) { MachineClass *mc = MACHINE_GET_CLASS(ms); @@ -2638,6 +2642,10 @@ static int kvm_init(MachineState *ms) } } + if (kvm_check_extension(kvm_state, KVM_CAP_BINARY_STATS_FD)) { + add_stats_callbacks(query_stats_cb, query_stats_schemas_cb); + } + return 0; err: @@ -3697,3 +3705,387 @@ static void kvm_type_init(void) } type_init(kvm_type_init); + +typedef struct StatsArgs { + union StatsResultsType { + StatsResultList **stats; + StatsSchemaList **schema; + } result; + Error **errp; +} StatsArgs; + +static StatsList *add_kvmstat_entry(struct kvm_stats_desc *pdesc, + uint64_t *stats_data, + StatsList *stats_list, + Error **errp) +{ + + Stats *stats; + uint64List *val_list = NULL; + + /* Only add stats that we understand. */ + switch (pdesc->flags & KVM_STATS_TYPE_MASK) { + case KVM_STATS_TYPE_CUMULATIVE: + case KVM_STATS_TYPE_INSTANT: + case KVM_STATS_TYPE_PEAK: + case KVM_STATS_TYPE_LINEAR_HIST: + case KVM_STATS_TYPE_LOG_HIST: + break; + default: + return stats_list; + } + + switch (pdesc->flags & KVM_STATS_UNIT_MASK) { + case KVM_STATS_UNIT_NONE: + case KVM_STATS_UNIT_BYTES: + case KVM_STATS_UNIT_CYCLES: + case KVM_STATS_UNIT_SECONDS: + break; + default: + return stats_list; + } + + switch (pdesc->flags & KVM_STATS_BASE_MASK) { + case KVM_STATS_BASE_POW10: + case KVM_STATS_BASE_POW2: + break; + default: + return stats_list; + } + + /* Alloc and populate data list */ + stats = g_new0(Stats, 1); + stats->name = g_strdup(pdesc->name); + stats->value = g_new0(StatsValue, 1);; + + if (pdesc->size == 1) { + stats->value->u.scalar = *stats_data; + stats->value->type = QTYPE_QNUM; + } else { + int i; + for (i = 0; i < pdesc->size; i++) { + QAPI_LIST_PREPEND(val_list, stats_data[i]); + } + stats->value->u.list = val_list; + stats->value->type = QTYPE_QLIST; + } + + QAPI_LIST_PREPEND(stats_list, stats); + return stats_list; +} + +static StatsSchemaValueList *add_kvmschema_entry(struct kvm_stats_desc *pdesc, + StatsSchemaValueList *list, + Error **errp) +{ + StatsSchemaValueList *schema_entry = g_new0(StatsSchemaValueList, 1); + schema_entry->value = g_new0(StatsSchemaValue, 1); + + switch (pdesc->flags & KVM_STATS_TYPE_MASK) { + case KVM_STATS_TYPE_CUMULATIVE: + schema_entry->value->type = STATS_TYPE_CUMULATIVE; + break; + case KVM_STATS_TYPE_INSTANT: + schema_entry->value->type = STATS_TYPE_INSTANT; + break; + case KVM_STATS_TYPE_PEAK: + schema_entry->value->type = STATS_TYPE_PEAK; + break; + case KVM_STATS_TYPE_LINEAR_HIST: + schema_entry->value->type = STATS_TYPE_LINEAR_HISTOGRAM; + schema_entry->value->bucket_size = pdesc->bucket_size; + schema_entry->value->has_bucket_size = true; + break; + case KVM_STATS_TYPE_LOG_HIST: + schema_entry->value->type = STATS_TYPE_LOG2_HISTOGRAM; + break; + default: + goto exit; + } + + switch (pdesc->flags & KVM_STATS_UNIT_MASK) { + case KVM_STATS_UNIT_NONE: + break; + case KVM_STATS_UNIT_BYTES: + schema_entry->value->has_unit = true; + schema_entry->value->unit = STATS_UNIT_BYTES; + break; + case KVM_STATS_UNIT_CYCLES: + schema_entry->value->has_unit = true; + schema_entry->value->unit = STATS_UNIT_CYCLES; + break; + case KVM_STATS_UNIT_SECONDS: + schema_entry->value->has_unit = true; + schema_entry->value->unit = STATS_UNIT_SECONDS; + break; + default: + goto exit; + } + + schema_entry->value->exponent = pdesc->exponent; + if (pdesc->exponent) { + switch (pdesc->flags & KVM_STATS_BASE_MASK) { + case KVM_STATS_BASE_POW10: + schema_entry->value->has_base = true; + schema_entry->value->base = 10; + break; + case KVM_STATS_BASE_POW2: + schema_entry->value->has_base = true; + schema_entry->value->base = 2; + break; + default: + goto exit; + } + } + + schema_entry->value->name = g_strdup(pdesc->name); + schema_entry->next = list; + return schema_entry; +exit: + g_free(schema_entry->value); + g_free(schema_entry); + return list; +} + +/* Cached stats descriptors */ +typedef struct StatsDescriptors { + const char *ident; /* cache key, currently the StatsTarget */ + struct kvm_stats_desc *kvm_stats_desc; + struct kvm_stats_header *kvm_stats_header; + QTAILQ_ENTRY(StatsDescriptors) next; +} StatsDescriptors; + +static QTAILQ_HEAD(, StatsDescriptors) stats_descriptors = + QTAILQ_HEAD_INITIALIZER(stats_descriptors); + +/* + * Return the descriptors for 'target', that either have already been read + * or are retrieved from 'stats_fd'. + */ +static StatsDescriptors *find_stats_descriptors(StatsTarget target, int stats_fd, + Error **errp) +{ + StatsDescriptors *descriptors; + const char *ident; + struct kvm_stats_desc *kvm_stats_desc; + struct kvm_stats_header *kvm_stats_header; + size_t size_desc; + ssize_t ret; + + ident = StatsTarget_str(target); + QTAILQ_FOREACH(descriptors, &stats_descriptors, next) { + if (g_str_equal(descriptors->ident, ident)) { + return descriptors; + } + } + + descriptors = g_new0(StatsDescriptors, 1); + + /* Read stats header */ + kvm_stats_header = g_malloc(sizeof(*kvm_stats_header)); + ret = read(stats_fd, kvm_stats_header, sizeof(*kvm_stats_header)); + if (ret != sizeof(*kvm_stats_header)) { + error_setg(errp, "KVM stats: failed to read stats header: " + "expected %zu actual %zu", + sizeof(*kvm_stats_header), ret); + return NULL; + } + size_desc = sizeof(*kvm_stats_desc) + kvm_stats_header->name_size; + + /* Read stats descriptors */ + kvm_stats_desc = g_malloc0_n(kvm_stats_header->num_desc, size_desc); + ret = pread(stats_fd, kvm_stats_desc, + size_desc * kvm_stats_header->num_desc, + kvm_stats_header->desc_offset); + + if (ret != size_desc * kvm_stats_header->num_desc) { + error_setg(errp, "KVM stats: failed to read stats descriptors: " + "expected %zu actual %zu", + size_desc * kvm_stats_header->num_desc, ret); + g_free(descriptors); + g_free(kvm_stats_desc); + return NULL; + } + descriptors->kvm_stats_header = kvm_stats_header; + descriptors->kvm_stats_desc = kvm_stats_desc; + descriptors->ident = ident; + QTAILQ_INSERT_TAIL(&stats_descriptors, descriptors, next); + return descriptors; +} + +static void query_stats(StatsResultList **result, StatsTarget target, + int stats_fd, Error **errp) +{ + struct kvm_stats_desc *kvm_stats_desc; + struct kvm_stats_header *kvm_stats_header; + StatsDescriptors *descriptors; + g_autofree uint64_t *stats_data = NULL; + struct kvm_stats_desc *pdesc; + StatsList *stats_list = NULL; + size_t size_desc, size_data = 0; + ssize_t ret; + int i; + + descriptors = find_stats_descriptors(target, stats_fd, errp); + if (!descriptors) { + return; + } + + kvm_stats_header = descriptors->kvm_stats_header; + kvm_stats_desc = descriptors->kvm_stats_desc; + size_desc = sizeof(*kvm_stats_desc) + kvm_stats_header->name_size; + + /* Tally the total data size; read schema data */ + for (i = 0; i < kvm_stats_header->num_desc; ++i) { + pdesc = (void *)kvm_stats_desc + i * size_desc; + size_data += pdesc->size * sizeof(*stats_data); + } + + stats_data = g_malloc0(size_data); + ret = pread(stats_fd, stats_data, size_data, kvm_stats_header->data_offset); + + if (ret != size_data) { + error_setg(errp, "KVM stats: failed to read data: " + "expected %zu actual %zu", size_data, ret); + return; + } + + for (i = 0; i < kvm_stats_header->num_desc; ++i) { + uint64_t *stats; + pdesc = (void *)kvm_stats_desc + i * size_desc; + + /* Add entry to the list */ + stats = (void *)stats_data + pdesc->offset; + stats_list = add_kvmstat_entry(pdesc, stats, stats_list, errp); + } + + if (!stats_list) { + return; + } + + switch (target) { + case STATS_TARGET_VM: + add_stats_entry(result, STATS_PROVIDER_KVM, NULL, stats_list); + break; + case STATS_TARGET_VCPU: + add_stats_entry(result, STATS_PROVIDER_KVM, + current_cpu->parent_obj.canonical_path, + stats_list); + break; + default: + break; + } +} + +static void query_stats_schema(StatsSchemaList **result, StatsTarget target, + int stats_fd, Error **errp) +{ + struct kvm_stats_desc *kvm_stats_desc; + struct kvm_stats_header *kvm_stats_header; + StatsDescriptors *descriptors; + struct kvm_stats_desc *pdesc; + StatsSchemaValueList *stats_list = NULL; + size_t size_desc; + int i; + + descriptors = find_stats_descriptors(target, stats_fd, errp); + if (!descriptors) { + return; + } + + kvm_stats_header = descriptors->kvm_stats_header; + kvm_stats_desc = descriptors->kvm_stats_desc; + size_desc = sizeof(*kvm_stats_desc) + kvm_stats_header->name_size; + + /* Tally the total data size; read schema data */ + for (i = 0; i < kvm_stats_header->num_desc; ++i) { + pdesc = (void *)kvm_stats_desc + i * size_desc; + stats_list = add_kvmschema_entry(pdesc, stats_list, errp); + } + + add_stats_schema(result, STATS_PROVIDER_KVM, target, stats_list); +} + +static void query_stats_vcpu(CPUState *cpu, run_on_cpu_data data) +{ + StatsArgs *kvm_stats_args = (StatsArgs *) data.host_ptr; + int stats_fd = kvm_vcpu_ioctl(cpu, KVM_GET_STATS_FD, NULL); + Error *local_err = NULL; + + if (stats_fd == -1) { + error_setg_errno(&local_err, errno, "KVM stats: ioctl failed"); + error_propagate(kvm_stats_args->errp, local_err); + return; + } + query_stats(kvm_stats_args->result.stats, STATS_TARGET_VCPU, stats_fd, + kvm_stats_args->errp); + close(stats_fd); +} + +static void query_stats_schema_vcpu(CPUState *cpu, run_on_cpu_data data) +{ + StatsArgs *kvm_stats_args = (StatsArgs *) data.host_ptr; + int stats_fd = kvm_vcpu_ioctl(cpu, KVM_GET_STATS_FD, NULL); + Error *local_err = NULL; + + if (stats_fd == -1) { + error_setg_errno(&local_err, errno, "KVM stats: ioctl failed"); + error_propagate(kvm_stats_args->errp, local_err); + return; + } + query_stats_schema(kvm_stats_args->result.schema, STATS_TARGET_VCPU, stats_fd, + kvm_stats_args->errp); + close(stats_fd); +} + +static void query_stats_cb(StatsResultList **result, StatsTarget target, Error **errp) +{ + KVMState *s = kvm_state; + CPUState *cpu; + int stats_fd; + + switch (target) { + case STATS_TARGET_VM: + { + stats_fd = kvm_vm_ioctl(s, KVM_GET_STATS_FD, NULL); + if (stats_fd == -1) { + error_setg_errno(errp, errno, "KVM stats: ioctl failed"); + return; + } + query_stats(result, target, stats_fd, errp); + close(stats_fd); + break; + } + case STATS_TARGET_VCPU: + { + StatsArgs stats_args; + stats_args.result.stats = result; + stats_args.errp = errp; + CPU_FOREACH(cpu) { + run_on_cpu(cpu, query_stats_vcpu, RUN_ON_CPU_HOST_PTR(&stats_args)); + } + break; + } + default: + break; + } +} + +void query_stats_schemas_cb(StatsSchemaList **result, Error **errp) +{ + StatsArgs stats_args; + KVMState *s = kvm_state; + int stats_fd; + + stats_fd = kvm_vm_ioctl(s, KVM_GET_STATS_FD, NULL); + if (stats_fd == -1) { + error_setg_errno(errp, errno, "KVM stats: ioctl failed"); + return; + } + query_stats_schema(result, STATS_TARGET_VM, stats_fd, errp); + close(stats_fd); + + stats_args.result.schema = result; + stats_args.errp = errp; + run_on_cpu(first_cpu, query_stats_schema_vcpu, RUN_ON_CPU_HOST_PTR(&stats_args)); +} diff --git a/qapi/stats.json b/qapi/stats.json index ada0fbf26f..df7c4d886c 100644 --- a/qapi/stats.json +++ b/qapi/stats.json @@ -52,7 +52,7 @@ # Since: 7.1 ## { 'enum': 'StatsProvider', - 'data': [ ] } + 'data': [ 'kvm' ] } ## # @StatsTarget: From patchwork Thu Jun 16 08:31:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NQPQp6JC; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwSy1y8hz9sG0 for ; Thu, 16 Jun 2022 18:34:24 +1000 (AEST) Received: from localhost ([::1]:50412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1kxJ-0001c7-Mi for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:34:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvR-0001az-95 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33564) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvO-0002ne-HO for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368341; 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=SYBRYiawYtP09jyU7ci5CXeY5D1qb2ObZJkrD/tnmFg=; b=NQPQp6JCXKfMB6a+6cgrP8x54yCsXB0OqP/kI67e+mM94w7iujrdIdQe/tjnbvsge7bdhy p4OZ0ooWU1wapiLTEzuqJSawY8s2Io9JMWmh+wvNSLe9l4JxRejuoHWHOo+qyp4+waCXwa 0xrT6DWNGOLYchbQBpBjAE0Rl1VsYSc= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-0tJRGMcVNwmri-IkR7da2A-1; Thu, 16 Jun 2022 04:32:19 -0400 X-MC-Unique: 0tJRGMcVNwmri-IkR7da2A-1 Received: by mail-ed1-f69.google.com with SMTP id cy18-20020a0564021c9200b0042dc7b4f36fso776788edb.4 for ; Thu, 16 Jun 2022 01:32:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SYBRYiawYtP09jyU7ci5CXeY5D1qb2ObZJkrD/tnmFg=; b=CzUYeUwHYsJc8YTL3+o2wN4vw5zRTs6Oav6eG9PhknLhojA0sj4+M29fxhlDXYmJIC 6etjRQ9IIBX48dUMZL4Ky+XJHqG745uXrfYK7P+ia+wm9yNz6UdD2ZWpvnEP5x81EM4f /izxWh/9iIN+asl0dO8VP3ssWbpy4H+hYQ+INo1JsstC9uxT7XitTHw9snOCoJGYDTwD G4GIBHGoUQjAycyeFIQ2SLKv+xyj861yiQM1pfQWAffGiE9VMSz4+5aj69yebRzE8EJ7 CQKoGdqzXVlTTv3wdTa6F4RU/IuOpGC40dDnBxcUHwPUmwqXpPzlOIoj8QGzvK1hQW2Y JMAw== X-Gm-Message-State: AJIora9Z/wnldvKZrtlga5bCHogtQ8sJl9j9V5oK+QgBg9Wblluo/0AL tkv94d15qgfPpkUFdus055ladhssdnMdYngM5H+8HzzK4CUcZYovvwbFPHv/mPH9nERDTJ3jGGL VMhwQReTjY49V3ybwYlYjKzgVDatu8U59jl+Qi2QmzfF5dNewydwyW3TWjtggRpNTnzo= X-Received: by 2002:a17:906:72cf:b0:712:20aa:46c7 with SMTP id m15-20020a17090672cf00b0071220aa46c7mr3392422ejl.768.1655368338278; Thu, 16 Jun 2022 01:32:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tL4EtWeFyxV24Vsg9Fn0EMRtoBqVNno0SIa7pWTcqHzRpUT7xPIPMVqEcxaLXj70+Bi7yuPw== X-Received: by 2002:a17:906:72cf:b0:712:20aa:46c7 with SMTP id m15-20020a17090672cf00b0071220aa46c7mr3392407ejl.768.1655368337964; Thu, 16 Jun 2022 01:32:17 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id j4-20020a50ed04000000b004318ba244dcsm1291058eds.10.2022.06.16.01.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Markus Armbruster Subject: [PULL 03/21] qmp: add filtering of statistics by target vCPU Date: Thu, 16 Jun 2022 10:31:51 +0200 Message-Id: <20220616083209.117397-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Introduce a simple filtering of statistics, that allows to retrieve statistics for a subset of the guest vCPUs. This will be used for example by the HMP monitor, in order to retrieve the statistics for the currently selected CPU. Example: { "execute": "query-stats", "arguments": { "target": "vcpu", "vcpus": [ "/machine/unattached/device[2]", "/machine/unattached/device[4]" ] } } Extracted from a patch by Mark Kanda. Reviewed-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 9 +++++++-- include/monitor/stats.h | 11 ++++++++++- monitor/qmp-cmds.c | 34 +++++++++++++++++++++++++++++++++- qapi/stats.json | 24 +++++++++++++++++++----- 4 files changed, 69 insertions(+), 9 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 7cc9e33bab..547de842fd 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2311,7 +2311,8 @@ bool kvm_dirty_ring_enabled(void) return kvm_state->kvm_dirty_ring_size ? true : false; } -static void query_stats_cb(StatsResultList **result, StatsTarget target, Error **errp); +static void query_stats_cb(StatsResultList **result, StatsTarget target, + strList *targets, Error **errp); static void query_stats_schemas_cb(StatsSchemaList **result, Error **errp); static int kvm_init(MachineState *ms) @@ -4038,7 +4039,8 @@ static void query_stats_schema_vcpu(CPUState *cpu, run_on_cpu_data data) close(stats_fd); } -static void query_stats_cb(StatsResultList **result, StatsTarget target, Error **errp) +static void query_stats_cb(StatsResultList **result, StatsTarget target, + strList *targets, Error **errp) { KVMState *s = kvm_state; CPUState *cpu; @@ -4062,6 +4064,9 @@ static void query_stats_cb(StatsResultList **result, StatsTarget target, Error * stats_args.result.stats = result; stats_args.errp = errp; CPU_FOREACH(cpu) { + if (!apply_str_list_filter(cpu->parent_obj.canonical_path, targets)) { + continue; + } run_on_cpu(cpu, query_stats_vcpu, RUN_ON_CPU_HOST_PTR(&stats_args)); } break; diff --git a/include/monitor/stats.h b/include/monitor/stats.h index 912eeadb2f..8c50feeaa9 100644 --- a/include/monitor/stats.h +++ b/include/monitor/stats.h @@ -11,7 +11,7 @@ #include "qapi/qapi-types-stats.h" typedef void StatRetrieveFunc(StatsResultList **result, StatsTarget target, - Error **errp); + strList *targets, Error **errp); typedef void SchemaRetrieveFunc(StatsSchemaList **result, Error **errp); /* @@ -31,4 +31,13 @@ void add_stats_entry(StatsResultList **, StatsProvider, const char *id, void add_stats_schema(StatsSchemaList **, StatsProvider, StatsTarget, StatsSchemaValueList *); +/* + * True if a string matches the filter passed to the stats_fn callabck, + * false otherwise. + * + * Note that an empty list means no filtering, i.e. all strings will + * return true. + */ +bool apply_str_list_filter(const char *string, strList *list); + #endif /* STATS_H */ diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index a6ac8d7473..5f8f1e620b 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -468,9 +468,26 @@ static bool invoke_stats_cb(StatsCallbacks *entry, StatsFilter *filter, Error **errp) { + strList *targets = NULL; ERRP_GUARD(); - entry->stats_cb(stats_results, filter->target, errp); + switch (filter->target) { + case STATS_TARGET_VM: + break; + case STATS_TARGET_VCPU: + if (filter->u.vcpu.has_vcpus) { + if (!filter->u.vcpu.vcpus) { + /* No targets allowed? Return no statistics. */ + return true; + } + targets = filter->u.vcpu.vcpus; + } + break; + default: + abort(); + } + + entry->stats_cb(stats_results, filter->target, targets, errp); if (*errp) { qapi_free_StatsResultList(*stats_results); *stats_results = NULL; @@ -536,3 +553,18 @@ void add_stats_schema(StatsSchemaList **schema_results, entry->stats = stats_list; QAPI_LIST_PREPEND(*schema_results, entry); } + +bool apply_str_list_filter(const char *string, strList *list) +{ + strList *str_list = NULL; + + if (!list) { + return true; + } + for (str_list = list; str_list; str_list = str_list->next) { + if (g_str_equal(string, str_list->value)) { + return true; + } + } + return false; +} diff --git a/qapi/stats.json b/qapi/stats.json index df7c4d886c..8c9abb57f1 100644 --- a/qapi/stats.json +++ b/qapi/stats.json @@ -70,15 +70,29 @@ 'data': [ 'vm', 'vcpu' ] } ## -# @StatsFilter: +# @StatsVCPUFilter: # -# The arguments to the query-stats command; specifies a target for which to -# request statistics. +# @vcpus: list of QOM paths for the desired vCPU objects. # # Since: 7.1 ## -{ 'struct': 'StatsFilter', - 'data': { 'target': 'StatsTarget' } } +{ 'struct': 'StatsVCPUFilter', + 'data': { '*vcpus': [ 'str' ] } } + +## +# @StatsFilter: +# +# The arguments to the query-stats command; specifies a target for which to +# request statistics and optionally the required subset of information for +# that target: +# - which vCPUs to request statistics for +# +# Since: 7.1 +## +{ 'union': 'StatsFilter', + 'base': { 'target': 'StatsTarget' }, + 'discriminator': 'target', + 'data': { 'vcpu': 'StatsVCPUFilter' } } ## # @StatsValue: From patchwork Thu Jun 16 08:31:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eRICxtbk; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwSy25dHz9sGF for ; Thu, 16 Jun 2022 18:34:24 +1000 (AEST) Received: from localhost ([::1]:50468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1kxJ-0001fU-Ns for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:34:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvS-0001b5-G3 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvP-0002o4-D9 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Glh9d8yFY0poxuW4I6ZKFimyvEHRkSEEwBdX8rUliEg=; b=eRICxtbk+EsgE6XwtUyEnD27p4rS8zvRyAPw1flZcco7ts1rDRAu3Xg1UzALX+LlzPZWly Pjhd8fZFrQIAFuHIHDk68kH4A8w1vn3Lu6l3jegpaw/QbscNLRUqEUm00Lfp9TthIYbC2g +7EQlKsYoompCTs7W93klsUtcdrcNQU= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-22-jFPKM1gUOyqN0w3JD_KOPw-1; Thu, 16 Jun 2022 04:32:21 -0400 X-MC-Unique: jFPKM1gUOyqN0w3JD_KOPw-1 Received: by mail-ed1-f70.google.com with SMTP id co13-20020a0564020c0d00b0042dc9ef4f01so751506edb.16 for ; Thu, 16 Jun 2022 01:32:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Glh9d8yFY0poxuW4I6ZKFimyvEHRkSEEwBdX8rUliEg=; b=wRXtojfAseo+vCCMsglStXgoZTN9DRc0W8sxz7OUhK4A3gZLs6VdloX//OTSNHXH8S WYVSxTRgbjsYZipT1EfYBCuTjFd1DuQSJ2u1Fp/EYonU2CNdGZLnu6L5HJJXutUTw6wZ V/XORWV6RV8waaFT3PnyG2ExIMs7lWmaYzmCeGEMzXv6gFheR9YHWRisSV7lPqMm7h2P gu4yq8YqIRgVP0OrblcnU7a8TA2KrlDl1gy/p/0y0biAiUEG73A686KVa/zIUNkj4ObK kJownLcKs5VIKVLLI7aAt7qP791ME3Uo3NhE3Pbl1ScgW/CXo/hIUvL+A6Sx9dTcBGfy 5QMA== X-Gm-Message-State: AJIora9U1o7BeIKyAiT8SoI/3o1ioci26zENzlhhU0QVH+pJnR/95o3O fp3tnB1ywSIE/DZsth9/J9r/mJLUsUJfuKGe0TLmYg40MuNeQu72ZFpNA6isgEkh3P23ZPf9ZEg QqVdQu+HE2zBebkDkOPX9+8wb1quEaFNE52CJv1DVVlR8iljnoH9NgMZHvTEXo5swSoo= X-Received: by 2002:a05:6402:378a:b0:431:6d8d:9023 with SMTP id et10-20020a056402378a00b004316d8d9023mr4854965edb.98.1655368339882; Thu, 16 Jun 2022 01:32:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uahxKBS/3n2nOO/dFNBEkSOxNWwTY9B8rB0ZATTOJ9v1Df/S1NMarqbSuKG86wqQwNhBQ63w== X-Received: by 2002:a05:6402:378a:b0:431:6d8d:9023 with SMTP id et10-20020a056402378a00b004316d8d9023mr4854934edb.98.1655368339438; Thu, 16 Jun 2022 01:32:19 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id z6-20020a05640235c600b0043158c608e4sm1325225edc.27.2022.06.16.01.32.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/21] cutils: add functions for IEC and SI prefixes Date: Thu, 16 Jun 2022 10:31:52 +0200 Message-Id: <20220616083209.117397-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Extract the knowledge of IEC and SI prefixes out of size_to_str and freq_to_str, so that it can be reused when printing statistics. Signed-off-by: Paolo Bonzini --- include/qemu/cutils.h | 18 ++++++++++++++ tests/unit/test-cutils.c | 52 ++++++++++++++++++++++++++++++++++++++++ util/cutils.c | 34 +++++++++++++++++++------- 3 files changed, 95 insertions(+), 9 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 40e10e19a7..d3e532b64c 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -1,6 +1,24 @@ #ifndef QEMU_CUTILS_H #define QEMU_CUTILS_H +/* + * si_prefix: + * @exp10: exponent of 10, a multiple of 3 between -18 and 18 inclusive. + * + * Return a SI prefix (n, u, m, K, M, etc.) corresponding + * to the given exponent of 10. + */ +const char *si_prefix(unsigned int exp10); + +/* + * iec_binary_prefix: + * @exp2: exponent of 2, a multiple of 10 between 0 and 60 inclusive. + * + * Return an IEC binary prefix (Ki, Mi, etc.) corresponding + * to the given exponent of 2. + */ +const char *iec_binary_prefix(unsigned int exp2); + /** * pstrcpy: * @buf: buffer to copy string into diff --git a/tests/unit/test-cutils.c b/tests/unit/test-cutils.c index 98671f1ac3..f5b780f012 100644 --- a/tests/unit/test-cutils.c +++ b/tests/unit/test-cutils.c @@ -2450,6 +2450,50 @@ static void test_qemu_strtosz_metric(void) g_assert(endptr == str + 7); } +static void test_freq_to_str(void) +{ + g_assert_cmpstr(freq_to_str(999), ==, "999 Hz"); + g_assert_cmpstr(freq_to_str(1000), ==, "1 KHz"); + g_assert_cmpstr(freq_to_str(1010), ==, "1.01 KHz"); +} + +static void test_size_to_str(void) +{ + g_assert_cmpstr(size_to_str(0), ==, "0 B"); + g_assert_cmpstr(size_to_str(1), ==, "1 B"); + g_assert_cmpstr(size_to_str(1016), ==, "0.992 KiB"); + g_assert_cmpstr(size_to_str(1024), ==, "1 KiB"); + g_assert_cmpstr(size_to_str(512ull << 20), ==, "512 MiB"); +} + +static void test_iec_binary_prefix(void) +{ + g_assert_cmpstr(iec_binary_prefix(0), ==, ""); + g_assert_cmpstr(iec_binary_prefix(10), ==, "Ki"); + g_assert_cmpstr(iec_binary_prefix(20), ==, "Mi"); + g_assert_cmpstr(iec_binary_prefix(30), ==, "Gi"); + g_assert_cmpstr(iec_binary_prefix(40), ==, "Ti"); + g_assert_cmpstr(iec_binary_prefix(50), ==, "Pi"); + g_assert_cmpstr(iec_binary_prefix(60), ==, "Ei"); +} + +static void test_si_prefix(void) +{ + g_assert_cmpstr(si_prefix(-18), ==, "a"); + g_assert_cmpstr(si_prefix(-15), ==, "f"); + g_assert_cmpstr(si_prefix(-12), ==, "p"); + g_assert_cmpstr(si_prefix(-9), ==, "n"); + g_assert_cmpstr(si_prefix(-6), ==, "u"); + g_assert_cmpstr(si_prefix(-3), ==, "m"); + g_assert_cmpstr(si_prefix(0), ==, ""); + g_assert_cmpstr(si_prefix(3), ==, "K"); + g_assert_cmpstr(si_prefix(6), ==, "M"); + g_assert_cmpstr(si_prefix(9), ==, "G"); + g_assert_cmpstr(si_prefix(12), ==, "T"); + g_assert_cmpstr(si_prefix(15), ==, "P"); + g_assert_cmpstr(si_prefix(18), ==, "E"); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -2729,5 +2773,13 @@ int main(int argc, char **argv) g_test_add_func("/cutils/strtosz/metric", test_qemu_strtosz_metric); + g_test_add_func("/cutils/size_to_str", + test_size_to_str); + g_test_add_func("/cutils/freq_to_str", + test_freq_to_str); + g_test_add_func("/cutils/iec_binary_prefix", + test_iec_binary_prefix); + g_test_add_func("/cutils/si_prefix", + test_si_prefix); return g_test_run(); } diff --git a/util/cutils.c b/util/cutils.c index a58bcfd80e..6d04e52907 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -872,6 +872,25 @@ int parse_debug_env(const char *name, int max, int initial) return debug; } +const char *si_prefix(unsigned int exp10) +{ + static const char *prefixes[] = { + "a", "f", "p", "n", "u", "m", "", "K", "M", "G", "T", "P", "E" + }; + + exp10 += 18; + assert(exp10 % 3 == 0 && exp10 / 3 < ARRAY_SIZE(prefixes)); + return prefixes[exp10 / 3]; +} + +const char *iec_binary_prefix(unsigned int exp2) +{ + static const char *prefixes[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei" }; + + assert(exp2 % 10 == 0 && exp2 / 10 < ARRAY_SIZE(prefixes)); + return prefixes[exp2 / 10]; +} + /* * Return human readable string for size @val. * @val can be anything that uint64_t allows (no more than "16 EiB"). @@ -880,7 +899,6 @@ int parse_debug_env(const char *name, int max, int initial) */ char *size_to_str(uint64_t val) { - static const char *suffixes[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei" }; uint64_t div; int i; @@ -891,25 +909,23 @@ char *size_to_str(uint64_t val) * (see e41b509d68afb1f for more info) */ frexp(val / (1000.0 / 1024.0), &i); - i = (i - 1) / 10; - div = 1ULL << (i * 10); + i = (i - 1) / 10 * 10; + div = 1ULL << i; - return g_strdup_printf("%0.3g %sB", (double)val / div, suffixes[i]); + return g_strdup_printf("%0.3g %sB", (double)val / div, iec_binary_prefix(i)); } char *freq_to_str(uint64_t freq_hz) { - static const char *const suffixes[] = { "", "K", "M", "G", "T", "P", "E" }; double freq = freq_hz; - size_t idx = 0; + size_t exp10 = 0; while (freq >= 1000.0) { freq /= 1000.0; - idx++; + exp10 += 3; } - assert(idx < ARRAY_SIZE(suffixes)); - return g_strdup_printf("%0.3g %sHz", freq, suffixes[idx]); + return g_strdup_printf("%0.3g %sHz", freq, si_prefix(exp10)); } int qemu_pstrcmp0(const char **str1, const char **str2) From patchwork Thu Jun 16 08:31:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644200 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZwYQh0Ll; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwZh09LFz9sG0 for ; Thu, 16 Jun 2022 18:39:23 +1000 (AEST) Received: from localhost ([::1]:59130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1l29-0007gI-Hm for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:39:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvU-0001bk-Sp for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvS-0002ov-6i for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368344; 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=6adHh8A0c0VJAWmBKS01WwbcdCA2rGuJLJ+le4u0rGs=; b=ZwYQh0Ll/HgtFJWkL9vJXkUhLdHhGsXE1iJ5pfzqRMORLgB13eCIF+nfSRR5UVtppby9mQ WRHxiY/k5hgBHKM9iEVZAZix7ly6OGn5di3JhKKpYcdbZ2Luea43Y4RY52wS8fl+omVGhq X1vySOdNH4HHxNTzUWKME+mqou+cuqI= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-88-bWuxKUisMe2FhSdb_XQ18g-1; Thu, 16 Jun 2022 04:32:23 -0400 X-MC-Unique: bWuxKUisMe2FhSdb_XQ18g-1 Received: by mail-ed1-f69.google.com with SMTP id j4-20020aa7ca44000000b0042dd12a7bc5so754261edt.13 for ; Thu, 16 Jun 2022 01:32:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6adHh8A0c0VJAWmBKS01WwbcdCA2rGuJLJ+le4u0rGs=; b=fEHu2BgzEwrENc+XKsFFDLg8UDIEZKIgyPCgwRNkfd1KsdsjOvspHnM2xe57hs0b9V /vt6E4VE6okHhAslvHZbC9I2LbKzoukQNQlTLOZlmH69R94VKlvViCxlp4dQn+wPZChW KUXIjAqL9VAb9uVizLWmWMEX71M7d2DKp+kAwTlUfxQWyWgVrL9zDl0zwdroak5jgtDL V1UDVY5qbxh6W9+aCMT1exdPvLk2h0Dlx3CZSkLLrbvX6CmZfemPpR+r3I5CRvzBn1ze 1JBQDWlT49CUApcWljsta3SyAVgBde1Q70A7QpfqGA/zs5Tsws9M+Ml5B/fBRQlIyG3f MxPw== X-Gm-Message-State: AJIora/YRRutVFYxAj7xcYwDBa6mnzHerZin3++t/HEOWnBbBq79hRDf 2AHdEAWOcB9ScQIJLJ6UbohJztY2DPwT4Jv6RdyV1Ljk6hOC/Ih1F5t58GIFr/sKFoAG5j00teU p4ymQ7G/496DEnvGz8BgovBhU0mbdE3wzpbdOvBB61BM0LFlHaT3FEjza39nuWXyx5gk= X-Received: by 2002:a17:906:c154:b0:711:ce44:a0a0 with SMTP id dp20-20020a170906c15400b00711ce44a0a0mr3545937ejc.420.1655368341669; Thu, 16 Jun 2022 01:32:21 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tULrqz5a36nDxJYA4hml840sNNN2miS7vW9eSgokr7xmMHFKWc2+BbI+rmgUl910MxYpqjAA== X-Received: by 2002:a17:906:c154:b0:711:ce44:a0a0 with SMTP id dp20-20020a170906c15400b00711ce44a0a0mr3545917ejc.420.1655368341370; Thu, 16 Jun 2022 01:32:21 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id 18-20020a170906211200b006fea43db5c1sm503358ejt.21.2022.06.16.01.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Mark Kanda , "Dr . David Alan Gilbert" Subject: [PULL 05/21] hmp: add basic "info stats" implementation Date: Thu, 16 Jun 2022 10:31:53 +0200 Message-Id: <20220616083209.117397-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Mark Kanda Add an HMP command to retrieve statistics collected at run-time. The command will retrieve and print either all VM-level statistics, or all vCPU-level statistics for the currently selected CPU. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 13 +++ include/monitor/hmp.h | 1 + monitor/hmp-cmds.c | 190 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 834bed089e..28757768f7 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -894,3 +894,16 @@ SRST ``info via`` Show guest mos6522 VIA devices. ERST + + { + .name = "stats", + .args_type = "target:s", + .params = "target", + .help = "show statistics; target is either vm or vcpu", + .cmd = hmp_info_stats, + }, + +SRST + ``stats`` + Show runtime-collected statistics +ERST diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 96d014826a..2e89a97bd6 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -133,5 +133,6 @@ void hmp_info_dirty_rate(Monitor *mon, const QDict *qdict); void hmp_calc_dirty_rate(Monitor *mon, const QDict *qdict); void hmp_human_readable_text_helper(Monitor *mon, HumanReadableText *(*qmp_handler)(Error **)); +void hmp_info_stats(Monitor *mon, const QDict *qdict); #endif diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 622c783c32..04d5ee8fb7 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -40,6 +40,7 @@ #include "qapi/qapi-commands-pci.h" #include "qapi/qapi-commands-rocker.h" #include "qapi/qapi-commands-run-state.h" +#include "qapi/qapi-commands-stats.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qapi-visit-net.h" @@ -52,6 +53,7 @@ #include "ui/console.h" #include "qemu/cutils.h" #include "qemu/error-report.h" +#include "hw/core/cpu.h" #include "hw/intc/intc.h" #include "migration/snapshot.h" #include "migration/misc.h" @@ -2239,3 +2241,191 @@ void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict) } hmp_handle_error(mon, err); } + +static void print_stats_schema_value(Monitor *mon, StatsSchemaValue *value) +{ + const char *unit = NULL; + monitor_printf(mon, " %s (%s%s", value->name, StatsType_str(value->type), + value->has_unit || value->exponent ? ", " : ""); + + if (value->has_unit) { + if (value->unit == STATS_UNIT_SECONDS) { + unit = "s"; + } else if (value->unit == STATS_UNIT_BYTES) { + unit = "B"; + } + } + + if (unit && value->base == 10 && + value->exponent >= -18 && value->exponent <= 18 && + value->exponent % 3 == 0) { + monitor_printf(mon, "%s", si_prefix(value->exponent)); + } else if (unit && value->base == 2 && + value->exponent >= 0 && value->exponent <= 60 && + value->exponent % 10 == 0) { + + monitor_printf(mon, "%s", iec_binary_prefix(value->exponent)); + } else if (value->exponent) { + /* Use exponential notation and write the unit's English name */ + monitor_printf(mon, "* %d^%d%s", + value->base, value->exponent, + value->has_unit ? " " : ""); + unit = NULL; + } + + if (value->has_unit) { + monitor_printf(mon, "%s", unit ? unit : StatsUnit_str(value->unit)); + } + + /* Print bucket size for linear histograms */ + if (value->type == STATS_TYPE_LINEAR_HISTOGRAM && value->has_bucket_size) { + monitor_printf(mon, ", bucket size=%d", value->bucket_size); + } + monitor_printf(mon, ")"); +} + +static StatsSchemaValueList *find_schema_value_list( + StatsSchemaList *list, StatsProvider provider, + StatsTarget target) +{ + StatsSchemaList *node; + + for (node = list; node; node = node->next) { + if (node->value->provider == provider && + node->value->target == target) { + return node->value->stats; + } + } + return NULL; +} + +static void print_stats_results(Monitor *mon, StatsTarget target, + StatsResult *result, + StatsSchemaList *schema) +{ + /* Find provider schema */ + StatsSchemaValueList *schema_value_list = + find_schema_value_list(schema, result->provider, target); + StatsList *stats_list; + + if (!schema_value_list) { + monitor_printf(mon, "failed to find schema list for %s\n", + StatsProvider_str(result->provider)); + return; + } + + monitor_printf(mon, "provider: %s\n", + StatsProvider_str(result->provider)); + + for (stats_list = result->stats; stats_list; + stats_list = stats_list->next, + schema_value_list = schema_value_list->next) { + + Stats *stats = stats_list->value; + StatsValue *stats_value = stats->value; + StatsSchemaValue *schema_value = schema_value_list->value; + + /* Find schema entry */ + while (!g_str_equal(stats->name, schema_value->name)) { + if (!schema_value_list->next) { + monitor_printf(mon, "failed to find schema entry for %s\n", + stats->name); + return; + } + schema_value_list = schema_value_list->next; + schema_value = schema_value_list->value; + } + + print_stats_schema_value(mon, schema_value); + + if (stats_value->type == QTYPE_QNUM) { + monitor_printf(mon, ": %" PRId64 "\n", stats_value->u.scalar); + } else if (stats_value->type == QTYPE_QLIST) { + uint64List *list; + int i; + + monitor_printf(mon, ": "); + for (list = stats_value->u.list, i = 1; + list; + list = list->next, i++) { + monitor_printf(mon, "[%d]=%" PRId64 " ", i, list->value); + } + monitor_printf(mon, "\n"); + } + } +} + +/* Create the StatsFilter that is needed for an "info stats" invocation. */ +static StatsFilter *stats_filter(StatsTarget target, int cpu_index) +{ + StatsFilter *filter = g_malloc0(sizeof(*filter)); + + filter->target = target; + switch (target) { + case STATS_TARGET_VM: + break; + case STATS_TARGET_VCPU: + { + strList *vcpu_list = NULL; + CPUState *cpu = qemu_get_cpu(cpu_index); + char *canonical_path = object_get_canonical_path(OBJECT(cpu)); + + QAPI_LIST_PREPEND(vcpu_list, canonical_path); + filter->u.vcpu.has_vcpus = true; + filter->u.vcpu.vcpus = vcpu_list; + break; + } + default: + break; + } + return filter; +} + +void hmp_info_stats(Monitor *mon, const QDict *qdict) +{ + const char *target_str = qdict_get_str(qdict, "target"); + StatsTarget target; + Error *err = NULL; + g_autoptr(StatsSchemaList) schema = NULL; + g_autoptr(StatsResultList) stats = NULL; + g_autoptr(StatsFilter) filter = NULL; + StatsResultList *entry; + + target = qapi_enum_parse(&StatsTarget_lookup, target_str, -1, &err); + if (err) { + monitor_printf(mon, "invalid stats target %s\n", target_str); + goto exit_no_print; + } + + schema = qmp_query_stats_schemas(&err); + if (err) { + goto exit; + } + + switch (target) { + case STATS_TARGET_VM: + filter = stats_filter(target, -1); + break; + case STATS_TARGET_VCPU: {} + int cpu_index = monitor_get_cpu_index(mon); + filter = stats_filter(target, cpu_index); + break; + default: + abort(); + } + + stats = qmp_query_stats(filter, &err); + if (err) { + goto exit; + } + for (entry = stats; entry; entry = entry->next) { + print_stats_results(mon, target, entry->value, schema); + } + +exit: + if (err) { + monitor_printf(mon, "%s\n", error_get_pretty(err)); + } +exit_no_print: + error_free(err); +} From patchwork Thu Jun 16 08:31:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644198 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bjGNFMqM; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwZT22fLz9sG0 for ; Thu, 16 Jun 2022 18:39:13 +1000 (AEST) Received: from localhost ([::1]:58818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1l1x-0007Tl-FV for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:39:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvV-0001c5-HA for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50130) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvT-0002qG-K7 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368347; 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=QS43H9MfTeK/E+sJBrLOh6npRZDt1PPjvkyJAJn1Qzk=; b=bjGNFMqMqWK4RV2QBKrHqfvxCEFolRgEgXEvK3l74at15wuPxXzRKOHVr1ZvPLTz2sS/QY DVPUgDuqn8uSGbGSavgcrF0XElBZwCkf8kuJtY/fn8GEdT96HWuNX6s+PeodEjSPIEDmKH /w7ZPxLjcSpCy0S1VXxtoAMUx4SJ9EM= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628--HrzNyfaOJaftyJ5yZz97Q-1; Thu, 16 Jun 2022 04:32:25 -0400 X-MC-Unique: -HrzNyfaOJaftyJ5yZz97Q-1 Received: by mail-ed1-f70.google.com with SMTP id w14-20020a056402268e00b0043556edda4dso76700edd.0 for ; Thu, 16 Jun 2022 01:32:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QS43H9MfTeK/E+sJBrLOh6npRZDt1PPjvkyJAJn1Qzk=; b=6lgjukUMiSx2S+8LBaIajiwgWPDE01tdfGZ/5aeE2JoUJH+M9OtHkDKm/3FQsMyJUG Qgwz+ZKysQk6xcAOLeYJuN58bqsQrwCVK2IQfT7ND+2Lgoh72gWZzTqU7grI5jztDGJ5 boTgOURBvOeJkgNN9qOqza08iFOjkPUyDMLoxJWgn50CrmPcFmqqgU9Hk95GJtE9ga22 OIyoWTCIKJIxtd7tFgn65OuzFCN1hcIEm3zNgLAo30HWS9pDXvBilwYTbcbOiC+utj4U dDsiVVSMsQdga8Q+iW8cLb3/BLyUbvHY7wlOKTiV71b3aM0J+2iZG6BAI4vuyXMLmvjt Vb6g== X-Gm-Message-State: AJIora9beFLb4n1WtggpB9OAOLsx1+ajAizptWPW4lDQM6myd4adDTX8 BeQz9M0Pd2x3lCvMSCzss66Fb36sdx5pWmyPBZPLTzRC2R/XYFSJxaCUhujJQkg5fHtsTgtPB+V 7RzCOR00pj8PXsu2lL495QG8qMr6tdzAlHwfAnWSoeSphf4HkMs17AfbttDztwaqzq7c= X-Received: by 2002:a17:906:6a1c:b0:70a:fd95:ee6a with SMTP id qw28-20020a1709066a1c00b0070afd95ee6amr3557914ejc.36.1655368343893; Thu, 16 Jun 2022 01:32:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sRFHviVXL6u0AQpybj4Buec2cnJYTEeANMgIiuO2gVAujkrW7Arg3RArjnHAizkdHpGi+ATg== X-Received: by 2002:a17:906:6a1c:b0:70a:fd95:ee6a with SMTP id qw28-20020a1709066a1c00b0070afd95ee6amr3557893ejc.36.1655368343539; Thu, 16 Jun 2022 01:32:23 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id kw25-20020a170907771900b007044ae2538esm491092ejc.33.2022.06.16.01.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:22 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Markus Armbruster , "Dr . David Alan Gilbert" Subject: [PULL 06/21] qmp: add filtering of statistics by provider Date: Thu, 16 Jun 2022 10:31:54 +0200 Message-Id: <20220616083209.117397-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Allow retrieving the statistics from a specific provider only. This can be used in the future by HMP commands such as "info sync-profile" or "info profile". The next patch also adds filter-by-provider capabilities to the HMP equivalent of query-stats, "info stats". Example: { "execute": "query-stats", "arguments": { "target": "vm", "providers": [ { "provider": "kvm" } ] } } The QAPI is a bit more verbose than just a list of StatsProvider, so that it can be subsequently extended with filtering of statistics by name. If a provider is specified more than once in the filter, each request will be included separately in the output. Extracted from a patch by Mark Kanda. Reviewed-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 3 ++- include/monitor/stats.h | 4 +++- monitor/hmp-cmds.c | 2 +- monitor/qmp-cmds.c | 41 ++++++++++++++++++++++++++++++++--------- qapi/stats.json | 19 +++++++++++++++++-- 5 files changed, 55 insertions(+), 14 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 547de842fd..2e819beaeb 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2644,7 +2644,8 @@ static int kvm_init(MachineState *ms) } if (kvm_check_extension(kvm_state, KVM_CAP_BINARY_STATS_FD)) { - add_stats_callbacks(query_stats_cb, query_stats_schemas_cb); + add_stats_callbacks(STATS_PROVIDER_KVM, query_stats_cb, + query_stats_schemas_cb); } return 0; diff --git a/include/monitor/stats.h b/include/monitor/stats.h index 8c50feeaa9..80a523dd29 100644 --- a/include/monitor/stats.h +++ b/include/monitor/stats.h @@ -17,10 +17,12 @@ typedef void SchemaRetrieveFunc(StatsSchemaList **result, Error **errp); /* * Register callbacks for the QMP query-stats command. * + * @provider: stats provider checked against QMP command arguments * @stats_fn: routine to query stats: * @schema_fn: routine to query stat schemas: */ -void add_stats_callbacks(StatRetrieveFunc *stats_fn, +void add_stats_callbacks(StatsProvider provider, + StatRetrieveFunc *stats_fn, SchemaRetrieveFunc *schemas_fn); /* diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 04d5ee8fb7..9180cf1841 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2397,7 +2397,7 @@ void hmp_info_stats(Monitor *mon, const QDict *qdict) goto exit_no_print; } - schema = qmp_query_stats_schemas(&err); + schema = qmp_query_stats_schemas(false, STATS_PROVIDER__MAX, &err); if (err) { goto exit; } diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 5f8f1e620b..e49ab345d7 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -445,6 +445,7 @@ HumanReadableText *qmp_x_query_irq(Error **errp) } typedef struct StatsCallbacks { + StatsProvider provider; StatRetrieveFunc *stats_cb; SchemaRetrieveFunc *schemas_cb; QTAILQ_ENTRY(StatsCallbacks) next; @@ -453,10 +454,12 @@ typedef struct StatsCallbacks { static QTAILQ_HEAD(, StatsCallbacks) stats_callbacks = QTAILQ_HEAD_INITIALIZER(stats_callbacks); -void add_stats_callbacks(StatRetrieveFunc *stats_fn, +void add_stats_callbacks(StatsProvider provider, + StatRetrieveFunc *stats_fn, SchemaRetrieveFunc *schemas_fn) { StatsCallbacks *entry = g_new(StatsCallbacks, 1); + entry->provider = provider; entry->stats_cb = stats_fn; entry->schemas_cb = schemas_fn; @@ -465,12 +468,18 @@ void add_stats_callbacks(StatRetrieveFunc *stats_fn, static bool invoke_stats_cb(StatsCallbacks *entry, StatsResultList **stats_results, - StatsFilter *filter, + StatsFilter *filter, StatsRequest *request, Error **errp) { strList *targets = NULL; ERRP_GUARD(); + if (request) { + if (request->provider != entry->provider) { + return true; + } + } + switch (filter->target) { case STATS_TARGET_VM: break; @@ -500,27 +509,41 @@ StatsResultList *qmp_query_stats(StatsFilter *filter, Error **errp) { StatsResultList *stats_results = NULL; StatsCallbacks *entry; + StatsRequestList *request; QTAILQ_FOREACH(entry, &stats_callbacks, next) { - if (!invoke_stats_cb(entry, &stats_results, filter, errp)) { - break; + if (filter->has_providers) { + for (request = filter->providers; request; request = request->next) { + if (!invoke_stats_cb(entry, &stats_results, filter, + request->value, errp)) { + break; + } + } + } else { + if (!invoke_stats_cb(entry, &stats_results, filter, NULL, errp)) { + break; + } } } return stats_results; } -StatsSchemaList *qmp_query_stats_schemas(Error **errp) +StatsSchemaList *qmp_query_stats_schemas(bool has_provider, + StatsProvider provider, + Error **errp) { StatsSchemaList *stats_results = NULL; StatsCallbacks *entry; ERRP_GUARD(); QTAILQ_FOREACH(entry, &stats_callbacks, next) { - entry->schemas_cb(&stats_results, errp); - if (*errp) { - qapi_free_StatsSchemaList(stats_results); - return NULL; + if (!has_provider || provider == entry->provider) { + entry->schemas_cb(&stats_results, errp); + if (*errp) { + qapi_free_StatsSchemaList(stats_results); + return NULL; + } } } diff --git a/qapi/stats.json b/qapi/stats.json index 8c9abb57f1..503918ea4c 100644 --- a/qapi/stats.json +++ b/qapi/stats.json @@ -69,6 +69,18 @@ { 'enum': 'StatsTarget', 'data': [ 'vm', 'vcpu' ] } +## +# @StatsRequest: +# +# Indicates a set of statistics that should be returned by query-stats. +# +# @provider: provider for which to return statistics. +# +# Since: 7.1 +## +{ 'struct': 'StatsRequest', + 'data': { 'provider': 'StatsProvider' } } + ## # @StatsVCPUFilter: # @@ -86,11 +98,14 @@ # request statistics and optionally the required subset of information for # that target: # - which vCPUs to request statistics for +# - which providers to request statistics from # # Since: 7.1 ## { 'union': 'StatsFilter', - 'base': { 'target': 'StatsTarget' }, + 'base': { + 'target': 'StatsTarget', + '*providers': [ 'StatsRequest' ] }, 'discriminator': 'target', 'data': { 'vcpu': 'StatsVCPUFilter' } } @@ -226,5 +241,5 @@ # Since: 7.1 ## { 'command': 'query-stats-schemas', - 'data': { }, + 'data': { '*provider': 'StatsProvider' }, 'returns': [ 'StatsSchema' ] } From patchwork Thu Jun 16 08:31:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AJvzKrVH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwgF0BFRz9sG0 for ; Thu, 16 Jun 2022 18:43:21 +1000 (AEST) Received: from localhost ([::1]:39072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1l5y-0005GB-JW for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:43:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvZ-0001dd-Qb for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27955) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvX-0002qk-GX for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368350; 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=t2g+8gBbCA1JqVZPzLxDO7Cbm4w8pMDb5v5OsIm+iG8=; b=AJvzKrVH1Mah2HD+AVUnr/DD25FyMqAmoSCHmwSzeqVQz0YSLCaMXjkF7a8jp8UiKgxx8Q yvjhtALIBMaegZZo+KeJtV76fkVzEWXcnjjv6QQW0BKXIBGEvJJWIQZQ2dP0ZVyTv5OyJv 2cLusS1tM9hNn+5IfRqLMaXYVyTbZSc= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-237-KZy2Wb7APKmu4_u7N0jc3Q-1; Thu, 16 Jun 2022 04:32:27 -0400 X-MC-Unique: KZy2Wb7APKmu4_u7N0jc3Q-1 Received: by mail-ed1-f70.google.com with SMTP id s15-20020a056402520f00b004327f126170so775362edd.7 for ; Thu, 16 Jun 2022 01:32:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t2g+8gBbCA1JqVZPzLxDO7Cbm4w8pMDb5v5OsIm+iG8=; b=kN6r2jF+WntZKS4z22YvVRgjSo0/w8JyzCNGExp3VV3XAnRbJPvpMJo41z1vUFw8Ig FkD0WLbBiyKiOTlN55Ae0CcSkld8V+xzq/d9AdXVU6N5vE2JcdMjlypcwAq7RCMNTdwc ob9xWJwhHMZMyOVgf+rWzial656EvCPtfBDJB2SUk73BGdLQKRBPutV8dNyCwmmUy849 nxlQGvT2VnR2ESfA1JeXLGsmO9zrzaBbjEBL2+hM3UMUq9l0AfoExWILsB4cBBYT16Qh ZE0TfnhaxmnYW+tdThZeIHgvezwd2p+IcK4uLelOuP4RLgS6FcU+T+t6JVwa+XMeKrsB Wkxw== X-Gm-Message-State: AJIora+aHK+FH1Ss5HFI3Fue9qqDRnzM4WKsXmzshZATQHS73RJwmpdd dv1cuNdBxIK/uWuCfO5C7/MJxCswD4J0vkfNutYDJv7FZ4HfW+RKG8M5PnkLcUSt8M0rnE2RMLf LWY4uVmx3e/TY+Oq3Fy8DwugSdm55VB72fS1Pj9QUVkqHIjxHZYlnpDkI0QnHdAcho+M= X-Received: by 2002:a17:906:72d2:b0:712:302b:a1d9 with SMTP id m18-20020a17090672d200b00712302ba1d9mr3335084ejl.539.1655368345755; Thu, 16 Jun 2022 01:32:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uLQYud4L3bIqgkaZvjzB6YMfXwCDkJzc0OQ57eqnJ9yyIdgH8McIjFOROQWkWRnjNbHFYc/g== X-Received: by 2002:a17:906:72d2:b0:712:302b:a1d9 with SMTP id m18-20020a17090672d200b00712302ba1d9mr3335067ejl.539.1655368345480; Thu, 16 Jun 2022 01:32:25 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id ss17-20020a170907039100b006fed787478asm484239ejb.92.2022.06.16.01.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: "Dr . David Alan Gilbert" Subject: [PULL 07/21] hmp: add filtering of statistics by provider Date: Thu, 16 Jun 2022 10:31:55 +0200 Message-Id: <20220616083209.117397-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Allow the user to request statistics for a single provider of interest. Extracted from a patch by Mark Kanda. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 7 ++++--- monitor/hmp-cmds.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 28757768f7..a67040443b 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -897,9 +897,10 @@ ERST { .name = "stats", - .args_type = "target:s", - .params = "target", - .help = "show statistics; target is either vm or vcpu", + .args_type = "target:s,provider:s?", + .params = "target [provider]", + .help = "show statistics for the given target (vm or vcpu); optionally filter by " + "provider", .cmd = hmp_info_stats, }, diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 9180cf1841..9278439533 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2300,6 +2300,7 @@ static StatsSchemaValueList *find_schema_value_list( } static void print_stats_results(Monitor *mon, StatsTarget target, + bool show_provider, StatsResult *result, StatsSchemaList *schema) { @@ -2314,8 +2315,10 @@ static void print_stats_results(Monitor *mon, StatsTarget target, return; } - monitor_printf(mon, "provider: %s\n", - StatsProvider_str(result->provider)); + if (show_provider) { + monitor_printf(mon, "provider: %s\n", + StatsProvider_str(result->provider)); + } for (stats_list = result->stats; stats_list; stats_list = stats_list->next, @@ -2356,7 +2359,8 @@ static void print_stats_results(Monitor *mon, StatsTarget target, } /* Create the StatsFilter that is needed for an "info stats" invocation. */ -static StatsFilter *stats_filter(StatsTarget target, int cpu_index) +static StatsFilter *stats_filter(StatsTarget target, int cpu_index, + StatsProvider provider) { StatsFilter *filter = g_malloc0(sizeof(*filter)); @@ -2378,12 +2382,25 @@ static StatsFilter *stats_filter(StatsTarget target, int cpu_index) default: break; } + + if (provider == STATS_PROVIDER__MAX) { + return filter; + } + + /* "info stats" can only query either one or all the providers. */ + filter->has_providers = true; + filter->providers = g_new0(StatsRequestList, 1); + filter->providers->value = g_new0(StatsRequest, 1); + filter->providers->value->provider = provider; return filter; } void hmp_info_stats(Monitor *mon, const QDict *qdict) { const char *target_str = qdict_get_str(qdict, "target"); + const char *provider_str = qdict_get_try_str(qdict, "provider"); + + StatsProvider provider = STATS_PROVIDER__MAX; StatsTarget target; Error *err = NULL; g_autoptr(StatsSchemaList) schema = NULL; @@ -2396,19 +2413,27 @@ void hmp_info_stats(Monitor *mon, const QDict *qdict) monitor_printf(mon, "invalid stats target %s\n", target_str); goto exit_no_print; } + if (provider_str) { + provider = qapi_enum_parse(&StatsProvider_lookup, provider_str, -1, &err); + if (err) { + monitor_printf(mon, "invalid stats provider %s\n", provider_str); + goto exit_no_print; + } + } - schema = qmp_query_stats_schemas(false, STATS_PROVIDER__MAX, &err); + schema = qmp_query_stats_schemas(provider_str ? true : false, + provider, &err); if (err) { goto exit; } switch (target) { case STATS_TARGET_VM: - filter = stats_filter(target, -1); + filter = stats_filter(target, -1, provider); break; case STATS_TARGET_VCPU: {} int cpu_index = monitor_get_cpu_index(mon); - filter = stats_filter(target, cpu_index); + filter = stats_filter(target, cpu_index, provider); break; default: abort(); @@ -2419,7 +2444,7 @@ void hmp_info_stats(Monitor *mon, const QDict *qdict) goto exit; } for (entry = stats; entry; entry = entry->next) { - print_stats_results(mon, target, entry->value, schema); + print_stats_results(mon, target, provider_str == NULL, entry->value, schema); } exit: From patchwork Thu Jun 16 08:31:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644211 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DtBD1kWu; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwnx3DtLz9sG0 for ; Thu, 16 Jun 2022 18:49:08 +1000 (AEST) Received: from localhost ([::1]:47456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lBX-0002gV-K2 for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:49:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvc-0001dw-1R for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvZ-0002qv-Fq for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368352; 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=BrZKZJJGTa9/FjXaE6cM6pHCdchukzS67tFNB2xY2bE=; b=DtBD1kWuu3zubiqnRpTIQbIF/THD36UWS/0knJHB5yoqX7O2qmrFQXjKC3+RaE+mXf8Agy NXDEVUiNYrcDSDDx7iXiGf9mzIhqZzXVlwThafzXkBx/zDfl7KW+C/nVj3vRJG4LKOgAaZ TNr6jQbbfKVlKdxEszTcrIxNN3i6bV4= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-515-uFLZlzidPaeuCR2_Tq1KTg-1; Thu, 16 Jun 2022 04:32:31 -0400 X-MC-Unique: uFLZlzidPaeuCR2_Tq1KTg-1 Received: by mail-ej1-f71.google.com with SMTP id q5-20020a17090676c500b00704ffb95131so314123ejn.8 for ; Thu, 16 Jun 2022 01:32:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BrZKZJJGTa9/FjXaE6cM6pHCdchukzS67tFNB2xY2bE=; b=VcT3Atz/meacEIFWJBVDOZqQ6EWAN5Mzx1i0NikMrCEa0iEHG9VgqmdyyQStZHDEPk z6G+iTqQWCdmSiSyzJKh72GlivtCzWqPYsvc9ERrrVhYB1UcSg+yjOktCpWTGB4k2qac PicB/XdYivodo1FKMaQBApjH3LMeSkADE5gAzX4k1fuwMXVeSxxiRahyMisnJ+V1t/RQ /cvb/E3m+ZzyIkOtXuXA07h6gB0nPb+Eo6uYM8hotMrZAYgfJXy+UY/vOIxz6lMVN/oD uxM3BroY8Kbi21zxOwFF7Cs1i0Nb4YvAGb23RI+6iV1KdgavMlSddRpwcjtrrODnd3gS GNsA== X-Gm-Message-State: AJIora9FpLByVLvztK1gfLN4ui73QULZ6AYP2yRb6BBeaPjGjXP989q1 /6eOeC6Ql/Z/8wZufyY+8Tk2WJs4sF2pTNaNrqp8N1hSOpqCZ6QbvYNuw6NtaYHVTODAuB1fFhq a2y7i+wMHjVQsRO6FP1kJNg3RMaPQ6zGZyfwIqMoC9TW61Da0DVAO632vI68M0OUDE3c= X-Received: by 2002:a17:907:160f:b0:70f:cceb:d78c with SMTP id hb15-20020a170907160f00b0070fccebd78cmr3449790ejc.247.1655368349721; Thu, 16 Jun 2022 01:32:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vZ6tF4BgDsl+DszKnG3+0QiL4BC8uHwMEhMsups0HPazKeRZMsaweK8EdEhdVPpvH7s15aMw== X-Received: by 2002:a17:907:160f:b0:70f:cceb:d78c with SMTP id hb15-20020a170907160f00b0070fccebd78cmr3449774ejc.247.1655368349324; Thu, 16 Jun 2022 01:32:29 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id v18-20020a170906293200b006f3ef214e20sm481336ejd.134.2022.06.16.01.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:28 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: "Dr . David Alan Gilbert" Subject: [PULL 08/21] qmp: add filtering of statistics by name Date: Thu, 16 Jun 2022 10:31:56 +0200 Message-Id: <20220616083209.117397-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Allow retrieving only a subset of statistics. This can be useful for example in order to plot a subset of the statistics many times a second: KVM publishes ~40 statistics for each vCPU on x86; retrieving and serializing all of them would be useless. Another use will be in HMP in the following patch; implementing the filter in the backend is easy enough that it was deemed okay to make this a public interface. Example: { "execute": "query-stats", "arguments": { "target": "vcpu", "vcpus": [ "/machine/unattached/device[2]", "/machine/unattached/device[4]" ], "providers": [ { "provider": "kvm", "names": [ "l1d_flush", "exits" ] } } } { "return": { "vcpus": [ { "path": "/machine/unattached/device[2]" "providers": [ { "provider": "kvm", "stats": [ { "name": "l1d_flush", "value": 41213 }, { "name": "exits", "value": 74291 } ] } ] }, { "path": "/machine/unattached/device[4]" "providers": [ { "provider": "kvm", "stats": [ { "name": "l1d_flush", "value": 16132 }, { "name": "exits", "value": 57922 } ] } ] } ] } } Extracted from a patch by Mark Kanda. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 17 +++++++++++------ include/monitor/stats.h | 2 +- monitor/qmp-cmds.c | 7 ++++++- qapi/stats.json | 6 +++++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 2e819beaeb..ba3210b1c1 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2312,7 +2312,7 @@ bool kvm_dirty_ring_enabled(void) } static void query_stats_cb(StatsResultList **result, StatsTarget target, - strList *targets, Error **errp); + strList *names, strList *targets, Error **errp); static void query_stats_schemas_cb(StatsSchemaList **result, Error **errp); static int kvm_init(MachineState *ms) @@ -3713,6 +3713,7 @@ typedef struct StatsArgs { StatsResultList **stats; StatsSchemaList **schema; } result; + strList *names; Error **errp; } StatsArgs; @@ -3916,7 +3917,7 @@ static StatsDescriptors *find_stats_descriptors(StatsTarget target, int stats_fd } static void query_stats(StatsResultList **result, StatsTarget target, - int stats_fd, Error **errp) + strList *names, int stats_fd, Error **errp) { struct kvm_stats_desc *kvm_stats_desc; struct kvm_stats_header *kvm_stats_header; @@ -3958,6 +3959,9 @@ static void query_stats(StatsResultList **result, StatsTarget target, /* Add entry to the list */ stats = (void *)stats_data + pdesc->offset; + if (!apply_str_list_filter(pdesc->name, names)) { + continue; + } stats_list = add_kvmstat_entry(pdesc, stats, stats_list, errp); } @@ -4019,8 +4023,8 @@ static void query_stats_vcpu(CPUState *cpu, run_on_cpu_data data) error_propagate(kvm_stats_args->errp, local_err); return; } - query_stats(kvm_stats_args->result.stats, STATS_TARGET_VCPU, stats_fd, - kvm_stats_args->errp); + query_stats(kvm_stats_args->result.stats, STATS_TARGET_VCPU, + kvm_stats_args->names, stats_fd, kvm_stats_args->errp); close(stats_fd); } @@ -4041,7 +4045,7 @@ static void query_stats_schema_vcpu(CPUState *cpu, run_on_cpu_data data) } static void query_stats_cb(StatsResultList **result, StatsTarget target, - strList *targets, Error **errp) + strList *names, strList *targets, Error **errp) { KVMState *s = kvm_state; CPUState *cpu; @@ -4055,7 +4059,7 @@ static void query_stats_cb(StatsResultList **result, StatsTarget target, error_setg_errno(errp, errno, "KVM stats: ioctl failed"); return; } - query_stats(result, target, stats_fd, errp); + query_stats(result, target, names, stats_fd, errp); close(stats_fd); break; } @@ -4063,6 +4067,7 @@ static void query_stats_cb(StatsResultList **result, StatsTarget target, { StatsArgs stats_args; stats_args.result.stats = result; + stats_args.names = names; stats_args.errp = errp; CPU_FOREACH(cpu) { if (!apply_str_list_filter(cpu->parent_obj.canonical_path, targets)) { diff --git a/include/monitor/stats.h b/include/monitor/stats.h index 80a523dd29..fcf0983154 100644 --- a/include/monitor/stats.h +++ b/include/monitor/stats.h @@ -11,7 +11,7 @@ #include "qapi/qapi-types-stats.h" typedef void StatRetrieveFunc(StatsResultList **result, StatsTarget target, - strList *targets, Error **errp); + strList *names, strList *targets, Error **errp); typedef void SchemaRetrieveFunc(StatsSchemaList **result, Error **errp); /* diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index e49ab345d7..7314cd813d 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -472,12 +472,17 @@ static bool invoke_stats_cb(StatsCallbacks *entry, Error **errp) { strList *targets = NULL; + strList *names = NULL; ERRP_GUARD(); if (request) { if (request->provider != entry->provider) { return true; } + if (request->has_names && !request->names) { + return true; + } + names = request->has_names ? request->names : NULL; } switch (filter->target) { @@ -496,7 +501,7 @@ static bool invoke_stats_cb(StatsCallbacks *entry, abort(); } - entry->stats_cb(stats_results, filter->target, targets, errp); + entry->stats_cb(stats_results, filter->target, names, targets, errp); if (*errp) { qapi_free_StatsResultList(*stats_results); *stats_results = NULL; diff --git a/qapi/stats.json b/qapi/stats.json index 503918ea4c..2f8bfe8fdb 100644 --- a/qapi/stats.json +++ b/qapi/stats.json @@ -75,11 +75,14 @@ # Indicates a set of statistics that should be returned by query-stats. # # @provider: provider for which to return statistics. + +# @names: statistics to be returned (all if omitted). # # Since: 7.1 ## { 'struct': 'StatsRequest', - 'data': { 'provider': 'StatsProvider' } } + 'data': { 'provider': 'StatsProvider', + '*names': [ 'str' ] } } ## # @StatsVCPUFilter: @@ -99,6 +102,7 @@ # that target: # - which vCPUs to request statistics for # - which providers to request statistics from +# - which named values to return within each provider # # Since: 7.1 ## From patchwork Thu Jun 16 08:31:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gSEwp0Zx; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwgG0djvz9sGF for ; Thu, 16 Jun 2022 18:43:22 +1000 (AEST) Received: from localhost ([::1]:39368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1l5z-0005Tz-V1 for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:43:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvd-0001er-0z for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32610) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvb-0002r5-1w for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368354; 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=iq+gOHxdsaq8yaaQJvJQCIAWrFSqRvFdx05ykqq+UlU=; b=gSEwp0ZxQLVAxy02RU0BQd5FjR6UY49nTpKbtgynDyBe3qLjqTrYn4RvVm0Pdi5/9ZflBb Murzh7hCSlttKzX0mZ+pCeuS3jAY+2e+ljqstj+5Ld4aYwTrHuqqRMIlaGPZFJhh7dcgg0 Q8kzDbZzl+UwPlS8VmEaIisnm7CB4T8= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-428-DDN-gZf_OlC_h6N2U4_Duw-1; Thu, 16 Jun 2022 04:32:33 -0400 X-MC-Unique: DDN-gZf_OlC_h6N2U4_Duw-1 Received: by mail-ed1-f70.google.com with SMTP id a4-20020a056402168400b0042dc5b94da6so766848edv.10 for ; Thu, 16 Jun 2022 01:32:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iq+gOHxdsaq8yaaQJvJQCIAWrFSqRvFdx05ykqq+UlU=; b=ohn3JRAAOhjq03v+jNqmsekp276AmEZFx+e+Bu1zKSBIgzjZJXKYa6Pk8e/YhtFDJx 1ch/skxk7MoRpDGtP/rz4tLck5bSs4XVDjYOzUd7ac6T9qFirbno1H4wrTBSv0KeRDpi VrihVj/yTiOwq8V2biiTps+WQqaMfB3QCFe0tBn+6QNehFMRBK4obGr+V88ebGuSliXU tU6pdEXWLIFYlWGTFGQQ/P3CNPJkNENK84iIwCk6PTbOJe0lku2H8ZFDokRcR4UmTThr 3f00+YbiwRJCdlYM6mpgpC4g9VkP3jaxYerGlFhsq4Hs8riGEX5RXZ1pRVu+GVVDBEIn WUlA== X-Gm-Message-State: AJIora9w47ipYa9kdAXRAYZx4Bv1j5iO+CmX2L1a8EC4X3EndqV3iMM6 H0U1GDATP1MYUeXgMiE0DQjC+16QvYSCRUiV/gzEw1oYNaPYLXRmzvpKXEq/gICfwGJXYxaqR+C +p8wAp8+f0py3jBhw4yaUCBjjyuL4Ae/wZI1tX9xT+d8RYdw0SoRGFTXJAb9L0543Afs= X-Received: by 2002:a17:907:c24:b0:711:d4c6:9161 with SMTP id ga36-20020a1709070c2400b00711d4c69161mr3526974ejc.760.1655368351810; Thu, 16 Jun 2022 01:32:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vin+zgrMos17KDPvebkruzC3Fo24dKxZPOStJF7AYzsFot3U8px6xXZLKzNcduolCx4p9E/w== X-Received: by 2002:a17:907:c24:b0:711:d4c6:9161 with SMTP id ga36-20020a1709070c2400b00711d4c69161mr3526956ejc.760.1655368351519; Thu, 16 Jun 2022 01:32:31 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id k10-20020a05640212ca00b0042de29d8fc0sm1244188edx.94.2022.06.16.01.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:30 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: "Dr . David Alan Gilbert" Subject: [PULL 09/21] hmp: add filtering of statistics by name Date: Thu, 16 Jun 2022 10:31:57 +0200 Message-Id: <20220616083209.117397-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Allow the user to request only a specific subset of statistics. This can be useful when working on a feature or optimization that is known to affect that statistic. Example: (qemu) info stats vcpu halt_poll_fail_ns provider: kvm halt_poll_fail_ns (cumulative, ns): 0 In case multiple providers have the same statistic, the provider can be specified too: (qemu) info stats vcpu halt_poll_fail_ns kvm provider: kvm halt_poll_fail_ns (cumulative, ns): 0 Extracted from a patch by Mark Kanda. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Paolo Bonzini --- hmp-commands-info.hx | 8 ++++---- monitor/hmp-cmds.c | 35 ++++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index a67040443b..3ffa24bd67 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -897,10 +897,10 @@ ERST { .name = "stats", - .args_type = "target:s,provider:s?", - .params = "target [provider]", - .help = "show statistics for the given target (vm or vcpu); optionally filter by " - "provider", + .args_type = "target:s,names:s?,provider:s?", + .params = "target [names] [provider]", + .help = "show statistics for the given target (vm or vcpu); optionally filter by" + "name (comma-separated list, or * for all) and provider", .cmd = hmp_info_stats, }, diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 9278439533..47a27326ee 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2359,10 +2359,12 @@ static void print_stats_results(Monitor *mon, StatsTarget target, } /* Create the StatsFilter that is needed for an "info stats" invocation. */ -static StatsFilter *stats_filter(StatsTarget target, int cpu_index, - StatsProvider provider) +static StatsFilter *stats_filter(StatsTarget target, const char *names, + int cpu_index, StatsProvider provider) { StatsFilter *filter = g_malloc0(sizeof(*filter)); + StatsProvider provider_idx; + StatsRequestList *request_list = NULL; filter->target = target; switch (target) { @@ -2383,15 +2385,29 @@ static StatsFilter *stats_filter(StatsTarget target, int cpu_index, break; } - if (provider == STATS_PROVIDER__MAX) { + if (!names && provider == STATS_PROVIDER__MAX) { return filter; } - /* "info stats" can only query either one or all the providers. */ + /* + * "info stats" can only query either one or all the providers. Querying + * by name, but not by provider, requires the creation of one filter per + * provider. + */ + for (provider_idx = 0; provider_idx < STATS_PROVIDER__MAX; provider_idx++) { + if (provider == STATS_PROVIDER__MAX || provider == provider_idx) { + StatsRequest *request = g_new0(StatsRequest, 1); + request->provider = provider_idx; + if (names && !g_str_equal(names, "*")) { + request->has_names = true; + request->names = strList_from_comma_list(names); + } + QAPI_LIST_PREPEND(request_list, request); + } + } + filter->has_providers = true; - filter->providers = g_new0(StatsRequestList, 1); - filter->providers->value = g_new0(StatsRequest, 1); - filter->providers->value->provider = provider; + filter->providers = request_list; return filter; } @@ -2399,6 +2415,7 @@ void hmp_info_stats(Monitor *mon, const QDict *qdict) { const char *target_str = qdict_get_str(qdict, "target"); const char *provider_str = qdict_get_try_str(qdict, "provider"); + const char *names = qdict_get_try_str(qdict, "names"); StatsProvider provider = STATS_PROVIDER__MAX; StatsTarget target; @@ -2429,11 +2446,11 @@ void hmp_info_stats(Monitor *mon, const QDict *qdict) switch (target) { case STATS_TARGET_VM: - filter = stats_filter(target, -1, provider); + filter = stats_filter(target, names, -1, provider); break; case STATS_TARGET_VCPU: {} int cpu_index = monitor_get_cpu_index(mon); - filter = stats_filter(target, cpu_index, provider); + filter = stats_filter(target, names, cpu_index, provider); break; default: abort(); From patchwork Thu Jun 16 08:31:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644212 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XM+j+oh7; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwnx4dvGz9sGF for ; Thu, 16 Jun 2022 18:49:08 +1000 (AEST) Received: from localhost ([::1]:47630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lBZ-0002nr-Hh for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:49:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvh-0001hW-DG for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kve-0002rj-Qx for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368358; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oGWtm3jQvEYYoTyPDWcuflR2G4aAwxob3w8JVaj9KgQ=; b=XM+j+oh7gmTt6v2zQdcq0NAJHjRt8JK8JGpSSi7XVpTm+SPWMQmUKBSePKJuhAz4Gb4XQZ hvFLYmZ86qyVQfsrS7nHLjTPpjzN49MKoPJk/CWvTSDMXDkJv4gK3a/LEL5zvbs8hl8PUh wYrI3TI4OE5dN6wA7vNYSTW+yvfkDzk= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-367-ZKQf3Qy6ON6pPT03uFFvoA-1; Thu, 16 Jun 2022 04:32:35 -0400 X-MC-Unique: ZKQf3Qy6ON6pPT03uFFvoA-1 Received: by mail-ej1-f70.google.com with SMTP id p10-20020a170906b20a00b0070c21a6d378so316696ejz.2 for ; Thu, 16 Jun 2022 01:32:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oGWtm3jQvEYYoTyPDWcuflR2G4aAwxob3w8JVaj9KgQ=; b=oLd+A4G+V0KxYoS9dNcTKJXv+HpM7FD/diZlpVwZHwqykjoMta87WsV03mZU6rgzvL 55bhu3i/d05CliuIgWsHdgUjkgPPs/5SaHh3HTwEFDWch4w6ZkgRB+t1Mr2durptHl10 sPA/wUavdyfp/uGaAPZX71MGBFmMGj9BpBCyNzkO4yllVSj6qwmLfUrFiHDTqYlHx7pF nyKUz1ylmyJ5q2cOoSJcNjMSNi6F80pWmFqAJhidbDFZUFvyWLhtF224zTw94iuCbcqk GcBP7DdVyePfO1PVgT48mhTApmUHL1951HvH3D2nmE66oPKqgvc3c1sBJ6YwjvZLzMUo op3g== X-Gm-Message-State: AJIora8nrHGPlspUoS3ssAYGAr/ZR1IyHfQRGZYy++/9zYrFFOTwXbDR F+onPQoYHlZtWYEPQ3+/hGDD0nOHN6vY2IShuQmIZxQ/+fadf0ESgWK1FC3jxAyIkb91LykwuWs kMbpJBcPEqJNGMlqixILwKajErRSHMPXKxCtjLWyu9XN53dZw+LJ7Xm/o6Vz4rKM1CyE= X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr3493711ejn.598.1655368354033; Thu, 16 Jun 2022 01:32:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vM89CzwZp/LOx8Ay+V3Df2hda9fRSpm/MXTAWEj7rpncZgcqzYvix8RDhKcI/41z91xmJYBA== X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr3493681ejn.598.1655368353511; Thu, 16 Jun 2022 01:32:33 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id cd18-20020a170906b35200b0070a80f03a44sm479735ejb.119.2022.06.16.01.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= Subject: [PULL 10/21] block: add more commands to preconfig mode Date: Thu, 16 Jun 2022 10:31:58 +0200 Message-Id: <20220616083209.117397-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PP_MIME_FAKE_ASCII_TEXT=0.999, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Of the block device commands, those that are available outside system emulators do not require a fully constructed machine by definition. Allow running them before machine initialization has concluded. Of the ones that are available inside system emulation, allow querying the PR managers, and setting up accounting and throttling. Reviewed-by: Daniel P. Berrangé Signed-off-by: Paolo Bonzini --- hmp-commands.hx | 14 +++++ qapi/block-core.json | 117 +++++++++++++++++++++++++++-------------- qapi/block-export.json | 21 +++++--- qapi/block.json | 6 ++- 4 files changed, 110 insertions(+), 48 deletions(-) '*boundaries-read': ['uint64'], '*boundaries-write': ['uint64'], - '*boundaries-flush': ['uint64'] } } + '*boundaries-flush': ['uint64'] }, + 'allow-preconfig': true } diff --git a/hmp-commands.hx b/hmp-commands.hx index 564f1de364..c9d465735a 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -78,6 +78,7 @@ ERST .help = "resize a block image", .cmd = hmp_block_resize, .coroutine = true, + .flags = "p", }, SRST @@ -94,6 +95,7 @@ ERST .params = "device [speed [base]]", .help = "copy data from a backing file into a block device", .cmd = hmp_block_stream, + .flags = "p", }, SRST @@ -107,6 +109,7 @@ ERST .params = "device speed", .help = "set maximum speed for a background block operation", .cmd = hmp_block_job_set_speed, + .flags = "p", }, SRST @@ -122,6 +125,7 @@ ERST "\n\t\t\t if you want to abort the operation immediately" "\n\t\t\t instead of keep running until data is in sync)", .cmd = hmp_block_job_cancel, + .flags = "p", }, SRST @@ -135,6 +139,7 @@ ERST .params = "device", .help = "stop an active background block operation", .cmd = hmp_block_job_complete, + .flags = "p", }, SRST @@ -149,6 +154,7 @@ ERST .params = "device", .help = "pause an active background block operation", .cmd = hmp_block_job_pause, + .flags = "p", }, SRST @@ -162,6 +168,7 @@ ERST .params = "device", .help = "resume a paused background block operation", .cmd = hmp_block_job_resume, + .flags = "p", }, SRST @@ -1406,6 +1413,7 @@ ERST .params = "nbd_server_start [-a] [-w] host:port", .help = "serve block devices on the given host and port", .cmd = hmp_nbd_server_start, + .flags = "p", }, SRST ``nbd_server_start`` *host*:*port* @@ -1421,6 +1429,7 @@ ERST .params = "nbd_server_add [-w] device [name]", .help = "export a block device via NBD", .cmd = hmp_nbd_server_add, + .flags = "p", }, SRST ``nbd_server_add`` *device* [ *name* ] @@ -1436,6 +1445,7 @@ ERST .params = "nbd_server_remove [-f] name", .help = "remove an export previously exposed via NBD", .cmd = hmp_nbd_server_remove, + .flags = "p", }, SRST ``nbd_server_remove [-f]`` *name* @@ -1452,6 +1462,7 @@ ERST .params = "nbd_server_stop", .help = "stop serving block devices using the NBD protocol", .cmd = hmp_nbd_server_stop, + .flags = "p", }, SRST ``nbd_server_stop`` @@ -1481,6 +1492,7 @@ ERST .params = "getfd name", .help = "receive a file descriptor via SCM rights and assign it a name", .cmd = hmp_getfd, + .flags = "p", }, SRST @@ -1496,6 +1508,7 @@ ERST .params = "closefd name", .help = "close a file descriptor previously passed via SCM rights", .cmd = hmp_closefd, + .flags = "p", }, SRST @@ -1511,6 +1524,7 @@ ERST .params = "device bps bps_rd bps_wr iops iops_rd iops_wr", .help = "change I/O throttle limits for a block drive", .cmd = hmp_block_set_io_throttle, + .flags = "p", }, SRST diff --git a/qapi/block-core.json b/qapi/block-core.json index f0383c7925..457df16638 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -737,7 +737,8 @@ # } # ## -{ 'command': 'query-block', 'returns': ['BlockInfo'] } +{ 'command': 'query-block', 'returns': ['BlockInfo'], + 'allow-preconfig': true } ## # @BlockDeviceTimedStats: @@ -1113,7 +1114,8 @@ ## { 'command': 'query-blockstats', 'data': { '*query-nodes': 'bool' }, - 'returns': ['BlockStats'] } + 'returns': ['BlockStats'], + 'allow-preconfig': true } ## # @BlockdevOnError: @@ -1262,7 +1264,8 @@ # # Since: 1.1 ## -{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'] } +{ 'command': 'query-block-jobs', 'returns': ['BlockJobInfo'], + 'allow-preconfig': true } ## # @block_resize: @@ -1293,7 +1296,8 @@ 'data': { '*device': 'str', '*node-name': 'str', 'size': 'int' }, - 'coroutine': true } + 'coroutine': true, + 'allow-preconfig': true } ## # @NewImageMode: @@ -1509,7 +1513,8 @@ # ## { 'command': 'blockdev-snapshot-sync', - 'data': 'BlockdevSnapshotSync' } + 'data': 'BlockdevSnapshotSync', + 'allow-preconfig': true } ## # @blockdev-snapshot: @@ -1550,7 +1555,8 @@ ## { 'command': 'blockdev-snapshot', 'data': 'BlockdevSnapshot', - 'features': [ 'allow-write-only-overlay' ] } + 'features': [ 'allow-write-only-overlay' ], + 'allow-preconfig': true } ## # @change-backing-file: @@ -1582,7 +1588,8 @@ ## { 'command': 'change-backing-file', 'data': { 'device': 'str', 'image-node-name': 'str', - 'backing-file': 'str' } } + 'backing-file': 'str' }, + 'allow-preconfig': true } ## # @block-commit: @@ -1692,7 +1699,8 @@ '*backing-file': 'str', '*speed': 'int', '*on-error': 'BlockdevOnError', '*filter-node-name': 'str', - '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } + '*auto-finalize': 'bool', '*auto-dismiss': 'bool' }, + 'allow-preconfig': true } ## # @drive-backup: @@ -1721,7 +1729,8 @@ # ## { 'command': 'drive-backup', 'boxed': true, - 'data': 'DriveBackup', 'features': ['deprecated'] } + 'data': 'DriveBackup', 'features': ['deprecated'], + 'allow-preconfig': true } ## # @blockdev-backup: @@ -1747,7 +1756,8 @@ # ## { 'command': 'blockdev-backup', 'boxed': true, - 'data': 'BlockdevBackup' } + 'data': 'BlockdevBackup', + 'allow-preconfig': true } ## # @query-named-block-nodes: @@ -1813,7 +1823,8 @@ ## { 'command': 'query-named-block-nodes', 'returns': [ 'BlockDeviceInfo' ], - 'data': { '*flat': 'bool' } } + 'data': { '*flat': 'bool' }, + 'allow-preconfig': true } ## # @XDbgBlockGraphNodeType: @@ -1922,7 +1933,8 @@ # Since: 4.0 ## { 'command': 'x-debug-query-block-graph', 'returns': 'XDbgBlockGraph', - 'features': [ 'unstable' ] } + 'features': [ 'unstable' ], + 'allow-preconfig': true } ## # @drive-mirror: @@ -1950,7 +1962,8 @@ # ## { 'command': 'drive-mirror', 'boxed': true, - 'data': 'DriveMirror' } + 'data': 'DriveMirror', + 'allow-preconfig': true } ## # @DriveMirror: @@ -2123,7 +2136,8 @@ # ## { 'command': 'block-dirty-bitmap-add', - 'data': 'BlockDirtyBitmapAdd' } + 'data': 'BlockDirtyBitmapAdd', + 'allow-preconfig': true } ## # @block-dirty-bitmap-remove: @@ -2147,7 +2161,8 @@ # ## { 'command': 'block-dirty-bitmap-remove', - 'data': 'BlockDirtyBitmap' } + 'data': 'BlockDirtyBitmap', + 'allow-preconfig': true } ## # @block-dirty-bitmap-clear: @@ -2170,7 +2185,8 @@ # ## { 'command': 'block-dirty-bitmap-clear', - 'data': 'BlockDirtyBitmap' } + 'data': 'BlockDirtyBitmap', + 'allow-preconfig': true } ## # @block-dirty-bitmap-enable: @@ -2191,7 +2207,8 @@ # ## { 'command': 'block-dirty-bitmap-enable', - 'data': 'BlockDirtyBitmap' } + 'data': 'BlockDirtyBitmap', + 'allow-preconfig': true } ## # @block-dirty-bitmap-disable: @@ -2212,7 +2229,8 @@ # ## { 'command': 'block-dirty-bitmap-disable', - 'data': 'BlockDirtyBitmap' } + 'data': 'BlockDirtyBitmap', + 'allow-preconfig': true } ## # @block-dirty-bitmap-merge: @@ -2244,7 +2262,8 @@ # ## { 'command': 'block-dirty-bitmap-merge', - 'data': 'BlockDirtyBitmapMerge' } + 'data': 'BlockDirtyBitmapMerge', + 'allow-preconfig': true } ## # @BlockDirtyBitmapSha256: @@ -2275,7 +2294,8 @@ ## { 'command': 'x-debug-block-dirty-bitmap-sha256', 'data': 'BlockDirtyBitmap', 'returns': 'BlockDirtyBitmapSha256', - 'features': [ 'unstable' ] } + 'features': [ 'unstable' ], + 'allow-preconfig': true } ## # @blockdev-mirror: @@ -2361,7 +2381,8 @@ '*on-target-error': 'BlockdevOnError', '*filter-node-name': 'str', '*copy-mode': 'MirrorCopyMode', - '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } + '*auto-finalize': 'bool', '*auto-dismiss': 'bool' }, + 'allow-preconfig': true } ## # @BlockIOThrottle: @@ -2663,7 +2684,8 @@ '*base-node': 'str', '*backing-file': 'str', '*bottom': 'str', '*speed': 'int', '*on-error': 'BlockdevOnError', '*filter-node-name': 'str', - '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } } + '*auto-finalize': 'bool', '*auto-dismiss': 'bool' }, + 'allow-preconfig': true } ## # @block-job-set-speed: @@ -2687,7 +2709,8 @@ # Since: 1.1 ## { 'command': 'block-job-set-speed', - 'data': { 'device': 'str', 'speed': 'int' } } + 'data': { 'device': 'str', 'speed': 'int' }, + 'allow-preconfig': true } ## # @block-job-cancel: @@ -2726,7 +2749,8 @@ # # Since: 1.1 ## -{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' } } +{ 'command': 'block-job-cancel', 'data': { 'device': 'str', '*force': 'bool' }, + 'allow-preconfig': true } ## # @block-job-pause: @@ -2750,7 +2774,8 @@ # # Since: 1.3 ## -{ 'command': 'block-job-pause', 'data': { 'device': 'str' } } +{ 'command': 'block-job-pause', 'data': { 'device': 'str' }, + 'allow-preconfig': true } ## # @block-job-resume: @@ -2772,7 +2797,8 @@ # # Since: 1.3 ## -{ 'command': 'block-job-resume', 'data': { 'device': 'str' } } +{ 'command': 'block-job-resume', 'data': { 'device': 'str' }, + 'allow-preconfig': true } ## # @block-job-complete: @@ -2800,7 +2826,8 @@ # # Since: 1.3 ## -{ 'command': 'block-job-complete', 'data': { 'device': 'str' } } +{ 'command': 'block-job-complete', 'data': { 'device': 'str' }, + 'allow-preconfig': true } ## # @block-job-dismiss: @@ -2820,7 +2847,8 @@ # # Since: 2.12 ## -{ 'command': 'block-job-dismiss', 'data': { 'id': 'str' } } +{ 'command': 'block-job-dismiss', 'data': { 'id': 'str' }, + 'allow-preconfig': true } ## # @block-job-finalize: @@ -2838,7 +2866,8 @@ # # Since: 2.12 ## -{ 'command': 'block-job-finalize', 'data': { 'id': 'str' } } +{ 'command': 'block-job-finalize', 'data': { 'id': 'str' }, + 'allow-preconfig': true } ## # @BlockdevDiscardOptions: @@ -4354,7 +4383,8 @@ # <- { "return": {} } # ## -{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true } +{ 'command': 'blockdev-add', 'data': 'BlockdevOptions', 'boxed': true, + 'allow-preconfig': true } ## # @blockdev-reopen: @@ -4398,7 +4428,8 @@ # Since: 6.1 ## { 'command': 'blockdev-reopen', - 'data': { 'options': ['BlockdevOptions'] } } + 'data': { 'options': ['BlockdevOptions'] }, + 'allow-preconfig': true } ## # @blockdev-del: @@ -4431,7 +4462,8 @@ # <- { "return": {} } # ## -{ 'command': 'blockdev-del', 'data': { 'node-name': 'str' } } +{ 'command': 'blockdev-del', 'data': { 'node-name': 'str' }, + 'allow-preconfig': true } ## # @BlockdevCreateOptionsFile: @@ -4872,7 +4904,8 @@ ## { 'command': 'blockdev-create', 'data': { 'job-id': 'str', - 'options': 'BlockdevCreateOptions' } } + 'options': 'BlockdevCreateOptions' }, + 'allow-preconfig': true } ## # @BlockdevAmendOptionsLUKS: @@ -4944,7 +4977,8 @@ 'node-name': 'str', 'options': 'BlockdevAmendOptions', '*force': 'bool' }, - 'features': [ 'unstable' ] } + 'features': [ 'unstable' ], + 'allow-preconfig': true } ## # @BlockErrorAction: @@ -5294,7 +5328,8 @@ # ## { 'command': 'block-set-write-threshold', - 'data': { 'node-name': 'str', 'write-threshold': 'uint64' } } + 'data': { 'node-name': 'str', 'write-threshold': 'uint64' }, + 'allow-preconfig': true } ## # @x-blockdev-change: @@ -5355,7 +5390,8 @@ 'data' : { 'parent': 'str', '*child': 'str', '*node': 'str' }, - 'features': [ 'unstable' ] } + 'features': [ 'unstable' ], + 'allow-preconfig': true } ## # @x-blockdev-set-iothread: @@ -5397,7 +5433,8 @@ 'data' : { 'node-name': 'str', 'iothread': 'StrOrNull', '*force': 'bool' }, - 'features': [ 'unstable' ] } + 'features': [ 'unstable' ], + 'allow-preconfig': true } ## # @QuorumOpType: @@ -5529,7 +5566,8 @@ # ## { 'command': 'blockdev-snapshot-internal-sync', - 'data': 'BlockdevSnapshotInternal' } + 'data': 'BlockdevSnapshotInternal', + 'allow-preconfig': true } ## # @blockdev-snapshot-delete-internal-sync: @@ -5576,4 +5614,5 @@ ## { 'command': 'blockdev-snapshot-delete-internal-sync', 'data': { 'device': 'str', '*id': 'str', '*name': 'str'}, - 'returns': 'SnapshotInfo' } + 'returns': 'SnapshotInfo', + 'allow-preconfig': true } diff --git a/qapi/block-export.json b/qapi/block-export.json index 0685cb8b9a..8afb1b65b3 100644 --- a/qapi/block-export.json +++ b/qapi/block-export.json @@ -65,7 +65,8 @@ 'data': { 'addr': 'SocketAddressLegacy', '*tls-creds': 'str', '*tls-authz': 'str', - '*max-connections': 'uint32' } } + '*max-connections': 'uint32' }, + 'allow-preconfig': true } ## # @BlockExportOptionsNbdBase: @@ -215,7 +216,8 @@ # Since: 1.3 ## { 'command': 'nbd-server-add', - 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'] } + 'data': 'NbdServerAddOptions', 'boxed': true, 'features': ['deprecated'], + 'allow-preconfig': true } ## # @BlockExportRemoveMode: @@ -260,7 +262,8 @@ ## { 'command': 'nbd-server-remove', 'data': {'name': 'str', '*mode': 'BlockExportRemoveMode'}, - 'features': ['deprecated'] } + 'features': ['deprecated'], + 'allow-preconfig': true } ## # @nbd-server-stop: @@ -270,7 +273,8 @@ # # Since: 1.3 ## -{ 'command': 'nbd-server-stop' } +{ 'command': 'nbd-server-stop', + 'allow-preconfig': true } ## # @BlockExportType: @@ -342,7 +346,8 @@ # Since: 5.2 ## { 'command': 'block-export-add', - 'data': 'BlockExportOptions', 'boxed': true } + 'data': 'BlockExportOptions', 'boxed': true, + 'allow-preconfig': true } ## # @block-export-del: @@ -362,7 +367,8 @@ # Since: 5.2 ## { 'command': 'block-export-del', - 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' } } + 'data': { 'id': 'str', '*mode': 'BlockExportRemoveMode' }, + 'allow-preconfig': true } ## # @BLOCK_EXPOR '*boundaries': ['uint64'], From patchwork Thu Jun 16 08:31:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gJ3cwAkF; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwp75TC8z9sG0 for ; Thu, 16 Jun 2022 18:49:19 +1000 (AEST) Received: from localhost ([::1]:47924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lBl-00032A-Is for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:49:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvi-0001iF-Bh for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40562) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvf-0002rq-Ow for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368359; 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=mcqfsdZcNariGGUMvLOfISWoXv8DGnhVbrRdvfEo1GE=; b=gJ3cwAkFXaMwWtZvzBdzirk/V/BbWUVW7VwEUK+MfyPSH00jTeakm+JojvmYTv8kR0uAjI qXjClogTHsOLwlsbpgv+zM9SROSgL+1qVix4cn6GxavOKE0f/iQiBmwdmVnqCPu8sSh4Bm 33UoF3tLyDsoW6pLwII7/1fQpO2XHb8= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-DTT5jApAMi2EDXgsalxZJg-1; Thu, 16 Jun 2022 04:32:37 -0400 X-MC-Unique: DTT5jApAMi2EDXgsalxZJg-1 Received: by mail-ej1-f69.google.com with SMTP id l2-20020a170906078200b006fed42bfeacso309623ejc.16 for ; Thu, 16 Jun 2022 01:32:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mcqfsdZcNariGGUMvLOfISWoXv8DGnhVbrRdvfEo1GE=; b=eZrDzCNq5we8bHvR+ozrQN3EmnLbLo4ZaPYsKQYlPwlIaRBnT9fvS2bakvn0CKBmUb I1Pj2IPL2wL3MoQDArJH36qAR9g7QEedeKqQna6jpoCYE0XnomOpu0ZiZVxszbdrju5j 8etu7J1dRiNVN8V1SeLO4t/QvYGljPOowMlMLAEGOFPu8JUMvTnCblJ7FPdbfJD7JXgY AjttUcpO1E0kjZ/1moJIBqQNulDpsYx/EkXesisqtAZeB3kdYZdeqEsmtuN6Lj8UP8in 6vMEgVx2QJjWxPYzfd55ZrLNqwNzYwSk/xH24swwfEMVRW/KV2bITj5FZEmV8q7eRHei Lk1w== X-Gm-Message-State: AJIora94IGow4zNPMGAicqLaSYRCZO8hniRMDu2W8Mw1Kmg/0ITPcAmt GCNyAWkd4ehjInVAcusKG2fXqjrwVaabCa24vkt6gGbQPqzFDVQqkRvIt+5Sb8dGR5gkKWaAqJs AaoBqVIkswqZPA1TXlJA1nnDJ2VmK505yVf7eG0SY6BwqAGdlXfXZD+yAyWWS8AtO5EI= X-Received: by 2002:aa7:c846:0:b0:431:6c7b:26af with SMTP id g6-20020aa7c846000000b004316c7b26afmr4773125edt.123.1655368356296; Thu, 16 Jun 2022 01:32:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u9PybE+vLquQPHg6pAgDx4Lqt5iTB2Jlhj9r/kHI5NNc1+5gePasdEf69zWyYXE7oZZ5a7Uw== X-Received: by 2002:aa7:c846:0:b0:431:6c7b:26af with SMTP id g6-20020aa7c846000000b004316c7b26afmr4773064edt.123.1655368355432; Thu, 16 Jun 2022 01:32:35 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id f5-20020a1709064dc500b00706287ba061sm467834ejw.180.2022.06.16.01.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Cornelia Huck Subject: [PULL 11/21] s390x: simplify virtio_ccw_reset_virtio Date: Thu, 16 Jun 2022 10:31:59 +0200 Message-Id: <20220616083209.117397-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Call virtio_bus_reset instead of virtio_reset, so that the function need not receive the VirtIODevice. Reviewed-by: Cornelia Huck Signed-off-by: Paolo Bonzini --- hw/s390x/virtio-ccw.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 15b458527e..066a387802 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -249,12 +249,12 @@ static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBlock *info, return 0; } -static void virtio_ccw_reset_virtio(VirtioCcwDevice *dev, VirtIODevice *vdev) +static void virtio_ccw_reset_virtio(VirtioCcwDevice *dev) { CcwDevice *ccw_dev = CCW_DEVICE(dev); virtio_ccw_stop_ioeventfd(dev); - virtio_reset(vdev); + virtio_bus_reset(&dev->bus); if (dev->indicators) { release_indicator(&dev->routes.adapter, dev->indicators); dev->indicators = NULL; @@ -359,7 +359,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) ret = virtio_ccw_handle_set_vq(sch, ccw, check_len, dev->revision < 1); break; case CCW_CMD_VDEV_RESET: - virtio_ccw_reset_virtio(dev, vdev); + virtio_ccw_reset_virtio(dev); ret = 0; break; case CCW_CMD_READ_FEAT: @@ -536,7 +536,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) } if (virtio_set_status(vdev, status) == 0) { if (vdev->status == 0) { - virtio_ccw_reset_virtio(dev, vdev); + virtio_ccw_reset_virtio(dev); } if (status & VIRTIO_CONFIG_S_DRIVER_OK) { virtio_ccw_start_ioeventfd(dev); @@ -921,10 +921,9 @@ static void virtio_ccw_notify(DeviceState *d, uint16_t vector) static void virtio_ccw_reset(DeviceState *d) { VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); - VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); VirtIOCCWDeviceClass *vdc = VIRTIO_CCW_DEVICE_GET_CLASS(dev); - virtio_ccw_reset_virtio(dev, vdev); + virtio_ccw_reset_virtio(dev); if (vdc->parent_reset) { vdc->parent_reset(d); } From patchwork Thu Jun 16 08:32:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644214 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=COCqknG9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwyR64RKz9sG0 for ; Thu, 16 Jun 2022 18:56:30 +1000 (AEST) Received: from localhost ([::1]:55552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lIg-0008LN-UI for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:56:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvl-0001np-F2 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36232) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvj-0002tP-PZ for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368363; 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=NXuyXvKJHh1ScnEKLGw4n5wQHt4LGnf3pTNOBm5Xpkg=; b=COCqknG9V76I4I/+UzTtVs8f+/6x4AOLtupAiKHTCjdQBxjc6yUDmbpPeUQVbV22ousJkO nH39Da6mAzPBU+8XxS900QgBg4/cVFI6XnuQqBgF3fu9MYS/pys/ArDEayPx+/VQnjZ9FM tA49eBkxk1qGA6BX6ue0IK7tIMHZimU= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-217-05bFYbD3MwuHaGRT5h7NDg-1; Thu, 16 Jun 2022 04:32:40 -0400 X-MC-Unique: 05bFYbD3MwuHaGRT5h7NDg-1 Received: by mail-ej1-f71.google.com with SMTP id k7-20020a1709062a4700b006fe92440164so308535eje.23 for ; Thu, 16 Jun 2022 01:32:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NXuyXvKJHh1ScnEKLGw4n5wQHt4LGnf3pTNOBm5Xpkg=; b=jElkJ1sCmXnUhyeQUZu/mHVtxjE2psWfqgIfVvVSGwkuIjDZ5GZ5yMc36wCvs36yjD xbTYL+RZFxiBPjQhtI8axiGkP+4+BEqfF3J+IDHRwkkNsLVUj5pQAnt/lK3gNHYTnX0Q hAGBLGcl4ovtU7zzBBQGOBP9AzWa0nPN7CPq7TMj0h8I3EgVd7f9DGll+xorQ9y3R8f9 7gqs1B1aiV5t84BghH+yHmGFuiGce7dyKONcNTgZlUUKDv3fQRY2OgWZewMHIjlmFA+1 /uI1/i9JfiF7kn3D6YuFticwrvxP53ZZRwuiiYol+u81sUiGcfFM9A+mUd3xoXpFX1Nw LrQA== X-Gm-Message-State: AJIora8Yi5NgqgXLMVqNPCh0m6xP1E+M9CXnKd2upmLa9pzha/QbOaRw JAgKTVqk+R0Kl82oSfgTVIYtvRzyLaqBMdX26/roBuwro9ORFyjTXa/s91qjkrWifo5lOajzuXM OLkMUr9WXpQ5uSE79UX9spfGJ2ijlxWaEqmDqwztBjqTmFaT/PpcEZj0Zn58V8U9AvIE= X-Received: by 2002:aa7:c84d:0:b0:431:4226:70c9 with SMTP id g13-20020aa7c84d000000b00431422670c9mr4910205edt.51.1655368359299; Thu, 16 Jun 2022 01:32:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v9aOupoWwIP73CFiElX5b/xPwPaqZyP6945KJXduomzM2cSdmfuXWVhXZ8ybMfASCrEFvExg== X-Received: by 2002:aa7:c84d:0:b0:431:4226:70c9 with SMTP id g13-20020aa7c84d000000b00431422670c9mr4910182edt.51.1655368359009; Thu, 16 Jun 2022 01:32:39 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id 18-20020a170906201200b00705fa7087bbsm487978ejo.142.2022.06.16.01.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Cornelia Huck Subject: [PULL 12/21] virtio-mmio: stop ioeventfd on legacy reset Date: Thu, 16 Jun 2022 10:32:00 +0200 Message-Id: <20220616083209.117397-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If the queue PFN is set to zero on a virtio-mmio device, the device is reset. In that case however the virtio_bus_stop_ioeventfd function was not called; add it so that the behavior is similar to when status is set to 0. Reviewed-by: Cornelia Huck Signed-off-by: Paolo Bonzini --- hw/virtio/virtio-mmio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 688eccda94..41a35d31c8 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -376,6 +376,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, return; } if (value == 0) { + virtio_mmio_stop_ioeventfd(proxy); virtio_reset(vdev); } else { virtio_queue_set_addr(vdev, vdev->queue_sel, From patchwork Thu Jun 16 08:32:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XC2xbJ8m; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNx5x48YTz9sFw for ; Thu, 16 Jun 2022 19:02:59 +1000 (AEST) Received: from localhost ([::1]:35524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lOw-0005Ur-65 for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 05:02:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvm-0001oh-6h for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvk-0002tU-DX for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368363; 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=4D8ygp9nA66nbZVz6nMpDbUKSxH50YOaceSJW/1gvAw=; b=XC2xbJ8mjjKcANRid/vArN8czH1oqwET3C8ZgUT8N+RY8nKHZHH1EHdwVKt3CH5WUQnuEK ApFZj86OtgirOwdgtkwsSmuQKeg47WKqeUiMFeT3aSKt+PJdZGT2tHKp1oyNQkV8tOEALw mSJTM/P5g45Fb97OZRXEEkzoI6YxIaY= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-75-TaULx0lJNIqHPS3s69S-Sw-1; Thu, 16 Jun 2022 04:32:42 -0400 X-MC-Unique: TaULx0lJNIqHPS3s69S-Sw-1 Received: by mail-ed1-f69.google.com with SMTP id s15-20020a056402520f00b004327f126170so775775edd.7 for ; Thu, 16 Jun 2022 01:32:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4D8ygp9nA66nbZVz6nMpDbUKSxH50YOaceSJW/1gvAw=; b=b4B5SgkwF1t8npATpP4GzRNDqZWPq7D6wcUaLAcVr8cNipW5gm+dO4NknCqhFYG0O1 yChyV7tZ3diPmi41b5LQWRJWc6bTa36lmVSQBfewmxHBbwzweJEMLxxGy4pWAgiTW18H L1HrS7C38EyQeNIZup8rw9lv6zrOKrf6ALEErtrdOrymGiDHDrfLcP2LTX5gfvu2bWOc lO264J1noQQRXs+OIksN0+5VvjPGKI9JX4nrstgN9e/fzYFUOWAkLemppclfgiiPPayy 6s8gosl00/L2j/NomlUo5CJf8NmDK9OxNSrqef44dLGnRzPK+8jPyIP4SSYhLHNWwNW4 rJSw== X-Gm-Message-State: AJIora9/gM68zyX63t4ILomz8fBE1dmfUq4m91Fn4902398bWGGaEK3d pWMjwgjdXFqpuyP5coLbHiiPm2gM0raIYqtR1AhA6JUGGQyUHu6B9jcQse8Z/PtK3J7nt8EpV2w zap718euKI5DpP9y5TYw9174IF1XLuUglYX+C5N/NNqBQWz+Dd3GJNakatruGWt4YW54= X-Received: by 2002:aa7:ce84:0:b0:42d:ce51:8c6e with SMTP id y4-20020aa7ce84000000b0042dce518c6emr5086201edv.10.1655368361294; Thu, 16 Jun 2022 01:32:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uIVhXqg/CjMVZXxTCIJ9Yg0+salf0TkKduzQ6/R4JgKktKtWa0b9ATh64wy0XG5wSqlfN36A== X-Received: by 2002:aa7:ce84:0:b0:42d:ce51:8c6e with SMTP id y4-20020aa7ce84000000b0042dce518c6emr5086174edv.10.1655368361010; Thu, 16 Jun 2022 01:32:41 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id d9-20020a50fe89000000b0042e09f44f81sm1280820edt.38.2022.06.16.01.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:40 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Cornelia Huck Subject: [PULL 13/21] virtio: stop ioeventfd on reset Date: Thu, 16 Jun 2022 10:32:01 +0200 Message-Id: <20220616083209.117397-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" All calls to virtio_bus_reset are preceded by virtio_bus_stop_ioeventfd, move the call in virtio_bus_reset: that makes sense and clarifies that the vdc->reset function is called with ioeventfd already stopped. Reviewed-by: Cornelia Huck Signed-off-by: Paolo Bonzini --- hw/s390x/virtio-ccw.c | 1 - hw/virtio/virtio-bus.c | 1 + hw/virtio/virtio-mmio.c | 4 +--- hw/virtio/virtio-pci.c | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 066a387802..e33e5207ab 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -253,7 +253,6 @@ static void virtio_ccw_reset_virtio(VirtioCcwDevice *dev) { CcwDevice *ccw_dev = CCW_DEVICE(dev); - virtio_ccw_stop_ioeventfd(dev); virtio_bus_reset(&dev->bus); if (dev->indicators) { release_indicator(&dev->routes.adapter, dev->indicators); diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index d7ec023adf..896feb37a1 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -104,6 +104,7 @@ void virtio_bus_reset(VirtioBusState *bus) VirtIODevice *vdev = virtio_bus_get_device(bus); DPRINTF("%s: reset device.\n", BUS(bus)->name); + virtio_bus_stop_ioeventfd(bus); if (vdev != NULL) { virtio_reset(vdev); } diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 41a35d31c8..6d81a26473 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -376,8 +376,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, return; } if (value == 0) { - virtio_mmio_stop_ioeventfd(proxy); - virtio_reset(vdev); + virtio_bus_reset(&vdev->bus); } else { virtio_queue_set_addr(vdev, vdev->queue_sel, value << proxy->guest_page_shift); @@ -628,7 +627,6 @@ static void virtio_mmio_reset(DeviceState *d) VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d); int i; - virtio_mmio_stop_ioeventfd(proxy); virtio_bus_reset(&proxy->bus); proxy->host_features_sel = 0; proxy->guest_features_sel = 0; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 0566ad7d00..45327f0b31 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1945,7 +1945,6 @@ static void virtio_pci_reset(DeviceState *qdev) PCIDevice *dev = PCI_DEVICE(qdev); int i; - virtio_pci_stop_ioeventfd(proxy); virtio_bus_reset(bus); msix_unuse_all_vectors(&proxy->pci_dev); From patchwork Thu Jun 16 08:32:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aESSVmxP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwjB00f3z9sGF for ; Thu, 16 Jun 2022 18:45:01 +1000 (AEST) Received: from localhost ([::1]:43398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1l7b-0008HD-AJ for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:44:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvo-0001q7-FZ for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvm-0002tm-EA for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368365; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UhU5hIpnBhngBCDdQdspoAO2R7ca5GkL0HNZN9gkK3Q=; b=aESSVmxPFU6sOWN8ZMBYzvFoRBCrOzP3npay+aDU5GclUjfmWt9THdq70mIVjT+BwMprBT Euy7kYEV9FZ9j7RFXibyrcKqtynpPMkcvf4jNxfUt9e3Hx9+GKglrQ1Vm7c/Gzkc7c8wHu 5tl9mzrFE8Cv8HKwMYIIynYCarIlr9Y= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-102-kfnJdMFGPSq1HzdBzMMtDw-1; Thu, 16 Jun 2022 04:32:44 -0400 X-MC-Unique: kfnJdMFGPSq1HzdBzMMtDw-1 Received: by mail-ed1-f70.google.com with SMTP id a4-20020a056402168400b0042dc5b94da6so767130edv.10 for ; Thu, 16 Jun 2022 01:32:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UhU5hIpnBhngBCDdQdspoAO2R7ca5GkL0HNZN9gkK3Q=; b=G6wAKqWz2JIn+tlh9j1vT4gggSUDyT9PN7jn/kT1qEkwE3igI+ZoTgVjvpfhuOKp9n OKz6f3mKEVhjKeG5L7yVkvVtpAS1vzoXyfX9ueQlziiC8fDpl+kq313hPccvy00jpe3/ lSsf/C+ksjX1tAO3bsUNY0HXC4Szywrx2A8ozVSdz0XlsZo23US9AGMYex3yUpThsFZz mVwj49X376JR7vvAD5xK+YrcjALih9FO5x8TFitQX1ZVLkxeQhIg6ZityxZ2J40FzC1/ RaHWAVen7+Hze1WEbsdXGQuxksACFAwz7lPFC4IWRQmr9Px5PtN5tXnbS40FzlETJkp+ hudA== X-Gm-Message-State: AJIora8FkzbhbLfFD7PoBFgIXkbM+1FNYiEJSFXkauHpZLyXml5B2YjW KKh/3uoNVpoSLaj1yoxuxtiaBiWRktCcm2nWLnfccEwkDaFWc5X5TbRwAOJCL+Wkfll5fvr9CYE LHOMa139c6CWhJyuAsFdz75ndSiwYnyY6DvaVbHzygrsIxROGEa0N2ttER4dpxxbo4Ng= X-Received: by 2002:a05:6402:24a4:b0:434:e43e:2462 with SMTP id q36-20020a05640224a400b00434e43e2462mr4957199eda.312.1655368362983; Thu, 16 Jun 2022 01:32:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyvpTfJA3nq7ylZ8SlcJpBxFrFoOdoKeNzn39/4fOxYAH6/YoM07I6uxGqj1CX//ztQkeAgg== X-Received: by 2002:a05:6402:24a4:b0:434:e43e:2462 with SMTP id q36-20020a05640224a400b00434e43e2462mr4957176eda.312.1655368362641; Thu, 16 Jun 2022 01:32:42 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id y3-20020a056402358300b0042dc25fdf5bsm1331136edc.29.2022.06.16.01.32.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 14/21] virtio-mmio: cleanup reset Date: Thu, 16 Jun 2022 10:32:02 +0200 Message-Id: <20220616083209.117397-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Make virtio_mmio_soft_reset reset the virtio device, which is performed by both the "soft" and the "hard" reset; and then call virtio_mmio_soft_reset from virtio_mmio_reset to emphasize that the latter is a superset of the former. Signed-off-by: Paolo Bonzini --- hw/virtio/virtio-mmio.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 6d81a26473..d240efef97 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -72,12 +72,12 @@ static void virtio_mmio_soft_reset(VirtIOMMIOProxy *proxy) { int i; - if (proxy->legacy) { - return; - } + virtio_bus_reset(&proxy->bus); - for (i = 0; i < VIRTIO_QUEUE_MAX; i++) { - proxy->vqs[i].enabled = 0; + if (!proxy->legacy) { + for (i = 0; i < VIRTIO_QUEUE_MAX; i++) { + proxy->vqs[i].enabled = 0; + } } } @@ -376,7 +376,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, return; } if (value == 0) { - virtio_bus_reset(&vdev->bus); + virtio_mmio_soft_reset(proxy); } else { virtio_queue_set_addr(vdev, vdev->queue_sel, value << proxy->guest_page_shift); @@ -432,7 +432,6 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, } if (vdev->status == 0) { - virtio_reset(vdev); virtio_mmio_soft_reset(proxy); } break; @@ -627,7 +626,8 @@ static void virtio_mmio_reset(DeviceState *d) VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d); int i; - virtio_bus_reset(&proxy->bus); + virtio_mmio_soft_reset(proxy); + proxy->host_features_sel = 0; proxy->guest_features_sel = 0; proxy->guest_page_shift = 0; @@ -636,7 +636,6 @@ static void virtio_mmio_reset(DeviceState *d) proxy->guest_features[0] = proxy->guest_features[1] = 0; for (i = 0; i < VIRTIO_QUEUE_MAX; i++) { - proxy->vqs[i].enabled = 0; proxy->vqs[i].num = 0; proxy->vqs[i].desc[0] = proxy->vqs[i].desc[1] = 0; proxy->vqs[i].avail[0] = proxy->vqs[i].avail[1] = 0; From patchwork Thu Jun 16 08:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644202 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iC6Tn01X; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwdl1tGBz9sG0 for ; Thu, 16 Jun 2022 18:42:01 +1000 (AEST) Received: from localhost ([::1]:34882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1l4g-0002Ec-Td for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:41:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvq-0001qW-1x for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50136) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvn-0002tv-Us for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fBsuJkBaK49xYkBSfED4nMxGZwjPP4fEEospD3RWZ9s=; b=iC6Tn01XolT/S8MsQ0FfEA+LYLYm1zn6bxmNd3nzJfkjYqwPJGkZl2Tbcz8X39GXEj4evD aotAFVbZx2st2f/9fyds/odLNvzWeqIr78M8HdM1gQ7xWrDdMHBqgg8mbWOrrZ119DytMG tletaiXxbDnwMtE8uMiq+O6CkcD1rMw= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-295-byVIDIcsPOucvfhN85Pj5Q-1; Thu, 16 Jun 2022 04:32:45 -0400 X-MC-Unique: byVIDIcsPOucvfhN85Pj5Q-1 Received: by mail-ej1-f72.google.com with SMTP id l2-20020a170906078200b006fed42bfeacso309763ejc.16 for ; Thu, 16 Jun 2022 01:32:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fBsuJkBaK49xYkBSfED4nMxGZwjPP4fEEospD3RWZ9s=; b=cVRsOH4KBxfYgoZt49OWmpCgY2nmY1Xp+zQqDGDX+vv50V0ChfG9e5MEuM/Qhz9MCM o8ACQ6GtGzKqyABT1NPmXDzOdrXdlBxYVwsFZ9WHaU22TaUfXl3yf/Mi5YCF4V2Lmjo6 7Rf8HRipybkzo9Erxu88jb0jGSRsP36J7bWblcQ0VYKtMa3UsQFRbtvx2jVVwJyTbe80 VrXEG5LKV+y29LKtNC2tMhgRA94t3WpVAL5vsce/t3wRtOXAdEGhqa2OYeaa35YmHe3T TyMUiw0IUaSlPY2pAbo5ey1f0FxxPkGTEv6zyW+I5sbBez620bQHSf/7d/31O3A9/crh EmRw== X-Gm-Message-State: AJIora8rEvHxISmQAi7LVtNHyQ+qHrp5m0FJ+QrSBNyc1Hk0DOtStdz6 5J1uEBzsPiXCrDwttN3Zh3R82Dp/kCccT5QXjOfBkjGDaSdCGHVepnnNudex2oSV2NF+3KdsSBS bB59i89gvZXLs7rxQFNh9qrmARYgKESvj8u9IjlwKz4rzme1LnInahUFMh8s8OzLLaXg= X-Received: by 2002:a17:907:8a13:b0:707:194c:30df with SMTP id sc19-20020a1709078a1300b00707194c30dfmr3498007ejc.154.1655368364509; Thu, 16 Jun 2022 01:32:44 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uipCy8p0xfLhig9U9WWEasEK4+HTgyz83btBdzalHYCMS4RvJ0FelFis+JSrJkEvDGTEhoUQ== X-Received: by 2002:a17:907:8a13:b0:707:194c:30df with SMTP id sc19-20020a1709078a1300b00707194c30dfmr3497996ejc.154.1655368364296; Thu, 16 Jun 2022 01:32:44 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id o16-20020a50fd90000000b0042617ba63basm1251028edt.68.2022.06.16.01.32.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 15/21] configure: update list of preserved environment variables Date: Thu, 16 Jun 2022 10:32:03 +0200 Message-Id: <20220616083209.117397-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" INSTALL and LIBTOOL are not used anymore, but OBJCFLAGS is new and was not listed. Signed-off-by: Paolo Bonzini --- configure | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configure b/configure index 4b12a8094c..d41c7eddff 100755 --- a/configure +++ b/configure @@ -2722,13 +2722,12 @@ preserve_env CC preserve_env CFLAGS preserve_env CXX preserve_env CXXFLAGS -preserve_env INSTALL preserve_env LD preserve_env LDFLAGS preserve_env LD_LIBRARY_PATH -preserve_env LIBTOOL preserve_env MAKE preserve_env NM +preserve_env OBJCFLAGS preserve_env OBJCOPY preserve_env PATH preserve_env PKG_CONFIG From patchwork Thu Jun 16 08:32:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PJ41AUg3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwzt5ydPz9sFw for ; Thu, 16 Jun 2022 18:57:46 +1000 (AEST) Received: from localhost ([::1]:57954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lJw-0001c5-Li for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:57:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvr-0001re-Qw for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28094) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvp-0002uM-Og for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368368; 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=ns720VWulrkWhyB7bozvdSN9VEh7MyrdoQ2B4TQTFW4=; b=PJ41AUg3rAvC9oTWoybOHQuo0pAL42szaEy5yZ7FwxKV34HI7Fr7NgdPwG13uNnZgFIguq jyTBDxheewY62pAoSBT4PwcDMcDHjO7Qh6lotzfvoL87KLDTpTilBozi6/mt9+6xCM77aT hiXMsT9ho7x3aFH2rGguOAidDvBHHJ4= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-99-X5w0d5TpNdGYrOy2PxTo-A-1; Thu, 16 Jun 2022 04:32:47 -0400 X-MC-Unique: X5w0d5TpNdGYrOy2PxTo-A-1 Received: by mail-ej1-f70.google.com with SMTP id kf3-20020a17090776c300b0070d149300e9so312155ejc.15 for ; Thu, 16 Jun 2022 01:32:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ns720VWulrkWhyB7bozvdSN9VEh7MyrdoQ2B4TQTFW4=; b=Ss0LZsY2lawAFSKgRHUEGicH0VG5wdI1e1uJVRV60zDV5EJTOw0g+2lfvoTk31DkTu +zmbmNFaD6ymI/zGYvNHWry1sjwrOnL9rDoy/CbMvmUsWCrT8mBcVsDxuH9rRiMRyZ+E cpGDlCPj6mlp034bDr2Y2EOnUAAcd8aXNnNNmf2TZ839ja+OzgazIyVebZ4nS131G8H1 A7SXyKsaVyLwGygtGNqVC0vPtl7nDnmF+gYZDK7Y1SWBpY41Aof2zBMVGZOJtjh4DRXq jMzBRu5N7ADvdYaxwQsUl0r5Cxal1QlJEv87Q4EQ2Xp4uGJS4IYREPcDWGDj2yP+1L5J WjHg== X-Gm-Message-State: AJIora80qUuLL1SaJhuJOi51SDf91TJgm4TYnOFSkTVUZnbmFnN9MIGA 60O60ExNCnkFJf1QIp5t7VdJhoBa6DO+vhJk17xErFVlNOZvNa4O1XeHRodldZ8fat+boXge8TT wPijssj66sSDOWkzD6HBA3qP+w0Ea3rIbVCRIxsEx4Sw8E6XZGCCszURFct6HmOcfkeI= X-Received: by 2002:a17:906:7a08:b0:712:12f6:243a with SMTP id d8-20020a1709067a0800b0071212f6243amr3501276ejo.619.1655368365911; Thu, 16 Jun 2022 01:32:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tbvgIogi3vWEyQPWi6mq2WTkqyENpCmX6yTkIYeFkLL7/AK4lrJtpX0y/k5T8jjGE1cB4EFg== X-Received: by 2002:a17:906:7a08:b0:712:12f6:243a with SMTP id d8-20020a1709067a0800b0071212f6243amr3501261ejo.619.1655368365637; Thu, 16 Jun 2022 01:32:45 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id la12-20020a170907780c00b007081282cbd8sm487413ejc.76.2022.06.16.01.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 16/21] configure: cleanup -fno-pie detection Date: Thu, 16 Jun 2022 10:32:04 +0200 Message-Id: <20220616083209.117397-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Place it only inside the 'if test "$pie" = "no"' conditional. Since commit 43924d1e53 ("pc-bios/optionrom: detect -fno-pie", 2022-05-12), the PIE options are detected independently by pc-bios/optionrom/Makefile, and the CFLAGS_NOPIE/LDFLAGS_NOPIE variables are not used anymore. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- configure | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/configure b/configure index d41c7eddff..9fba134746 100755 --- a/configure +++ b/configure @@ -1346,13 +1346,6 @@ static THREAD int tls_var; int main(void) { return tls_var; } EOF -# Check we support -fno-pie and -no-pie first; we will need the former for -# building ROMs, and both for everything if --disable-pie is passed. -if compile_prog "-Werror -fno-pie" "-no-pie"; then - CFLAGS_NOPIE="-fno-pie" - LDFLAGS_NOPIE="-no-pie" -fi - if test "$static" = "yes"; then if test "$pie" != "no" && compile_prog "-Werror -fPIE -DPIE" "-static-pie"; then CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" @@ -1365,8 +1358,10 @@ if test "$static" = "yes"; then pie="no" fi elif test "$pie" = "no"; then - CONFIGURE_CFLAGS="$CFLAGS_NOPIE $CONFIGURE_CFLAGS" - CONFIGURE_LDFLAGS="$LDFLAGS_NOPIE $CONFIGURE_LDFLAGS" + if compile_prog "-Werror -fno-pie" "-no-pie"; then + CONFIGURE_CFLAGS="-fno-pie $CONFIGURE_CFLAGS" + CONFIGURE_LDFLAGS="-no-pie $CONFIGURE_LDFLAGS" + fi elif compile_prog "-Werror -fPIE -DPIE" "-pie"; then CONFIGURE_CFLAGS="-fPIE -DPIE $CONFIGURE_CFLAGS" CONFIGURE_LDFLAGS="-pie $CONFIGURE_LDFLAGS" From patchwork Thu Jun 16 08:32:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644215 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gR7jydo2; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNwyT724mz9sG0 for ; Thu, 16 Jun 2022 18:56:33 +1000 (AEST) Received: from localhost ([::1]:55676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lIl-0008QM-Kq for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 04:56:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvt-0001tA-7l for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvr-0002uY-GS for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368370; 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=e8HG/qQXLswedE4EcBkedeTP89cywFYsO8c70f7Dd9U=; b=gR7jydo2yHyng+Bhe+JqKy+3HaZdMdDdsVViLXGKb3C3RBaX1bbWeDXhkla/6ULTNbsrba 6seToUZyAFPaoS+7FsDj5MfoxdHr4QkJRvQL9ffC+X++6zyxY/vHnsEUvhW1vMdzLaWgiC Evg0o2hkPdTjhTMtm7JYYyYefrwo9P0= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-368-jNFGgcRwMG2m6cMemKKrsw-1; Thu, 16 Jun 2022 04:32:49 -0400 X-MC-Unique: jNFGgcRwMG2m6cMemKKrsw-1 Received: by mail-ed1-f70.google.com with SMTP id k21-20020aa7d2d5000000b0042dcac48313so773775edr.8 for ; Thu, 16 Jun 2022 01:32:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=e8HG/qQXLswedE4EcBkedeTP89cywFYsO8c70f7Dd9U=; b=rOo5wxVEWjGzs3PQdPbsQHrwDSpt/tFWPoNDu4wHZoBxia1W4xnvl5ZfVJS8auavZn AbKOaVwbHesNtzm3rxWyoBQD4zxevuHlwpVxfV1mQVv20xYNtVv954PsBVkEXHc224Xl 3FFHNN6627GGwBKmMbJGjxtVJZ8DoZvBJVOWHu25ROe8JOTUrUJ5QQBTWp7LxxROB6lI lRXR4TEjomxieSSZjvcnlP1kcBAThueJUD+6zk13RSybIxsOSS/YhluhRG/CbBHDoMj6 CYL2q2F287mI0w0TfvVHQASkOINaV74ppLQ39tX7KvCIZI0zu03RezOQuP9nYgRbkbM9 Xe9A== X-Gm-Message-State: AJIora93bqBm5Scu8LaDdGKcozuNr4W1dnXIL3PS2NFkp0fHbD6qTnZ6 ClMUdsZXztTddZbh47iroo18O6rK8OTDpcGSKBf4AUNVi0M4A+92IGP+4SNwv4Fa4eWEirPrn4b Hp/OP7u8f7Aj75Xrj5XCZELKh0SGdj38+0lZ5dEPcBpXlGmVtePeOHZ2JYx5YL4PWp6U= X-Received: by 2002:a05:6402:1851:b0:42d:c904:d73b with SMTP id v17-20020a056402185100b0042dc904d73bmr4863883edy.417.1655368367516; Thu, 16 Jun 2022 01:32:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uJ0ENbW5Xa7JBeBD82kxZ5JaHMyHZx1icpJrFRNh2vbtbca83ptI9XLxSuGEf51JPZCJh0KA== X-Received: by 2002:a05:6402:1851:b0:42d:c904:d73b with SMTP id v17-20020a056402185100b0042dc904d73bmr4863852edy.417.1655368367178; Thu, 16 Jun 2022 01:32:47 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id lb25-20020a170907785900b006febc1e9fc8sm493622ejc.47.2022.06.16.01.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: John Snow Subject: [PULL 17/21] tests/vm: allow running tests in an unconfigured source tree Date: Thu, 16 Jun 2022 10:32:05 +0200 Message-Id: <20220616083209.117397-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" tests/vm/Makefile.include used to assume that it could run in an unconfigured source tree, and Cirrus CI relies on that. It was however broken by commit f4c66f1705 ("tests: use tests/venv to run basevm.py-based scripts", 2022-06-06), which co-opted the virtual environment being used by avocado tests to also run the basevm.py tests. For now, reintroduce the usage of qemu.qmp from the source directory, but without the sys.path() hacks. The CI configuration can be changed to install the package via pip when qemu.qmp is removed from the source tree. Cc: John Snow Signed-off-by: Paolo Bonzini --- tests/vm/Makefile.include | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/vm/Makefile.include b/tests/vm/Makefile.include index 588bc999cc..5f5b1fbfe6 100644 --- a/tests/vm/Makefile.include +++ b/tests/vm/Makefile.include @@ -1,8 +1,17 @@ # Makefile for VM tests -.PHONY: vm-build-all vm-clean-all +# Hack to allow running in an unconfigured build tree +ifeq ($(wildcard $(SRC_PATH)/config-host.mak),) +VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3 +VM_VENV = +HOST_ARCH := $(shell uname -m) +else +VM_PYTHON = $(TESTS_PYTHON) +VM_VENV = check-venv +HOST_ARCH = $(ARCH) +endif -HOST_ARCH = $(if $(ARCH),$(ARCH),$(shell uname -m)) +.PHONY: vm-build-all vm-clean-all EFI_AARCH64 = $(wildcard $(BUILD_DIR)/pc-bios/edk2-aarch64-code.fd) @@ -85,10 +94,10 @@ vm-clean-all: $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ $(SRC_PATH)/tests/vm/Makefile.include \ - check-venv + $(VM_VENV) @mkdir -p $(IMAGES_DIR) $(call quiet-command, \ - $(TESTS_PYTHON) $< \ + $(VM_PYTHON) $< \ $(if $(V)$(DEBUG), --debug) \ $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ @@ -100,11 +109,10 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ --build-image $@, \ " VM-IMAGE $*") - # Build in VM $(IMAGE) -vm-build-%: $(IMAGES_DIR)/%.img check-venv +vm-build-%: $(IMAGES_DIR)/%.img $(VM_VENV) $(call quiet-command, \ - $(TESTS_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(V)$(DEBUG), --debug) \ $(if $(DEBUG), --interactive) \ $(if $(J),--jobs $(J)) \ @@ -128,9 +136,9 @@ vm-boot-serial-%: $(IMAGES_DIR)/%.img -device virtio-net-pci,netdev=vnet \ || true -vm-boot-ssh-%: $(IMAGES_DIR)/%.img check-venv +vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(VM_VENV) $(call quiet-command, \ - $(TESTS_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(J),--jobs $(J)) \ $(if $(V)$(DEBUG), --debug) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \ From patchwork Thu Jun 16 08:32:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GdOeVEZ0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNx665LnXz9sFw for ; Thu, 16 Jun 2022 19:03:10 +1000 (AEST) Received: from localhost ([::1]:36078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lPA-0005vJ-4V for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 05:03:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvu-0001tP-3A for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38419) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvs-0002uk-BI for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368371; 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=/kJWt8j3how8cos95/19EMdtnSkeL0N3FGx4nYIhsak=; b=GdOeVEZ0A7lvGhL2q/V/bvcu5x0vXJEUz73pDgTjZG7MzPKC+jnCcBPQFXytnDlkpbd+dy ix3x3op4+IC+M/SAribGpAx+vXwI7aQa8XidnutTwsanPz48zR92VrJsVcdrrRjPEYI+wS UAMlI2wOe3z8TfmV0JXJCXgTsd5MaAo= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-185-fRu9t19BN1ysXtk6ZnlxvA-1; Thu, 16 Jun 2022 04:32:50 -0400 X-MC-Unique: fRu9t19BN1ysXtk6ZnlxvA-1 Received: by mail-ed1-f71.google.com with SMTP id s15-20020a056402520f00b004327f126170so775978edd.7 for ; Thu, 16 Jun 2022 01:32:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/kJWt8j3how8cos95/19EMdtnSkeL0N3FGx4nYIhsak=; b=EEt0JiG6AAUXRedDLtNwDiar1U9PTVi+3XUjykVphlwjKZee2o3dYAMWupfQArkene ebDQoAAKyB0ux2LmlffHy514ZcjLkJj/I4kRRsuZ3t6jKV3SA1fQzzUkeLdX2/c6MzB4 aGMjU+v1t30yO03eB3egMnHxB+3d/Q6unpaIHpCRfwMYS0jjsXJG27Y1Vjf9h7J2Pjak xwk8asQojhq2i1dm4Mh58zu4EimPt/27gEMPZN/Q3kqJUjFoLGQ5LTb2e/AeiJoFR9aW PphnoP9RKUrXxFm7nxp/PwiVtrpaL99Y870dzYGDdQXNKs2ZfkG6OHZMhOxctjdA1SHS 6wIg== X-Gm-Message-State: AJIora+1i64uzCrJz+3bekiNp2I3IpJ6um7zBhK7JEvDqMb8Fza6RSUU pXbhfk5HiYiwaFeknvVZ1jv2xHGwLne8dgl9Pgv9PQPY5MyYCdLw0+V1UV8tczBqVA6nKJAv6qU XathcHWvIfnuur48jmFSGuCdCpC8ybATOc4BBlFZDG2J7mvo0/+na8dswDC7bxIlg3nQ= X-Received: by 2002:a05:6402:2741:b0:434:fe8a:1f96 with SMTP id z1-20020a056402274100b00434fe8a1f96mr4825508edd.331.1655368369008; Thu, 16 Jun 2022 01:32:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sV3SU/25PS0i5q3L1DcTOeXfPrXE5cN7RkiB5xQIcpaOW6h+RZTVpkUH4Mi+jqSKwYZdhb2Q== X-Received: by 2002:a05:6402:2741:b0:434:fe8a:1f96 with SMTP id z1-20020a056402274100b00434fe8a1f96mr4825488edd.331.1655368368753; Thu, 16 Jun 2022 01:32:48 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id f16-20020a17090631d000b006f3ef214d9fsm500288ejf.5.2022.06.16.01.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Alexander Bulekov Subject: [PULL 18/21] build: fix check for -fsanitize-coverage-allowlist Date: Thu, 16 Jun 2022 10:32:06 +0200 Message-Id: <20220616083209.117397-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexander Bulekov The existing check has two problems: 1. Meson uses a private directory for the get_supported_arguments check. ./instrumentation-filter does not exist in that private directory (it is copied into the root of the build-directory). 2. fsanitize-coverage-allowlist is unused when coverage instrumentation is not configured. No instrumentation are passed for the get_supported_arguments check Thus the check always fails. To work around this, change the check to an "if cc.compiles" check and provide /dev/null, instead of the real filter. Meson log: Working directory: build/meson-private/tmpl6wld2d9 Command line: clang-13 -m64 -mcx16 build/meson-private/tmpl6wld2d9/output.obj -c -O3 -D_FILE_OFFSET_BITS=64 -O0 -Werror=implicit-function-declaration -Werror=unknown-warning-option -Werror=unused-command-line-argument -Werror=ignored-optimization-argument -fsanitize-coverage-allowlist=instrumentation-filter Error: error: argument unused during compilation: '-fsanitize-coverage-allowlist=instrumentation-filter' Signed-off-by: Alexander Bulekov Message-Id: <20220614155415.4023833-1-alxndr@bu.edu> Signed-off-by: Paolo Bonzini --- meson.build | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 21cd949082..fe5d6632fb 100644 --- a/meson.build +++ b/meson.build @@ -209,9 +209,13 @@ if get_option('fuzzing') configure_file(output: 'instrumentation-filter', input: 'scripts/oss-fuzz/instrumentation-filter-template', copy: true) - add_global_arguments( - cc.get_supported_arguments('-fsanitize-coverage-allowlist=instrumentation-filter'), - native: false, language: ['c', 'cpp', 'objc']) + + if cc.compiles('int main () { return 0; }', + name: '-fsanitize-coverage-allowlist=/dev/null', + args: ['-fsanitize-coverage-allowlist=/dev/null'] ) + add_global_arguments('-fsanitize-coverage-allowlist=instrumentation-filter', + native: false, language: ['c', 'cpp', 'objc']) + endif if get_option('fuzzing_engine') == '' # Add CFLAGS to tell clang to add fuzzer-related instrumentation to all the From patchwork Thu Jun 16 08:32:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OF+5/CdR; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNxPw6LKcz9sG2 for ; Thu, 16 Jun 2022 19:16:51 +1000 (AEST) Received: from localhost ([::1]:48076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lcO-0006W5-BU for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 05:16:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kw0-00020y-69 for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:33:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvv-0002v9-FP for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368374; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZVARjugAIjnT/VKUsTwlLt+SkZNqOAcdCvLVW7E7KE8=; b=OF+5/CdR2w/1gs0Grd88eZI8Y5EH2cpEK3a69hVEMcgyjeLn9bwGLu1wWQWIXzAhcY/kNJ ZLlSdoGZiCjqbZd7E82om1M3K+0Jm0Qwzyq8S/8xbBuCUuftryoyxqpgOY+bqc2ly2E/9U 4rzF+dxzA16sDtwRs88dQeSIO1VPRtE= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-70-A_VLtL6EM66CyR4-yjSdBw-1; Thu, 16 Jun 2022 04:32:52 -0400 X-MC-Unique: A_VLtL6EM66CyR4-yjSdBw-1 Received: by mail-ed1-f71.google.com with SMTP id g7-20020a056402424700b0042dee9d11d0so777925edb.3 for ; Thu, 16 Jun 2022 01:32:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZVARjugAIjnT/VKUsTwlLt+SkZNqOAcdCvLVW7E7KE8=; b=JmksTcxOKGQBLgczL9EUdN14UEKchQ3IzlZcEweFUKH9JHXSoyXm5FfmKqPJCudI2I 2ihcnSLL5JPjqcYLT1aSs19OTQr6WIEZFnuaE+nOm6tST3u52kKdyzt95K8t8iUWq39M 2NwmoFINgpOeEHGP8JurtFR4RWnbDfTzmdKdYqnfwtebOE9WAKmwQtexx1xsPCHCiGZW awNz16Ztuho4nBKTQPBPQXHwsZMC0kj4PnZ091Yjl+VamLpCChdZEhSWwv6BbaKClZH4 GFwoB0F9j7JqKPbbXHr6UmV8q89RbCpcyQ2ypvyvqZ/LeSeeM6hANJJaDZyfdxSPGLZv sCKQ== X-Gm-Message-State: AJIora/+H4XarLEPh71fOmL+1YgEfQDQQJ61vT4+7zKD46oNUadToyxa QbkuIpDBm9vvdRORQ+kqftBb/hMVjRQKRnN6wtVJGMUP07WpsA8Mm2c1R51e1lGchvqVzpO0AG3 smD6K6quBIP4I2p8YZWc90Ok9z5C4RWLHAVDS/TG8fRQgs5tZa3qVfAukRFuh9D1JV2A= X-Received: by 2002:a05:6402:2397:b0:42d:dd10:6c11 with SMTP id j23-20020a056402239700b0042ddd106c11mr4885819eda.167.1655368371372; Thu, 16 Jun 2022 01:32:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v6vl4bLQGV21CAfsiS3JNZIu6IWiQvI3pb4qSmDazuTTf1UwLsFdLcCbUsk/+sgwGG+uCTyA== X-Received: by 2002:a05:6402:2397:b0:42d:dd10:6c11 with SMTP id j23-20020a056402239700b0042ddd106c11mr4885794eda.167.1655368371123; Thu, 16 Jun 2022 01:32:51 -0700 (PDT) Received: from goa-sendmail ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id ky20-20020a170907779400b006f4cb79d9a8sm488863ejc.75.2022.06.16.01.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Zhenzhong Duan Subject: [PULL 19/21] =?utf-8?q?q35=EF=BC=9AEnable_TSEG_only_when_G=5FSMRAME?= =?utf-8?q?_and_TSEG=5FEN_both_enabled?= Date: Thu, 16 Jun 2022 10:32:07 +0200 Message-Id: <20220616083209.117397-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Zhenzhong Duan According to spec: "TSEG Enable (T_EN): Enabling of SMRAM memory for Extended SMRAM space only. When G_SMRAME = 1 and TSEG_EN = 1, the TSEG is enabled to appear in the appropriate physical address space. Note that once D_LCK is set, this bit becomes read only." Changed to match the spec description. Signed-off-by: Zhenzhong Duan Message-Id: <20220615034501.2733802-1-zhenzhong.duan@intel.com> Signed-off-by: Paolo Bonzini --- hw/pci-host/q35.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index ab5a47aff5..20da121374 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -379,7 +379,8 @@ static void mch_update_smram(MCHPCIState *mch) memory_region_set_enabled(&mch->high_smram, false); } - if (pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_T_EN) { + if ((pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_T_EN) && + (pd->config[MCH_HOST_BRIDGE_SMRAM] & SMRAM_G_SMRAME)) { switch (pd->config[MCH_HOST_BRIDGE_ESMRAMC] & MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_MASK) { case MCH_HOST_BRIDGE_ESMRAMC_TSEG_SZ_1MB: From patchwork Thu Jun 16 08:32:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Bxt1seUv; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNxHJ5Wj2z9sG2 for ; Thu, 16 Jun 2022 19:11:07 +1000 (AEST) Received: from localhost ([::1]:42794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lWp-0002gD-Uh for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 05:11:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvx-0001yN-UP for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:49769) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvw-0002vF-Ec for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:32:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TkMcaMw54kqRicgUZ5/Gqp/miDgkyZfV9Nj3WpRnuSs=; b=Bxt1seUvDOEujU4H6R3HLs3EF/WoeI3kFR3zGaLfZ2F73Dn+RpySC1565Vdr17ayz+7y/Z kuTXCMOy8i3pIBC9AEPZzrTYtNVTjPHfyKA4M8/rMy8QILe3myd8cLeiJD71OtzDbYzvjv jW3axJJKWvSilDy/1BG2rLXkgJ9XugY= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-625-9AkW6TKgNzGiUB-7uylaHw-1; Thu, 16 Jun 2022 04:32:54 -0400 X-MC-Unique: 9AkW6TKgNzGiUB-7uylaHw-1 Received: by mail-ed1-f72.google.com with SMTP id n8-20020a05640205c800b00434fb0c150cso744193edx.19 for ; Thu, 16 Jun 2022 01:32:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TkMcaMw54kqRicgUZ5/Gqp/miDgkyZfV9Nj3WpRnuSs=; b=l8WBPJuGJ3i1AyCIQNU2wj2wA5qk+4fbnKNvy9dOEXDxqcXtPdZ9Ko8wo64zBp0u9Y Egb4TVcP+r+zZIRaFt6euWdVQYk06OsFg4Okvhz+Rl+agXKfsCrEiRnrc75dkEdo6mYv 3uEvP9se0sjji8isQepoe4kB0az0bm+XQ8tAZYduLxWEwWOG2P7pNdfwjVFq16TZRUEd x8IeEdalfua1D4gX9B21utNdPHC0dOUrll40CVsdX/FWi8BKN5Z7N7XF/CUiVtECxSWT K8lqL7ZY8REkjN99Pn55iNX4V3c/8r6hpj0lRDlNmM7cyxSsMF2tn4Dn/z8Sd3hpLwWr wfag== X-Gm-Message-State: AJIora/68Jqad6j2fnQcjmFomW0vNfOIE10bt8fgu/BhzzoH6fEQyIv7 lk2JH8rYyZEbVnNZ5gXhUUB+aCYYbBK1ac035IVP9xioWTaMcA0R2ehFqO/UmRNvj/Jsinlb2bv 2857fZZ24XP7LgiOFjnNxOWKSJlG+T0vFlnuOpv9Y70dOv2+sK01IS5GGU1RYI1gRFbg= X-Received: by 2002:a05:6402:51d3:b0:431:6c7b:28d with SMTP id r19-20020a05640251d300b004316c7b028dmr4762729edd.281.1655368372822; Thu, 16 Jun 2022 01:32:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tuhrK9XpTUW2FyQvB7ISqXwQhzoZw71gSUcdX/AzGfjVcQImCIq/X9xN1MW6tLZsOqeAR1Yg== X-Received: by 2002:a05:6402:51d3:b0:431:6c7b:28d with SMTP id r19-20020a05640251d300b004316c7b028dmr4762711edd.281.1655368372630; Thu, 16 Jun 2022 01:32:52 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id d5-20020a170906344500b006fed062c68esm464309ejb.182.2022.06.16.01.32.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 20/21] meson: put cross compiler info in a separate section Date: Thu, 16 Jun 2022 10:32:08 +0200 Message-Id: <20220616083209.117397-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" While at it, remove a dead assignment and simply inline the value of the "target" variable, which is used just once. Signed-off-by: Paolo Bonzini --- meson.build | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index fe5d6632fb..0458b69cdf 100644 --- a/meson.build +++ b/meson.build @@ -3744,21 +3744,24 @@ endif summary_info += {'strip binaries': get_option('strip')} summary_info += {'sparse': sparse} summary_info += {'mingw32 support': targetos == 'windows'} +summary(summary_info, bool_yn: true, section: 'Compilation') # snarf the cross-compilation information for tests +summary_info = {} +have_cross = false foreach target: target_dirs tcg_mak = meson.current_build_dir() / 'tests/tcg' / 'config-' + target + '.mak' if fs.exists(tcg_mak) config_cross_tcg = keyval.load(tcg_mak) - target = config_cross_tcg['TARGET_NAME'] - compiler = '' if 'CC' in config_cross_tcg - summary_info += {target + ' tests': config_cross_tcg['CC']} + summary_info += {config_cross_tcg['TARGET_NAME']: config_cross_tcg['CC']} + have_cross = true endif - endif + endif endforeach - -summary(summary_info, bool_yn: true, section: 'Compilation') +if have_cross + summary(summary_info, bool_yn: true, section: 'Cross compilers') +endif # Targets and accelerators summary_info = {} From patchwork Thu Jun 16 08:32:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1644225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WzSmccmK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LNxHY5sD8z9sG2 for ; Thu, 16 Jun 2022 19:11:21 +1000 (AEST) Received: from localhost ([::1]:43020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o1lX1-0002qe-Mw for incoming@patchwork.ozlabs.org; Thu, 16 Jun 2022 05:11:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kw0-00021X-JF for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:33:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o1kvx-0002vN-VW for qemu-devel@nongnu.org; Thu, 16 Jun 2022 04:33:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655368377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wm4jV4ne6eRReZ+e1Hp0CzkELFz8F0VJafQcLc+3ApM=; b=WzSmccmKYwJIoXZPlO0wfkhQrYNwPazqytCYhF5L+8aRGBAO7ju/+1oZtj/3k1BJMCGF5t Ye0Z9JaBL0IldvMXZNckGoUKNtFIZSdiAmzK6vBr08wInUu8PnqElh3u4ONk5xt8xd1pgP zE4o5Rs15AyhQSRWGKiOw5YYuoo4yJc= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-462-sC_TxZSgOdWGfFdxtwJKDA-1; Thu, 16 Jun 2022 04:32:55 -0400 X-MC-Unique: sC_TxZSgOdWGfFdxtwJKDA-1 Received: by mail-ej1-f72.google.com with SMTP id rs21-20020a170907037500b0070c40030f0aso310597ejb.20 for ; Thu, 16 Jun 2022 01:32:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wm4jV4ne6eRReZ+e1Hp0CzkELFz8F0VJafQcLc+3ApM=; b=2Ukej3RzHxRFu9/URkujIbV20l4amDZgELfd4hbzJqPAWdkMQDgcs2Jn2nVF4P3uCY M6fOqFFVht4w51tPPrPB1WEojBkXCzhFkMk3HHMxcobCueNjsuzWfCqcrm6+8JTGEJdA Z34M+Fqgq3+enGRVZMOjEISOREjnRrWhVZ0Fojjn0Pe9mMX4+P1uHl8kYxgk99yfrKKO AmxD/3vDEI4GQOeF5dE79QBpF56KzanyWCMNzidihkXQDcuVIim6096nv+LdyB49evS9 4VuCzsb4YeOihz6mhkQ7mlckNLHlCOvvX7wRsZ1IF0D6F/YEZL8GqAMb+z0+p602d62u 4afQ== X-Gm-Message-State: AJIora/Vq/agFosF4X2nirVTUwfennxGpRuRQkqkEkKI7vIvu2z9+fb5 rYAwDIPi7IigwbYQw7ti7cyWAGo0/Jki3msnV0ySvc8eEnNy6okFIUc8hr8Dh+6B4dizC0nDrIT noG19APTkVbXHipg5KzU41YQO7ezkayipvzZMuwieG3Tgg/aQfhPoJS1naqjTXxOu/M8= X-Received: by 2002:a17:906:5fc4:b0:715:ebe6:7415 with SMTP id k4-20020a1709065fc400b00715ebe67415mr3370544ejv.725.1655368374437; Thu, 16 Jun 2022 01:32:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vQIV/hv8+h8oA1XXWxq7N6eVWZSflhW0/4qQ0SywFsqlKYrEiepqkyA+GlJSRxIR1CRnNQbA== X-Received: by 2002:a17:906:5fc4:b0:715:ebe6:7415 with SMTP id k4-20020a1709065fc400b00715ebe67415mr3370524ejv.725.1655368374009; Thu, 16 Jun 2022 01:32:54 -0700 (PDT) Received: from goa-sendmail ([93.56.169.184]) by smtp.gmail.com with ESMTPSA id qc23-20020a170906d8b700b006feb047502bsm477348ejb.151.2022.06.16.01.32.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:32:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 21/21] build: include pc-bios/ part in the ROMS variable Date: Thu, 16 Jun 2022 10:32:09 +0200 Message-Id: <20220616083209.117397-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220616083209.117397-1-pbonzini@redhat.com> References: <20220616083209.117397-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Include the full path in TARGET_DIR, so that messages from sub-Makefiles are clearer. Also, prepare for possibly building firmware outside pc-bios/ from the Makefile, Signed-off-by: Paolo Bonzini --- Makefile | 12 +++++------- configure | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 3c0d89057e..ec4445db9a 100644 --- a/Makefile +++ b/Makefile @@ -186,16 +186,14 @@ include $(SRC_PATH)/tests/Makefile.include all: recurse-all -ROM_DIRS = $(addprefix pc-bios/, $(ROMS)) -ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS))) -# Only keep -O and -g cflags -.PHONY: $(ROM_DIRS_RULES) -$(ROM_DIRS_RULES): +ROMS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROMS))) +.PHONY: $(ROMS_RULES) +$(ROMS_RULES): $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),) .PHONY: recurse-all recurse-clean -recurse-all: $(addsuffix /all, $(ROM_DIRS)) -recurse-clean: $(addsuffix /clean, $(ROM_DIRS)) +recurse-all: $(addsuffix /all, $(ROMS)) +recurse-clean: $(addsuffix /clean, $(ROMS)) ###################################################################### diff --git a/configure b/configure index 9fba134746..a4d61fe504 100755 --- a/configure +++ b/configure @@ -2236,7 +2236,7 @@ if test -n "$target_cc" && fi done if test -n "$ld_i386_emulation"; then - roms="optionrom" + roms="pc-bios/optionrom" config_mak=pc-bios/optionrom/config.mak echo "# Automatically generated by configure - do not modify" > $config_mak echo "TOPSRC_DIR=$source_path" >> $config_mak @@ -2247,7 +2247,7 @@ fi probe_target_compilers ppc ppc64 if test -n "$target_cc" && test "$softmmu" = yes; then - roms="$roms vof" + roms="$roms pc-bios/vof" config_mak=pc-bios/vof/config.mak echo "# Automatically generated by configure - do not modify" > $config_mak echo "SRC_DIR=$source_path/pc-bios/vof" >> $config_mak @@ -2266,7 +2266,7 @@ if test -n "$target_cc" && test "$softmmu" = yes; then echo "WARNING: Your compiler does not support the z900!" echo " The s390-ccw bios will only work with guest CPUs >= z10." fi - roms="$roms s390-ccw" + roms="$roms pc-bios/s390-ccw" config_mak=pc-bios/s390-ccw/config-host.mak echo "# Automatically generated by configure - do not modify" > $config_mak echo "SRC_PATH=$source_path/pc-bios/s390-ccw" >> $config_mak