From nobody Sun May 19 04:05:30 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1624463816; cv=none; d=zohomail.com; s=zohoarc; b=ZA+fhYZKgvnh6Gc87hIoxFhaNFZ7HAwKm4A8BsxpOhF+yIGQUjekM0KlXlIBPgZ3rnMg1r6R1Jyqt/KwgJkLDDY1R7DgtIFAP7Cx1qV3jRVmKhCdNkHFzGtagFgEnpy+I3DAuuqPZ1bk6P9eOuyOdv1wXhJJoNg90yn0P+DpeI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624463816; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=uXGN0cpV3Gpof1WpgLXj/iSpt68g2IUYatXeahWbpps=; b=UfWc5PFF/6wpoA5FPtoum2lolkXB0Rti9yEHa6nve2O5o04v+iv11d8DVGUfw2pMjYm+i7gPxaSXiO56iVoNQfXxlG5YsUokmn1jGN+IhRqr+TrrvLG5u0qyYn3a+S3WiSg6KgbZsM086kLLtW5geMLdpUaC1GdujDEZkgdBWaw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624463816901338.48925634624493; Wed, 23 Jun 2021 08:56:56 -0700 (PDT) Received: from localhost ([::1]:38898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lw5FF-0003Cl-UI for importer@patchew.org; Wed, 23 Jun 2021 11:56:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lw5EV-0002U3-DY for qemu-devel@nongnu.org; Wed, 23 Jun 2021 11:56:07 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:39660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lw5ET-0005VD-Jn for qemu-devel@nongnu.org; Wed, 23 Jun 2021 11:56:07 -0400 Received: by mail-wr1-x429.google.com with SMTP id b3so3214529wrm.6 for ; Wed, 23 Jun 2021 08:56:05 -0700 (PDT) Received: from localhost.localdomain ([197.61.84.15]) by smtp.gmail.com with ESMTPSA id s62sm6325210wms.13.2021.06.23.08.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 08:56:03 -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:mime-version :content-transfer-encoding; bh=uXGN0cpV3Gpof1WpgLXj/iSpt68g2IUYatXeahWbpps=; b=MOK+l568X2KrlpqHdDBMHStvcMI9doxnGuYleTliIbml7jr6Pjqppb+UkgJ8EbLZ90 +pL3ZBkzPhfZ0GXQIilO4f+w0laWinpMjOMSb1cneO9W35LJNMJkAufjWbUkST8FwF/5 XuGDH2njGj1hll2sHRIyh3wm883x69a6VOgFKyo0oR0YPsaHqXYZDUAMeXm7mel/0dK5 7cmcIKtgaUr4a6Nu8E4qkDv1hEseg0QccAe/hJrQ6Qoh5JSrtptAquRqJLlnJEGggSz+ EwKcdSwVgj03wAApsjyAjP9cMwoAYdhLEdnxjzHOzRSY/RmEGivD/covemGbg8GJxtET +GTQ== 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:mime-version :content-transfer-encoding; bh=uXGN0cpV3Gpof1WpgLXj/iSpt68g2IUYatXeahWbpps=; b=AIF8YcZqGNJdhoj7FtuaCp28KLkx7AoZ8JWTiwujNKmhOpnMDK2EdvCU0uLRE4S2NV g/lrLyqj+A/vKrtB9GlDwhNcXpvr2rpgjV6c5ZQG2VO4tUSjQfEO1ZKacPt0NV/z1uH6 JtTxm3B9a/RpqVGH+FJN4/8QxKR0z6fF9B2dUAWF4gOCDvzrwzW7vd/hX1BTfOG2kWOZ krxo2NskgoBJpuvyqSJ6++F99xjxqQL3e1J6IfN7+uwHwV9J0Mi+ppYsWKhRqhEPPM6G 2W7IM9yAaMg1YTQY6H9dvsbLKuwAJg4gnp3hF6l04c/ZDixKMmecAs7UHrvH5SEO+9f3 FIKw== X-Gm-Message-State: AOAM531xZexhRNzAZAgQ306dDZCjsboDFvLgADfQ4fW/FkIRjadeQ1mf WBrfXvbO0ibrA74+zBFfSPgUeiWPAwuKWw== X-Google-Smtp-Source: ABdhPJywsrf7VJmzYr00hd+dx+zI4ZcE91JLRZyEih4KKZZiE8zU9QWSNlWaLf6H9Rb+z6esJL2QkQ== X-Received: by 2002:a05:6000:4b:: with SMTP id k11mr863701wrx.192.1624463763741; Wed, 23 Jun 2021 08:56:03 -0700 (PDT) From: Mahmoud Mandour To: qemu-devel@nongnu.org Subject: [RFC PATCH] Subject: [RFC PATCH] plugins: Passed the parsed arguments directly to plugins Date: Wed, 23 Jun 2021 17:55:53 +0200 Message-Id: <20210623155553.481099-1-ma.mandourr@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=ma.mandourr@gmail.com; helo=mail-wr1-x429.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 , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) Content-Type: text/plain; charset="utf-8" Arguments were passed to plugins in the following form: -plugin path/to/plugin,arg=3D"positional_arg=3Dvalue",arg=3D"second_arg" This patch removes the need for "arg" so that the argument name itself is now expected and passed directly to the plugin. Now options can be passed in the following manner: -plugin path/to/plugin,positional_arg=3Dvalue,second_arg Since short boolean arguments are deprecated, passing an argument that takes no value will trigger a warning saying that the user should use a full "arg_name=3Don" instead of just "arg_name". In either case, the argument is passed to the plugin as only the name, omitting the "=3Don" part. Signed-off-by: Mahmoud Mandour --- plugins/loader.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/loader.c b/plugins/loader.c index 05df40398d..7f32b8c8bd 100644 --- a/plugins/loader.c +++ b/plugins/loader.c @@ -94,6 +94,7 @@ static int plugin_add(void *opaque, const char *name, con= st char *value, { struct qemu_plugin_parse_arg *arg =3D opaque; struct qemu_plugin_desc *p; + char *full_arg; =20 if (strcmp(name, "file") =3D=3D 0) { if (strcmp(value, "") =3D=3D 0) { @@ -107,7 +108,7 @@ static int plugin_add(void *opaque, const char *name, c= onst char *value, QTAILQ_INSERT_TAIL(arg->head, p, entry); } arg->curr =3D p; - } else if (strcmp(name, "arg") =3D=3D 0) { + } else { if (arg->curr =3D=3D NULL) { error_setg(errp, "missing earlier '-plugin file=3D' option"); return 1; @@ -115,9 +116,12 @@ static int plugin_add(void *opaque, const char *name, = const char *value, p =3D arg->curr; p->argc++; p->argv =3D g_realloc_n(p->argv, p->argc, sizeof(char *)); - p->argv[p->argc - 1] =3D g_strdup(value); - } else { - error_setg(errp, "-plugin: unexpected parameter '%s'; ignored", na= me); + if (strcmp(value, "on")) { + full_arg =3D g_strdup_printf("%s=3D%s", name, value); + } else { + full_arg =3D g_strdup(name); + } + p->argv[p->argc - 1] =3D full_arg; } return 0; } --=20 2.25.1