From patchwork Fri Jun 14 10:38:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 10995007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB0C8924 for ; Fri, 14 Jun 2019 10:39:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB0ED2847F for ; Fri, 14 Jun 2019 10:39:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF91228497; Fri, 14 Jun 2019 10:39:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DD3F2283BF for ; Fri, 14 Jun 2019 10:39:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbjb4-0002m9-M5; Fri, 14 Jun 2019 10:38:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbjb3-0002lG-6J for xen-devel@lists.xenproject.org; Fri, 14 Jun 2019 10:38:13 +0000 X-Inumbo-ID: 813336ec-8e90-11e9-85da-3b146665613f Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 813336ec-8e90-11e9-85da-3b146665613f; Fri, 14 Jun 2019 10:38:11 +0000 (UTC) Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: LQ3Xs+FckjuDEppubsJzf4Ia8O+hxAZzOWIu6xNCHdQmtS/wNlPORRnkjlKFTFhxlUtVjRsPa1 ec5Cd0t0e191qEFJ00JgtCTVNW0HbryO+and2yQE2nTYGhzaN+aSjIGb34dO8HB6nZSx7GE+mL ed0phQx6mZTxGFtiL7BtaA1U2pYk4ph77E6R+tX9uvw3e5bNCFwsjMMdhjR51rWMc8DXEhoQ1F ORXaR4BqFnszp4IUbc17zxvV/ZvdN7qy+TqdcPbp0f1BFs2esXXj3NEAbQlOPiy5QE+zM7mFii pp4= X-SBRS: 2.7 X-MesageID: 1744469 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,373,1557201600"; d="scan'208";a="1744469" From: Anthony PERARD To: Date: Fri, 14 Jun 2019 11:38:00 +0100 Message-ID: <20190614103801.22619-9-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190614103801.22619-1-anthony.perard@citrix.com> References: <20190614103801.22619-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 8/9] libxl: Move qmp_parameters_* prototypes to libxl_internal.h X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP .. and rename them to libxl__qmp_param_*. This is to allow other files than libxl_qmp.c to make QMP calls with parameters. Signed-off-by: Anthony PERARD Acked-by: Ian Jackson --- tools/libxl/libxl_internal.h | 15 ++++++++ tools/libxl/libxl_qmp.c | 75 +++++++++++++++++------------------- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 2c2476b55b..2dc5a31755 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -470,6 +470,21 @@ struct libxl__ev_qmp { int msg_id; }; +/* QMP parameters helpers */ + +_hidden void libxl__qmp_param_add_string(libxl__gc *gc, + libxl__json_object **param, + const char *name, const char *s); +_hidden void libxl__qmp_param_add_bool(libxl__gc *gc, + libxl__json_object **param, + const char *name, bool b); +_hidden void libxl__qmp_param_add_integer(libxl__gc *gc, + libxl__json_object **param, + const char *name, const int i); +#define QMP_PARAMETERS_SPRINTF(args, name, format, ...) \ + libxl__qmp_param_add_string(gc, args, name, \ + GCSPRINTF(format, __VA_ARGS__)) + /* * evgen structures, which are the state we use for generating diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 42c8ab8d8d..b6a691d9fc 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -752,9 +752,9 @@ static void qmp_parameters_common_add(libxl__gc *gc, flexarray_append((*param)->u.map, arg); } -static void qmp_parameters_add_string(libxl__gc *gc, - libxl__json_object **param, - const char *name, const char *argument) +void libxl__qmp_param_add_string(libxl__gc *gc, + libxl__json_object **param, + const char *name, const char *argument) { libxl__json_object *obj; @@ -764,9 +764,9 @@ static void qmp_parameters_add_string(libxl__gc *gc, qmp_parameters_common_add(gc, param, name, obj); } -static void qmp_parameters_add_bool(libxl__gc *gc, - libxl__json_object **param, - const char *name, bool b) +void libxl__qmp_param_add_bool(libxl__gc *gc, + libxl__json_object **param, + const char *name, bool b) { libxl__json_object *obj; @@ -775,9 +775,9 @@ static void qmp_parameters_add_bool(libxl__gc *gc, qmp_parameters_common_add(gc, param, name, obj); } -static void qmp_parameters_add_integer(libxl__gc *gc, - libxl__json_object **param, - const char *name, const int i) +void libxl__qmp_param_add_integer(libxl__gc *gc, + libxl__json_object **param, + const char *name, const int i) { libxl__json_object *obj; @@ -787,9 +787,6 @@ static void qmp_parameters_add_integer(libxl__gc *gc, qmp_parameters_common_add(gc, param, name, obj); } -#define QMP_PARAMETERS_SPRINTF(args, name, format, ...) \ - qmp_parameters_add_string(gc, args, name, GCSPRINTF(format, __VA_ARGS__)) - /* * API */ @@ -943,7 +940,7 @@ int libxl__qmp_run_command_flexarray(libxl__gc *gc, int domid, for (i = 0; i < array->count; i += 2) { flexarray_get(array, i, &name); flexarray_get(array, i + 1, &value); - qmp_parameters_add_string(gc, &args, (char *)name, (char *)value); + libxl__qmp_param_add_string(gc, &args, (char *)name, (char *)value); } return qmp_run_command(gc, domid, cmd, args, NULL, NULL); @@ -965,10 +962,10 @@ int libxl__qmp_pci_add(libxl__gc *gc, int domid, libxl_device_pci *pcidev) if (!hostaddr) return -1; - qmp_parameters_add_string(gc, &args, "driver", "xen-pci-passthrough"); + libxl__qmp_param_add_string(gc, &args, "driver", "xen-pci-passthrough"); QMP_PARAMETERS_SPRINTF(&args, "id", PCI_PT_QDEV_ID, pcidev->bus, pcidev->dev, pcidev->func); - qmp_parameters_add_string(gc, &args, "hostaddr", hostaddr); + libxl__qmp_param_add_string(gc, &args, "hostaddr", hostaddr); if (pcidev->vdevfn) { QMP_PARAMETERS_SPRINTF(&args, "addr", "%x.%x", PCI_SLOT(pcidev->vdevfn), PCI_FUNC(pcidev->vdevfn)); @@ -984,7 +981,7 @@ int libxl__qmp_pci_add(libxl__gc *gc, int domid, libxl_device_pci *pcidev) * reason to set the flag so this is ok. */ if (pcidev->permissive) - qmp_parameters_add_bool(gc, &args, "permissive", true); + libxl__qmp_param_add_bool(gc, &args, "permissive", true); rc = qmp_synchronous_send(qmp, "device_add", args, NULL, NULL, qmp->timeout); @@ -1001,7 +998,7 @@ static int qmp_device_del(libxl__gc *gc, int domid, char *id) { libxl__json_object *args = NULL; - qmp_parameters_add_string(gc, &args, "id", id); + libxl__qmp_param_add_string(gc, &args, "id", id); return qmp_run_command(gc, domid, "device_del", args, NULL, NULL); } @@ -1023,7 +1020,7 @@ int libxl__qmp_restore(libxl__gc *gc, int domid, const char *state_file) { libxl__json_object *args = NULL; - qmp_parameters_add_string(gc, &args, "filename", state_file); + libxl__qmp_param_add_string(gc, &args, "filename", state_file); return qmp_run_command(gc, domid, "xen-load-devices-state", args, NULL, NULL); @@ -1035,10 +1032,10 @@ static int qmp_change(libxl__gc *gc, libxl__qmp_handler *qmp, libxl__json_object *args = NULL; int rc = 0; - qmp_parameters_add_string(gc, &args, "device", device); - qmp_parameters_add_string(gc, &args, "target", target); + libxl__qmp_param_add_string(gc, &args, "device", device); + libxl__qmp_param_add_string(gc, &args, "target", target); if (arg) { - qmp_parameters_add_string(gc, &args, "arg", arg); + libxl__qmp_param_add_string(gc, &args, "arg", arg); } rc = qmp_synchronous_send(qmp, "change", args, @@ -1056,7 +1053,7 @@ int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable) { libxl__json_object *args = NULL; - qmp_parameters_add_bool(gc, &args, "enable", enable); + libxl__qmp_param_add_bool(gc, &args, "enable", enable); return qmp_run_command(gc, domid, "xen-set-global-dirty-log", args, NULL, NULL); @@ -1073,8 +1070,8 @@ int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, if (disk->format == LIBXL_DISK_FORMAT_EMPTY) { return qmp_run_command(gc, domid, "eject", args, NULL, NULL); } else { - qmp_parameters_add_string(gc, &args, "target", disk->pdev_path); - qmp_parameters_add_string(gc, &args, "arg", + libxl__qmp_param_add_string(gc, &args, "target", disk->pdev_path); + libxl__qmp_param_add_string(gc, &args, "arg", libxl__qemu_disk_format_string(disk->format)); return qmp_run_command(gc, domid, "change", args, NULL, NULL); } @@ -1084,7 +1081,7 @@ int libxl__qmp_cpu_add(libxl__gc *gc, int domid, int idx) { libxl__json_object *args = NULL; - qmp_parameters_add_integer(gc, &args, "id", idx); + libxl__qmp_param_add_integer(gc, &args, "id", idx); return qmp_run_command(gc, domid, "cpu-add", args, NULL, NULL); } @@ -1142,10 +1139,10 @@ int libxl__qmp_nbd_server_start(libxl__gc *gc, int domid, * } * } */ - qmp_parameters_add_string(gc, &data, "host", host); - qmp_parameters_add_string(gc, &data, "port", port); + libxl__qmp_param_add_string(gc, &data, "host", host); + libxl__qmp_param_add_string(gc, &data, "port", port); - qmp_parameters_add_string(gc, &addr, "type", "inet"); + libxl__qmp_param_add_string(gc, &addr, "type", "inet"); qmp_parameters_common_add(gc, &addr, "data", data); qmp_parameters_common_add(gc, &args, "addr", addr); @@ -1157,8 +1154,8 @@ int libxl__qmp_nbd_server_add(libxl__gc *gc, int domid, const char *disk) { libxl__json_object *args = NULL; - qmp_parameters_add_string(gc, &args, "device", disk); - qmp_parameters_add_bool(gc, &args, "writable", true); + libxl__qmp_param_add_string(gc, &args, "device", disk); + libxl__qmp_param_add_bool(gc, &args, "writable", true); return qmp_run_command(gc, domid, "nbd-server-add", args, NULL, NULL); } @@ -1167,8 +1164,8 @@ int libxl__qmp_start_replication(libxl__gc *gc, int domid, bool primary) { libxl__json_object *args = NULL; - qmp_parameters_add_bool(gc, &args, "enable", true); - qmp_parameters_add_bool(gc, &args, "primary", primary); + libxl__qmp_param_add_bool(gc, &args, "enable", true); + libxl__qmp_param_add_bool(gc, &args, "primary", primary); return qmp_run_command(gc, domid, "xen-set-replication", args, NULL, NULL); } @@ -1189,8 +1186,8 @@ int libxl__qmp_stop_replication(libxl__gc *gc, int domid, bool primary) { libxl__json_object *args = NULL; - qmp_parameters_add_bool(gc, &args, "enable", false); - qmp_parameters_add_bool(gc, &args, "primary", primary); + libxl__qmp_param_add_bool(gc, &args, "enable", false); + libxl__qmp_param_add_bool(gc, &args, "primary", primary); return qmp_run_command(gc, domid, "xen-set-replication", args, NULL, NULL); } @@ -1205,11 +1202,11 @@ int libxl__qmp_x_blockdev_change(libxl__gc *gc, int domid, const char *parent, { libxl__json_object *args = NULL; - qmp_parameters_add_string(gc, &args, "parent", parent); + libxl__qmp_param_add_string(gc, &args, "parent", parent); if (child) - qmp_parameters_add_string(gc, &args, "child", child); + libxl__qmp_param_add_string(gc, &args, "child", child); if (node) - qmp_parameters_add_string(gc, &args, "node", node); + libxl__qmp_param_add_string(gc, &args, "node", node); return qmp_run_command(gc, domid, "x-blockdev-change", args, NULL, NULL); } @@ -1246,7 +1243,7 @@ int libxl__qmp_hmp(libxl__gc *gc, int domid, const char *command_line, { libxl__json_object *args = NULL; - qmp_parameters_add_string(gc, &args, "command-line", command_line); + libxl__qmp_param_add_string(gc, &args, "command-line", command_line); return qmp_run_command(gc, domid, "human-monitor-command", args, hmp_callback, output); @@ -1383,7 +1380,7 @@ static void dm_state_fd_ready(libxl__egc *egc, libxl__ev_qmp *ev, * the save operation is for a live migration rather than for taking a * snapshot. */ if (qmp_ev_qemu_compare_version(ev, 2, 11, 0) >= 0) - qmp_parameters_add_bool(gc, &args, "live", dsps->live); + libxl__qmp_param_add_bool(gc, &args, "live", dsps->live); QMP_PARAMETERS_SPRINTF(&args, "filename", "/dev/fdset/%d", fdset); rc = libxl__ev_qmp_send(gc, ev, "xen-save-devices-state", args); if (rc)