From patchwork Fri Mar 1 17:45:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D9C49C5478C for ; Fri, 1 Mar 2024 17:47:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6xw-0005J6-LK; Fri, 01 Mar 2024 12:46:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xu-0005I3-PY for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:34 -0500 Received: from ivory.cherry.relay.mailchannels.net ([23.83.223.94]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xr-0000Xc-GP for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:34 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 36C6E801514 for ; Fri, 1 Mar 2024 17:46:29 +0000 (UTC) Received: from outbound5a.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id 42644800FC6 for ; Fri, 1 Mar 2024 17:46:28 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315188; a=rsa-sha256; cv=pass; b=bS8dVBFV4a8KnLxYhB8wSC06PQPy6T5Ow/twy/45jTR2qSNkRjjaA/kwL4CrjVMr0oSI/J I/lehyjY140AQy/P1jcUpV2wOdGtEABbcupVzYNP837t2V2VgZMCeVpxnyXIMC/8RFoJAO F5LDMJ3OdoEn1XnBCv/VEz/RyNXRvcTXtva+K2sVTCmMaSNhHmz7S6Mia1NGusoOIhJoGR Vj1VsgzxqP0QMrGEEAb3ErfiZdlNaAW7zfaLzPaP9ffsa2h/UtUnT5DxSM9WwranpPq1zE pYiGKEGHL4jAF4uVKdvVYAN70ibeAvi8vgh668P1z4lYXlBcXrmSIBZvgUv8cg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ckyDvUxj1zxZs27PAO8n1Ocnl8jbS4RRgALTBGi+/So=; b=rPvOjbFCXeaL4+b4I/XMn2/vWygN+89B0oYzYWD4ZgG2ccGe6IHQQBhc22Qt58JHj+i7lP 45CPeG/2UN0/LJKpKusfKIZMmLey0M9fVQR/P0mxOnNk7XsDQsghNs/n81C9D9MO6KSv6T +UIO9WGVQmwZH5TSE+IyiHV8+uuBjCzJZHdyKWOdVDLKV6fN0VizZLZso4FC5dEkQCmrqi dLO5V/thLIrraqNh2C1iItv3J8WWsphW1lAITeT+a8lYrwhJ+g99Je0An8P7oLEUAIBn/P Pqiyp54isN5k7DOP45PWiv/WWFr3WX6jIZqgof5JlpAJQwuvbe32nKfQefFkAA== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-lc9cj; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Soft-Plucky: 55332b4a4f7d7416_1709315188786_430695244 X-MC-Loop-Signature: 1709315188786:581606334 X-MC-Ingress-Time: 1709315188785 Received: from outbound5a.eu.mailhop.org (outbound5a.eu.mailhop.org [3.124.88.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.101.14.227 (trex/6.9.2); Fri, 01 Mar 2024 17:46:28 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315160; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=PFZqw39QRK/hSgJPFGhAu+fNcmOc1PhyeeZGWfk5M0LrjaKUMIztEvJhFQLyV/gBPmpTxe5Z61Qaj RmrZQQzMA8GVV8Q5IjtgPnKKuzZwjLrBFoO2eCJxnhMk7YqY1KKsYbtTPXgXMpApys79ng/7FEntib 4rv0MuXK13jrjK7NAF2SlPnNxpM9j9k1/aqotrCOLTuNtlHT2XgnbH8FoyiTGbntjxmglOevZVrcpP hnumYOUMUndekDS/vy7saQKGIPgClCYf3ZhAvegX27pzWsBdNudGO5FMyO47jpC+V1o1Ygh9cISXbt rU/zjlQmDHEUoy05f7TRASu6I+fwp5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=ckyDvUxj1zxZs27PAO8n1Ocnl8jbS4RRgALTBGi+/So=; b=RYG76jqBLnOr8Q1B7QbvJHe9AUvLyxiu8QIr1OddmD3S+5kH0XX5aWRhoaSdZrUs3OWA8cmwfvDRE PvuHRsIUH1rMVGRqErRbikGAn+LpjcAan3ehlppHmnPj3qZssNvmgoxJJFEvvxJ69L8tw49HBV7sv2 4CpElxjl85UDT7N7pOr4jY4SNe9Ui+Ak3k2QrvL7Ixku3znVjX4aYoTr23pmJyVy0h4Vydr2wcGXBV bEKKy/nkUqEf+pA1+PHYXhmU+nS2oT6VMXfqP10vtEEpNFLyQzXz5SbN1suO3CgOUmSdiRuEhnbdGW qnTF263ALGfLrCjj3UDpd3rMPhbs+9w== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=Zl6mXkUB; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=ckyDvUxj1zxZs27PAO8n1Ocnl8jbS4RRgALTBGi+/So=; b=m2a4aLqVDnpapOB8YikrH0ovq90hId/auWIRbdY6ysyHNjL8j6yUW0lrVh/CccEUiuB5gglXkOszE UV2nOgli6ucf2eoubxA0GIqM1zwm6EWK9xPyJUavZlyshNODhlbJNG1bJ3MvLiMuCypfoZym+Z3e7o WDAUWCe8kzDQ+8MA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=ckyDvUxj1zxZs27PAO8n1Ocnl8jbS4RRgALTBGi+/So=; b=kEn2FaTD1oMcuQQD4RwDgxDoffRmwvRJXXG8RMBDgOLKX3jWVWcw4FJrIQhrGt6Sa8fbJQvqeoepG 2d2L2IjCIivtMhyqrCLUrC9mrZItxCVjNywfHXX8f8vFpZsmagZ6ykhPhm7cd5LTeBQGZOKTEi2vjP yD6Vw77BWaCExioNV/7LYlHqns/QUya7HpdH3KvItTZ8wSRayyzaLdwUM01Gi7n2nSJzxPs2oBDMOy 5occkwVJmbqK0uwwXtjq/KNs6347b0Dc66ULJ84IPIkM3UEt7WISHbKPQfAp2ki2VItoQf/XIIAreh A7XZ+zvr9pOE7WCm9R2KRyC37ePamQw== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 8dbb11fc-d7f3-11ee-afda-eda7e384987e X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 8dbb11fc-d7f3-11ee-afda-eda7e384987e; Fri, 01 Mar 2024 17:45:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ckyDvUxj1zxZs27PAO8n1Ocnl8jbS4RRgALTBGi+/So=; b=Zl6mXkUBSuZHawGP6RpaN3KCrN VzkS1ma4k+R7Yr47BHbLDkubRs9iqx1s796pq+WFYupJxNXdMStXzSg769Qn+zbwJWVKHqbek6sIB 9NIdau4uEkwr3Lb0f3P/pA5BCkM5D45Na5s8ALdSUPdafjMGvnr5fQyOWJIjf7k8J68i5c55lA1aH qdlIFmCFrnwbqXfiImsujLZ0cTOE4BXXXreCNktqtij0OPQebNP6LCru1sXaHWI6fO21wOsXg4/te D9AloLhSzvqiX6Zto2f/Wr1tMDMuUffJMkMGBCsW3vCppdxZ9+qHuV/ygxwCmoyCW3p3/F3OmGytM sFzmH3kQ==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xf-000bs2-0d; Fri, 01 Mar 2024 18:46:19 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 01/12] util/log: convert debug_regions to GList Date: Fri, 1 Mar 2024 18:45:58 +0100 Message-ID: <20240301174609.1964379-2-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.223.94; envelope-from=svens@stackframe.org; helo=ivory.cherry.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In preparation of making the parsing part of qemu_set_dfilter_ranges() available to other users, convert it to return a GList, so the result can be used with other functions taking a GList of struct Range. Signed-off-by: Sven Schnelle --- util/log.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/util/log.c b/util/log.c index d36c98da0b..779c0689a9 100644 --- a/util/log.c +++ b/util/log.c @@ -46,7 +46,7 @@ static __thread Notifier qemu_log_thread_cleanup_notifier; int qemu_loglevel; static bool log_per_thread; -static GArray *debug_regions; +static GList *debug_regions; /* Returns true if qemu_log() will really write somewhere. */ bool qemu_log_enabled(void) @@ -368,38 +368,36 @@ bool qemu_set_log_filename_flags(const char *name, int flags, Error **errp) */ bool qemu_log_in_addr_range(uint64_t addr) { - if (debug_regions) { - int i = 0; - for (i = 0; i < debug_regions->len; i++) { - Range *range = &g_array_index(debug_regions, Range, i); - if (range_contains(range, addr)) { - return true; - } - } - return false; - } else { + GList *p; + + if (!debug_regions) { return true; } -} + for (p = g_list_first(debug_regions); p; p = g_list_next(p)) { + if (range_contains(p->data, addr)) { + return true; + } + } + return false; +} void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp) { gchar **ranges = g_strsplit(filter_spec, ",", 0); + struct Range *range = NULL; int i; if (debug_regions) { - g_array_unref(debug_regions); + g_list_free_full(debug_regions, g_free); debug_regions = NULL; } - debug_regions = g_array_sized_new(FALSE, FALSE, - sizeof(Range), g_strv_length(ranges)); for (i = 0; ranges[i]; i++) { const char *r = ranges[i]; const char *range_op, *r2, *e; uint64_t r1val, r2val, lob, upb; - struct Range range; + range = g_new0(struct Range, 1); range_op = strstr(r, "-"); r2 = range_op ? range_op + 1 : NULL; @@ -448,10 +446,12 @@ void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp) error_setg(errp, "Invalid range"); goto out; } - range_set_bounds(&range, lob, upb); - g_array_append_val(debug_regions, range); + range_set_bounds(range, lob, upb); + debug_regions = g_list_append(debug_regions, range); + range = NULL; } out: + g_free(range); g_strfreev(ranges); } From patchwork Fri Mar 1 17:45:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 39984C5478C for ; Fri, 1 Mar 2024 17:48:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6xy-0005NX-SN; Fri, 01 Mar 2024 12:46:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xw-0005Ip-Cw for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:36 -0500 Received: from chameleon.pear.relay.mailchannels.net ([23.83.216.33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xu-0000Xo-MT for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:36 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id BEA6E4C269C for ; Fri, 1 Mar 2024 17:46:31 +0000 (UTC) Received: from outbound1g.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id B0A254C2310 for ; Fri, 1 Mar 2024 17:46:30 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315191; a=rsa-sha256; cv=pass; b=or1XBgRA6cHrzLpilgL98aOTnuWOzOYJcFDf1oQ1zQaGGVmiOjOHSPte8MOpUEyhF/25y0 bbo/E3HQ6X4eh1o6FgStRue/NomKkcYCZne7b5qiip/I6aURNeKH2lHEfV4tHtfDWPFwsQ kkaQkerBAW9NHyyAbK+ABkJUFDnT6dg3Uw7eacVT3VA9rqvfOqQZmSm9jrWVCXmmIptCry Fhq1JJLTIaFjOLdvKFDg9c4CFBtFlYX4lPG9RYgW7ngHJUyHdr0GMbKsHYjn1uKiY0CJDv uBRKKc8XC4GC9p8AzWn+eSLPXCOlovZBGvJe+heI4np7RbdNxYN2p2qz8SAe8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=s0rD/E55eu1dy3gy9zrqMvtlkoGP/2RyTrDaNAJAFP4=; b=i4sDhkxH/v36/qDe00atWCpa6lhyuHdA0P7APC/V3SCyVbvhV0vXZg+KfFubYepSHidv/B fEQ9Jw+kNBHsIH70+9DWwGR7yXqgt4lwz4T0ygNlJDm/dxY+AzUgzvW5ZMidiCPAE5qh1W n7UGTqknnVfDEgElZZBvip7zDVp9O2nGr7mrK5fmwK83LZEAlOsFCMvuaBSHwOJHRAMjPB PJAlrYRbmVQI8HN5kjMwBSFHrT36ElUwe3Bq1YGEBBvQHcqtsUYU40OnriyOpmkrtpyGJS ZxXhVALQ4mqpGwN0l92NqwuZmeopZ00RH9WJXthNKf52WKf3cspMHMXAp1EKQA== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-jmwb2; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Decisive-Battle: 03028bf9029b2e1a_1709315191227_2501781902 X-MC-Loop-Signature: 1709315191227:2238914392 X-MC-Ingress-Time: 1709315191226 Received: from outbound1g.eu.mailhop.org (outbound1g.eu.mailhop.org [52.28.6.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.123.27.58 (trex/6.9.2); Fri, 01 Mar 2024 17:46:31 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315162; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=Rg2NSP2/jvvNAQQffUTYLAqbtrQCk/AzlWCZBRiljkA2u7JneMHFsGCPmmxXMgl4nDWAGGQ2Id8l2 su8zmdJ1otDHcaXZecwna3IRPwH1buO0mowDQaYqgH9HSAbz7oTwFEo3UDHR6IhYlKc+5/GkHvHu5E yH3eVlYB4LseqoXFRm62uM7jFlW32UJtnMnags+Si53D9OqeCTz2uF0u7HFYr0rUS9weLQCRnu/lra rzpe2GKNo6frvUWuLxkUs3wISeWvA9rbD6gDcvSlIEgPDwmu70H4MbOhPrddxw71D88sonEe58AeRG SUN5bowYiQVjv9TbOhwDmdKuc8nlipQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=s0rD/E55eu1dy3gy9zrqMvtlkoGP/2RyTrDaNAJAFP4=; b=DmLdQLU4aAydo//5MvfKI8vBxOWdx+uM9Khu8KAoXhEnWGHgVZv09DyfTw4TBkBWXYWBDeCcnY6ci CzMENkRmkOACQDajIdcmVrxUsv60clopWhhGReqtjlvwl60NmE0HjBkRB6o+82tt9rPIWrO2gAohx9 U7bswUirvF6d5+FjvLWJuCSNRa7rjVhq7nUWA+sBBHgy3fklucJ78kceodRWjW0guOvqlhiCV/oiBB CnBd2e2yecFEXIZQpJV9Ef8/bdQx7vAHcD7Wn3IG0P7YZRr+LbVzgWQjhkoiPxf3EXKF7ARxGWJxbM vurCbbh32+M1FUJaW1hGHwyQcSGmeMw== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=aX8A+CUW; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=s0rD/E55eu1dy3gy9zrqMvtlkoGP/2RyTrDaNAJAFP4=; b=WpsmVCXuJopxtiIvdot/boTgpAPamJR+RqfPObJS9xEZqGMF173YjBAsseVGdwkC3pKLI8/CroSIf iYNTx7dfVZyd8vREmOqu66raGXQ0/EOPSVSLQtu3rKrVNDXmk7AwLps/Y3xD1wZfIlybf0L58R1GCD 4+VNALHhG4dpL5LE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=s0rD/E55eu1dy3gy9zrqMvtlkoGP/2RyTrDaNAJAFP4=; b=PZnL0JTGKbR1ZiKUZl58FjhwGHVEHxeA40nFjrTAvkFBvs39cyMRIZ9svwV/GNmXiHB+v757Tj1wE /cyyV7ATyHU7u8EkI1CJYHdsJco5HOtAL+6TqLcaTE2h+2fEAEPo+4wkunzV6m+MZ2+RZTTpoeSVYE pUs9yIi+XGs5ckZPPcLzI3gXWaSgoiDykR8/qPOvRl1+8p2uGdNuCCze/wXXaDgORGZk6t1aJU6u8I kZZPrizNGZV+x2TnR68DtJas/iigXJ1ILIQf1+HIJ3/muNL8kY4mp9jRrG58aQIMKws7/kL8houjM8 f2ngu6ewf596Gdp54gJ8SwWo4bTkErA== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 8eb5151e-d7f3-11ee-afda-eda7e384987e X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 8eb5151e-d7f3-11ee-afda-eda7e384987e; Fri, 01 Mar 2024 17:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=s0rD/E55eu1dy3gy9zrqMvtlkoGP/2RyTrDaNAJAFP4=; b=aX8A+CUWuWb6t9UA7ZNV37sg5t i5Haels4MPKPuFIgMy/At9xFTndRO6Vlf3ell4XF1BjGWDdQkseX1BSUOSvCC95R0umWsAc2CHGXv AIXEqvNt1u3wqdbNfUlEDzkr/AQg/PK4ukg+85zjoradanZ8jpYKVlUzJj/tniF40u6p7AHLorIC9 +zpAL9XVtstVmgo8EMRWW/ebs8yoGUX47R/0C+PSisBZWI7Ff7o6WyxpuCahKfQrhzJ6c1gUhaOQP X7vkCHkD+rJhXcN60JiccuYnAlGI0IIH7FwtaFC8Hc5H4Gio/y2o5dtpXiDl4+byg46xC664F65IY BErOusJw==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xg-000bs2-21; Fri, 01 Mar 2024 18:46:20 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 02/12] util/log: make qemu_set_dfilter_ranges() take a GList Date: Fri, 1 Mar 2024 18:45:59 +0100 Message-ID: <20240301174609.1964379-3-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.216.33; envelope-from=svens@stackframe.org; helo=chameleon.pear.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org In preparation of making qemu_set_dfilter_ranges() available to other users, move the code to a new function range_list_from_string() which takes an additional GList argument. Signed-off-by: Sven Schnelle --- util/log.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/util/log.c b/util/log.c index 779c0689a9..f183ea4e4d 100644 --- a/util/log.c +++ b/util/log.c @@ -382,15 +382,16 @@ bool qemu_log_in_addr_range(uint64_t addr) return false; } -void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp) +static void range_list_from_string(GList **out_ranges, const char *filter_spec, + Error **errp) { gchar **ranges = g_strsplit(filter_spec, ",", 0); struct Range *range = NULL; int i; - if (debug_regions) { - g_list_free_full(debug_regions, g_free); - debug_regions = NULL; + if (*out_ranges) { + g_list_free_full(*out_ranges, g_free); + *out_ranges = NULL; } for (i = 0; ranges[i]; i++) { @@ -447,7 +448,7 @@ void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp) goto out; } range_set_bounds(range, lob, upb); - debug_regions = g_list_append(debug_regions, range); + *out_ranges = g_list_append(*out_ranges, range); range = NULL; } out: @@ -455,6 +456,11 @@ out: g_strfreev(ranges); } +void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp) +{ + range_list_from_string(&debug_regions, filter_spec, errp); +} + const QEMULogItem qemu_log_items[] = { { CPU_LOG_TB_OUT_ASM, "out_asm", "show generated host assembly code for each compiled TB" }, From patchwork Fri Mar 1 17:46:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 536C5C5475B for ; Fri, 1 Mar 2024 17:47:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6xz-0005Nz-Rv; Fri, 01 Mar 2024 12:46:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xy-0005LM-37 for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:38 -0500 Received: from bongo.birch.relay.mailchannels.net ([23.83.209.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xw-0000Y5-6A for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:37 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 41753C396B for ; Fri, 1 Mar 2024 17:46:34 +0000 (UTC) Received: from outbound1g.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id 69A95C27E3 for ; Fri, 1 Mar 2024 17:46:33 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315193; a=rsa-sha256; cv=pass; b=3m5wCWfqr3v1yw6g5rS96qKUsxzygKqKPoZGdzVwaq7lFUmR4szngAmszx9z84pMZ5nHI9 mJPKfzUtG+L5UnmC5gzEvTQGBB3bO7iA+GmXaD+sHG8GhyxrWyrClCKNvgG4mmdqah1YIT 3ZGiNnj6hNVYsQPz4CmCZxcDPpvkHS+kwFkfs0GS4jGTWmQMcX7LDRipPkMPDULsNQ5r4a qn6CoibejZU59cojmBx2ssho/NJOUHDJvgk+iPXgl7wh8e3+1MUAHdZahO3nVert3ln3ML XG6y6w0dQEGN8MQX8e7JRzHoPOdSdqEu4Im8gdcfK80EwKM12CzObscyNU0DcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bopqUPl5QO0pq8Rv2GfWUFdNI4IyEMDQCmogGXg31WU=; b=WbIwnU0YDnYic0dnaO4I1IwqleXfsI5MwZ8pHT6Lo89jzGY5CtO9Nfwo0psfmbFP9RvdIn mQiYTJKYiekFpByLA2HrTdtnpvHFL/Hbx6UxSHxDxpf7F9GPNj/RHtEufR6E6x8EmQoMjr pc8ziFcK87jIU5KiisLjFbmu1ldf5GIvz7YC1/zU+kNIINDksJQ/VfsIP7Es4MtI5K4Bos 1BEVCOTCCpBNUxwMJ0tF3DPh62AapX13wU5f/l0UggYdAXSn5OaeDi/dwQ3m0+XvHWiL/e gmwteOBjYvGpTbpxrizZMOVGN/4adSqYoAEMSH3laRAQfSc2sm3vlmxCFE2Ung== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-rwchp; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Drop-Turn: 656a20a44026efb9_1709315193928_2351392444 X-MC-Loop-Signature: 1709315193928:3520662604 X-MC-Ingress-Time: 1709315193928 Received: from outbound1g.eu.mailhop.org (outbound1g.eu.mailhop.org [52.28.6.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.123.27.58 (trex/6.9.2); Fri, 01 Mar 2024 17:46:33 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315162; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=AyalXKN2aHmRdLp29xeAuRg8IliB+63Oj3quuJwMIwT+nXKg/Aw+ltqtYLY1lID0zmkm5B70yEqrs oy7ZB5xHJCRbE6/G+ph30/vsgZTG76e+tqhCRtfVYfqWwD4vtqnuFiCFSwQrA77/UwN0rWkCd1o7Us J/ZG2JenP5ZD0ZC2otWTlBa9Vusw24i8HqVNXuKXofnDrjeOnI/u+rteVsHQ4xB1GyyZ4zEeCis5TR tfIVS4+l7ZHOqBU5vmofMdowHdBdyXRZ4lUXpVI9YyvtYYkYRM/R/eA+dBtm9KdWCQKXnqK8tbqo2f 8BcQNT/cbX4XbQPgyqqduc1vPRFHAiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=bopqUPl5QO0pq8Rv2GfWUFdNI4IyEMDQCmogGXg31WU=; b=IavVtoqX7WyRExbN8h5pLdiBaT8Ar6kvGIcntS4Wfwhz3YznFs1gbhMjp6VnhaI+bOyPn6YjTgB2C arC+qbhPnmkM/Hk+3RUBuaroBu2LA5Bf0HGKtUwBwuvFNyTVnbC5HcvCH/4lOPhmwMV+PTG/AyVfgR 79xngMPPqaqkMwHTq4rm/whKsjZ3OrAVq0KFNYnaX6QNd3xyXI1o56fxXPuIxHArVI64okoTa+36TS yN3mtSf7fKFA+o9+/coTDmWa/gVjl3hj2a9bfqGBauPZ3rTQrdaGehrL/Xi/aAjiCzTDq62LumckIj wpe05DZ72lF4HKQWi72AoaRyOYn5MSg== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=TUhFu2Hs; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=bopqUPl5QO0pq8Rv2GfWUFdNI4IyEMDQCmogGXg31WU=; b=gxHfPJ8r7sXRfU2SxrpJC/znatZ6IuvdbPDejdPax6t99JIEetJQCtz+/XYcyV+ZrQoc/4DXkCrNZ BGu7LFh2NIRsrAfyJUaDrWYX+BBnEYIgfgRXz+ffbeLMY+jTRhS/Iy8cD2OsZg08HGaFTTU0la7kzX hBgf/VZfG9Ppx2as= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=bopqUPl5QO0pq8Rv2GfWUFdNI4IyEMDQCmogGXg31WU=; b=aLsjPpmTOrFMxGm3wCMtrgT5FzTEOPg2bgJaUbuVWYWGG0M2ptkwpTcl/sRujbcSTwY8C9JkmfaCU ngfYtWmnMQJXmHJFnSvbcfcaubJr09fL14QaKE4ztqhVt57E0dHhogkazgdvhyFV2vacYL+GknqAKJ 77SNQg0XIG7m6boPNK0VqWVbI/2DJIj0HskRI3c5ndkudCnEcvN4vwSw5PRCCzq5sVTtqjBN8p47Q1 BoWiTeQT5jyBsDpSoI+uMtwPISPvSec9fev17Diomvf4UUGdUx8BH8Au1Mf9k2CobexOaz42rnYeqp nJDxM9PZCAv7BcF5zCNyC9kugcvJm/Q== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 8f443cf7-d7f3-11ee-afda-eda7e384987e X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 8f443cf7-d7f3-11ee-afda-eda7e384987e; Fri, 01 Mar 2024 17:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bopqUPl5QO0pq8Rv2GfWUFdNI4IyEMDQCmogGXg31WU=; b=TUhFu2HsvMkAGL0R8IpobMXIxG jQ1gorrtLcVmLfl+FA+bdIKsZI9dCDXCbIe2wDSSWQoHUBBpDzHuIGU2dt6i32sbR1WH7h2umlv8d 3fjiTSMv6Zj/V1iBmrZyG+GZCoFCIntozDPVnHvWh6vCW/B7ImcEx+cKTWMW38cPMBfQBKIzTDNHQ eAmyajkFLBLFUWKdno/mxRE1YNrfA5wf3IGsBRXfmZyz34L4hbyxut2lySv3v8RC14z1i6KGhJHus 7vwiUpgN2FeBoZokpJ1pzoI2QECOcEgJJKU/sXCnTmJ6GFyy38DzZIMTzTsVHYrZBBx98PWUeOeNe rI3PizGQ==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xh-000bs2-2i; Fri, 01 Mar 2024 18:46:21 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 03/12] util/range: move range_list_from_string() to range.c Date: Fri, 1 Mar 2024 18:46:00 +0100 Message-ID: <20240301174609.1964379-4-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.209.21; envelope-from=svens@stackframe.org; helo=bongo.birch.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Sven Schnelle --- include/qemu/range.h | 7 ++++ util/log.c | 74 ------------------------------------------ util/range.c | 76 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 74 deletions(-) diff --git a/include/qemu/range.h b/include/qemu/range.h index 205e1da76d..530b0c7db1 100644 --- a/include/qemu/range.h +++ b/include/qemu/range.h @@ -233,4 +233,11 @@ void range_inverse_array(GList *in_ranges, GList **out_ranges, uint64_t low, uint64_t high); +/* + * Parse a comma separated list of address ranges into a @GArray + * of @Range entries. On error @errp is set. + */ +void range_list_from_string(GList **out_ranges, const char *filter_spec, + Error **errp); + #endif diff --git a/util/log.c b/util/log.c index f183ea4e4d..90897ef0f9 100644 --- a/util/log.c +++ b/util/log.c @@ -382,80 +382,6 @@ bool qemu_log_in_addr_range(uint64_t addr) return false; } -static void range_list_from_string(GList **out_ranges, const char *filter_spec, - Error **errp) -{ - gchar **ranges = g_strsplit(filter_spec, ",", 0); - struct Range *range = NULL; - int i; - - if (*out_ranges) { - g_list_free_full(*out_ranges, g_free); - *out_ranges = NULL; - } - - for (i = 0; ranges[i]; i++) { - const char *r = ranges[i]; - const char *range_op, *r2, *e; - uint64_t r1val, r2val, lob, upb; - range = g_new0(struct Range, 1); - - range_op = strstr(r, "-"); - r2 = range_op ? range_op + 1 : NULL; - if (!range_op) { - range_op = strstr(r, "+"); - r2 = range_op ? range_op + 1 : NULL; - } - if (!range_op) { - range_op = strstr(r, ".."); - r2 = range_op ? range_op + 2 : NULL; - } - if (!range_op) { - error_setg(errp, "Bad range specifier"); - goto out; - } - - if (qemu_strtou64(r, &e, 0, &r1val) - || e != range_op) { - error_setg(errp, "Invalid number to the left of %.*s", - (int)(r2 - range_op), range_op); - goto out; - } - if (qemu_strtou64(r2, NULL, 0, &r2val)) { - error_setg(errp, "Invalid number to the right of %.*s", - (int)(r2 - range_op), range_op); - goto out; - } - - switch (*range_op) { - case '+': - lob = r1val; - upb = r1val + r2val - 1; - break; - case '-': - upb = r1val; - lob = r1val - (r2val - 1); - break; - case '.': - lob = r1val; - upb = r2val; - break; - default: - g_assert_not_reached(); - } - if (lob > upb) { - error_setg(errp, "Invalid range"); - goto out; - } - range_set_bounds(range, lob, upb); - *out_ranges = g_list_append(*out_ranges, range); - range = NULL; - } -out: - g_free(range); - g_strfreev(ranges); -} - void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp) { range_list_from_string(&debug_regions, filter_spec, errp); diff --git a/util/range.c b/util/range.c index f3f40098d5..bd2d0961bd 100644 --- a/util/range.c +++ b/util/range.c @@ -19,6 +19,8 @@ #include "qemu/osdep.h" #include "qemu/range.h" +#include "qemu/cutils.h" +#include "qapi/error.h" int range_compare(Range *a, Range *b) { @@ -121,3 +123,77 @@ void range_inverse_array(GList *in, GList **rev, exit: *rev = out; } + +void range_list_from_string(GList **out_ranges, const char *filter_spec, + Error **errp) +{ + gchar **ranges = g_strsplit(filter_spec, ",", 0); + struct Range *range = NULL; + int i; + + if (*out_ranges) { + g_list_free_full(*out_ranges, g_free); + *out_ranges = NULL; + } + + for (i = 0; ranges[i]; i++) { + const char *r = ranges[i]; + const char *range_op, *r2, *e; + uint64_t r1val, r2val, lob, upb; + range = g_new0(struct Range, 1); + + range_op = strstr(r, "-"); + r2 = range_op ? range_op + 1 : NULL; + if (!range_op) { + range_op = strstr(r, "+"); + r2 = range_op ? range_op + 1 : NULL; + } + if (!range_op) { + range_op = strstr(r, ".."); + r2 = range_op ? range_op + 2 : NULL; + } + if (!range_op) { + error_setg(errp, "Bad range specifier"); + goto out; + } + + if (qemu_strtou64(r, &e, 0, &r1val) + || e != range_op) { + error_setg(errp, "Invalid number to the left of %.*s", + (int)(r2 - range_op), range_op); + goto out; + } + if (qemu_strtou64(r2, NULL, 0, &r2val)) { + error_setg(errp, "Invalid number to the right of %.*s", + (int)(r2 - range_op), range_op); + goto out; + } + + switch (*range_op) { + case '+': + lob = r1val; + upb = r1val + r2val - 1; + break; + case '-': + upb = r1val; + lob = r1val - (r2val - 1); + break; + case '.': + lob = r1val; + upb = r2val; + break; + default: + g_assert_not_reached(); + } + if (lob > upb) { + error_setg(errp, "Invalid range"); + goto out; + } + range_set_bounds(range, lob, upb); + *out_ranges = g_list_append(*out_ranges, range); + range = NULL; + } +out: + g_free(range); + g_strfreev(ranges); +} From patchwork Fri Mar 1 17:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 91F18C5478C for ; Fri, 1 Mar 2024 17:48:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6y3-0005Pm-3H; Fri, 01 Mar 2024 12:46:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6y0-0005OD-02 for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:40 -0500 Received: from catfish.pear.relay.mailchannels.net ([23.83.216.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xw-0000YS-KQ for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:38 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 54F382C1FD4 for ; Fri, 1 Mar 2024 17:46:35 +0000 (UTC) Received: from outbound5h.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id A8E4B2C20FB for ; Fri, 1 Mar 2024 17:46:34 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315194; a=rsa-sha256; cv=pass; b=laAKSyBWs37E0T5KDqUOzf5I+Vp+tItvmiPydN5DjBAvvkRZUeWLT74R9tiQ+H3Ge9hAcC X2aqgszH5wSUJyslziusbg/6EU1UkLudcKrgLUW8V0Cwwnh8Z/wDpCLYrB5ba0NVKu2rKd pxUXFdiouTp3nJmaIjGqJhQ6ABXOd+SNhb7FeHYi4thQ7QlIP8pqqVlE3ieJGlWKc2CGXr yszsat/AFNUxxkbkQFOJUHOiPGYnxq5VsnUSn6v0NtzO+3siy431ku/JJ59VkmJSjbJSIk Q8cBoP3OgUbgtQ+02dM/93E66fTU4VH28RzR7WcvV1Ajs1fepM1KKHBqHKAjLw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6qa/ABrIzNFeQmtdkh5F2jlICj/NXHjn33dee2Z9H48=; b=CnIDGllk0PUqwkKjh6VfcBja4wfToSbsVj/uKG+U0EuzHoJJBAlPV3J8vwDhZ7kQFbl5YT kop4Wen/xuMHJIddmcfQKK8uvcxkWhFd74ZLF7GLcXz3gUp9QEVndN+nX/0rvC+p4j1zef 1BEzgM9zPzPqhecJ/RDszowtS4Ha0dOrQf1jSqvjjCPjcaTIsPXyskvSxlcLCZxApXm9hg 3zBHxm8Tvui+bkl1994L5bz/fTESGzio90wawLZA3D4FH5tSzVvMNc36OdVZbGVYCtsIPR 7EpPhPH6cD9+rT0ZvpSK1YpoBYUtftJXL4Q3TDhFLmlff+lj5arP5EFKw0zbvw== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-d4z79; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Whistle-Name: 4629c484205e85bb_1709315195182_1839156030 X-MC-Loop-Signature: 1709315195182:1736634380 X-MC-Ingress-Time: 1709315195181 Received: from outbound5h.eu.mailhop.org (outbound5h.eu.mailhop.org [18.156.94.234]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.111.52.242 (trex/6.9.2); Fri, 01 Mar 2024 17:46:35 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315098; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=Qh1gDycCYdELK21o356rmV5Tm9Bai0YtO3euqgO1QO5sZofl8z55ls9iO1QqkWmCn9DdIByqRFk7s WKWyDauNd6YIIwgGTw7WXLkiE/TGwsVL9E3ZHh1jSkgccRW0svirtNycf5XXZRlh5y81Zyp0hvvM6z BLETqXxGBxnHES8wUj5Dp5QPJjG8OG7aTghmrMy0+1p/PxFPbz3Gt4oDItHpYMWJ5Wlke+ccZex9Iz WdwaUY/dM9bxagP7OGbUHKAp3+PhK5HK4za2eTeYAmzGMW4oNKO3lcEThb8Mmt/TXEbznSi/4OUM8m /sGEdkQZZN3SrKnMnReR7dAjBKhwqmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=6qa/ABrIzNFeQmtdkh5F2jlICj/NXHjn33dee2Z9H48=; b=o5G1FOVyKpL49SO9LgH+/yNW8oHT2LVk+gz37XaEov9hU4F0vwBBF/JY6VNPvFwO3AhHJLRTFebT7 992bxsf+fsdXWyMRf0TC+DUY4lxZWNwViZINyNPLo7UN5RMUeDIDO7OSUr8HfT5MSBlX4KllZPjla+ YVtKG1f9GS6a9cT5A9BCwZCzy6Sav//dbaUJCnBywZucQ9MxnRv4SNzOtlKJAN9HLri3bRh5yobU3O Wa8BVw3S23Z1PuGjnDMNNK2OeQqIF3O9+nY8MeII6hr038DskXVEFJjmdvYWhW4ClbXgASLFbjsYAx P4rId7XIRp6Cj0wgeNmZpYuaSjUJADw== ARC-Authentication-Results: i=1; outbound2.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=as0lzJGo; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=6qa/ABrIzNFeQmtdkh5F2jlICj/NXHjn33dee2Z9H48=; b=XJCL6aPMDKv3x1fkHAIUnGGr9p0ziS8asFZnF81juXXxvZn7+v9fi7VrpAzDsgEDHvoDBRhEAxo0+ 5CYEU2qAiMxs5xwQRNMi0aYbrjePyy4Oif8DJHwna4X7PlDSJ2M7bpMv5Ls4aVR502o6rlEUZH051o T7/X/tBivpEECVHg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=6qa/ABrIzNFeQmtdkh5F2jlICj/NXHjn33dee2Z9H48=; b=LquhqCVmLNmh1PcNZVRjeeId+t4oJpFcJnFjtRlFim7hsCJym21wn0CXP0yVCbvG+AcUNDMrRUtHW J9BI8jByct83oi96hIK0ub0+PRG+VlOY84o4tnKvX0Y+qD4AWUxVV0d2Fsuq+rtfW84Wi2MdynJ9cB 5V7RMpy19681hqGbiSl/PEcC1yiUwgsiFaNRtwKvUb7QGd6b8PL7pzZKyfCOMwmE87RPparTxgM/fz 8M6Q7USINx2YsenkL488HjbI+2wd9za3CLPjANxC61YaUjAvzXERofCff5BnhZX8/bhBB+FIDdKu83 GGZoA7NfOWP5ZxpnY9ONUvjo3Jw/3wQ== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 68dd22f3-d7f3-11ee-b66d-9b9d9be6ef2c X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound2.eu.mailhop.org (Halon) with ESMTPSA id 68dd22f3-d7f3-11ee-b66d-9b9d9be6ef2c; Fri, 01 Mar 2024 17:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6qa/ABrIzNFeQmtdkh5F2jlICj/NXHjn33dee2Z9H48=; b=as0lzJGoPkMQXbZGj0fXfwxvJI bi1r6gg4MtrTvxNcMVOz3CtO3kPClxE5l4md3zfJEipJ+jNf6nOkjPnfG3/COK4m4Uah0w5Qaw8/z 55uAWqgIu/IRoiKC82ucSla0ysaDAlbrDAdrS7UeEkW2PUJ+FbVJIZXWJJ5Xl9j8fwQhTTCCR9eit bLGAxM0iEgmCRqnbJ76HJVyjHrTeEE5D53qEuWQ1fbzUE1ORM+5eD3mF4Q/GEyQxXnpT4k9ix66/D hnIvCpx6hqLZQFqP0gQ/voP3ZI33Ps3KoG/iIt5EfZXyct14cj/B93/0FNO6aRlSwBXMIpp955oIs pI5ZfZZQ==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xi-000bs2-32; Fri, 01 Mar 2024 18:46:23 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 04/12] util/range: add range_list_free() Date: Fri, 1 Mar 2024 18:46:01 +0100 Message-ID: <20240301174609.1964379-5-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.216.32; envelope-from=svens@stackframe.org; helo=catfish.pear.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Introduce range_list_free(), which takes a GList of ranges and frees the list and each range. Signed-off-by: Sven Schnelle --- include/qemu/range.h | 5 +++++ util/range.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/include/qemu/range.h b/include/qemu/range.h index 530b0c7db1..4ff9799d89 100644 --- a/include/qemu/range.h +++ b/include/qemu/range.h @@ -240,4 +240,9 @@ void range_inverse_array(GList *in_ranges, void range_list_from_string(GList **out_ranges, const char *filter_spec, Error **errp); +/* + * Free a list of ranges. + */ +void range_list_free(GList *ranges); + #endif diff --git a/util/range.c b/util/range.c index bd2d0961bd..7234ab7a53 100644 --- a/util/range.c +++ b/util/range.c @@ -197,3 +197,8 @@ out: g_free(range); g_strfreev(ranges); } + +void range_list_free(GList *ranges) +{ + g_list_free_full(ranges, g_free); +} From patchwork Fri Mar 1 17:46:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CE0CBC5478C for ; Fri, 1 Mar 2024 17:48:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6xy-0005NI-Ob; Fri, 01 Mar 2024 12:46:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xw-0005JF-QA for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:36 -0500 Received: from gorilla.birch.relay.mailchannels.net ([23.83.209.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xv-0000Xr-4b for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:36 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B88F336221A for ; Fri, 1 Mar 2024 17:46:32 +0000 (UTC) Received: from outbound1a.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id 091643620D3 for ; Fri, 1 Mar 2024 17:46:31 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315192; a=rsa-sha256; cv=pass; b=4O0pnmecDo6f6w248d0ypIbE+9PM7hnEApbwDGuR4GejT+em0M8ZOh0lpM9ulxPMdeOupq zzC0thl5/87HKPRsReS6ieLSMrIQeK8w3bZPw6nUHKV6VORrNVfATQwyQske4W19+VNHl/ 7KSVM7cdZTUiQau1bzD/rkhuc5vIJSAOrp9bZA+Wg373a5RBTI4PuT5TRrIQIBveWA/QcX IMjtsZ1fIHXndbg3DocB4QI1h8Ag+COt+b+hMOw19X3arQJd9F8ZF7Pn4iEG9tyKelnTZP CEFlENqSMvRdNlc4llsnYtZYtCIlbHM8uHUw3WAmh/kbnjc36H4qdfwUsXBKQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=suldy6Pm53qRnmnMjTrVoAOvBs33/kELVHo74PC4+Gc=; b=p0KBmWeg4iPJXuhWwiwGfZWmPDGhhczHI1njKoqBr0H6CsdMUVjuxflttN20cz6ePZ/2nV 5bcGqnDtdf0pcqKWff4u4MRP14/OJd7cXx0ejXn3pcqPc72ZDWueq6t9Jt90WQ7AF3T2B5 1MLQTrr6aXVD83J5f6ahiWOqnJNPhMZNTBJ2j36NA7Ie5048Shx/x5mqsMmu2lLmhq67F3 +tJ/QYGoen5PMnbvLMMMdtJuNNDBL462KQ9dOYMt2KjO2oDM7GF2q31knw1Og82pFBGXnB l5oi1t1rZVtWze4ayMsmIlTGCwTCfw1utSqnAw+w+GOsEXjKSkzaRTqu9s5yIw== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-tqm9s; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Cooing-Print: 097c24fc0ca33073_1709315192539_2281873587 X-MC-Loop-Signature: 1709315192539:4189527769 X-MC-Ingress-Time: 1709315192539 Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.101.14.227 (trex/6.9.2); Fri, 01 Mar 2024 17:46:32 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315099; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=ONdFBcFDqDy33n+VwroYjdS6t68l82mqqF6dnZVbJp3MvX/m/70OwdKjEs2Bog6c7b53S0nfYCxpk gKJgttgxdxadxNRIIfqYOvmkM1/n4BZFEjpVb2Q2hmNwz4sSklooH6UpNkt1i0Z60GAiMRrZJ532i8 /cBG1MGAvNfClQj2ryRZVwwMaaz6OJ2e8w6iHSLXbkxP59pGvijhLEkkCfsqbUNAZwogXcNCXPd15u iHBHvfHDrNtxzZlOaY8RDcCOerNAz03wuyDfJZhckGrKeheFuVKL4aITrJqx998jTy1pY7wMEIQdFl 6SucBtI0aYMOgRo40zrffogZzVO9EQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=suldy6Pm53qRnmnMjTrVoAOvBs33/kELVHo74PC4+Gc=; b=rYw5B2TqrpoJS2oU8MPNoSkQM87NEyXc11BXeJAf652Yt+h38aI3zy8C7tBzNTGbvFhzspv0zvHeG SHJflt2IjjKrg7tGQeVTF5z3JEIMTkbE8jUtdbfuOHNj4yf2hfdOTVxA9YU445VgX/ZClC5k0P/5Rg 5y6eEt0GT2A0hkw+WkBMke9QuugDuEai+TVUfp2hydoeh0CkDj9ph7mjXkV2ZCK4OcsMSrWDlEnMcW N2gxAPFCjLV6SS4tPycUuwAeLY+MmnAW3CAu1a+3BXy1ibC/TQtyGBfgAysSogbsa1mplm/NJ68cEI I/2Mz+bbVpeetSOjjKdGMCBfhMEtYlw== ARC-Authentication-Results: i=1; outbound2.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=ldM9/7FX; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=suldy6Pm53qRnmnMjTrVoAOvBs33/kELVHo74PC4+Gc=; b=FKTdafPYn35vXsfauBV77f6QmlNxMcfGtNj3AGtlJy6/fUL99aH9tFC2aKiqtau/zqfP/XLVa2/tN Qa9jwLr5ddxxZPSFHFRmvXlv2BhOo28LWdbomc+3OUr91pPKECWiIOlNY3mDDaEiMEbTdhGPqhDTF9 kz6Jle7o7HRwpnyM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=suldy6Pm53qRnmnMjTrVoAOvBs33/kELVHo74PC4+Gc=; b=epNtBOzj5SnqZ5hPAd1qnENdyeYo1iEGiEaTh0beUezB+0/NrWc+6Vun+OIHvc7+JLcYHHxieMhwc EtxmTBjGtXQwVftOc1q26Asf1F7+8IMrNZ+J7lN6JKeWF5jBR5yiTiK1Cti2Q/nG7BhSNxyLb/486Q gFX/4kmiVDb8Kbm9L1JRj/khmvFbx6vAsYpZtyF+KboZERjymb//pK5Gdmc9CwfLg6ZfeuX5RKrZAg 69HkYuA9daeDCvt9baaXXRhe406SshoTAZZXnrdrkFYIgGh8iOMVV4hvvem5iq45L6Z/2VJU3u5Bz5 1+Quon2WYsjE1wYP8ufhTGuMUbp7uUg== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 696857e2-d7f3-11ee-b66d-9b9d9be6ef2c X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound2.eu.mailhop.org (Halon) with ESMTPSA id 696857e2-d7f3-11ee-b66d-9b9d9be6ef2c; Fri, 01 Mar 2024 17:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=suldy6Pm53qRnmnMjTrVoAOvBs33/kELVHo74PC4+Gc=; b=ldM9/7FXpzwsTp40SajH5+8QP7 9skIO0VH4KbUetj1lFD4bRL8poczpTJjK3giAcbSqDdhptRmC0EbTVEGu2UU5U1QVBaDJ4eg9QGgU ebKKy/asrQbuxg78T2hVaouFBbLnWPf46MRQvY8zzXZgmPs9cwIhH6omfc3oSn6Yj1ReB+7cXOyqq 3Dlo34vKwucRkB8x8/JLstTdA+BesMgz4OmWSlmFAGd5sXvidRCDCGCnnlTaNMgD8w/8PCutyu9Mk nqqpkRtGjBiGBG3b6J2jsLbpQJ0KMFQUdr5a1XWByyaQw/lPLSx5C6KLVUuNE17Loynd3Qv8+7p1F +zh5mk/Q==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xj-000bs2-35; Fri, 01 Mar 2024 18:46:24 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 05/12] util/range: use append_new_range() in range_list_from_string() Date: Fri, 1 Mar 2024 18:46:02 +0100 Message-ID: <20240301174609.1964379-6-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.209.75; envelope-from=svens@stackframe.org; helo=gorilla.birch.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Use append_new_ranges() instead of manually allocating and filling the new range member. Signed-off-by: Sven Schnelle --- util/range.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/util/range.c b/util/range.c index 7234ab7a53..db535de9a7 100644 --- a/util/range.c +++ b/util/range.c @@ -128,7 +128,6 @@ void range_list_from_string(GList **out_ranges, const char *filter_spec, Error **errp) { gchar **ranges = g_strsplit(filter_spec, ",", 0); - struct Range *range = NULL; int i; if (*out_ranges) { @@ -140,7 +139,6 @@ void range_list_from_string(GList **out_ranges, const char *filter_spec, const char *r = ranges[i]; const char *range_op, *r2, *e; uint64_t r1val, r2val, lob, upb; - range = g_new0(struct Range, 1); range_op = strstr(r, "-"); r2 = range_op ? range_op + 1 : NULL; @@ -189,12 +187,9 @@ void range_list_from_string(GList **out_ranges, const char *filter_spec, error_setg(errp, "Invalid range"); goto out; } - range_set_bounds(range, lob, upb); - *out_ranges = g_list_append(*out_ranges, range); - range = NULL; + *out_ranges = append_new_range(*out_ranges, lob, upb); } out: - g_free(range); g_strfreev(ranges); } From patchwork Fri Mar 1 17:46:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578871 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CCA1EC5478C for ; Fri, 1 Mar 2024 17:46:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6xx-0005KQ-QV; Fri, 01 Mar 2024 12:46:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xw-0005IV-6U for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:36 -0500 Received: from jackal.cherry.relay.mailchannels.net ([23.83.223.95]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xt-0000Xp-Mv for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:35 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 3ECBD2C14BC for ; Fri, 1 Mar 2024 17:46:32 +0000 (UTC) Received: from outbound3.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id 886D72C0DAD for ; Fri, 1 Mar 2024 17:46:31 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315191; a=rsa-sha256; cv=pass; b=4lidzezoFL8tyQOlRsmqBX8/3Tj5pXXAehoqU9q1d+4rwhJdLTh6TrGOZoXeUbm3QJoulp Q/Wj65r8KZU0FboJA+eo8cB1irJcQZC/uLPa3yzdx/ExlOed9RhXLvP19XHtLlzXQrrK1O tl65C4DgoBWg75SLqQklHrtszyNviKEa7XFWDjgqfG9k93BuT5a1TgbJ+o3KljBPogXjN4 AEssV+3I66Z7T1e+hhm7TUJIhUcy7TLLxKQvHrn1ZQ9sn9my08sDKwkWpsWy71jtcwFgae r9JZJCuLgk3JF+ug8FwURss77fIn49bcE9CmiWmdpKChsSyjkEKzQy5dLJbT8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RKHlFYQEvFhYMO/SO8aNWCGjXelzy2FG8sU89hTJDvs=; b=GXESp/3rIUaqI3+VljMYjfIhYIRrc1UV0U6IjVvCUW4cRdVd78M7BMtexm+L7V6NKzFK9Q v/YZxvpusAXYs7pczjt4r8GvbjWuizdajpTl/R32/Eu28eXf+YvGOttuXUZ+tSLTQIQPIv /m+5sKNdXGsO0cfSd5soKXTBKPm9OnyS8mpGxaHis/lsGhnmWDgALmwS4xcLxw3lqG1u4V 6Rm+r40b8s6ZU5dM2NWHPGmufavsR1rrdkcB7oW2Ssjqe8R+AH5N8HDeTpb3ZZjuAbIyts u+uVw1VmAs34RhgulVVLOfG2uw/fdOujqmx0ANMd3Q/AdsmqMDIbhVQAVlfURw== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-2hzk2; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Macabre-Robust: 0d0f432d4f071f35_1709315192059_589722710 X-MC-Loop-Signature: 1709315192059:3960506157 X-MC-Ingress-Time: 1709315192058 Received: from outbound3.eu.mailhop.org (outbound3.eu.mailhop.org [52.29.21.168]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.112.142.242 (trex/6.9.2); Fri, 01 Mar 2024 17:46:32 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315165; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=TXeUXZfq7NbPXOXlyfwKO0WmHXuIYhvzMH679f8amDDOMh5z17pDhy2YE5C38FoVMVgaEdLkuqPXJ GnvgP57atbglzHaxJUIkdSlbjFsWvFD17mPwax9sCfm+QZ8IfKMKCgB06vYcWPMXw3sqDSFamNhw3i C95x7HoSr+O3k79ME++3Mt0FisnwVRj622ioP8ZwQ0rpMQJ+yTerGg5KB5vfUqwKOC8s5EbsADJpND gFrIYuGfnyCpVphlh+SSsUfnilxE7Hu/2Tgq3r1pgW0KeoZAPA1eDhJQ+BtRqAEDu+2yYG1adb6wo7 iJYH33FPmmk7v+1JIhTZ/6q8Df70P2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=RKHlFYQEvFhYMO/SO8aNWCGjXelzy2FG8sU89hTJDvs=; b=lCtYwg1uBAGmT1Q4QoedWyonTf4R9894oQK/M2CR9buXk8aAVp4YH9yG0EwfazRfNONMSleGIUnIP EVMWcLeiA/B/fCp3zGKSC1D2A5rGQed7A35AB//WbWRa9fwbD6J5BcDGXTAHDjTWxnFmW65U2IatJr AZlhuCdfoM4j7D9q5WLXd3ef3iv6rLGW+4Sw0e5l6jhSoQcF3oI0k4xUFz4b5nanq5+mCp1fMGoT32 B/inGCvdKT2bn2j09MHSAeyPgJQyyVCLLzE6XrK/0fqkHyYDj7/jl0iCWjQMsbJ4xZMee7t1P86Gtc ODEPRGfMOnWzd8RYXsUsyrR77Gq/9/g== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=b196JUsG; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=RKHlFYQEvFhYMO/SO8aNWCGjXelzy2FG8sU89hTJDvs=; b=OgFa9V+l9KnOpQN0DvVob7DiMnCoXRLlUjxr/z9KksGYt9s/2pWIG90KDyHN4Q8wL4p9QtRY0fYXv A/erXH10ktzrq04reJgyjVY8WjhQX47misxn5zMbi8tdFQ/QVBlk2dH0D/UnfYP2ngPD/8/N6WOSdD G+HZaFpaTmG59zeo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=RKHlFYQEvFhYMO/SO8aNWCGjXelzy2FG8sU89hTJDvs=; b=dzDbJNEX9AdUDfVDwSzXQbqrXMniv6cQKJeAdgPJzAR5HpEl/nZtX4eMpGLMeGcakttG1iT/e7WoC XUxT1EScyrDeukIH3jWGtPcOnkkOhUbN32VBFMYFLBK/FVpp/lFDyg7dQIOEr3Jjf/buXC0HTYIvYS tCJGUA01ysRqzqLJp4PLRMfpV0R0JgCbCq6fQzkBMGsJV1f0rjyMUZyZMrRK6UarHXgO19T6NUiDcq yC4ULHGMVLsO/0ZVMHwQnqBjctehFN6drc9iKxyUj+0vP1M959nKJpv+TZZkwr60yjdyd17eOgr4Vg 0rPFxTLnTOk5++X2JoZm5sxCSzWvGuQ== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 9112721e-d7f3-11ee-afda-eda7e384987e X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 9112721e-d7f3-11ee-afda-eda7e384987e; Fri, 01 Mar 2024 17:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RKHlFYQEvFhYMO/SO8aNWCGjXelzy2FG8sU89hTJDvs=; b=b196JUsGtXak3wJy9rX5JLFc1/ EpgTLuvrP6aNlKZCJGrOKzE4C3LN5p7uT1QnH3GvH9R2Vm18Fv7B/0NAKtSV8tC8PTNNIuDgdFCZc 7X5w84dOMKnxzBoG5Kxop/TkQ3wWG4MV4yTA78+onzY7aN04vTC9TzKaR9BXSqwMLvVPHDFiOwQOB KILRJfnoN2D3rIhA5M+FRVwbt/MfetN6se1YngV5vM253/mh7clXTW4C/ux5pTZqXvcis1aixIi8t soroB+CATnPp+XiuKih7WhlLx0t8/fkEFnxFBIBS+qz3eNZW/lRX0+Pwz6VbagtMXdkCLSefMg+Uc lPLvLzIA==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xk-000bs2-2p; Fri, 01 Mar 2024 18:46:24 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 06/12] util/range: split up range_list_from_string() Date: Fri, 1 Mar 2024 18:46:03 +0100 Message-ID: <20240301174609.1964379-7-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.223.95; envelope-from=svens@stackframe.org; helo=jackal.cherry.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Makes the code a bit easier to read and maintain. Signed-off-by: Sven Schnelle --- util/range.c | 119 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 70 insertions(+), 49 deletions(-) diff --git a/util/range.c b/util/range.c index db535de9a7..8c463995e7 100644 --- a/util/range.c +++ b/util/range.c @@ -124,6 +124,74 @@ exit: *rev = out; } +static const char *split_single_range(const char *r, const char **r2) +{ + char *range_op; + + range_op = strstr(r, "-"); + if (range_op) { + *r2 = range_op + 1; + return range_op; + } + range_op = strstr(r, "+"); + if (range_op) { + *r2 = range_op + 1; + return range_op; + } + range_op = strstr(r, ".."); + if (range_op) { + *r2 = range_op + 2; + return range_op; + } + return NULL; +} + +static int parse_single_range(const char *r, Error **errp, + uint64_t *lob, uint64_t *upb) +{ + const char *range_op, *r2, *e; + uint64_t r1val, r2val; + + range_op = split_single_range(r, &r2); + if (!range_op) { + error_setg(errp, "Bad range specifier"); + return 1; + } + if (qemu_strtou64(r, &e, 0, &r1val) + || e != range_op) { + error_setg(errp, "Invalid number to the left of %.*s", + (int)(r2 - range_op), range_op); + return 1; + } + if (qemu_strtou64(r2, NULL, 0, &r2val)) { + error_setg(errp, "Invalid number to the right of %.*s", + (int)(r2 - range_op), range_op); + return 1; + } + + switch (*range_op) { + case '+': + *lob = r1val; + *upb = r1val + r2val - 1; + break; + case '-': + *upb = r1val; + *lob = r1val - (r2val - 1); + break; + case '.': + *lob = r1val; + *upb = r2val; + break; + default: + g_assert_not_reached(); + } + if (*lob > *upb) { + error_setg(errp, "Invalid range"); + return 1; + } + return 0; +} + void range_list_from_string(GList **out_ranges, const char *filter_spec, Error **errp) { @@ -136,60 +204,13 @@ void range_list_from_string(GList **out_ranges, const char *filter_spec, } for (i = 0; ranges[i]; i++) { - const char *r = ranges[i]; - const char *range_op, *r2, *e; - uint64_t r1val, r2val, lob, upb; - - range_op = strstr(r, "-"); - r2 = range_op ? range_op + 1 : NULL; - if (!range_op) { - range_op = strstr(r, "+"); - r2 = range_op ? range_op + 1 : NULL; - } - if (!range_op) { - range_op = strstr(r, ".."); - r2 = range_op ? range_op + 2 : NULL; - } - if (!range_op) { - error_setg(errp, "Bad range specifier"); - goto out; - } - - if (qemu_strtou64(r, &e, 0, &r1val) - || e != range_op) { - error_setg(errp, "Invalid number to the left of %.*s", - (int)(r2 - range_op), range_op); - goto out; - } - if (qemu_strtou64(r2, NULL, 0, &r2val)) { - error_setg(errp, "Invalid number to the right of %.*s", - (int)(r2 - range_op), range_op); - goto out; - } + uint64_t lob, upb; - switch (*range_op) { - case '+': - lob = r1val; - upb = r1val + r2val - 1; + if (parse_single_range(ranges[i], errp, &lob, &upb)) { break; - case '-': - upb = r1val; - lob = r1val - (r2val - 1); - break; - case '.': - lob = r1val; - upb = r2val; - break; - default: - g_assert_not_reached(); - } - if (lob > upb) { - error_setg(errp, "Invalid range"); - goto out; } *out_ranges = append_new_range(*out_ranges, lob, upb); } -out: g_strfreev(ranges); } From patchwork Fri Mar 1 17:46:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 56442C5478C for ; Fri, 1 Mar 2024 17:47:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6xz-0005Ng-Cj; Fri, 01 Mar 2024 12:46:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xx-0005LB-Sg for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:37 -0500 Received: from kudu.cherry.relay.mailchannels.net ([23.83.223.97]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xw-0000YM-1A for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:37 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id AE8FF4C27CA for ; Fri, 1 Mar 2024 17:46:34 +0000 (UTC) Received: from outbound3.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id D18834C23BC for ; Fri, 1 Mar 2024 17:46:33 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315194; a=rsa-sha256; cv=pass; b=gD38D4j5V6gJCxe8cYB7p2EGUZLaa8dkdKh1SIymGM+vbReIy86lD6AXuraFk+6HFR/SSh bNrYBciTRu+bbeWA8YYmkOag48plgOxpxiYbBkua2YC+L/b7R3uc0I9wTAsyAftzT3eXG8 vF65S8FDRmpj9KnB4TsHzEIG5YLa0iAygwjoOCaLqzCN65wRXUbZnaMv6+++wfqgUPr5lW ZoiThGCES3+G2eZJSjMi/W4veVu9RpT52ZzWL9C32sgptfu+VazPDTsosHUzK02YuZrU3F Jznz91pdX4Q9p/HLV5Ja/6DDd1raFzDMTX9kNDc1th86uDvU1rW01XXe6yj5xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EDGjLGC6+iggpwOGgPEUhv6ALw0cm2bykCS2uoNYmHU=; b=+QTlKeOis9RR8vuxXqTD7RKY2Xo0i4SFLoKvOKlsXtyRNSMV7acpuiQAQKdYZ8eMMO1Kz/ bTsdfufiwHa3hzF5jwq/Ur3ex95gJaRZ6OhetPrOzQK5qqo4JRkzVvV6/0puWqS7SWQQhx cV4bE9rZUS5vJ5TDpPdyzbMJc4CSRm3bCHEZXuybww/RoFCBFi4Thu6+fTI5OkYb+8WtTq img/KvzWspwxLZlq6Fs2olqTUrN/RKz1T1RtTERglDTjYkuTJOiZ6hc9wDL62YY99ZsaWX 7GcnIaTGezLNKT1sfgqyzSQlFDQu87RfDpjCtfAuA1K+7hLg45x+L6uncd5B+A== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-jmwb2; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Left-Imminent: 508425fb36bac44e_1709315194353_855391027 X-MC-Loop-Signature: 1709315194351:1609689411 X-MC-Ingress-Time: 1709315194350 Received: from outbound3.eu.mailhop.org (outbound3.eu.mailhop.org [52.29.21.168]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.114.53.127 (trex/6.9.2); Fri, 01 Mar 2024 17:46:34 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315167; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=HfpUlDhMTJ3jVEYdTW6wcjDJBBAe5iCbwwF80RAhM2IwkNmWe1bMRmVSNiwAIecNnBaZaGLNf5cvp iYt7Hi+zg/7kIGnKk88PAIDy4wkfU4BPfQmnmGoATO9oV8QZDxL8LVBt/oE2UzUL51/TcxmRdtbUM+ 6ddL+MWvOOfgtYGN07bgEi7+UqtgumRKPe9m3WuqguYRqLim0e+4PEVFmHla1o/f8wFIO31XSYa7HL foO6uAnf54UCL5zMSrLF3DppFVk0p3lyft36BilVHmLRJ+GZWKnI21ngk/91INi8Txq9xjGn3yRq3q O/CX+dUWFqT5BVD9D4SAvOUggY1bb7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=EDGjLGC6+iggpwOGgPEUhv6ALw0cm2bykCS2uoNYmHU=; b=v3Z8KAxS6cyvF/UgX97Wqz6le8ud7yppyvBaBBhOh8sD2T/jjTmIl5Yvs+g5P7YwituhIAXEAzl0t ejbAhvcZlby6cYlZcLmCRbI4e8xgVjq2249cltHkf2JiLBl2y8SF9B9c1sWAYandloVQ4Yimnh84gv s97KHbRkjLudBEMnCua3HiaMLxyYBM59g7Qm45dKYCaygYT/2892NZkPU7/I1Fm7PqW8fPEe8IPDHF IG9Gtl+YsU8qmkrOlMsO5zW5wR4HyKX6nQzpRqq6b24Tc2DyEceIt9MRteOAqOjJ03g247f3UUSPY0 VVYboHWZsVfhPXvqKNokZFVY8DAALfw== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=eC6ZbTx5; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=EDGjLGC6+iggpwOGgPEUhv6ALw0cm2bykCS2uoNYmHU=; b=nj/hjMpNGo8BkFHMiv7Vm4V6u9E+Neqkm9D8X3+/oR0oj+KgK85+E3Erm7O6PnfRMcYI3NOgg+lfG jUNxLVYwyF6TBfUZvnkw1X6ad1e5ivgxDAMm1pbzmB3qkDR5ZbKGRP6NaVdN/FUhWcUJGsPEwPW1/F DpHhUlNRCh/kkX9Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=EDGjLGC6+iggpwOGgPEUhv6ALw0cm2bykCS2uoNYmHU=; b=UX5k5V7JU+IS1NqwBfv4JhlJcERPlqIIbZeMRApKdmbnqkAwieRZsX108mszuWk4ltdC7I/wtJ9Iq ld22cEc7sRbKbUpWKxF/bXIRnwCEk9H5DC/KFezo2FE0q0krOSXjbCWZ7cj6hG3lOKm2905R7U/USZ 0hLNu9EOrsD6MKgAG1rPHOYLzgI4ugEqd+yltaim+McKCaHP5RlWDH5oMMsdormWlNh2SrIRgZ86Iu LEVmst76ODN/8nhWYulO6nutrYcYM58fY1zkSHO6tHZKg/PWWj1pLx8aXD3USkSTNTDtcSX2CrhlXd ZHIdLu1RVKG03NUr+moURddwp5S6fPA== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 91a9270a-d7f3-11ee-afda-eda7e384987e X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 91a9270a-d7f3-11ee-afda-eda7e384987e; Fri, 01 Mar 2024 17:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EDGjLGC6+iggpwOGgPEUhv6ALw0cm2bykCS2uoNYmHU=; b=eC6ZbTx5wPLgqg7EsnpLkqxazW PX+hz7hxgCWCqyzNE3OYNjJzuKCUC63a3duf/qb1fvLxOWvod8VRhhs+FP91L081CQki2j6II/COb n/53dMzHDcI3seK1F0V/Jy4vZ6cGXU35CtOpQbxOtuuZHG8dczzX4RQGcLDN3+5+bhelXtTZFDNqo ucHxdKbupx/OESMD37MWQUIwFCDU6r/N1/GtqQwjrfyAtyX0GVkGir6IlOlLBXsfOr7Lcl2liDFFK SEZtixnxWGU/5jedUXQ/cjEzAmPtoAkTmweyTmHN2Z4Cj2PJzSup9bygrLWi0V/8k3CunoK3lXgSM XKrnPw7g==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xl-000bs2-2d; Fri, 01 Mar 2024 18:46:25 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 07/12] util/range: make range_list_from_string() accept a single number Date: Fri, 1 Mar 2024 18:46:04 +0100 Message-ID: <20240301174609.1964379-8-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.223.97; envelope-from=svens@stackframe.org; helo=kudu.cherry.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org To use range_list_from_string() as a replacement in the execlog plugin, make it accept single numbers instead of a range. This might also be useful for the already present debug_ranges filtering. Signed-off-by: Sven Schnelle --- util/range.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/range.c b/util/range.c index 8c463995e7..7784c21b12 100644 --- a/util/range.c +++ b/util/range.c @@ -154,6 +154,11 @@ static int parse_single_range(const char *r, Error **errp, range_op = split_single_range(r, &r2); if (!range_op) { + if (!qemu_strtou64(r, &e, 0, &r1val) && *e == '\0') { + *lob = r1val; + *upb = r1val; + return 0; + } error_setg(errp, "Bad range specifier"); return 1; } From patchwork Fri Mar 1 17:46:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578880 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A76F7C5475B for ; Fri, 1 Mar 2024 17:48:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6y0-0005OL-Ag; Fri, 01 Mar 2024 12:46:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xy-0005LI-2j for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:38 -0500 Received: from kudu.cherry.relay.mailchannels.net ([23.83.223.97]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xw-0000YP-G5 for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:37 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 1A65D2C1084 for ; Fri, 1 Mar 2024 17:46:35 +0000 (UTC) Received: from outbound1f.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id 6D3662C1D98 for ; Fri, 1 Mar 2024 17:46:34 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315194; a=rsa-sha256; cv=pass; b=NK/nXuJEYtIggWqN5LqUMXQH4/MIn6MtdVti59eC5SWDomPgUJhM5WBGn3F+INys8I5980 22u8vobYaKPvd4x2EuTpRgYfsYV4gf8X/2LXvDr2SI4rFVZ/a7lA4tbMBr3ASS74y6bWFm zMZlyLid1kfBzNDaoui6+bqOjsI4hUulhdlFC4f02e1vqHkaPXVYRG3MpmKA/MWLC1q03m gfHWWc9z6i9in0QIdnrBN9T+U3qucpHgAchuDpjdgjIrFpErFy1/hxTV7wA7FkpDOf0FUR rrbZ4oxBuFxAoqTb0AKnHzGYnJQ5bVQzEieWe+3u7vVaxxZwtFRuGKX1l7tvXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HUL4zxvHsk3QHlw5QiDCgjuSljLjXHEAHk3yu+AzSaY=; b=57da1J6Z/3iGJdOmXKM0Kb0od4Po7Sp4r4jQejzs4va4axEPZIatUFeYpv+0bbIv513c+f 4OYEDaWQ5kbu8wpXhKMl10tPuWOJGapgCTVIp7+RBlBTkEcjXb5h4PQ30hTcIc5yTezhKu kTPJP1d/5ahRyNG4c5HcQUsK7m9yUgmAsc49KkDlVvMLIyWvvCdNSFr+LhZdizhj77FlvE Fm6PwDqj+pONmN8uqdAAfwHB2ZHcxoYa1muXRxDOTm2wLVEsQDPFasl9/4o4bQ8vrId4jN gyyrxNpb0vQHyQ303kf27JK+/N5EdCoScybPWq5AvySD9lsHPbBxNbmhomZI5g== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-9jms7; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Scare-Shade: 14ee16277f0fbd86_1709315194947_1297384744 X-MC-Loop-Signature: 1709315194947:3419211672 X-MC-Ingress-Time: 1709315194946 Received: from outbound1f.eu.mailhop.org (outbound1f.eu.mailhop.org [52.28.59.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.124.220.170 (trex/6.9.2); Fri, 01 Mar 2024 17:46:34 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315101; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=bgS1bkK4T/pqbMlP8hghVXRmnl4OwbkbLmvc8x3qEfMKu9dcvLIwmomH7VOzOcXG2NHLpo88LNF+6 MpcXsodJPxttrtyRN3zLtq9ctQ8RbzdmXnr/RkmRfca+jth9ukuoC6OJA35JD5l8fKugescLDLnE7y fULx2DUuiDzJ0UbnEUTZ+G3XSN6EKh18kT38yaPuccWHZ9okz5w+r/8JUdEMAfszc4VAmn7vgykHwQ L3+K5HAlSH3QVnmx3bu5jrKNma/yx99JKxHZCY769UI3BYrpahv6pYo0o+6RhpYhmPaPUC8vZu0bQY Ny5DNRLdt5llUWhNj8YYm7AU6CFLg7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=HUL4zxvHsk3QHlw5QiDCgjuSljLjXHEAHk3yu+AzSaY=; b=MjAQ31yATOxyZzgEMXGhkajIoSdxFTa9gQd009pUC7oeFmDk8OdkJvfXHSiDHwYXtTx63mqTPTjhr tcS2+VXKPk70DiCd322FQuVY19PhGsSW3pGILdS1cotlv9Ve21y/KbRLfMBzXH89SQD6ncyHWisWyb NCZBs34kFM3rdFyBfLgR1DyOODhfCXVgZRrrvdWLwi1LPGF9bssxuv/RzAocprahXW5OKiyRJrKehs 1IqI+0Zv//nxbfNYb8ZsKP3nyoKRxIzgmIAY8h2VEi4W0TVq3Yd4/gHldc+K2cRucKYhybS+EXmGA0 qv57N1FY0OJZAFkc7BHr1g3vKglldUg== ARC-Authentication-Results: i=1; outbound2.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=CERtcaUL; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=HUL4zxvHsk3QHlw5QiDCgjuSljLjXHEAHk3yu+AzSaY=; b=Vy3IXlR0M2LmEn1XQUsubOcLbZcurdaAAT0x+vxaA1BG0YtASkXaeYBvPsIs6y1U+J8mpbdGncr0B Q1YsMtHa+FyjvHyD3B1Ts1cC0ecmZDDsJie2STsiz9qJzB552ntodBUzybBds7gHdBPp4NJpg2WzvB 7ioxaw58Bt6qVteI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=HUL4zxvHsk3QHlw5QiDCgjuSljLjXHEAHk3yu+AzSaY=; b=mdutM8SGBmS9SUtGK/lhahpRpmm85GHV0QBtjZat9CKLQ7ugagpCUp1olRHVYE86CoNOpPBw09If4 2/PZ1kygxdpClnijcRJQVfHI2Iak2ms6X6cMQ4Z+icF/OCqbeQT8QO2mNWXwmeCEH0bZe1+QQfOCRw /Rai4VQQPUGKDvxTC8wp90KqsCMhDrTiZCZLMq59z8iM0IhB5rc9nJE28IOxGn4s29fMZBv03oN1XG yiZRZRrr+20mjD0HCZeGMUUnCKuHl5p0qh/IR7GRtj2wXMaUsTcHNzkE2iNvUwFxcDFThM7F8jrl5U FV3LxwCnPKcWUee2K7tZA1G+WSDZ6Bw== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 6b291732-d7f3-11ee-b66d-9b9d9be6ef2c X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound2.eu.mailhop.org (Halon) with ESMTPSA id 6b291732-d7f3-11ee-b66d-9b9d9be6ef2c; Fri, 01 Mar 2024 17:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HUL4zxvHsk3QHlw5QiDCgjuSljLjXHEAHk3yu+AzSaY=; b=CERtcaULkHpLvA4bOUu0v8vAjT 5SLbWtTOl4NajL7YA0UX5WA8OkDiKBN0i3Ahy32+PQUaPC4xnNnNU4+h+BGnIHqLN5TaCHpsVr1An 8017a+h3AMpOqYlRhpPJgSduBvIJYl9uW9vg7K5U2OEl03GEGr6ft9WPpPNeHHjM3TvX6uf5CQslv oHbKEpVlB4uawZRMubZFsmwVlurV/ab28AK4pgv5vkfOa/hytdmGRW3J1w7YFf2k1XLsRphQopw9O ifJiw7y8uZT1gWz1N6lgYAez64+kv+awi7tBSNhUGuPZtdVzR9OF9C18iOmjK+TRFMfSP+gmoNU30 2oOWd+4g==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xm-000bs2-2n; Fri, 01 Mar 2024 18:46:26 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 08/12] qemu/range: add range_list_contains() function Date: Fri, 1 Mar 2024 18:46:05 +0100 Message-ID: <20240301174609.1964379-9-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.223.97; envelope-from=svens@stackframe.org; helo=kudu.cherry.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a small inline function to match an address against a list of ranges. Signed-off-by: Sven Schnelle --- include/qemu/range.h | 12 ++++++++++++ util/log.c | 10 +--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/qemu/range.h b/include/qemu/range.h index 4ff9799d89..7ef9b3d5fb 100644 --- a/include/qemu/range.h +++ b/include/qemu/range.h @@ -57,6 +57,18 @@ static inline bool range_contains(const Range *range, uint64_t val) return val >= range->lob && val <= range->upb; } +static inline bool range_list_contains(GList *ranges, uint64_t val) +{ + GList *p; + + for (p = g_list_first(ranges); p; p = g_list_next(p)) { + if (range_contains(p->data, val)) { + return true; + } + } + return false; +} + /* Initialize @range to the empty range */ static inline void range_make_empty(Range *range) { diff --git a/util/log.c b/util/log.c index 90897ef0f9..032110d700 100644 --- a/util/log.c +++ b/util/log.c @@ -368,18 +368,10 @@ bool qemu_set_log_filename_flags(const char *name, int flags, Error **errp) */ bool qemu_log_in_addr_range(uint64_t addr) { - GList *p; - if (!debug_regions) { return true; } - - for (p = g_list_first(debug_regions); p; p = g_list_next(p)) { - if (range_contains(p->data, addr)) { - return true; - } - } - return false; + return range_list_contains(debug_regions, addr); } void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp) From patchwork Fri Mar 1 17:46:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0B4C2C5478C for ; Fri, 1 Mar 2024 17:48:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6yT-0005mH-Ld; Fri, 01 Mar 2024 12:47:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6yQ-0005i7-CK for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:47:06 -0500 Received: from cockroach.apple.relay.mailchannels.net ([23.83.208.37]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6yO-0000bv-KC for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:47:06 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 43E11362B12 for ; Fri, 1 Mar 2024 17:47:03 +0000 (UTC) Received: from outbound5a.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id 4144C362F91 for ; Fri, 1 Mar 2024 17:47:02 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315222; a=rsa-sha256; cv=pass; b=K3P9UPMUdNug1JEqaNcFBhffTV68AVPcHyhyvD80m8ey7pfR5lVkbJNEEQQxL04PaEbigO zqiKozwYg3n3o74BM3b80g+S/RNI5eSw4Nuo0wuKYtht8m/GTVRMasE49i0TZoTYH0MTIT /LZ7b6s5IEF1LSuHRuKVf8SuBcPefK5obIi2vXUbVZvB3PFuVn+TZ5t8/JOnJ+JpveP18G A53keLzQP8cJD1DdPCOTr2kcGAIhl+LDmauwsZkFpdWKPFOQAMQevaXqVke/KVIn5OJhND rpHuGDSVCvJzdflK4Lwu1y9eDpHlKNctWBzStEo21CGBhYwo0e/IiDtXF1KI7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UXyHuOL2Zz1wN0HSN8V7hVB8CKhogOCL5fIhUH2hyss=; b=0yhFC+pFx62q/a3k1cPAAjo74dwVGranRmToU1VCKoQw67ShSvVuon0oDZG/ie3Wjha5TX 7YEfVX2p9iMFgcyxamgwTTcuh6o4HKdsdJZrJ5slRMne4Xp87l6RsbtbwJV/0IG6ZEeWdH z0t6cqajUvbLgK+lezweKX5+Bd+e0CatgmC5ovHMxAaKBpmwET7j9nWPheRJyJbR0qEBpx pe7JCFsP+BT5bWYj6GgDsN+hzpHBGgCuilRDgiTuffYS0UerIeLkM4kVhWNr1/0R1zwFlf QZ33tH4F53KVBxkJE9ANY8BFSUPUrZdmHetll48clqwExq2KAN/QkE+fqfc9zg== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-rwchp; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Arithmetic-Spill: 0b9bb44c212e5120_1709315222770_3516816653 X-MC-Loop-Signature: 1709315222770:2772798783 X-MC-Ingress-Time: 1709315222769 Received: from outbound5a.eu.mailhop.org (outbound5a.eu.mailhop.org [3.124.88.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.101.14.227 (trex/6.9.2); Fri, 01 Mar 2024 17:47:02 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315168; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=eqfgD4CSOGAVLucLER65HWmmPFa1m0qWAWKBq1zs4Faoi+ApmUH7+AoOZT1zYPnBu9lr+0B3Jt/Kz fO55SOs6drdHALMyAcyZdBGj+zpS+jySUO9xHgFkpVMAmgHn8hIZxFIp8aGx01ZHXAbSbykgowdYjW YizcV9bMcwd6bBe+mIddWym+nzlZXJB/athAzkUZYJfkGXp8LrdRNhGMSaiF98/3EhZQwzlLfrsR8J kE90n7zI/mSMS9eLRDNHFk1Y55n5jdyaD+zXc6jUOIQRnuIPJEVKoF8qIo+DIxo5LyFPYvks83UuYU 9WFqF0p4Zzljk6cHRiTbJo5rH0yu3BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=UXyHuOL2Zz1wN0HSN8V7hVB8CKhogOCL5fIhUH2hyss=; b=HYbcfpg5/eiCZEJ3/xmPFJ0ZJHx4vL2gY2smhpRzVD5nZOY/xV9h89Pzvc23EqOJU3DOFGiaBI/Xx EkuKqGSMqF7C+Whp/qH5AqXuixDGyxJTQePB06BXJpj104lvQJqMrLtisam2gKjOUq0jRhWPdNmYCz d8CgP3M6mSlLDYvLih3PysjIM9LiEj+DHxl3G18a6EKR/J0Tfr6Re5obxjhx5UeWb8bA9hrMscy2fk gCZ4C+BJPJ1yY02th4stOmGTna3/fvdcKxL/4Ui8DoS27MuQf/iGP8o97/7c/uA3OHIj4tgxfKNzIZ cakAbHWpntC55S3w18RST0M6Wjishpg== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=OwYfFHZR; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=UXyHuOL2Zz1wN0HSN8V7hVB8CKhogOCL5fIhUH2hyss=; b=p2/ot/HT+bwxUDcs8b9tdNGCPHu1sMKVNHKpkMNHXkwmIGe7lcDHX1TiadtSaF8Kgd6WdK+jrDV4S L1+Gc2zBX7ThKeMmWP7OdqtneVz2wk0oGthTXFNsrmvFGFCvOY+MqeYDIYZsoHYI/10IywP5hH1AYv sSdMmk142jBOJ6SM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=UXyHuOL2Zz1wN0HSN8V7hVB8CKhogOCL5fIhUH2hyss=; b=CvOs3nOgq0E0UkIq2safJ7sk/av3cS+2xhXkDBZl4eneBVK48OpaX7hSodZE9YfN2VeTgL0ay+s4u bn3E89LYbE65iHa6QQfKNuNd9tj4AbGRzfDmK4+fnh5PLrGXbXXnPpLAPqidnNWleN+P7Lm0yk/QH0 Q2maki2bhXDQ7wTirpinNxSgbLyb45/GMYjq0ObzHy9ldV+A0wFCgmlM/yL/loErx6ceDxldS+XEMq yiNGJ0KVWEhDH5seQdvnhgt2Rv6Kp3hyf5HRvdYUbvprxJsh/Rsc5fY79dQGJ22tGEH2RCutMrFSeW eXyV7cJuqLLgFHnCdjPo0UUerxJxq1w== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 92c79b1f-d7f3-11ee-afda-eda7e384987e X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 92c79b1f-d7f3-11ee-afda-eda7e384987e; Fri, 01 Mar 2024 17:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UXyHuOL2Zz1wN0HSN8V7hVB8CKhogOCL5fIhUH2hyss=; b=OwYfFHZRkx1Fv/MGwieuGE+kj7 CqcA0fIlEZSvvsG2F9uqc52bVH1UNnIXIN/RKtLpMqZKGIDUdUZUQFxBbQ6VmgzBGyGvyasUjHVl9 NCNai1AKy3VgcTxM7w6bKLuGwmgA3PIOnZkhia3apc9Ag+FwcWLglo23MQ4660CGTp03tuXxCrI70 kgF/Kw4+9rA2Intdy6jry7I2QwdLukOhxbK+kfmTfqgtT5fZdHI4UYEq34vw0hWnHTJZsf2xkMUKp mhLzGQh/Vg9H6RgBE4yYPooQ+KcOz/tMJwUxsqfij0VwoKv35mUKZD5SCgZiaXUeFlde7P/b0Fo/s pJ00b36Q==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xn-000bs2-2D; Fri, 01 Mar 2024 18:46:27 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 09/12] plugins: add API to print errors Date: Fri, 1 Mar 2024 18:46:06 +0100 Message-ID: <20240301174609.1964379-10-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.208.37; envelope-from=svens@stackframe.org; helo=cockroach.apple.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org add qemu_plugin_error_print() which is a wrapper around error_report_err(). This will be used by qemu_plugin_parse_filter_ranges() to report parse failures. Signed-off-by: Sven Schnelle --- include/qemu/qemu-plugin.h | 12 ++++++++++++ plugins/api.c | 7 +++++++ plugins/qemu-plugins.symbols | 1 + 3 files changed, 20 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 45e2ebc8f8..5839feea4d 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -752,5 +752,17 @@ QEMU_PLUGIN_API int qemu_plugin_read_register(struct qemu_plugin_register *handle, GByteArray *buf); +typedef struct Error Error; + +/** + * qemu_plugin_error_print() - print and free error + * + * @err: a @Error handle + * + * This function shows and and frees the supplied error. + */ + +QEMU_PLUGIN_API +void qemu_plugin_error_print(Error *err); #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index 81f43c9ce8..8fd3a8964a 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -45,6 +45,7 @@ #include "exec/ram_addr.h" #include "disas/disas.h" #include "plugin.h" +#include "qapi/error.h" #ifndef CONFIG_USER_ONLY #include "qemu/plugin-memory.h" #include "hw/boards.h" @@ -465,3 +466,9 @@ int qemu_plugin_read_register(struct qemu_plugin_register *reg, GByteArray *buf) return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg)); } + +void qemu_plugin_error_print(Error *err) +{ + error_report_err(err); +} + diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 27fe97239b..b142d11e58 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -2,6 +2,7 @@ qemu_plugin_bool_parse; qemu_plugin_end_code; qemu_plugin_entry_code; + qemu_plugin_error_print; qemu_plugin_get_hwaddr; qemu_plugin_get_registers; qemu_plugin_hwaddr_device_name; From patchwork Fri Mar 1 17:46:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C0505C5478C for ; Fri, 1 Mar 2024 17:47:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6y3-0005PQ-3V; Fri, 01 Mar 2024 12:46:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6y0-0005OO-T4 for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:40 -0500 Received: from bactrian.maple.relay.mailchannels.net ([23.83.214.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6xy-0000Yt-6J for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:40 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6B93B142AC3 for ; Fri, 1 Mar 2024 17:46:36 +0000 (UTC) Received: from outbound5d.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id B4557142846 for ; Fri, 1 Mar 2024 17:46:35 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315196; a=rsa-sha256; cv=pass; b=zn2V8JZAhgaOvWMkgutFeUBAxVPwV1wVyUQ4wet+WYpro2Pvh5puRYRChKiH9GnNbymAo7 S8Qb0bB9XCdOAjJOL1LaY8dZm8NQPXaZ5X9sh4PfGSIL3435aMVXmarjNiEGy+EeRJkZtt eD76pzPPEMHvjsMvyokn0ARhoPuWleprJFHuXFgzxUlzLCdUEuyuTc9EsGqS2E0vJnIQUl 2zwQdk4YAEsl3NqwnZ+d210eGX6N/2NCa/+aqr3l0dfivTLdIpN9OGswf1OOP2143Nfpaq XtuAt3VM2nBDbtEy5e1M6/Ix8sg/odt15oNR903/BjYxZFDsbajLQjaOrPtEqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315196; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lF1TQZ6vVTcGlia7ncIRF5s8q9DWQ/f7QQ+9EL+vjCc=; b=5y8C2rzuuPvJQ2Wg3BCMcDcCelDjnmmcqtRM7uGIEwuDYQ8opahp2XwCPtxrzeaCBDiU5I MFqTFl+ogdkUhoDw91yH5dxH+9jVXsuio8zfg1v6G8CdHcxPqh0xuPKvMLBNhS+uKF4XZ/ TGIdlsCt01GZEbkhSVDoqK8k1URJV+QRthLSX5VmOH9nZU9vOzTSleJvBK4t8XdM+Fi52z aIIg7gGCCawmyrnmeAxz2MzUVTtC5Q++zmQ7xeeNLIbEeqIwcx4BaRwMjoP5DDnAy9jdFB Y7WHYSmfltFn1h1Z2O/PoIDMzuUkP33xaLUQS+l7D31Dc/yXXfpkmHFWDVoLtw== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-jmwb2; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Tangy-Shrill: 64b9ba6b20b56e44_1709315196260_3703453385 X-MC-Loop-Signature: 1709315196260:775692329 X-MC-Ingress-Time: 1709315196259 Received: from outbound5d.eu.mailhop.org (outbound5d.eu.mailhop.org [3.121.156.226]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.124.220.170 (trex/6.9.2); Fri, 01 Mar 2024 17:46:36 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315169; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=dC3UPaTCcZW/yUcPbkU0PESgHyhKgsWYGXkmmn+cgAjnCDgQrU94/K2wHjEc+iSfi5MlaCr7Isp8K ZspY/X7scE9PJo7315nEYMQdS2JciAcj0xjG+bHjc345Hdo8b+gKtBAieajo72rh4FS5uDVwUyPq13 dgZghf7FPuX1u/85hOVH0Pu9I+cYTvtLmIdvnHHPpVMnCR/DsrK3clkkJlxeKMU7swtkDDPZ9DhTTl Cw3Wf5z+eg7aiX6YEZoir+pbCQ6hljypHc0UhecFZDmHcPLijA9JaUW7i4sEtidEKmPJMiQ4BNJFFM S2ACceOv0EfyYXGftIcxFHjHcwnBceA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=lF1TQZ6vVTcGlia7ncIRF5s8q9DWQ/f7QQ+9EL+vjCc=; b=BNvhfbpg5PV6smKojuhR2qd2BXQYZFsjgBJM8Y9DT2PgR/BlNBDZyr6xiRb4QGb1DNR97A9B+UVoB GvTgVBY4TC7rvKePL/RW6WDb8WkJhYjd85RxhkVQRLoNS70KnARqpZHJv92KeoVImCILchagdEQOXK tz1L1oJuIBEITcC9zTiGzTHPAr8TfncqUMjq14+dwgZp/QTFuHoMflCxLi3OVANPeLR+1kkjp2qF2y ZaZ4gNYmJo23si6lHAFdS5Jf0tTEETF3O+1jER3EBDXbuTf+4tNqWP8BpF/ZCO9VemkwTwi+wxkNpp KKBZo/v7Ed3ptnPTA3Mrzbzc5i9mj7g== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=BS1vLZa2; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=lF1TQZ6vVTcGlia7ncIRF5s8q9DWQ/f7QQ+9EL+vjCc=; b=NhnL8g0buQct0VKx2jcN3QyybvUiFYnpmZaglh6/tAuxvp+8YZQedWRdo7a9jp2AVGuqoI8P9QMDw ePLpO5YMX+SJPbhqgFvawgD+8Bf55+5XM6fVdNeo1Cp7NkXcsMKFlLvZZKk9ddX3Yr1sGE551JwMls YaWWdjPOwa9C5YAE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=lF1TQZ6vVTcGlia7ncIRF5s8q9DWQ/f7QQ+9EL+vjCc=; b=t/YCMnMyYV62/Gc/VirF83TIuJPk29xKt6TDFZ/Abx5jw96yIzY81bMVvRags4MW39g6e89DPhYo1 Qohgo1Hrhul82+1PUphJA5UebzKij2WdBgck7trqRJ9VeIgoUsgnZZGw+mPreUK4VU1dS4Zgda8kxA fVBQdQXD5WVa06WDuiTiPGnHXMxnRy9ou42WRDXszq0XBfOGmtm3TLS6i9AUlDfLkfedmPQoDsZemx 7oXPdVl6DAFXWwI1kVV1ZoNsR73RWyhN4ajbTy4rCm11PrSru2cS2TJmWTvH9Vd+mwwkndqZQOdJCd D51mU3KncWhne8jGv9r4KYQJoiW0ssA== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 93473682-d7f3-11ee-afda-eda7e384987e X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 93473682-d7f3-11ee-afda-eda7e384987e; Fri, 01 Mar 2024 17:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lF1TQZ6vVTcGlia7ncIRF5s8q9DWQ/f7QQ+9EL+vjCc=; b=BS1vLZa2vMoh/w1V1MuAwLX2cS DlMNKtcR1OQ3QtqZEcfg48DkJdVsHuVYPHE4yzC+F8JbcSUngw4ApAMXOTdj9FadQtqAMrPOy/8Yo +KXJCjNMdHIBjVIiG7qAcBIj8fkTYXIBCgv4Z78EOQPpAzmyeGaij5XTMRQtvLDEzD6AOmSoNO6gT DhBgFjdEdRwWA1VpZ0l3o+Nnoez4SDB9rClZS7Hr/XXgJ1h/GU2aU5ZG6vtWt03uG4fwBc66wvFK4 1lxf63iV5+Ijeib+/uS91QCXXVb6JQYEyom2yFoVR+MD/UbaAbi+xlyU3KnaDiGIf4okZ95WKQqa5 uTRpv9AA==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xo-000bs2-1o; Fri, 01 Mar 2024 18:46:28 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 10/12] plugins: add range list API Date: Fri, 1 Mar 2024 18:46:07 +0100 Message-ID: <20240301174609.1964379-11-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.214.9; envelope-from=svens@stackframe.org; helo=bactrian.maple.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Export range_list_from_string(), range_contains() and range_list_free() to allow plugins to parse filter ranges and match them to avoid reimplementing this functionality. Signed-off-by: Sven Schnelle --- include/qemu/qemu-plugin.h | 41 ++++++++++++++++++++++++++++++++++++ plugins/api.c | 18 ++++++++++++++++ plugins/qemu-plugins.symbols | 3 +++ 3 files changed, 62 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 5839feea4d..4910a63d70 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -765,4 +765,45 @@ typedef struct Error Error; QEMU_PLUGIN_API void qemu_plugin_error_print(Error *err); +typedef GList qemu_plugin_range_list; + +/** + * qemu_plugin_ranges_from_string() - parse a filter range string + * + * @out_ranges: a pointer to a @qemu_plugin_range_list pointer + * @filter_spec: input string + * @errp: @Error string on parse failure + * + * This function parses a filter specification string and stores the + * parsed adress ranges found in @out. On parse failure a @Error pointer + * is stored in @errp. The function accepts a comma-separated list + * of start and end addresses or single addresses. + */ +QEMU_PLUGIN_API +void qemu_plugin_range_list_from_string(qemu_plugin_range_list **out_range, + const char *filter_spec, + Error **errp); + +/** + * qemu_plugin_range_list_contains() - match a value against a list + * of ranges + * + * @ranges: a pointer to a @qemu_plugin_range_list + * @val: the value to match + * + * This function matches @val against the adress range list in @ranges. + * On success, true is returned, otherwise false. + */ +QEMU_PLUGIN_API +bool qemu_plugin_range_list_contains(qemu_plugin_range_list *ranges, + uint64_t val); + +/** + * qemu_plugin_range_list_free() - free a list of ranges + * + * @ranges: a pointer to the list to be freed + */ +QEMU_PLUGIN_API +void qemu_plugin_range_list_free(qemu_plugin_range_list *ranges); + #endif /* QEMU_QEMU_PLUGIN_H */ diff --git a/plugins/api.c b/plugins/api.c index 8fd3a8964a..8dbd14c648 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -472,3 +472,21 @@ void qemu_plugin_error_print(Error *err) error_report_err(err); } +void qemu_plugin_range_list_from_string(qemu_plugin_range_list **out, + const char *filter_spec, + Error **errp) +{ + return range_list_from_string(out, filter_spec, errp); +} + +bool qemu_plugin_range_list_contains(qemu_plugin_range_list *ranges, + uint64_t val) +{ + return range_list_contains(ranges, val); +} + +void qemu_plugin_range_list_free(qemu_plugin_range_list *ranges) +{ + return range_list_free(ranges); +} + diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index b142d11e58..472b29fc5f 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -21,6 +21,9 @@ qemu_plugin_num_vcpus; qemu_plugin_outs; qemu_plugin_path_to_binary; + qemu_plugin_range_list_contains; + qemu_plugin_range_list_free; + qemu_plugin_range_list_from_string; qemu_plugin_read_register; qemu_plugin_register_atexit_cb; qemu_plugin_register_flush_cb; From patchwork Fri Mar 1 17:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4BD4EC5478C for ; Fri, 1 Mar 2024 17:48:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6yZ-0006Hw-OD; Fri, 01 Mar 2024 12:47:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6yX-00066F-UP for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:47:13 -0500 Received: from gorilla.birch.relay.mailchannels.net ([23.83.209.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6yW-0000cN-4q for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:47:13 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 86DCE362AD0 for ; Fri, 1 Mar 2024 17:47:09 +0000 (UTC) Received: from outbound5a.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id E1ED636107C for ; Fri, 1 Mar 2024 17:47:04 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315225; a=rsa-sha256; cv=pass; b=TKGJW4eVsT9x+ndl3EKRWrfH+XBFXC1uSj8pBUF5c4c7j3DXfsWQ2FMQ2UubLYpy/WH0/i As08hGZZVygx0yBVy5oji+Y6mHRVZQvBl+UDRy6Idge++yrzMdIhDVBv0DZuFmxBdw7I9B 2ZZ97yo2EN+9+CgDZAEFcmz6bhXnTPFOZkXVqpbqiTQIJW9eXCMJgfsl460jRd932uDreR KOosQDAfXVqq6W84u2Aj6RN4T06yGehc3cf/NM4n01OckQRW0uUs6aI8yK6JcZLjGbvXHB V3JuoFvfIQCvK8iVyQOUEy/zUd9uLA3WhCBD5sEpjuxAKQViPJJ/fe/hmLgStw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=S7SHDhlmpFjlxOugOz6KuS8B3f2c7/2cN5ozYLomgeU=; b=TYI2Jyg2VycHAT1dV9LElkrUCB7HUow4rYhuHdrPgU6FreOSC5kNsxiWa/VHWOXXLyj1dn nM0NwX9vAHxnE0W7uT2AqwxJEixzu4A574HaS6pzbwa4idMBihBI4y4m3cNvc5UXGljXUS MvS6cW/Q6tV1T9cfo/EzYUf1T8YDV+uYxUbLO+N0U8zEvI/pM+9XJOOZm3DyOpjuGvUqQy bnT9Yl/benZFDq4kvnCdkkNcyP7R1vsnvnp99SEhQnfz6+RLw11lEK1KhIl2rwsFcDHnPV wCoaNU/TYLbiB5VxixP9HvNzGKfd3/A3zjZ9PNCEdVjKXfDi7At6/ap5lGwKkQ== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-d4z79; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Stop-Whistle: 565f78922a0729c8_1709315225420_441547854 X-MC-Loop-Signature: 1709315225420:2756215266 X-MC-Ingress-Time: 1709315225420 Received: from outbound5a.eu.mailhop.org (outbound5a.eu.mailhop.org [3.124.88.253]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.101.14.227 (trex/6.9.2); Fri, 01 Mar 2024 17:47:05 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315170; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=D7Jw08MHue6O6zgYmXZX+C+fHq+RJlsgs0fV9lsJvtVou9kaoVY7qSmuRAfCN9OOt2dYBz0QLBHLy 68p2AtluPR8YezXbaQ/f3JOXXV9/4Mei+x0Og8vhSUA/xGT/P9lTZPFcUCLlQDs8PdMDumFL/1xIld 57QK7Yo3U2rZkXtO2lbH5M99m2wAgpXpr+X9JkhulJ5vB6xutuHhlZgv7gEYBKFP2yMCTZjfGpY/jp BuL+gm1XJPo55+yBjG8HxDZGNIGb5wgfpgKd3BiOE8No1k0PokGRFgBEbwWlpAXVVBKorab0iuttoC f7MvT9ZOolhe+9TNytmVsrueBlNM4/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=S7SHDhlmpFjlxOugOz6KuS8B3f2c7/2cN5ozYLomgeU=; b=RU/S/r/DG2HIkFxG5kE6f9og5whvxoFN6h1FW6FwjmKpqox4MfRFjKnD6Yffrmcww1f3qZt3FuqbP sLkBCp3Q/57RrInw3bmYwbg3TOYuEU9r9aQOUOYWOMSBxuRZNfT3ngBUmQXLeaJ6kGXdMl75nSi5dj LCgGT9aQ5zoaDAkWVnAyjtyuTzwVx5x5n/2z2vRRTnqF/ETzkRvJwT4YbLwgNAzsr1AK7zKXgy6arN 9TP5LlT7E67pFvMDRuwYNZuTi0+Ghi2ErMx0sAxbc/+a0Ph6EM37N+mqm5MOr/UjnA/o/LH8B8Y5hi jWWwTjW3O9NagoFRcOBiAuh5ohunXRw== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=HmIKXR4s; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=S7SHDhlmpFjlxOugOz6KuS8B3f2c7/2cN5ozYLomgeU=; b=IzitaiSTNmYvXOnmfqujoqWwWst5BKQVz+22JO226koyYTJoGLQPxomFoSjlZCyN5bbempskhlAPI Rk8cz6p7XzghyTOT4f6P2UQeFh2f4D8NN8VOsw5dRJvxi8zMY4IrCYPugu6mt84DrCROjdkdJYYmi7 7pXmP4PUOK4TF6S8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=S7SHDhlmpFjlxOugOz6KuS8B3f2c7/2cN5ozYLomgeU=; b=jVwhgBSM2DzMQdxWdksy8Kd4bVt+/Ur1Y2X4GKXtahI+zTE5oDZ8v3YdZUyyy+4QFr2DsHxplyJ+p qyZs/eCOmjA7uzlXkbrjYBn1IULHP74gn/7OXfHORGYBw3mjPgd7m6c8RvHxpDQl9wXY/jCLwmWpK9 YwveFKe2GxJvZAqXyx4Wo8N09hzylTlheNChWNEFVfjOq5Z/fJoWtsTIb2FNLcaw9tYLCYZm//tR7S bpOXQFjQh81d9EYFHSukWjwEBWsyTNBnrFuVjP9G5v8Zrhdb73KLONs5iVS6Q7ZS1o1GGs1G0wSW3b 5/kbCN6Gi9SArB8TOMlO3dCEtJ6gu1w== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 93cd28e6-d7f3-11ee-afda-eda7e384987e X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 93cd28e6-d7f3-11ee-afda-eda7e384987e; Fri, 01 Mar 2024 17:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=S7SHDhlmpFjlxOugOz6KuS8B3f2c7/2cN5ozYLomgeU=; b=HmIKXR4spxmN1DZ0bBUrkLpymA MIeP7NYPQZhgC5XoeKYaJhWmdvDQ5GEd5iZ0lYYSYUz3OtFr1tbyCg0D4sLIYtVho05yZtpZEFnPU xPb7wHB8DjvIE4KWm0GYG7E0+Au9y6+fJn8sQv1MqdvIttNZY+/pX/ommqtmOJhoS3Sig90GZ2yye igN1SQ15qKCNnML0GjMyJGl1JjMZvSz4x7LK4bLE+beqELqRxWBTxgV95jyvtEAyfrIxd4zUMMc6b Fz6wMj9BLIf6XhU98UaS9j5Uj8x4guMdjvB7PldxUxf1YdI+i5TX73pmZrGyVGNm0J1VGzJAS4pT8 7W47mbLQ==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xp-000bs2-1U; Fri, 01 Mar 2024 18:46:29 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 11/12] plugins/execlog: use range list api Date: Fri, 1 Mar 2024 18:46:08 +0100 Message-ID: <20240301174609.1964379-12-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.209.75; envelope-from=svens@stackframe.org; helo=gorilla.birch.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Instead of doing its own implementation, use the new range list API to parse and match address lists. Signed-off-by: Sven Schnelle --- contrib/plugins/execlog.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index a1dfd59ab7..c518797893 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -35,7 +35,7 @@ static GArray *cpus; static GRWLock expand_array_lock; static GPtrArray *imatches; -static GArray *amatches; +static GList *amatches; static GPtrArray *rmatches; static bool disas_assist; static GMutex add_reg_name_lock; @@ -215,12 +215,8 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) } if (skip && amatches) { - int j; - for (j = 0; j < amatches->len && skip; j++) { - uint64_t v = g_array_index(amatches, uint64_t, j); - if (v == insn_vaddr) { - skip = false; - } + if (qemu_plugin_range_list_contains(amatches, insn_vaddr)) { + skip = false; } } @@ -398,16 +394,6 @@ static void parse_insn_match(char *match) g_ptr_array_add(imatches, g_strdup(match)); } -static void parse_vaddr_match(char *match) -{ - uint64_t v = g_ascii_strtoull(match, NULL, 16); - - if (!amatches) { - amatches = g_array_new(false, true, sizeof(uint64_t)); - } - g_array_append_val(amatches, v); -} - /* * We have to wait until vCPUs are started before we can check the * patterns find anything. @@ -440,7 +426,12 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, if (g_strcmp0(tokens[0], "ifilter") == 0) { parse_insn_match(tokens[1]); } else if (g_strcmp0(tokens[0], "afilter") == 0) { - parse_vaddr_match(tokens[1]); + Error *err = NULL; + qemu_plugin_range_list_from_string(&amatches, tokens[1], &err); + if (err) { + qemu_plugin_error_print(err); + return -1; + } } else if (g_strcmp0(tokens[0], "reg") == 0) { add_regpat(tokens[1]); } else if (g_strcmp0(tokens[0], "rdisas") == 0) { From patchwork Fri Mar 1 17:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13578873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 79673C5475B for ; Fri, 1 Mar 2024 17:47:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rg6yI-0005dB-T2; Fri, 01 Mar 2024 12:46:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6yH-0005cj-1T for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:57 -0500 Received: from cockroach.apple.relay.mailchannels.net ([23.83.208.37]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rg6yF-0000Zf-9P for qemu-devel@nongnu.org; Fri, 01 Mar 2024 12:46:56 -0500 X-Sender-Id: _forwarded-from|134.3.94.10 Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 87137C3D31 for ; Fri, 1 Mar 2024 17:46:53 +0000 (UTC) Received: from outbound1.eu.mailhop.org (unknown [127.0.0.6]) (Authenticated sender: duocircle) by relay.mailchannels.net (Postfix) with ESMTPA id 2AA72C0EEA for ; Fri, 1 Mar 2024 17:46:50 +0000 (UTC) ARC-Seal: i=2; s=arc-2022; d=mailchannels.net; t=1709315210; a=rsa-sha256; cv=pass; b=uP7UKcK1JV2BKkRYh+1IQIqUBc+qu0IFhjM+qVQe6JnswR3SWo8cJKpnbY6p5xv1CobmZN udkE1VWzWiZarOqowEqLhWvETsDmySHua3xtjkGRRxIg5bb3tIeQ9WjU79GlRIidbEUN5j 1w3wQovbAucUYN5BZ7C7q0DdmuD3rg1lBc2SSTWHlRVYLHu5VUAt4nSpC3qZ5xp1S7KvsC iLiwDQyv13gskgYbYfWsvCjyh+6MUAp+PlagMej5KQ1orLVDtS9u+3GAIpn0wnckeEuxjn joGM8A9OV9XwpxwkbSUrtX3b3lYNwAS1K5qKrwPFUm9JAcv+7Yi3qhb1rLqR4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709315210; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=cdkKRJF8r6aZrtkiBOxc7rRIDL5nfso4OZ50Eglu720=; b=R9xgxyCd902pY6Y0byXNVbVenD9fQPjsvsI02PLdMgvXtUq4Gif2Ipk12+sOmZId5Mf5Qt pcaZJUOAflREELcVnYP2zpbf6YCWItDilDMYZQnw6/rGhKZ6KHodqWJol4PNKaJxGix/UK rpRD0ora2MRpklXb6NpQqQglBbH7Y46WI5uPPNqnvl9KaT7hsAoILT6OZAK1qsUg5L3hPM iqWbDgXQupqQsgQ//xqAliQjvQ49qg4XDaipKMx0/FR94DCm4ecGRtVwFqweVljoovi2fg 1KQ8fXBwPmSC0edKN62AmCLaA6+4A4JiybuvUNCNIfH9jmnHEexYFpFrDDySQA== ARC-Authentication-Results: i=2; rspamd-55b4bfd7cb-wmrnf; arc=pass ("outbound.mailhop.org:s=arc-outbound20181012:i=1"); auth=pass smtp.auth=duocircle smtp.mailfrom=svens@stackframe.org X-Sender-Id: _forwarded-from|134.3.94.10 X-MC-Relay: Forwarding X-MailChannels-SenderId: _forwarded-from|134.3.94.10 X-MailChannels-Auth-Id: duocircle X-Quick-Bubble: 11df773a1f3f6dd6_1709315210679_3670380048 X-MC-Loop-Signature: 1709315210679:398321630 X-MC-Ingress-Time: 1709315210678 Received: from outbound1.eu.mailhop.org (outbound1.eu.mailhop.org [52.28.251.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.116.14.15 (trex/6.9.2); Fri, 01 Mar 2024 17:46:50 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1709315171; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=Xme7XZJv9UNarWP+5ymRj+DQkj9Kpgk/t5BNgJvkGSaPPz8svozlOCKZrO6GtZyQ5xf66xO7mPLRO 2AiDwLrhNjDdvET+jNhMNhxaneHvRQba01CDpZHd47KGzvD3UjxJTgj/0lIbN6brpdOIzNZBwVqoFz 4j7+q+KbPQrDtBV+bS8REFMUGTQtSs3dgUExmwb6SMXRJfKtaL7Kek0BvVHbuI0Fre1D5G4AdlukZ4 bwwn5mqR/7UaNKflzmGCeFRPThyc+tWnRt+C7NOMyw0PbXQL3fUDM2zYdKSyxQmF7U1wfi3/5AuRVI 1oD32hvmq7Dng8hTlg26Jqmg1MJWbdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:dkim-signature:dkim-signature:dkim-signature:from; bh=cdkKRJF8r6aZrtkiBOxc7rRIDL5nfso4OZ50Eglu720=; b=Vm3tzYkzsz2ZjLx7/8vxRfzL4ZujVKwwSr7NllmbBTJ+QesurJ6HtqyWapPoIM8ViSY2SN4XGE8jT UdsbWP8BmljUjvJi4r7GNLH1AaV1O1tgQumBxjblVezdsl+YuOkHExjT1o0fcOPJyA8FyJIq0GMI96 jyZ/F8L6rQapNpu6yT9n1s53WioXDo6K8YT+uk9/LY2iXQvTW2GwcG2W5Ar3y47DNYIIbEzR9eQ3YB JLKhMQdS2dMDs1mEbfiqNdQXbbhpgtSfJqs0FHEyzq8lpWPdajl6KlbmOM2YNqurDKPghZJfwtzXIm xAs5Mg6imjbgMrHpmB+b6+VsoIu6ZQg== ARC-Authentication-Results: i=1; outbound3.eu.mailhop.org; spf=pass smtp.mailfrom=stackframe.org smtp.remote-ip=130.180.31.158; dkim=pass header.d=stackframe.org header.s=dkim1 header.a=rsa-sha256 header.b=GbfUHZjU; dmarc=none header.from=stackframe.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=cdkKRJF8r6aZrtkiBOxc7rRIDL5nfso4OZ50Eglu720=; b=gKQznHz5OX4VlIRHL2DeNkZGAhbEqaXG/eVQIDFuJ4LybTfr8YTJrmaEcPmYPSmOXIjwyM0tMqUgq bCajaA3e5ILp5eVBK5ZWgND6oQKlgNpnbOcbiiAnrHbMaojAgA02/7l6lnqjLpGeKnN1x2jWZiNow9 +fypuGqJCGNI5wVg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:references:in-reply-to:message-id:date: subject:cc:to:from:from; bh=cdkKRJF8r6aZrtkiBOxc7rRIDL5nfso4OZ50Eglu720=; b=T4dNUUZvEMBWxn0EOZFVZ9y07Di9iofmNfvFMNodqE1zLoNiLH3SZzIVUhHgHq9HVt/T8JvnHk0BS 30L4qPvznEDJHqJOLvUPVJREuyhOE2pS0u1rngXxSQCQmp5OUEz0coXy/MrRCn4owdDRbt1zNbPhoi 86/xaY9UwvOyMbokrsvA/eANiemB3AHfjks/zSse6PsD/nbbryi2UDbrtfl/0PjV5omf14VR605JUi 4PBc+fL4s8ynRWoPril7CWfuszMz/aFny2m5UTx4iAHVa7QWbI2DQUS9YqVkYREJWPlOsE/t5HqTNd +/aZ8i1c+GkxflQwjLU2WYGSsbcR82w== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 945a3604-d7f3-11ee-afda-eda7e384987e X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 945a3604-d7f3-11ee-afda-eda7e384987e; Fri, 01 Mar 2024 17:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cdkKRJF8r6aZrtkiBOxc7rRIDL5nfso4OZ50Eglu720=; b=GbfUHZjU8yXKgqMVCp1N3RbDS1 9RH6reMzEsfGwRSTg1JHSzrs5Ifg+U67NtUBFL9Q8ChMpUcDJUsxkhT/ex+B6zaHiIRB+MDHBd7wy ocY94cSaOe7WIgaVpfIvV8QP2kgaxrY+Kowj/rlH9spPPb+TzYK4iS1VPjXvt4fkLgvH28assPCyf wxM2HevQL9Y1rg9/pjCCz1Bdjku4kw124AvxCBqN9mQduUP6OS95KTbg6eeEuIfzj7WYDTMyAavda 0O1V3sT3zb+FGQP9OHJPHYi10YjzVl4b0mvNG03NeXmFwucwFXDuUGdYLTEnpHp30CKHHOx7+IN7T Qvin0BXA==; Received: from ip-134-003-094-010.um41.pools.vodafone-ip.de ([134.3.94.10] helo=t14.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.96) (envelope-from ) id 1rg6xq-000bs2-18; Fri, 01 Mar 2024 18:46:30 +0100 From: Sven Schnelle To: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Cc: qemu-devel@nongnu.org, deller@gmx.de, Sven Schnelle Subject: [PATCH v3 12/12] plugins/execlog: add data address match Date: Fri, 1 Mar 2024 18:46:09 +0100 Message-ID: <20240301174609.1964379-13-svens@stackframe.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301174609.1964379-1-svens@stackframe.org> References: <20240301174609.1964379-1-svens@stackframe.org> MIME-Version: 1.0 Received-SPF: pass client-ip=23.83.208.37; envelope-from=svens@stackframe.org; helo=cockroach.apple.relay.mailchannels.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a match similar to the afilter address match, but for data addresses. When an address is specified with '-dfilter=0x12345' only load/stores to/from address 0x12345 are printed. All other instructions are hidden. Signed-off-by: Sven Schnelle --- contrib/plugins/execlog.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/contrib/plugins/execlog.c b/contrib/plugins/execlog.c index c518797893..c44fd0e593 100644 --- a/contrib/plugins/execlog.c +++ b/contrib/plugins/execlog.c @@ -27,6 +27,8 @@ typedef struct CPU { GString *last_exec; /* Ptr array of Register */ GPtrArray *registers; + /* whether this instruction should be logged */ + bool log; } CPU; QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; @@ -36,6 +38,7 @@ static GRWLock expand_array_lock; static GPtrArray *imatches; static GList *amatches; +static GList *dmatches; static GPtrArray *rmatches; static bool disas_assist; static GMutex add_reg_name_lock; @@ -62,6 +65,11 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t info, /* Find vCPU in array */ + if (dmatches && !qemu_plugin_range_list_contains(dmatches, vaddr)) { + return; + } + c->log = true; + /* Indicate type of memory access */ if (qemu_plugin_mem_is_store(info)) { g_string_append(s, ", store"); @@ -121,15 +129,17 @@ static void vcpu_insn_exec_with_regs(unsigned int cpu_index, void *udata) if (cpu->registers) { insn_check_regs(cpu); } - - qemu_plugin_outs(cpu->last_exec->str); - qemu_plugin_outs("\n"); + if (cpu->log) { + qemu_plugin_outs(cpu->last_exec->str); + qemu_plugin_outs("\n"); + } } /* Store new instruction in cache */ /* vcpu_mem will add memory access information to last_exec */ g_string_printf(cpu->last_exec, "%u, ", cpu_index); g_string_append(cpu->last_exec, (char *)udata); + cpu->log = dmatches ? false : true; } /* Log last instruction while checking registers, ignore next */ @@ -157,7 +167,7 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata) CPU *cpu = get_cpu(cpu_index); /* Print previous instruction in cache */ - if (cpu->last_exec->len) { + if (cpu->log && cpu->last_exec->len) { qemu_plugin_outs(cpu->last_exec->str); qemu_plugin_outs("\n"); } @@ -166,6 +176,7 @@ static void vcpu_insn_exec(unsigned int cpu_index, void *udata) /* vcpu_mem will add memory access information to last_exec */ g_string_printf(cpu->last_exec, "%u, ", cpu_index); g_string_append(cpu->last_exec, (char *)udata); + cpu->log = dmatches ? false : true; } /** @@ -377,7 +388,7 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) g_rw_lock_reader_lock(&expand_array_lock); for (i = 0; i < cpus->len; i++) { CPU *c = get_cpu(i); - if (c->last_exec && c->last_exec->str) { + if (c->log && c->last_exec && c->last_exec->str) { qemu_plugin_outs(c->last_exec->str); qemu_plugin_outs("\n"); } @@ -432,6 +443,13 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, qemu_plugin_error_print(err); return -1; } + } else if (g_strcmp0(tokens[0], "dfilter") == 0) { + Error *err = NULL; + qemu_plugin_range_list_from_string(&dmatches, tokens[1], &err); + if (err) { + qemu_plugin_error_print(err); + return -1; + } } else if (g_strcmp0(tokens[0], "reg") == 0) { add_regpat(tokens[1]); } else if (g_strcmp0(tokens[0], "rdisas") == 0) {