From: "Alex Bennée" <alex.bennee@linaro.org>
To: peter.maydell@linaro.org
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
"Mahmoud Mandour" <ma.mandourr@gmail.com>,
richard.henderson@linaro.org, qemu-devel@nongnu.org,
"Alexandre Iooss" <erdnaxe@crans.org>
Subject: [PULL 12/21] plugins/cache: split command line arguments into name and value
Date: Wed, 3 Nov 2021 17:05:49 +0000 [thread overview]
Message-ID: <20211103170558.717981-13-alex.bennee@linaro.org> (raw)
In-Reply-To: <20211103170558.717981-1-alex.bennee@linaro.org>
From: Mahmoud Mandour <ma.mandourr@gmail.com>
This way of handling args is more lenient and sets a better framework to
parse boolean command line arguments.
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210810134844.166490-4-ma.mandourr@gmail.com>
Message-Id: <20211026102234.3961636-16-alex.bennee@linaro.org>
diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c
index 908c967a09..ff325beb9f 100644
--- a/contrib/plugins/cache.c
+++ b/contrib/plugins/cache.c
@@ -11,6 +11,8 @@
#include <qemu-plugin.h>
+#define STRTOLL(x) g_ascii_strtoll(x, NULL, 10)
+
QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION;
static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW;
@@ -746,35 +748,36 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
for (i = 0; i < argc; i++) {
char *opt = argv[i];
- if (g_str_has_prefix(opt, "iblksize=")) {
- l1_iblksize = g_ascii_strtoll(opt + 9, NULL, 10);
- } else if (g_str_has_prefix(opt, "iassoc=")) {
- l1_iassoc = g_ascii_strtoll(opt + 7, NULL, 10);
- } else if (g_str_has_prefix(opt, "icachesize=")) {
- l1_icachesize = g_ascii_strtoll(opt + 11, NULL, 10);
- } else if (g_str_has_prefix(opt, "dblksize=")) {
- l1_dblksize = g_ascii_strtoll(opt + 9, NULL, 10);
- } else if (g_str_has_prefix(opt, "dassoc=")) {
- l1_dassoc = g_ascii_strtoll(opt + 7, NULL, 10);
- } else if (g_str_has_prefix(opt, "dcachesize=")) {
- l1_dcachesize = g_ascii_strtoll(opt + 11, NULL, 10);
- } else if (g_str_has_prefix(opt, "limit=")) {
- limit = g_ascii_strtoll(opt + 6, NULL, 10);
- } else if (g_str_has_prefix(opt, "cores=")) {
- cores = g_ascii_strtoll(opt + 6, NULL, 10);
- } else if (g_str_has_prefix(opt, "l2cachesize=")) {
- l2_cachesize = g_ascii_strtoll(opt + 6, NULL, 10);
- } else if (g_str_has_prefix(opt, "l2blksize=")) {
- l2_blksize = g_ascii_strtoll(opt + 6, NULL, 10);
- } else if (g_str_has_prefix(opt, "l2assoc=")) {
- l2_assoc = g_ascii_strtoll(opt + 6, NULL, 10);
- } else if (g_str_has_prefix(opt, "evict=")) {
- gchar *p = opt + 6;
- if (g_strcmp0(p, "rand") == 0) {
+ g_autofree char **tokens = g_strsplit(opt, "=", 2);
+
+ if (g_strcmp0(tokens[0], "iblksize") == 0) {
+ l1_iblksize = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "iassoc") == 0) {
+ l1_iassoc = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "icachesize") == 0) {
+ l1_icachesize = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "dblksize") == 0) {
+ l1_dblksize = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "dassoc") == 0) {
+ l1_dassoc = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "dcachesize") == 0) {
+ l1_dcachesize = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "limit") == 0) {
+ limit = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "cores") == 0) {
+ cores = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "l2cachesize") == 0) {
+ l2_cachesize = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "l2blksize") == 0) {
+ l2_blksize = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "l2assoc") == 0) {
+ l2_assoc = STRTOLL(tokens[1]);
+ } else if (g_strcmp0(tokens[0], "evict") == 0) {
+ if (g_strcmp0(tokens[1], "rand") == 0) {
policy = RAND;
- } else if (g_strcmp0(p, "lru") == 0) {
+ } else if (g_strcmp0(tokens[1], "lru") == 0) {
policy = LRU;
- } else if (g_strcmp0(p, "fifo") == 0) {
+ } else if (g_strcmp0(tokens[1], "fifo") == 0) {
policy = FIFO;
} else {
fprintf(stderr, "invalid eviction policy: %s\n", opt);
--
2.30.2
next prev parent reply other threads:[~2021-11-03 17:22 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-03 17:05 [PULL for 6.2 00/21] testing, plugin and gdbstub updates Alex Bennée
2021-11-03 17:05 ` [PULL 01/21] tests/docker: Update debian-hexagon-cross to a newer toolchain Alex Bennée
2021-11-03 17:05 ` [PULL 02/21] gitlab-ci: Remove special casing for hexagon testing Alex Bennée
2021-11-03 17:05 ` [PULL 03/21] tests/docker: Add debian-nios2-cross image Alex Bennée
2021-11-03 17:05 ` [PULL 04/21] tests/docker: Add debian-microblaze-cross image Alex Bennée
2021-11-03 17:05 ` [PULL 05/21] tests/tcg: Enable container_cross_cc for microblaze Alex Bennée
2021-11-03 17:05 ` [PULL 06/21] tests/tcg: Fix some targets default cross compiler path Alex Bennée
2021-11-03 17:05 ` [PULL 07/21] tests/docker: split PARTIAL into PARTIAL and VIRTUAL images Alex Bennée
2021-11-03 17:05 ` [PULL 08/21] tests/tcg: enable debian-nios2-cross for test building Alex Bennée
2021-11-03 17:05 ` [PULL 09/21] ebpf: really include it only in system emulators Alex Bennée
2021-11-03 17:05 ` [PULL 10/21] plugins/cache: freed heap-allocated mutexes Alex Bennée
2021-11-03 17:05 ` [PULL 11/21] plugins/cache: implement unified L2 cache emulation Alex Bennée
2021-11-03 17:05 ` Alex Bennée [this message]
2021-11-03 17:05 ` [PULL 13/21] plugins/cache: make L2 emulation optional through args Alex Bennée
2021-11-03 17:05 ` [PULL 14/21] docs/tcg-plugins: add L2 arguments to cache docs Alex Bennée
2021-11-03 17:05 ` [PULL 15/21] chardev: don't exit() straight away on C-a x Alex Bennée
2021-11-03 17:05 ` [PULL 16/21] tests/plugins: extend the insn plugin to track opcode sizes Alex Bennée
2021-11-03 17:05 ` [PULL 17/21] plugins: try and make plugin_insn_append more ergonomic Alex Bennée
2021-11-03 17:05 ` [PULL 18/21] tests/tcg: remove duplicate EXTRA_RUNS Alex Bennée
2021-11-03 17:05 ` [PULL 19/21] gdbstub: Switch to the thread receiving a signal Alex Bennée
2021-11-03 17:05 ` [PULL 20/21] tests/tcg: remove debug polluting make output Alex Bennée
2021-11-03 17:05 ` [PULL 21/21] tests/vm/openbsd: Update to release 7.0 Alex Bennée
2021-11-03 17:20 ` [PULL for 6.2 00/21] testing, plugin and gdbstub updates Alex Bennée
2021-11-03 19:32 ` Taylor Simpson
2021-11-04 4:45 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211103170558.717981-13-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=erdnaxe@crans.org \
--cc=ma.mandourr@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).