From patchwork Fri Sep 3 09:03:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 506487 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp829350jai; Fri, 3 Sep 2021 02:17:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmDzVAGXmZqmfu7Neg62YNGSIq8tlN18yV+/YmwU6BjICueDZD7lYCNMUkaeSIKC0MQcXJ X-Received: by 2002:a05:6102:134e:: with SMTP id j14mr1602509vsl.18.1630660641939; Fri, 03 Sep 2021 02:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630660641; cv=none; d=google.com; s=arc-20160816; b=yJBkBnruWddM9nII0D3XhaCUmqZjHpNo95uzD+eBOCWeD9TbLtJNWQfoAdf9DaDqLp gHKHxTT2N+juwwbrYywsDmnz8PuqZjzdBAr2G63fFFzcbGpy0Ccz13JYGg4QiwYtrHMj 3cqIzv7RjdaPK07+EEH6mPP4VmkvIKWH2t7PtGmZAsD/BeC2G9ZU21mS88VGg7RrdfT9 bXmbJ0rVKvNoHOD+KmdrBxHqyD/mE5X0Z1EJCNr89x1fQN8y/ipwnoIdmYnJIuU9Xjbz 6BQ1v//VurZ+x0Rjt8SfsT3/Jtd0wFVJnl4zqYCedL9KohgakMfOnWjUBopu1m8NKS9u AhwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=GrGtDf2HVWGiASARI4Tm+w/Zub0VNBXRgvn0lkzCIm0=; b=R7Eq7NaBGyqijVgDyQxySXwc4nkTsLLMndm8Fwua74/rZWE7eg68fTe1YPJFDwy5Gp Z0zp0IMb73lUYvyrLk9u/aT/0RsgdK5vx2l48E3wIYP7ipTa+Mvuvhhc+6Rnvd3GE4MX F8j7n+eMFbsZAfCV4jSyhA6/a4CKLHwklUeZBLw4dnOsuf2MdWH3+QfBUjrYeRhUprSG bPnSHJacUzky9Zd1JenGBp6Y3mmIH3OdDIESwOSUK0pyDCn5JUTHYAXFQNjTPYUTfDXy 2mpVi1R+i1letQUYNnCtKPjMHxHuwqubOejSlMohh8dtpIrJDqlq97rP8V0ILglLwodX rzzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OG2tUEas; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q187si2036862vkb.2.2021.09.03.02.17.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Sep 2021 02:17:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OG2tUEas; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:38762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM5K5-00036q-8T for patch@linaro.org; Fri, 03 Sep 2021 05:17:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM57F-0006Tg-GT for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:04:05 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:47045) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM57C-0005ik-Oq for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:04:05 -0400 Received: by mail-wr1-x42c.google.com with SMTP id x6so7159840wrv.13 for ; Fri, 03 Sep 2021 02:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GrGtDf2HVWGiASARI4Tm+w/Zub0VNBXRgvn0lkzCIm0=; b=OG2tUEas94EA+PZenVwSYKyRMEePFJ9bXvJPqtm6jmojAxN3WgHun2fzCQ1YmtWJNd kwds8m94eJGa+JJkkqtlw9Hy1zZF4xGG9gXDRrEUzx6viNchx9M5ZhTGGjhlthy0VRQ2 LXbNEilk7UX+QCQMSPonehEnTTBF1+LPckcue1ShAzuxzslvdDwQMru8o4g9lp/QTzKk Rg3G5d7rnsZeeEiQJd0nb6x/u+ezYPF+uvqNSt4UgfX5AR2GaHR/VfhwuUMagVl1jZUW YPJJGnR+r/79BePj2nQ98JMQfO2hPkylSVacreM2YwmnP/egJHuEfjGOOnNRsUJXuIee diGA== 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=GrGtDf2HVWGiASARI4Tm+w/Zub0VNBXRgvn0lkzCIm0=; b=jYZouceeBxmnidcJ/1nmkU37CFsUNXXuhzpSXCAJ7DTUWrnvwErKJnlVbYl+wq9C/e QY9R5wMyX6akyHl6Q6o4RhJnWPHZwj8pKCRjt5PZIN5UYzERo5u8anKAAubSATLWbIJY X5bMwdZseK/P+GPa6Dvwy3l7GYu8XN/SdvrusCM0xMvVtAsHpl1vJC++0fqoCboxPfnV UTDxwWG/7x3kG+clMXzFZqeepkR9dtI3oS2rNopoyWjFhdejGAb4I/I6GozCboYqPxPA 1hYT5OGGqPCwgnFuWhZOm+SDjDgDsb0LnrYIOr0pgMHF/vmp4o1c8Mr6BK7o7dn7H2Lb AGbA== X-Gm-Message-State: AOAM531JwJI6gWY1TSAAO9sCygtaGyYaLXrfAgUslgUK7Muv7YVrIgTP UWltj1mjpExXiGAuIFoKZMkulg== X-Received: by 2002:adf:f490:: with SMTP id l16mr2749048wro.136.1630659841315; Fri, 03 Sep 2021 02:04:01 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id f17sm4829325wrt.63.2021.09.03.02.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 02:03:55 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 683511FFB4; Fri, 3 Sep 2021 10:03:41 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 19/22] tests/plugins/mem: introduce "track" arg and make args not positional Date: Fri, 3 Sep 2021 10:03:36 +0100 Message-Id: <20210903090339.1074887-20-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210903090339.1074887-1-alex.bennee@linaro.org> References: <20210903090339.1074887-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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 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: Alexandre Iooss , Mahmoud Mandour , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Mahmoud Mandour This commit makes the plugin adhere to the new plugins arg-passing scheme by expecting full-form boolean args instead of short-form booleans. This necessitates that we introduce a new argument, here "track", to accept "r", "w", or "rw". Also, it makes arguments not positional and we only care about the last value specified for a certain argument. callback/inline args are now supplied separately as bool arguments so that both can be enabled individually. Signed-off-by: Mahmoud Mandour Reviewed-by: Alex Bennée Signed-off-by: Alex Bennée Message-Id: <20210730135817.17816-12-ma.mandourr@gmail.com> -- 2.30.2 diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index afd1d27e5c..4570f7d815 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -80,29 +80,40 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, int argc, char **argv) { - if (argc) { - if (argc >= 3) { - if (!strcmp(argv[2], "haddr")) { - do_haddr = true; - } - } - if (argc >= 2) { - const char *str = argv[1]; - if (!strcmp(str, "r")) { + for (int i = 0; i < argc; i++) { + char *opt = argv[i]; + g_autofree char **tokens = g_strsplit(opt, "=", 2); + + if (g_strcmp0(tokens[0], "haddr") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &do_haddr)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); + return -1; + } + } else if (g_strcmp0(tokens[0], "track") == 0) { + if (g_strcmp0(tokens[1], "r") == 0) { rw = QEMU_PLUGIN_MEM_R; - } else if (!strcmp(str, "w")) { + } else if (g_strcmp0(tokens[1], "w") == 0) { rw = QEMU_PLUGIN_MEM_W; + } else if (g_strcmp0(tokens[1], "rw") == 0) { + rw = QEMU_PLUGIN_MEM_RW; + } else { + fprintf(stderr, "invaild value for argument track: %s\n", opt); + return -1; + } + } else if (g_strcmp0(tokens[0], "inline") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &do_inline)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); + return -1; + } + } else if (g_strcmp0(tokens[0], "callback") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], &do_callback)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); + return -1; } - } - if (!strcmp(argv[0], "inline")) { - do_inline = true; - do_callback = false; - } else if (!strcmp(argv[0], "both")) { - do_inline = true; - do_callback = true; } else { - do_callback = true; + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; } }