From nobody Fri Sep 20 22:16:04 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=1624464349; cv=none; d=zohomail.com; s=zohoarc; b=DYdVUEe2h84xOu+Df2APJD7ETk/mtNfOWIg9Fq7QkCHCP8AMfnocDswiAd43CrEEIyyvcMKc9XpAfIjYzKhCMp8cVRqlxd25iWrr3zxtfFTa50PunrNs952k+n1EUijRSQ7yKnozl+M7TS/iPbjThrzVMdqP8OQCtWjr9DbrtBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624464349; 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=geWFKsRX+zf43Hsla7o7+3onIp2CCJy0Pj24/mwkyN8jdjJkLb33evHwZLHkADG9pkjCp3KcR66L1pNftE99c5mqJFhYI0ois+NwAmv8M+xHjfOWr/ZggwtnWamyFHhqX1ARkMioxlOuS7bpnFlWxJwIrhpNTi8Ue1v6KzRtPhQ= 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 1624464349478922.190040596548; Wed, 23 Jun 2021 09:05:49 -0700 (PDT) Received: from localhost ([::1]:57788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lw5Ns-0007bx-6M for importer@patchew.org; Wed, 23 Jun 2021 12:05:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lw5JK-0007eb-63 for qemu-devel@nongnu.org; Wed, 23 Jun 2021 12:01:06 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:44013) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lw5JH-0000LF-1k for qemu-devel@nongnu.org; Wed, 23 Jun 2021 12:01:05 -0400 Received: by mail-wm1-x336.google.com with SMTP id p8-20020a7bcc880000b02901dbb595a9f1so1695676wma.2 for ; Wed, 23 Jun 2021 09:01:00 -0700 (PDT) Received: from localhost.localdomain ([197.61.84.15]) by smtp.gmail.com with ESMTPSA id s62sm6338273wms.13.2021.06.23.09.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 09:00:59 -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=SlixGbALIOKPAGG0I37Lr0opuv/WApBEY1670aCs4NMvGe2tBscd172VH6UtnVrfJX taVLxqx8SyVaJ+pfC3Q2pGZvh+6hn+++rMkRVTSmN/xWRBbh8HkJaTGrOG6IYECZbISY Hp0VrhOu7i8UD7V17fi+D2nsv0EdEiTNkX4VnOMjmLs9RVUuFIeEdfiLqtco2dUwsdXP 4u8D1i39KdJrFQrWCnAPcEiZh2HmTb9NyKYLLejho/KjcZfnZf9ljduAsIdqrNtBLzPP NJH2vimd0sAWfp6fMTkHXA/kj3l1bmoFryzvyuFgV9uSfHTmj74pXsrStu5Pn43M8/dm 1fOA== 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=cycUn3Dnz6QykEtrFgPTXuGJ3zGmpJKfWePhWwO0OXzCVv8gNRgp2TVeyZCTe8Zq0m tvpBFGeTmAYvkswRppU+732PaabwefYM/5Kw1d1A3/bBCDAuHW+KNlHn5RkBGLRj1mFa MK1y/HEkN+rwkVlbBhujSlKxOCbuZwHXzD74ovMUs1Ma60WL8K5to+ViTYFbUlJVLAQG 4g7ulVeQV/Cr8TDCjLJWVHb777yqSGIE60kiAkMxK9p6/7OmbG3q7DzfZYZgdUamoeFI yFE3CUAQ1ueULu516JbmF9mlz6q0JDlAXsJ1fgIdmh3yD5+XA2YuC/mako72Acc5SxoA Q7gQ== X-Gm-Message-State: AOAM531btuVLFWuXAe3JLtGapJtLyY6HNRJ855o3F9/Gcd6bURKaWRFX DVVFdTLjo1RDKbKTE02sgQ/z1MopAFp7MQ== X-Google-Smtp-Source: ABdhPJw6HM8NQqlWT561l0di8r9v3ykc+azEOFU8/1x3rsIf04005BjPtPjPmezNVSk5VGBQIDJ7sg== X-Received: by 2002:a7b:cb03:: with SMTP id u3mr450773wmj.119.1624464059478; Wed, 23 Jun 2021 09:00:59 -0700 (PDT) From: Mahmoud Mandour To: qemu-devel@nongnu.org Subject: [RFC PATCH v2] plugins: Passed the parsed arguments directly to plugins Date: Wed, 23 Jun 2021 18:00:51 +0200 Message-Id: <20210623160051.482646-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::336; envelope-from=ma.mandourr@gmail.com; helo=mail-wm1-x336.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