From patchwork Fri Jul 30 13:58:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mahmoud Abumandour X-Patchwork-Id: 12411361 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85269C4338F for ; Fri, 30 Jul 2021 14:07:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 49BAA61019 for ; Fri, 30 Jul 2021 14:07:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 49BAA61019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:59274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m9TAX-0003Jn-Gu for qemu-devel@archiver.kernel.org; Fri, 30 Jul 2021 10:07:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m9T2l-0004zp-E0 for qemu-devel@nongnu.org; Fri, 30 Jul 2021 09:59:19 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:38441) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m9T2j-0006jN-TG for qemu-devel@nongnu.org; Fri, 30 Jul 2021 09:59:19 -0400 Received: by mail-wr1-x430.google.com with SMTP id l18so11454042wrv.5 for ; Fri, 30 Jul 2021 06:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3nmUEZ6fsiaaAzFrMlJ9P6ABRodgQbIf6UW0T/fpo6M=; b=sqLPlywEGfLzKSNsMIJyxA+k9hi7EgoIS2hwgMmuKLqcBSpQ327wABVkQdodofoE2H CGRMkdLVrInTPgDlyxoRr1Wk+r32VKwgdd5whyYnAwQh349Z4I9FMQHtU/wVx3yiwAxs 4A1UFUnmbWIYjGRycx2cXuekgU3t5wJ7yw7u5Q0Y7bbkIW/p83FNrxzPxrnIWMHjLr/7 Xd+c37j34lzjglXP0dihrww/OZZGFsXaIg/fKqt6CFBwmVof0KQoESDHwe7O7k0WXzbD S/UaJSIuVa8rmS38GK5exTxOlpuLLlyGqb/LcsmzNWbPqgjucJ6pemtbiZvYO/u4AX9O sxHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3nmUEZ6fsiaaAzFrMlJ9P6ABRodgQbIf6UW0T/fpo6M=; b=KIyrRLZTd3BQiYMM82xhXGCELYdQEDHs3JaRzAtQUrTTdKGg20c5nYXSfSQSPks5hY 4FkgGewnM1qlI1Ck/JGvFgmvwg9oYa7j6cNomLzrcaGwWC8w0SonwlznihuosfZCZqog a2ylRIJiyxpf+3xRcELlwR9t5PS5cq3DUnV9uoSO+HXAOCPp38d2LMjkU/8WHJ63MTj9 aNZqxI5GPn4g92Ru890Dys513InoiNkingg3yTKBtmYw7yWU46wywLqraR+bE0QNiMnF pve0FtJbfa8uCdWSJxgexmGo8+IcMKZN0cfyXHGthMeHBM/GngF2h2LnhCd8SFyZjAj+ AHEg== X-Gm-Message-State: AOAM5325DOFLwhlAEFK+YQfASKYKzBXIu3pT2AzBP/OJ+zidyh6nRuij aT7CROircm8orCYFgRP+l5/TRnuQ1q8= X-Google-Smtp-Source: ABdhPJxi/Gr8RPZR/c1S/9qT3c7rP22j6Ypf5OexhQu/HkErXgt5YXiMcS7AFN7Gw2a5f7AkEn4A6w== X-Received: by 2002:adf:fc0c:: with SMTP id i12mr3209494wrr.373.1627653556510; Fri, 30 Jul 2021 06:59:16 -0700 (PDT) Received: from localhost.localdomain ([102.44.217.242]) by smtp.gmail.com with ESMTPSA id h9sm1770277wrw.38.2021.07.30.06.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 06:59:16 -0700 (PDT) From: Mahmoud Mandour To: qemu-devel@nongnu.org Subject: [PATCH v4 12/13] tests/plugins/syscalls: adhere to new arg-passing scheme Date: Fri, 30 Jul 2021 15:58:16 +0200 Message-Id: <20210730135817.17816-13-ma.mandourr@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210730135817.17816-1-ma.mandourr@gmail.com> References: <20210730135817.17816-1-ma.mandourr@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=ma.mandourr@gmail.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mahmoud Mandour , cota@braap.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Mahmoud Mandour Reviewed-by: Alex Bennée --- tests/plugin/syscall.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/plugin/syscall.c b/tests/plugin/syscall.c index 6dd71092e1..484b48de49 100644 --- a/tests/plugin/syscall.c +++ b/tests/plugin/syscall.c @@ -119,17 +119,26 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, int argc, char **argv) { - if (argc == 0) { - statistics = g_hash_table_new_full(NULL, g_direct_equal, NULL, g_free); - } else { - for (int i = 0; i < argc; i++) { - if (g_strcmp0(argv[i], "print") != 0) { - fprintf(stderr, "unsupported argument: %s\n", argv[i]); - return -1; + bool do_print = false; + + for (int i = 0; i < argc; i++) { + char *opt = argv[i]; + g_autofree char **tokens = g_strsplit(opt, "=", 2); + + if (g_strcmp0(tokens[0], "print") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &do_print)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); } + } else { + fprintf(stderr, "unsupported argument: %s\n", argv[i]); + return -1; } } + if (!do_print) { + statistics = g_hash_table_new_full(NULL, g_direct_equal, NULL, g_free); + } + qemu_plugin_register_vcpu_syscall_cb(id, vcpu_syscall); qemu_plugin_register_vcpu_syscall_ret_cb(id, vcpu_syscall_ret); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);