From patchwork Tue May 11 09:28:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12250301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6744BC433B4 for ; Tue, 11 May 2021 09:28:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 00BD0613C0 for ; Tue, 11 May 2021 09:28:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00BD0613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.125661.236497 (Exim 4.92) (envelope-from ) id 1lgOgc-0003Ck-BT; Tue, 11 May 2021 09:28:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 125661.236497; Tue, 11 May 2021 09:28:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgc-0003Cd-8V; Tue, 11 May 2021 09:28:18 +0000 Received: by outflank-mailman (input) for mailman id 125661; Tue, 11 May 2021 09:28:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOga-0003CS-TG for xen-devel@lists.xenproject.org; Tue, 11 May 2021 09:28:16 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 6181c3ad-3937-48ce-b657-1aedeeacc2a5; Tue, 11 May 2021 09:28:15 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6181c3ad-3937-48ce-b657-1aedeeacc2a5 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620725295; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lj/dnGcpZd9IQ9qo88EitYJiLnP3UnXfOqQmMLE15wg=; b=Snjy7GUECs3uD06LLyLADsC46UuYOG0CAtEVTSRHyiOgTneJEWmMnSrL daOwNNnX/NmmDJ7n9cduQ44OX0caJ32vHzRKjEh+yd4VZ0dQj6bND5f6g ZI72RE7BsnLENuNOXe1OpMdm0BiRyaKg5viBSPDcOlvr8L5AloHm5/4Qw s=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: U5WgJknRmmH6B6HptDW+4J1OkgsyHDtbD1e0NQvPWdXliV17Y3OwHm7agBTjuSDvYwmyRbj/RG gj8LSTFz4RAKEIhcQO3rIaA58IHF16DREYcBMHqCev9bXv5OJASG/imqCJZzbUR9v+tlRn954M +I0JOAjgI/hYpW8JfZ8W1r5AW9gV83XH4gDctJdLxodfFfQwlyDr2hOSzwEUA0AAkMXGC3u9Im zgXmqNPcM0n2PcNVvqDIaAJdD2Ir9kgJMELAtIvXlfprOtNcKfrZvo8UGDS0k0sitEnYoFhBY5 YK0= X-SBRS: 5.1 X-MesageID: 43528821 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:WrQI+KHdR6LotNM/pLqE0MeALOsnbusQ8zAXP0AYc3Jom6uj5q aTdZUgpGfJYVkqOE3I9ertBEDEewK4yXcX2/h3AV7BZniEhILAFugLhuGO/9SjIVybygc079 YYT0EUMrzN5DZB4voSmDPIceod/A== X-IronPort-AV: E=Sophos;i="5.82,290,1613451600"; d="scan'208";a="43528821" From: Anthony PERARD To: CC: Anthony PERARD , Jason Andryuk , Ian Jackson , Wei Liu Subject: [XEN PATCH v2 1/8] libxl: Replace deprecated QMP command by "query-cpus-fast" Date: Tue, 11 May 2021 10:28:03 +0100 Message-ID: <20210511092810.13759-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511092810.13759-1-anthony.perard@citrix.com> References: <20210511092810.13759-1-anthony.perard@citrix.com> MIME-Version: 1.0 We use the deprecated QMP command "query-cpus" which is removed in the QEMU 6.0 release. There's a replacement which is "query-cpus-fast", and have been available since QEMU 2.12 (April 2018). This patch try the new command first and when the command isn't available, it fall back to the deprecated one so libxl still works with older QEMU versions. Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- Notes: This is v2 of '[XEN PATCH for-4.15] libxl: Replace deprecated QMP command by "query-cpus-fast"' as the patch never made it into the release. changes: - introduce a fallback for when the new command isn't available. tools/libs/light/libxl_domain.c | 103 ++++++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 5 deletions(-) diff --git a/tools/libs/light/libxl_domain.c b/tools/libs/light/libxl_domain.c index 5d4ec9071160..8c003aa7cb04 100644 --- a/tools/libs/light/libxl_domain.c +++ b/tools/libs/light/libxl_domain.c @@ -1740,6 +1740,35 @@ static int libxl__set_vcpuonline_xenstore(libxl__gc *gc, uint32_t domid, return rc; } +static int qmp_parse_query_cpus_fast(libxl__gc *gc, + libxl_domid domid, + const libxl__json_object *response, + libxl_bitmap *const map) +{ + int i; + const libxl__json_object *cpu; + + libxl_bitmap_set_none(map); + /* Parse response to QMP command "query-cpus-fast": + * [ { 'cpu-index': 'int',...} ] + */ + for (i = 0; (cpu = libxl__json_array_get(response, i)); i++) { + unsigned int cpu_index; + const libxl__json_object *o; + + o = libxl__json_map_get("cpu-index", cpu, JSON_INTEGER); + if (!o) { + LOGD(ERROR, domid, "Failed to retrieve CPU index."); + return ERROR_QEMU_API; + } + + cpu_index = libxl__json_object_get_integer(o); + libxl_bitmap_set(map, cpu_index); + } + + return 0; +} + static int qmp_parse_query_cpus(libxl__gc *gc, libxl_domid domid, const libxl__json_object *response, @@ -1778,8 +1807,13 @@ typedef struct set_vcpuonline_state { int index; /* for loop on final_map */ } set_vcpuonline_state; +static void set_vcpuonline_qmp_cpus_fast_queried(libxl__egc *, + libxl__ev_qmp *, const libxl__json_object *, int rc); static void set_vcpuonline_qmp_cpus_queried(libxl__egc *, libxl__ev_qmp *, const libxl__json_object *, int rc); +static void set_vcpuonline_qmp_query_cpus_parse(libxl__egc *, + libxl__ev_qmp *qmp, const libxl__json_object *, + bool query_cpus_fast, int rc); static void set_vcpuonline_qmp_add_cpu(libxl__egc *, libxl__ev_qmp *, const libxl__json_object *response, int rc); static void set_vcpuonline_timeout(libxl__egc *egc, @@ -1840,8 +1874,8 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, set_vcpuonline_timeout, LIBXL_QMP_CMD_TIMEOUT * 1000); if (rc) goto out; - qmp->callback = set_vcpuonline_qmp_cpus_queried; - rc = libxl__ev_qmp_send(egc, qmp, "query-cpus", NULL); + qmp->callback = set_vcpuonline_qmp_cpus_fast_queried; + rc = libxl__ev_qmp_send(egc, qmp, "query-cpus-fast", NULL); if (rc) goto out; return AO_INPROGRESS; default: @@ -1860,11 +1894,39 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, return AO_INPROGRESS; } +static void set_vcpuonline_qmp_cpus_fast_queried(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) +{ + EGC_GC; + set_vcpuonline_state *svos = CONTAINER_OF(qmp, *svos, qmp); + + if (rc == ERROR_QMP_COMMAND_NOT_FOUND) { + /* Try again, we probably talking to a QEMU older than 2.12 */ + qmp->callback = set_vcpuonline_qmp_cpus_queried; + rc = libxl__ev_qmp_send(egc, qmp, "query-cpus", NULL); + if (rc) goto out; + return; + } + +out: + set_vcpuonline_qmp_query_cpus_parse(egc, qmp, response, true, rc); +} + static void set_vcpuonline_qmp_cpus_queried(libxl__egc *egc, libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) { EGC_GC; set_vcpuonline_state *svos = CONTAINER_OF(qmp, *svos, qmp); + + set_vcpuonline_qmp_query_cpus_parse(egc, qmp, response, false, rc); +} + +static void set_vcpuonline_qmp_query_cpus_parse(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, + bool query_cpus_fast, int rc) +{ + EGC_GC; + set_vcpuonline_state *svos = CONTAINER_OF(qmp, *svos, qmp); int i; libxl_bitmap current_map; @@ -1876,7 +1938,11 @@ static void set_vcpuonline_qmp_cpus_queried(libxl__egc *egc, if (rc) goto out; libxl_bitmap_alloc(CTX, ¤t_map, svos->info.vcpu_max_id + 1); - rc = qmp_parse_query_cpus(gc, qmp->domid, response, ¤t_map); + if (query_cpus_fast) { + rc = qmp_parse_query_cpus_fast(gc, qmp->domid, response, ¤t_map); + } else { + rc = qmp_parse_query_cpus(gc, qmp->domid, response, ¤t_map); + } if (rc) goto out; libxl_bitmap_copy_alloc(CTX, final_map, svos->cpumap); @@ -2121,6 +2187,9 @@ typedef struct { static void retrieve_domain_configuration_lock_acquired( libxl__egc *egc, libxl__ev_slowlock *, int rc); +static void retrieve_domain_configuration_cpu_fast_queried( + libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, int rc); static void retrieve_domain_configuration_cpu_queried( libxl__egc *egc, libxl__ev_qmp *qmp, const libxl__json_object *response, int rc); @@ -2198,8 +2267,8 @@ static void retrieve_domain_configuration_lock_acquired( if (rc) goto out; libxl_bitmap_alloc(CTX, &rdcs->qemuu_cpus, d_config->b_info.max_vcpus); - rdcs->qmp.callback = retrieve_domain_configuration_cpu_queried; - rc = libxl__ev_qmp_send(egc, &rdcs->qmp, "query-cpus", NULL); + rdcs->qmp.callback = retrieve_domain_configuration_cpu_fast_queried; + rc = libxl__ev_qmp_send(egc, &rdcs->qmp, "query-cpus-fast", NULL); if (rc) goto out; has_callback = true; } @@ -2210,6 +2279,30 @@ static void retrieve_domain_configuration_lock_acquired( retrieve_domain_configuration_end(egc, rdcs, rc); } +static void retrieve_domain_configuration_cpu_fast_queried( + libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, int rc) +{ + EGC_GC; + retrieve_domain_configuration_state *rdcs = + CONTAINER_OF(qmp, *rdcs, qmp); + + if (rc == ERROR_QMP_COMMAND_NOT_FOUND) { + /* Try again, we probably talking to a QEMU older than 2.12 */ + rdcs->qmp.callback = retrieve_domain_configuration_cpu_queried; + rc = libxl__ev_qmp_send(egc, &rdcs->qmp, "query-cpus", NULL); + if (rc) goto out; + return; + } + + if (rc) goto out; + + rc = qmp_parse_query_cpus_fast(gc, qmp->domid, response, &rdcs->qemuu_cpus); + +out: + retrieve_domain_configuration_end(egc, rdcs, rc); +} + static void retrieve_domain_configuration_cpu_queried( libxl__egc *egc, libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) From patchwork Tue May 11 09:28:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12250305 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8933C43460 for ; Tue, 11 May 2021 09:28:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 797376161F for ; Tue, 11 May 2021 09:28:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 797376161F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.125662.236522 (Exim 4.92) (envelope-from ) id 1lgOgh-0003mL-SS; Tue, 11 May 2021 09:28:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 125662.236522; Tue, 11 May 2021 09:28:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgh-0003mB-OE; Tue, 11 May 2021 09:28:23 +0000 Received: by outflank-mailman (input) for mailman id 125662; Tue, 11 May 2021 09:28:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgf-0003CS-Pm for xen-devel@lists.xenproject.org; Tue, 11 May 2021 09:28:21 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 85060c84-865a-4bc3-9c6f-515465efa1e0; Tue, 11 May 2021 09:28:16 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 85060c84-865a-4bc3-9c6f-515465efa1e0 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620725296; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jiAw2u4kXozSgOauXMnxK9qZm/ervdgw/ztBsqd2eLI=; b=OiVYsSK8TKUSFlP5C3uSqoIRcxek28mdL9b65ta7a8gp3UgoChkTmUIL hqsab+U4WXR0Vc3nUXIHjolsm895tl4e51Ugyy+UOJQjomwdc78ZSEfMg LISyDf48T9dDpNWsHViSyGntkp6OfrZSWNCWNyZZR+9ewggpDILDVD3ZJ Q=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: cbBs2QPmEOmmoXSsPEzkdgREFMXI17afDX3VWPunzRw5ia2Pv/t5ZZ+n53QuxVXafus7Yc2xsE elalCSepbXc9ocXLb9UUsJHPe/ZOhHJtYNGXJQHQtVuU+P4qy1I7ieXHdh4nWbBm3xETgQ7vxQ U1Hxlvh3Ge8Av5cBnmOWxQPFOVlyn4uFnu9M9SsPzCrLfpz8gkEoM3aBGazP1cAqVYjb6NeGcN 86E5+XQx5wrHVnfOjX7x706fqTzQWHJWOxtIityel7zpsSHkEkgXFHw0ZudskN77SpWvVHUjG4 rKk= X-SBRS: 5.1 X-MesageID: 45044864 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:3oOxZahw3hufCEIkGsqYbVu0PnBQX+x13DAbv31ZSRFFG/FwyP rBoB1L73DJYWgqNE3I+OrwdJVoLkmsk6KdjbNhXotKGTOWw1dAT7sSorcKoQeQYhEWn9Q1vc wLHskfNDSzNykDsS+T2nj+Lz9K+qjjzEncv5a4854bd3APV0gP1XYaNu+zKDwKeCB2Qb4CUL aM7MtOoDStPV4NaN6gO3UDV+/f4/XWiZPPe3c9dlAawTjLqQntxK/xEhCe0BtbeShI260e/W /MlBG8zrm/ssu81gTX2wbontVrcZrau5t+7f63+4oowwbX+0OVjbFaKv6/VGpcmpDS1L9lqq iJn/5qBbUI15qYRBDLnfKq4Xin7N9m0Q6d9bfM6UGT0fDRVXY0DdFMipledQac4008vMtk2K YOxG6BsYFLZCmw1hgVyuK4Hy2CrHDE6kbKUNRj+EC2eeMlGcxsRaV2xjIlLH7BJlOy1GkDKp giMCjx3ociTbqqVQGugoA0+q3fYp0aJGbzfnQ/ X-IronPort-AV: E=Sophos;i="5.82,290,1613451600"; d="scan'208";a="45044864" From: Anthony PERARD To: CC: Anthony PERARD , Jason Andryuk , Ian Jackson , Wei Liu Subject: [XEN PATCH v2 2/8] libxl: Replace QEMU's command line short-form boolean option Date: Tue, 11 May 2021 10:28:04 +0100 Message-ID: <20210511092810.13759-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511092810.13759-1-anthony.perard@citrix.com> References: <20210511092810.13759-1-anthony.perard@citrix.com> MIME-Version: 1.0 Short-form boolean options are deprecated in QEMU 6.0. Upstream commit that deprecate those: ccd3b3b8112b ("qemu-option: warn for short-form boolean options"). Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/libs/light/libxl_dm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c index 3599a82ef01b..0a0c1ef7c62e 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -977,14 +977,14 @@ static char *dm_spice_options(libxl__gc *gc, if (spice->host) opt = GCSPRINTF("%s,addr=%s", opt, spice->host); if (libxl_defbool_val(spice->disable_ticketing)) - opt = GCSPRINTF("%s,disable-ticketing", opt); + opt = GCSPRINTF("%s,disable-ticketing=on", opt); else opt = GCSPRINTF("%s,password=%s", opt, spice->passwd); opt = GCSPRINTF("%s,agent-mouse=%s", opt, libxl_defbool_val(spice->agent_mouse) ? "on" : "off"); if (!libxl_defbool_val(spice->clipboard_sharing)) - opt = GCSPRINTF("%s,disable-copy-paste", opt); + opt = GCSPRINTF("%s,disable-copy-paste=on", opt); if (spice->image_compression) opt = GCSPRINTF("%s,image-compression=%s", opt, @@ -1224,7 +1224,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, flexarray_append(dm_args, "-chardev"); if (state->dm_monitor_fd >= 0) { flexarray_append(dm_args, - GCSPRINTF("socket,id=libxl-cmd,fd=%d,server,nowait", + GCSPRINTF("socket,id=libxl-cmd,fd=%d,server=on,wait=off", state->dm_monitor_fd)); /* @@ -1237,7 +1237,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, } else { flexarray_append(dm_args, GCSPRINTF("socket,id=libxl-cmd," - "path=%s,server,nowait", + "path=%s,server=on,wait=off", libxl__qemu_qmp_path(gc, guest_domid))); } @@ -1247,7 +1247,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, flexarray_append(dm_args, "-chardev"); flexarray_append(dm_args, GCSPRINTF("socket,id=libxenstat-cmd," - "path=%s/qmp-libxenstat-%d,server,nowait", + "path=%s/qmp-libxenstat-%d,server=on,wait=off", libxl__run_dir_path(), guest_domid)); flexarray_append(dm_args, "-mon"); @@ -1264,7 +1264,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, case LIBXL_CHANNEL_CONNECTION_SOCKET: path = guest_config->channels[i].u.socket.path; chardev = GCSPRINTF("socket,id=libxl-channel%d,path=%s," - "server,nowait", devid, path); + "server=on,wait=off", devid, path); break; default: /* We've forgotten to add the clause */ @@ -1577,7 +1577,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, nics[i].colo_##sock_port) { \ flexarray_append(dm_args, "-chardev"); \ flexarray_append(dm_args, \ - GCSPRINTF("socket,id=%s,host=%s,port=%s,server,nowait", \ + GCSPRINTF("socket,id=%s,host=%s,port=%s,server=on,wait=off", \ nics[i].colo_##sock_id, \ nics[i].colo_##sock_ip, \ nics[i].colo_##sock_port)); \ From patchwork Tue May 11 09:28:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12250307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2CE1C433B4 for ; Tue, 11 May 2021 09:28:36 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 40F0B613C0 for ; Tue, 11 May 2021 09:28:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 40F0B613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.125664.236546 (Exim 4.92) (envelope-from ) id 1lgOgm-0004Sr-Nj; Tue, 11 May 2021 09:28:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 125664.236546; Tue, 11 May 2021 09:28:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgm-0004Sb-Ja; Tue, 11 May 2021 09:28:28 +0000 Received: by outflank-mailman (input) for mailman id 125664; Tue, 11 May 2021 09:28:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgk-0003CS-Px for xen-devel@lists.xenproject.org; Tue, 11 May 2021 09:28:26 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 82d3ce8f-aaa5-4fa3-9509-4f83f14f2936; Tue, 11 May 2021 09:28:18 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 82d3ce8f-aaa5-4fa3-9509-4f83f14f2936 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620725297; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K8gPTzU82ZOUTi54+69xvIkJJNm7Kwz13GZQD0G5vXM=; b=Uk/lZAlilwApqdLm6/Tk6abu6cQ1ESLp3dx82f4AnFizxUxeWtrUhH1p SH/LPWc2cg3NKigMeEltZLGcqFw4Qw+aWKMUUB0CxH8r2KMWYj7Nm0K6l 5OryhWGec5s5oMR70fzQjaGmfx//g69GjqH4Wb77+PBKBMGNJ8k95GqLp 8=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: Sp4KX4JisA/iWq0YvBzhRNcLG4kFU0wshITCFgIWluPdyDNEqYUIzIIlvjEatra8IOdhV+Kv6V N+u9jyfGD0QZ/mi+Ozd27aIWBs1jCRlzBA00Csj7zkqEx7zLhzfepNY0ECBFQmpGqgowjz20DO 4gVQcGZPfRd3BS200wToEw1ssZXqYGVgNzbQvdzhumGbhmPZ1Agwj4ZK9bAHqkvGJ3y2SE/+RU vIch9P+FaYg6m+o8m7LrwbssnMMBa+oZzudRvE03uzyIEwAX20vM4pRT9ETy1I2jzXfrqPlCL/ Pa4= X-SBRS: 5.1 X-MesageID: 43313589 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:DMcLoq1yECnHCjlGXA8tlwqjBIokLtp133Aq2lEZdPRUGvb3qy nIpoV86faUskdoZJhOo7C90cW7LU80sKQFhLX5Xo3SOzUO2lHYT72KhLGKq1aLdhEWtNQtsZ uIG5IOceEYZmIasS+V2maF+q4bsbu6zJw= X-IronPort-AV: E=Sophos;i="5.82,290,1613451600"; d="scan'208";a="43313589" From: Anthony PERARD To: CC: Anthony PERARD , Jason Andryuk , Ian Jackson , Wei Liu Subject: [XEN PATCH v2 3/8] libxl: Replace deprecated "cpu-add" QMP command by "device_add" Date: Tue, 11 May 2021 10:28:05 +0100 Message-ID: <20210511092810.13759-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511092810.13759-1-anthony.perard@citrix.com> References: <20210511092810.13759-1-anthony.perard@citrix.com> MIME-Version: 1.0 The command "cpu-add" for CPU hotplug is deprecated and has been removed from QEMU 6.0 (April 2021). We need to add cpus with the command "device_add" now. In order to find out which parameters to pass to "device_add" we first make a call to "query-hotpluggable-cpus" which list the cpus drivers and properties. The algorithm to figure out which CPU to add, and by extension if any CPU needs to be hotplugged, is in the function that adds the cpus. Because of that, the command "query-hotpluggable-cpus" is always called, even when not needed. In case we are using a version of QEMU older than 2.7 (Sept 2016) which don't have "query-hotpluggable-cpus", we fallback to using "cpu-add". Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- Notes: v2: - fix coding style tools/libs/light/libxl_domain.c | 89 ++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 2 deletions(-) diff --git a/tools/libs/light/libxl_domain.c b/tools/libs/light/libxl_domain.c index 8c003aa7cb04..c00c36c92879 100644 --- a/tools/libs/light/libxl_domain.c +++ b/tools/libs/light/libxl_domain.c @@ -1805,6 +1805,7 @@ typedef struct set_vcpuonline_state { libxl_dominfo info; libxl_bitmap final_map; int index; /* for loop on final_map */ + const char *cpu_driver; } set_vcpuonline_state; static void set_vcpuonline_qmp_cpus_fast_queried(libxl__egc *, @@ -1814,6 +1815,10 @@ static void set_vcpuonline_qmp_cpus_queried(libxl__egc *, static void set_vcpuonline_qmp_query_cpus_parse(libxl__egc *, libxl__ev_qmp *qmp, const libxl__json_object *, bool query_cpus_fast, int rc); +static void set_vcpuonline_qmp_query_hotpluggable_cpus(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc); +static void set_vcpuonline_qmp_device_add_cpu(libxl__egc *, + libxl__ev_qmp *, const libxl__json_object *response, int rc); static void set_vcpuonline_qmp_add_cpu(libxl__egc *, libxl__ev_qmp *, const libxl__json_object *response, int rc); static void set_vcpuonline_timeout(libxl__egc *egc, @@ -1951,13 +1956,54 @@ static void set_vcpuonline_qmp_query_cpus_parse(libxl__egc *egc, libxl_bitmap_reset(final_map, i); } + qmp->callback = set_vcpuonline_qmp_query_hotpluggable_cpus; + rc = libxl__ev_qmp_send(egc, qmp, "query-hotpluggable-cpus", NULL); + out: libxl_bitmap_dispose(¤t_map); + if (rc) + set_vcpuonline_done(egc, svos, rc); /* must be last */ +} + +static void set_vcpuonline_qmp_query_hotpluggable_cpus(libxl__egc *egc, + libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) +{ + set_vcpuonline_state *svos = CONTAINER_OF(qmp, *svos, qmp); + const libxl__json_object *cpu; + const libxl__json_object *cpu_driver; + + if (rc == ERROR_QMP_COMMAND_NOT_FOUND) { + /* We are probably connected to a version of QEMU older than 2.7, + * let's fallback to using "cpu-add" command. */ + svos->index = -1; + set_vcpuonline_qmp_add_cpu(egc, qmp, NULL, 0); /* must be last */ + return; + } + + if (rc) goto out; + + /* Parse response to QMP command "query-hotpluggable-cpus" + * [ { 'type': 'str', ... ] + * + * We are looking for the driver name for CPU to be hotplug. We'll + * assume that cpus property are core-id=0, thread-id=0 and + * socket-id=$cpu_index, as we start qemu with "-smp %d,maxcpus=%d", so + * we don't parse the properties listed for each hotpluggable cpus. + */ + + cpu = libxl__json_array_get(response, 0); + cpu_driver = libxl__json_map_get("type", cpu, JSON_STRING); + svos->cpu_driver = libxl__json_object_get_string(cpu_driver); + + if (!svos->cpu_driver) + rc = ERROR_QEMU_API; + +out: svos->index = -1; - set_vcpuonline_qmp_add_cpu(egc, qmp, NULL, rc); /* must be last */ + set_vcpuonline_qmp_device_add_cpu(egc, qmp, NULL, rc); /* must be last */ } -static void set_vcpuonline_qmp_add_cpu(libxl__egc *egc, +static void set_vcpuonline_qmp_device_add_cpu(libxl__egc *egc, libxl__ev_qmp *qmp, const libxl__json_object *response, int rc) { STATE_AO_GC(qmp->ao); @@ -1969,6 +2015,45 @@ static void set_vcpuonline_qmp_add_cpu(libxl__egc *egc, if (rc) goto out; + while (libxl_bitmap_cpu_valid(map, ++svos->index)) { + if (libxl_bitmap_test(map, svos->index)) { + qmp->callback = set_vcpuonline_qmp_device_add_cpu; + libxl__qmp_param_add_string(gc, &args, "id", GCSPRINTF("cpu-%d", svos->index)); + libxl__qmp_param_add_string(gc, &args, "driver", svos->cpu_driver); + /* We'll assume that we start QEMU with -smp %d,maxcpus=%d, so + * that "core-id" and "thread-id" are always 0 so that + * "socket-id" correspond the cpu index. + * Those properties are otherwise listed by + * "query-hotpluggable-cpus". */ + libxl__qmp_param_add_integer(gc, &args, "socket-id", svos->index); + libxl__qmp_param_add_integer(gc, &args, "core-id", 0); + libxl__qmp_param_add_integer(gc, &args, "thread-id", 0); + rc = libxl__ev_qmp_send(egc, qmp, "device_add", args); + if (rc) goto out; + return; + } + } + +out: + set_vcpuonline_done(egc, svos, rc); +} + +/* Fallback function for QEMU older than 2.7, when + * 'query-hotpluggable-cpus' wasn't available and vcpu object couldn't be + * added with 'device_add'. */ +static void set_vcpuonline_qmp_add_cpu(libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + STATE_AO_GC(qmp->ao); + set_vcpuonline_state *svos = CONTAINER_OF(qmp, *svos, qmp); + libxl__json_object *args = NULL; + + /* Convenience aliases */ + libxl_bitmap *map = &svos->final_map; + + if (rc) goto out; + while (libxl_bitmap_cpu_valid(map, ++svos->index)) { if (libxl_bitmap_test(map, svos->index)) { qmp->callback = set_vcpuonline_qmp_add_cpu; From patchwork Tue May 11 09:28:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12250303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3165EC43462 for ; Tue, 11 May 2021 09:28:32 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C36F3613C0 for ; Tue, 11 May 2021 09:28:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C36F3613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.125663.236526 (Exim 4.92) (envelope-from ) id 1lgOgi-0003pI-5f; Tue, 11 May 2021 09:28:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 125663.236526; Tue, 11 May 2021 09:28:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgi-0003op-0W; Tue, 11 May 2021 09:28:24 +0000 Received: by outflank-mailman (input) for mailman id 125663; Tue, 11 May 2021 09:28:22 +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.92) (envelope-from ) id 1lgOgg-0003ke-62 for xen-devel@lists.xenproject.org; Tue, 11 May 2021 09:28:22 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 22332a16-40d8-4b02-b66d-8147fb086ada; Tue, 11 May 2021 09:28:19 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 22332a16-40d8-4b02-b66d-8147fb086ada DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620725299; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/Z5o0fCLmaSsMSrYh8CFK3qvyQu5rxrgLPAepK/jeWc=; b=Hs29rFC6RGkzL/odGi12nQ7e0RyIoQY7lHk0icUpKrXEzuXA6Kf5MfwS ve8DWH1yHlS0INWYq7ETlue7d0gcP8Olp9qfL7XThoRFWwSX/3CxQk+rB xC5GpahehBnXojlt5H0uNOxGzskcDa7IDEgXN7Z6dMV9kzAEux+UR6Syc U=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: WpfxmiJT8DXx6D3rvG677HDsf5LlmX52Dzeyb5yWzo4I7DLG2p0QEyKmkLvnd4d+8AJlyGK2FU F+lkIQfHO5nyxotHw93JLYLl3qXuTENC8ItMhlRqQsqxq2zbugnLQYGNT4FjNpB5qlBuisIpTL MGSKtiXF2KEA4/Szk4RTeoJS1PVOUeQCBALWSgJOd9vNsklVVrUiczg6lxUFSTsLh57v3Eet7s tyVXzlvv9eH4IpXHYzSUzX/r6lssaD9mwuXQOT68vqNUB5FsHLDRYUKwNLlMdIQBHDM6EQXqsL zqg= X-SBRS: 5.1 X-MesageID: 43508703 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:8UtQFKkMC4Z+dnqtAc2Yumge+7jpDfLo3DAbv31ZSRFFG/Fw9/ rCoB17726QtN91YhsdcL+7V5VoLUmzyXcX2/hyAV7BZmnbUQKTRekP0WKL+Vbd8kbFh41gPM lbEpSXCLfLfCJHZcSR2njELz73quP3jJxBho3lvghQpRkBUdAF0+/gYDzranGfQmN9dP0EPa vZ3OVrjRy6d08aa8yqb0N1JNQq97Xw5fTbiQdtPW9f1DWz X-IronPort-AV: E=Sophos;i="5.82,290,1613451600"; d="scan'208";a="43508703" From: Anthony PERARD To: CC: Anthony PERARD , Jason Andryuk , Ian Jackson , Wei Liu Subject: [XEN PATCH v2 4/8] libxl: Use -device for cd-rom drives Date: Tue, 11 May 2021 10:28:06 +0100 Message-ID: <20210511092810.13759-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511092810.13759-1-anthony.perard@citrix.com> References: <20210511092810.13759-1-anthony.perard@citrix.com> MIME-Version: 1.0 This allows to set an `id` on the device instead of only the drive. We are going to need the `id` with the "eject" and "blockdev-change-media" QMP command as using `device` parameter on those is deprecated. (`device` is the `id` of the `-drive` on the command line). We set the same `id` on both -device and -drive as QEMU doesn't complain and we can then either do "eject id=$id" or "eject device=$id". Using "-drive + -device" instead of only "-drive" has been available since at least QEMU 0.15, and seems to be the preferred way as it separates the host part (-drive which describe the disk image location and format) from the guest part (-device which describe the emulated device). More information in qemu.git/docs/qdev-device-use.txt . Changing the command line during migration for the cdrom seems fine. Also the documentation about migration in QEMU explains that the device state ID is "been formed from a bus name and device address", so second IDE bus and first device address on bus is still thus and doesn't matter if written "-drive if=ide,index=2" or "-drive ide-cd,bus=ide.1,unit=0". See qemu.git/docs/devel/migration.rst . Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/libs/light/libxl_dm.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c index 0a0c1ef7c62e..5b01cf284163 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -1913,6 +1913,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, } if (disks[i].is_cdrom) { + const char *drive_id; if (disk > 4) { LOGD(WARN, guest_domid, "Emulated CDROM can be only one of the first 4 disks.\n" "Disk %s will be available via PV drivers but not as an " @@ -1920,13 +1921,22 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, disks[i].vdev); continue; } - drive = libxl__sprintf(gc, - "if=ide,index=%d,readonly=on,media=cdrom,id=ide-%i", - disk, dev_number); + + drive_id = GCSPRINTF("ide-%i", dev_number); + drive = GCSPRINTF("if=none,readonly=on,id=%s", drive_id); if (target_path) drive = libxl__sprintf(gc, "%s,file=%s,format=%s", drive, target_path, format); + + flexarray_vappend(dm_args, + "-drive", drive, + "-device", + GCSPRINTF("ide-cd,id=%s,drive=%s,bus=ide.%u,unit=%u", + drive_id, drive_id, + disk / 2, disk % 2), + NULL); + continue; } else { /* * Explicit sd disks are passed through as is. From patchwork Tue May 11 09:28:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12250309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5B17C433ED for ; Tue, 11 May 2021 09:28:41 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 411FC6161F for ; Tue, 11 May 2021 09:28:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 411FC6161F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.125665.236558 (Exim 4.92) (envelope-from ) id 1lgOgs-0004xt-3n; Tue, 11 May 2021 09:28:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 125665.236558; Tue, 11 May 2021 09:28:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgr-0004wM-Tf; Tue, 11 May 2021 09:28:33 +0000 Received: by outflank-mailman (input) for mailman id 125665; Tue, 11 May 2021 09:28:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgp-0003CS-QC for xen-devel@lists.xenproject.org; Tue, 11 May 2021 09:28:31 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 627edbc2-2b6a-4689-8328-0edac7c00d06; Tue, 11 May 2021 09:28:21 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 627edbc2-2b6a-4689-8328-0edac7c00d06 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620725300; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZLCUuRpfeTD/8ZQ8pXbTB6NvDUzollCddxfo249yUko=; b=er9QO5AdnoO5JqY3T+AUdZZmw1WQjaFle+Y10oMeVuS/8Sj8h0Hnc2zR HylGI8MDUhZZXJwgrsISEDqIVwjxjyG3YOz/vtovZ7hSw/QNF3SkR4e9U 0GjfU4yX4ZlzfV67Elu5tk//IZs2/qbhWeQ2HNH+ImKQuyMzzeTmPiged s=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: sUJkmyKG96ytKhXu42Cn4ZJVXWTJ2rqAnIg9NjRaqokqlG/UoqralpEXCl3kFSUi0tVPvdLmtI Ro1NeCtspzBCEj73eOzoJ+eWn3zknUDRIdYtt/+AiQCcKM+DMeSjz8eH6BhNezTEFo4IXEUZhX dCfJ5QILn8yq4BjfrQu5SkaAPtiVC5e9hpsMyT+JX+c6DAkuPj/GWk33SmrSvxrYUYOEe0GOOm FxK6mZSAHBtTBZmaxSi05zVqJL3fT/NEnOL9SR70yGoOKXblfvIA0sY+9m42SCArtEhB6cQXt1 Xo8= X-SBRS: 5.1 X-MesageID: 43624001 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:VToBzqzH7LkEfRr1sUt0KrPw6L1zdoMgy1knxilNoHxuH/Bw9v re+cjzsCWftN9/Yh4dcLy7VpVoIkmsl6Kdg7NwAV7KZmCP1FdARLsI0WKI+UyCJ8SRzI9gPa cLSdkFNDXzZ2IK8PoTNmODYqodKNrsytHWuQ/HpU0dKT2D88tbnn9E4gDwKDwQeCB2QaAXOb C7/cR9qz+paR0sH7+G7ilsZZmkmzXT/qiWGCI7Ow== X-IronPort-AV: E=Sophos;i="5.82,290,1613451600"; d="scan'208";a="43624001" From: Anthony PERARD To: CC: Anthony PERARD , Jason Andryuk , Ian Jackson , Wei Liu Subject: [XEN PATCH v2 5/8] libxl: Assert qmp_ev's state in qmp_ev_qemu_compare_version Date: Tue, 11 May 2021 10:28:07 +0100 Message-ID: <20210511092810.13759-6-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511092810.13759-1-anthony.perard@citrix.com> References: <20210511092810.13759-1-anthony.perard@citrix.com> MIME-Version: 1.0 We are supposed to read the version information only when qmp_ev is in state "Connected" (that correspond to state==qmp_state_connected), assert it so that the function isn't used too early. Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/libs/light/libxl_qmp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/libs/light/libxl_qmp.c b/tools/libs/light/libxl_qmp.c index 9b638e6f5442..d0967c9f029f 100644 --- a/tools/libs/light/libxl_qmp.c +++ b/tools/libs/light/libxl_qmp.c @@ -292,6 +292,8 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp, static int qmp_ev_qemu_compare_version(libxl__ev_qmp *ev, int major, int minor, int micro) { + assert(ev->state == qmp_state_connected); + #define CHECK_VERSION(level) do { \ if (ev->qemu_version.level > (level)) return +1; \ if (ev->qemu_version.level < (level)) return -1; \ From patchwork Tue May 11 09:28:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12250311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 547C1C433B4 for ; Tue, 11 May 2021 09:28:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 093DA613C0 for ; Tue, 11 May 2021 09:28:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 093DA613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.125666.236570 (Exim 4.92) (envelope-from ) id 1lgOgw-0005cZ-CW; Tue, 11 May 2021 09:28:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 125666.236570; Tue, 11 May 2021 09:28:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgw-0005cJ-8c; Tue, 11 May 2021 09:28:38 +0000 Received: by outflank-mailman (input) for mailman id 125666; Tue, 11 May 2021 09:28:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgu-0003CS-QI for xen-devel@lists.xenproject.org; Tue, 11 May 2021 09:28:36 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4fd96fab-119e-4fd6-83c6-13902c1a4a75; Tue, 11 May 2021 09:28:21 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4fd96fab-119e-4fd6-83c6-13902c1a4a75 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620725301; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5TXGPQaxHF3c+AxwdM2mzDWq6ZbvGPMF7pL7COPhMao=; b=F32S+JuxxduiyLWGxIjSgs3qZSInsnhqdubCEFjQMSLvzqzxQTtE/VsN +Qr7ZiK6h0g4PcPhudIBPtLBSm8WFiLo4RLn0pNp6LZ24e1EN5x0nvxlM yYhFFPqfcZLTCb42Vf4oiS+KGBgBFEfbTPnQzJiOhRbqnyRVfxxCFphnu g=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: HBhO1fWqAGziFPHWeyyUFF6jO7hf3HQe7A7T3q1IOe5SWxgUYYsyfYQx8zTSe7sywaO2gPQLDe YbU1yPtxsAaSA6T1D8AQKQE0jors2PYumZf4MrgWGppL+DKe6h1TdEquiqKuuKAwqwqMyHCjcn 8ng/0YIQsU7gXOkY6y+YmfTFKkj3TYbZmyPubVGEQUQxWKZPvyJLKp9WDIWAWri09uxlswYpIp UiNneZeJ/9tFCLeFiL0AKR6FGEaaNW137sR7GnnX3ZR+wNVnUAnhjTMBEv5kwL/u3wR41KuMf7 tfI= X-SBRS: 5.1 X-MesageID: 43313593 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:Jknn4q8tSUR0/Rfqx8duk+DgI+orL9Y04lQ7vn2YSXRuHPBw8P re+sjztCWE8Ar5N0tBpTntAsW9qDbnhPtICOoqTNCftWvdyQiVxehZhOOIqVDd8m/Fh4pgPM 9bAtFD4bbLbGSS4/yU3ODBKadD/OW6 X-IronPort-AV: E=Sophos;i="5.82,290,1613451600"; d="scan'208";a="43313593" From: Anthony PERARD To: CC: Anthony PERARD , Jason Andryuk , Ian Jackson , Wei Liu Subject: [XEN PATCH v2 6/8] libxl: Export libxl__qmp_ev_qemu_compare_version Date: Tue, 11 May 2021 10:28:08 +0100 Message-ID: <20210511092810.13759-7-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511092810.13759-1-anthony.perard@citrix.com> References: <20210511092810.13759-1-anthony.perard@citrix.com> MIME-Version: 1.0 We are going to want to check QEMU's version in other places where we can use libxl__ev_qmp_send. Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/libs/light/libxl_internal.h | 8 ++++++++ tools/libs/light/libxl_qmp.c | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_internal.h index 44a2f3c8fe3b..0b4671318c82 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -492,6 +492,14 @@ _hidden int libxl__ev_qmp_send(libxl__egc *egc, libxl__ev_qmp *ev, const char *cmd, libxl__json_object *args); _hidden void libxl__ev_qmp_dispose(libxl__gc *gc, libxl__ev_qmp *ev); +/* return values: + * < 0 if qemu's version < asked version + * = 0 if qemu's version == asked version + * > 0 if qemu's version > asked version + */ +_hidden int libxl__qmp_ev_qemu_compare_version(libxl__ev_qmp *ev, int major, + int minor, int micro); + typedef enum { /* initial state */ qmp_state_disconnected = 1, diff --git a/tools/libs/light/libxl_qmp.c b/tools/libs/light/libxl_qmp.c index d0967c9f029f..fb146a54cb9c 100644 --- a/tools/libs/light/libxl_qmp.c +++ b/tools/libs/light/libxl_qmp.c @@ -289,7 +289,7 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp, * = 0 if qemu's version == asked version * > 0 if qemu's version > asked version */ -static int qmp_ev_qemu_compare_version(libxl__ev_qmp *ev, int major, +int libxl__qmp_ev_qemu_compare_version(libxl__ev_qmp *ev, int major, int minor, int micro) { assert(ev->state == qmp_state_connected); @@ -1073,7 +1073,7 @@ static void dm_state_save_to_fdset(libxl__egc *egc, libxl__ev_qmp *ev, int fdset /* The `live` parameter was added to QEMU 2.11. It signals QEMU that * 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) + if (libxl__qmp_ev_qemu_compare_version(ev, 2, 11, 0) >= 0) libxl__qmp_param_add_bool(gc, &args, "live", dsps->live); QMP_PARAMETERS_SPRINTF(&args, "filename", "/dev/fdset/%d", fdset); rc = libxl__ev_qmp_send(egc, ev, "xen-save-devices-state", args); From patchwork Tue May 11 09:28:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12250315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4BC6C433B4 for ; Tue, 11 May 2021 09:29:03 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80B03613C0 for ; Tue, 11 May 2021 09:29:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80B03613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.125680.236594 (Exim 4.92) (envelope-from ) id 1lgOhE-0007RF-8x; Tue, 11 May 2021 09:28:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 125680.236594; Tue, 11 May 2021 09:28:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOhE-0007Qv-5C; Tue, 11 May 2021 09:28:56 +0000 Received: by outflank-mailman (input) for mailman id 125680; Tue, 11 May 2021 09:28:55 +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.92) (envelope-from ) id 1lgOhD-00064e-KL for xen-devel@lists.xenproject.org; Tue, 11 May 2021 09:28:55 +0000 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5f774ed2-8a08-4d8d-b5c1-4a94b2073dcf; Tue, 11 May 2021 09:28:45 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5f774ed2-8a08-4d8d-b5c1-4a94b2073dcf DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620725325; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K74/i7Z8FufP+fc6tmHyA0vTMqCvL54/sWOINqL7csI=; b=KIufayX2it1DXubWr4oODHqXSInoQiKk8toRbdum7g/waO8K8UhBCdF1 9n6pEdi1AXeFTaHb4Ir1gPXuJ422DS/Gvzazla2WWgR91/T0jqTvcHWj3 NsuJYXlRxKfnvCk2ZOYJCRVnHRh1ORmdTxCtkFWaMU72Xz34Emsm4A2IU w=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: C2udhTb7XNw4I3BAQVNa47ZlG+25lLUTOmOlJtmRb+k/aGKnfDYl1dsCxbPQ9fg2O20EWNSfcw CBJGYl8HjuUvglOzjMqPANovYMmgt4KgqMHyCJh3McnPZGOtDfDQCYDzrUYqiisQL88FDELnYS l5yrQ9gXDJ0ED4VcGYwmtx9hmNGBJQgln0yL/reo/8fbEYn9xbnuzL0+284S5AABTv8K9qJ6Mc 3w1c64oe2EaRW7mA8SwZVkqQnAYRYcpbx5dbtjJ3FlrA6PIRXH1mNVOoMLGhtBG+7rDGdoK4ht ex0= X-SBRS: 5.1 X-MesageID: 43528826 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:XbYuM6+tY2xxHSW8z+tuk+DeI+orL9Y04lQ7vn2YSXRuHfBw8P re+8jztCWE8Qr5N0tApTntAsS9qDbnhPxICOoqTNOftWvd2FdARbsKheCJ/9SjIVyaygc079 YHT0EUMrPN5DZB4foSmDPIcOod/A== X-IronPort-AV: E=Sophos;i="5.82,290,1613451600"; d="scan'208";a="43528826" From: Anthony PERARD To: CC: Anthony PERARD , Jason Andryuk , Ian Jackson , Wei Liu Subject: [XEN PATCH v2 7/8] libxl: Use `id` with the "eject" QMP command Date: Tue, 11 May 2021 10:28:09 +0100 Message-ID: <20210511092810.13759-8-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511092810.13759-1-anthony.perard@citrix.com> References: <20210511092810.13759-1-anthony.perard@citrix.com> MIME-Version: 1.0 `device` parameter is deprecated since QEMU 2.8. This requires changes to the command line introduced by: "libxl: Use -device for cd-rom drives" Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/libs/light/libxl_disk.c | 43 +++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c index 411ffeaca6ce..faabdea7a4c3 100644 --- a/tools/libs/light/libxl_disk.c +++ b/tools/libs/light/libxl_disk.c @@ -656,6 +656,8 @@ typedef struct { static void cdrom_insert_lock_acquired(libxl__egc *, libxl__ev_slowlock *, int rc); +static void cdrom_insert_qmp_connected(libxl__egc *, libxl__ev_qmp *, + const libxl__json_object *, int rc); static void cdrom_insert_ejected(libxl__egc *egc, libxl__ev_qmp *, const libxl__json_object *, int rc); static void cdrom_insert_addfd_cb(libxl__egc *egc, libxl__ev_qmp *, @@ -770,13 +772,12 @@ static void cdrom_insert_lock_acquired(libxl__egc *egc, */ if (cis->dm_ver == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { - libxl__json_object *args = NULL; - int devid = libxl__device_disk_dev_number(cis->disk->vdev, - NULL, NULL); - - QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", devid); - cis->qmp.callback = cdrom_insert_ejected; - rc = libxl__ev_qmp_send(egc, &cis->qmp, "eject", args); + /* Before running the "eject" command, we need to know QEMU's + * version to find out which command to issue. + * cis->qmp isn't in Connected state yet, so run a dummy command + * to have QEMU's version available. */ + cis->qmp.callback = cdrom_insert_qmp_connected; + rc = libxl__ev_qmp_send(egc, &cis->qmp, "query-version", NULL); if (rc) goto out; } else { cdrom_insert_ejected(egc, &cis->qmp, NULL, 0); /* must be last */ @@ -787,6 +788,34 @@ static void cdrom_insert_lock_acquired(libxl__egc *egc, cdrom_insert_done(egc, cis, rc); /* must be last */ } +static void cdrom_insert_qmp_connected(libxl__egc *egc, libxl__ev_qmp *qmp, + const libxl__json_object *response, + int rc) +{ + libxl__cdrom_insert_state *cis = CONTAINER_OF(qmp, *cis, qmp); + STATE_AO_GC(cis->ao); + libxl__json_object *args = NULL; + int devid = libxl__device_disk_dev_number(cis->disk->vdev, + NULL, NULL); + + if (rc) goto out; + + /* Using `device` parameter is deprecated since QEMU 2.8, we should + * use `id` now. They both have different meaning but we set the + * same `id` on -drive and -device on the command line. + */ + if (libxl__qmp_ev_qemu_compare_version(qmp, 2, 8, 0) >= 0) + QMP_PARAMETERS_SPRINTF(&args, "id", "ide-%i", devid); + else + QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", devid); + qmp->callback = cdrom_insert_ejected; + rc = libxl__ev_qmp_send(egc, qmp, "eject", args); + if (rc) goto out; + return; +out: + cdrom_insert_done(egc, cis, rc); /* must be last */ +} + static void cdrom_insert_ejected(libxl__egc *egc, libxl__ev_qmp *qmp, const libxl__json_object *response, From patchwork Tue May 11 09:28:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12250313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E8D4C433B4 for ; Tue, 11 May 2021 09:28:51 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E168C613C0 for ; Tue, 11 May 2021 09:28:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E168C613C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.125669.236582 (Exim 4.92) (envelope-from ) id 1lgOh1-0006MO-RO; Tue, 11 May 2021 09:28:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 125669.236582; Tue, 11 May 2021 09:28:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOh1-0006Kn-L9; Tue, 11 May 2021 09:28:43 +0000 Received: by outflank-mailman (input) for mailman id 125669; Tue, 11 May 2021 09:28:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lgOgz-0003CS-QV for xen-devel@lists.xenproject.org; Tue, 11 May 2021 09:28:41 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 46a06a73-9bbc-4a92-90a9-b86aac1d7837; Tue, 11 May 2021 09:28:24 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 46a06a73-9bbc-4a92-90a9-b86aac1d7837 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620725303; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oQ0ssEsENtdgMjUiXBgiKma4Z4zbQ49R9PO2WXFh8mc=; b=KvTd8sjoVescoSgfhEW4g93S/Y+zTUMyIS2LHb5dbElW8lCADJVwKlg2 r8Ors8JO8CoMMjKp8kIcVrZzfcVVx7Ubokmrw9mpEZ86tO7i79wegJjXa IlDqWyLge5kzesOfRVARzRG1Yh05tHaFXApkdYMLjk/775E9DJJqq3BCF A=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: s1FEg6hnKqsfVKtX/Nvna1UfJOpMpc3lWMl3vRtD4XDJlvvBV9glarTxH3Om61vRuEmMTjoiZf ilAawEAZOEwQWVgF0cABftxT1/8Z2ws7WylXVLiGV+gQMYoeBhdzOGSOAPN1FUPJ6vxUPmHfNY f4jsbjqG7O72uNdlxmjCJFkXT81CMuN0PzXFMDHfO3rwGKsVrctcnECu/Fby0r3SOV59zvpOAk +xJAX8VK1Go1YGHwKHYE2frTNnDi/8rVf1irNM2JahytSpmWEaZFl14IvBwgUNrmLgtYK9Jq+y rDk= X-SBRS: 5.1 X-MesageID: 43624005 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:FNSAY64UP9lUT8BKLQPXwAzXdLJyesId70hD6qkQc3Fom62j5q WTdZEgvyMc5wx/ZJhNo7690cq7MBHhHPxOgbX5VI3KNGXbUQOTR72KhrGSoAEIdReeygZcv5 0QCZSXCrfLfCVHZRCR2njFLz4iquP3j5xBnY3lvhNQpZkBUdAZ0+9+YDzrdXFedU19KrcSMo GT3cZDryrIQwVtUizqbkN1OdQqvrfw5evbXSI= X-IronPort-AV: E=Sophos;i="5.82,290,1613451600"; d="scan'208";a="43624005" From: Anthony PERARD To: CC: Anthony PERARD , Jason Andryuk , Ian Jackson , Wei Liu Subject: [XEN PATCH v2 8/8] libxl: Replace QMP command "change" by "blockdev-change-media" Date: Tue, 11 May 2021 10:28:10 +0100 Message-ID: <20210511092810.13759-9-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511092810.13759-1-anthony.perard@citrix.com> References: <20210511092810.13759-1-anthony.perard@citrix.com> MIME-Version: 1.0 "change" command as been removed in QEMU 6.0. We can use "blockdev-change-medium" instead. Using `id` with "blockdev-change-medium" requires a change to the QEMU command line, introduced by: "libxl: Use -device for cd-rom drives" Signed-off-by: Anthony PERARD Reviewed-by: Jason Andryuk --- tools/libs/light/libxl_disk.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c index faabdea7a4c3..93936d0dd0f8 100644 --- a/tools/libs/light/libxl_disk.c +++ b/tools/libs/light/libxl_disk.c @@ -962,12 +962,26 @@ static void cdrom_insert_addfd_cb(libxl__egc *egc, fdset = libxl__json_object_get_integer(o); devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL); - QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", devid); - QMP_PARAMETERS_SPRINTF(&args, "target", "/dev/fdset/%d", fdset); - libxl__qmp_param_add_string(gc, &args, "arg", - libxl__qemu_disk_format_string(disk->format)); qmp->callback = cdrom_insert_inserted; - rc = libxl__ev_qmp_send(egc, qmp, "change", args); + + /* "change" is deprecated since QEMU 2.5 and the `device` parameter for + * for "blockdev-change-medium" is deprecated in QEMU 2.8. + * But `id` is only available in 2.8 we'll start using the new command + * with `id` with QEMU 2.8. + */ + if (libxl__qmp_ev_qemu_compare_version(qmp, 2, 8, 0) >= 0) { + QMP_PARAMETERS_SPRINTF(&args, "id", "ide-%i", devid); + QMP_PARAMETERS_SPRINTF(&args, "filename", "/dev/fdset/%d", fdset); + libxl__qmp_param_add_string(gc, &args, "format", + libxl__qemu_disk_format_string(disk->format)); + rc = libxl__ev_qmp_send(egc, qmp, "blockdev-change-medium", args); + } else { + QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", devid); + QMP_PARAMETERS_SPRINTF(&args, "target", "/dev/fdset/%d", fdset); + libxl__qmp_param_add_string(gc, &args, "arg", + libxl__qemu_disk_format_string(disk->format)); + rc = libxl__ev_qmp_send(egc, qmp, "change", args); + } out: if (rc) cdrom_insert_done(egc, cis, rc); /* must be last */