From patchwork Fri Sep 3 09:03:26 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: 506477 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp822543jai; Fri, 3 Sep 2021 02:06:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWAvLnlSbYZH4Mt+4OFLBK6KQnCPiRd1IcyC8aby1ooSdcpZzVb0ckwUuChRlm78rYbovL X-Received: by 2002:a67:cb0a:: with SMTP id b10mr1650396vsl.9.1630660013242; Fri, 03 Sep 2021 02:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630660013; cv=none; d=google.com; s=arc-20160816; b=vcWD7Je0YMndeWjEhc4o/JQSF301mlnazv6lBc1nmHp0oGuKYXvIcWvBILIBywxL9O 5ICCO1hZdxtCVE7WSZcDzMFNJBmwCxKVaX/gnHhDYiFjuEE3mkyEWDYNnF4vRBRjv2vd jTj0ha5QuFHRE8ATrAH99mcA8kFY32IEJaJvwWhN1EmSgZIkUH4bsXNP9Bl9+tcwfDuH WSq5YALQ/grdwStFQu++H9NsoGml3gktmxYq2bQWTIkeUXWw1sDVz1uQzpsyx7OFgCB/ YMnLQON62qGuTizSMpKS2P95zlcctfwaRRsEebiKTWdy15et7e0Nd8f1vHymhd8mo+DM avpQ== 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=5/N/ygGGEO4FJCbA3u79534rctxSYi1cLOVSuXy4QtY=; b=fQc0slnLDIzqKaw2XmiMA+vPsi3+Xty6Hj3ULrmbTG+tkoFh7ez7xP81XrjKKvfaQz U9Z+10F+ian7arJplOcjWnq0hFGFf2En4hyCBDSOiJ8f/r/on6R3ZbqxJFuEh8tp9Q7v VqCd8qPCK04lieqDY+L5xPy0iUHz97ottP/aAIjftZqlaosBUxLXepJ8paNuCn/kbgoj v/CDwzYKx0pPASWjC4OvPOe4Q7sIEGz1wZwjJUwRF4JSppzfnLU0rrhXXYzP0ikq7+IV qqf4zKMMfvrkbBO9P8qq3vQcIsu3Lj+1bCaL2sOkbxQ3O1cILWwIt+vt/JJZwi3lYRwS 3plA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=VZX6eXB8; 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 v5si1769792uar.190.2021.09.03.02.06.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Sep 2021 02:06:53 -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=VZX6eXB8; 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]:35906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mM59w-00070s-IN for patch@linaro.org; Fri, 03 Sep 2021 05:06:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mM57A-0006Bz-Dv for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:04:00 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:45931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mM577-0005f9-D0 for qemu-devel@nongnu.org; Fri, 03 Sep 2021 05:04:00 -0400 Received: by mail-wr1-x42b.google.com with SMTP id n5so7155472wro.12 for ; Fri, 03 Sep 2021 02:03:56 -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=5/N/ygGGEO4FJCbA3u79534rctxSYi1cLOVSuXy4QtY=; b=VZX6eXB8I2KChGZTeudU9P1NzKcHm1PgXW+LBNoqq7XY2MH+ZjgUvmAa+tsV60iv0l 30z7ZePXtWH8BOuDfERXqOrza8UtWDekGMRfPKv3jil7qrGTMB8ng1CgLhGkXU0N1udK dj6SatNSZmyxJMaMfXNby6tAdvUlJvuXtUx/3Wfx5xn8tBcEWIVkcU8z0gtvkKg3EnQQ p/qX7LAx2zv+LiP6NAmjxyczFEPEFUS1TDTJRwLmtlIWu98oRAFKcczjitE+3uZF6eDN cn32Cu0am4nOITYcVZrNRrf4thWtuG/lIxkWjha1edCp4Bde9fcT/bp79U19ERGt3rFU B1Zw== 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=5/N/ygGGEO4FJCbA3u79534rctxSYi1cLOVSuXy4QtY=; b=b3tIYQdhikH0sw4ry43cMv1A1rGnYRgWMLI+iH3a+C9Uh/Zs4T5UR6gmRwcG5koB/S S20ctQQP97/ntMjqI5529mXsziCYbPgsY19hePV1ELeUYwda9VUOsJ3TfbIiwizz5RD1 tTRQ6to9dRgyBOhiJFM8q9x6nPNhWNTxlmBlBECgCyqdw828EKoz77T4QlWwWp1VbyBX gS1UuapouDa5+CzA1Y9nFtLY5F/enUG8raaqVgj5dWKw6A2JoCaRJj5E2AkeU6LVXWx+ cjTPsbPHx7fbU0tCAdUUSCjczBv5rrNH2eC/Oxjxjc8zWCkEA2ktWP4ovwD4zfQ/eYXx gJHQ== X-Gm-Message-State: AOAM532AH1yv83iiNfFAaykzETd7bTu9+FUL6r5iPT5P0I0JQ5381lzW Y3/WeSkgLmq3+iIkUIlSNPj+JA== X-Received: by 2002:adf:e449:: with SMTP id t9mr2704370wrm.135.1630659835119; Fri, 03 Sep 2021 02:03:55 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y15sm4062044wrw.64.2021.09.03.02.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 02:03:49 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9641E1FFA5; Fri, 3 Sep 2021 10:03:40 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 09/22] plugins: allow plugin arguments to be passed directly Date: Fri, 3 Sep 2021 10:03:26 +0100 Message-Id: <20210903090339.1074887-10-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::42b; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42b.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, 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, Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Mahmoud Mandour Passing arguments to plugins had to be done through "arg=". This is redundant and introduces confusion especially when the argument has a name and value (e.g. `-plugin plugin_name,arg="argname=argvalue"`). This allows passing plugin arguments directly e.g: `-plugin plugin_name,argname=argvalue` For now, passing arguments through "arg=" is still supports but outputs a deprecation warning. Also, this commit makes boolean arguments passed to plugins in the `argname=on|off` form instead of the deprecated short-boolean form. Signed-off-by: Mahmoud Mandour Tested-by: Alex Bennée Reviewed-by: Alex Bennée Signed-off-by: Alex Bennée Message-Id: <20210730135817.17816-2-ma.mandourr@gmail.com> -- 2.30.2 diff --git a/linux-user/main.c b/linux-user/main.c index 37ed50d98e..a6094563b6 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -463,7 +463,7 @@ static const struct qemu_argument arg_table[] = { "", "[[enable=]][,events=][,file=]"}, #ifdef CONFIG_PLUGIN {"plugin", "QEMU_PLUGIN", true, handle_arg_plugin, - "", "[file=][,arg=]"}, + "", "[file=][,=]"}, #endif {"version", "QEMU_VERSION", false, handle_arg_version, "", "display version information and exit"}, diff --git a/plugins/loader.c b/plugins/loader.c index 05df40398d..a4ec281692 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -94,6 +94,8 @@ static int plugin_add(void *opaque, const char *name, const char *value, { struct qemu_plugin_parse_arg *arg = opaque; struct qemu_plugin_desc *p; + bool is_on; + char *fullarg; if (strcmp(name, "file") == 0) { if (strcmp(value, "") == 0) { @@ -107,18 +109,32 @@ static int plugin_add(void *opaque, const char *name, const char *value, QTAILQ_INSERT_TAIL(arg->head, p, entry); } arg->curr = p; - } else if (strcmp(name, "arg") == 0) { + } else { if (arg->curr == NULL) { error_setg(errp, "missing earlier '-plugin file=' option"); return 1; } + + if (g_strcmp0(name, "arg") == 0 && + !qapi_bool_parse(name, value, &is_on, NULL)) { + if (strchr(value, '=') == NULL) { + /* Will treat arg="argname" as "argname=on" */ + fullarg = g_strdup_printf("%s=%s", value, "on"); + } else { + fullarg = g_strdup_printf("%s", value); + } + warn_report("using 'arg=%s' is deprecated", value); + error_printf("Please use '%s' directly\n", fullarg); + } else { + fullarg = g_strdup_printf("%s=%s", name, value); + } + p = arg->curr; p->argc++; p->argv = g_realloc_n(p->argv, p->argc, sizeof(char *)); - p->argv[p->argc - 1] = g_strdup(value); - } else { - error_setg(errp, "-plugin: unexpected parameter '%s'; ignored", name); + p->argv[p->argc - 1] = fullarg; } + return 0; } diff --git a/qemu-options.hx b/qemu-options.hx index 83aa59a920..4a9ee722c9 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4532,19 +4532,18 @@ SRST ERST DEF("plugin", HAS_ARG, QEMU_OPTION_plugin, - "-plugin [file=][,arg=]\n" + "-plugin [file=][,=]\n" " load a plugin\n", QEMU_ARCH_ALL) SRST -``-plugin file=file[,arg=string]`` +``-plugin file=file[,argname=argvalue]`` Load a plugin. ``file=file`` Load the given plugin from a shared library file. - ``arg=string`` - Argument string passed to the plugin. (Can be given multiple - times.) + ``argname=argvalue`` + Argument passed to the plugin. (Can be given multiple times.) ERST HXCOMM Internal use