From nobody Sun May 19 03:02:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620725317; cv=none; d=zohomail.com; s=zohoarc; b=fAaXWMh8NbcbLFKtpcB6rLf7+oxa0AdbzJRTaPfzpH19WkhcLS/M9er8idTEyJ3EGY3vJeEYGwfGm8UmrxedVspae5ZMALM0y3s+nDh7TDMTPNhcZyLL4fDAYMo/CSoNITNDm57QP8C02UVCNFAEz5ox21zs1hdSL8aIYiKKn0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620725317; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vaG4kkJM/dRr/eArkqasYWVCzUbsF9/gLEQQ+oOFOdE=; b=OMBnjmwlBFziRYuWh6ySqVE38Bbii6Yw55xRZK5rx0vVrs67czmELvGdc7x+p5Bd521UwuR87981f+vgmsOq+60laUrP9iU7bSMNPVLLDeivi8sc3OhJXfB17xiPgfDkUqPrVHb53y/MIQUrEEplWpFBUGuNPheAjnjEhAiRz2I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620725317561484.6442471786919; Tue, 11 May 2021 02:28:37 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" 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. =20 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_domai= n.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; } =20 +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 =3D 0; (cpu =3D libxl__json_array_get(response, i)); i++) { + unsigned int cpu_index; + const libxl__json_object *o; + + o =3D 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 =3D 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; =20 +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 dom= id, set_vcpuonline_timeout, LIBXL_QMP_CMD_TIMEOUT * 1000); if (rc) goto out; - qmp->callback =3D set_vcpuonline_qmp_cpus_queried; - rc =3D libxl__ev_qmp_send(egc, qmp, "query-cpus", NULL); + qmp->callback =3D set_vcpuonline_qmp_cpus_fast_queried; + rc =3D 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 d= omid, return AO_INPROGRESS; } =20 +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 =3D CONTAINER_OF(qmp, *svos, qmp); + + if (rc =3D=3D ERROR_QMP_COMMAND_NOT_FOUND) { + /* Try again, we probably talking to a QEMU older than 2.12 */ + qmp->callback =3D set_vcpuonline_qmp_cpus_queried; + rc =3D 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 =3D 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 =3D CONTAINER_OF(qmp, *svos, qmp); int i; libxl_bitmap current_map; =20 @@ -1876,7 +1938,11 @@ static void set_vcpuonline_qmp_cpus_queried(libxl__e= gc *egc, if (rc) goto out; =20 libxl_bitmap_alloc(CTX, ¤t_map, svos->info.vcpu_max_id + 1); - rc =3D qmp_parse_query_cpus(gc, qmp->domid, response, ¤t_map); + if (query_cpus_fast) { + rc =3D qmp_parse_query_cpus_fast(gc, qmp->domid, response, ¤= t_map); + } else { + rc =3D qmp_parse_query_cpus(gc, qmp->domid, response, ¤t_map= ); + } if (rc) goto out; =20 libxl_bitmap_copy_alloc(CTX, final_map, svos->cpumap); @@ -2121,6 +2187,9 @@ typedef struct { =20 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_acquir= ed( if (rc) goto out; libxl_bitmap_alloc(CTX, &rdcs->qemuu_cpus, d_config->b_info.max_vcpus); - rdcs->qmp.callback =3D retrieve_domain_configuration_cpu_queried; - rc =3D libxl__ev_qmp_send(egc, &rdcs->qmp, "query-cpus", NULL); + rdcs->qmp.callback =3D retrieve_domain_configuration_cpu_fast_quer= ied; + rc =3D libxl__ev_qmp_send(egc, &rdcs->qmp, "query-cpus-fast", NULL= ); if (rc) goto out; has_callback =3D true; } @@ -2210,6 +2279,30 @@ static void retrieve_domain_configuration_lock_acqui= red( retrieve_domain_configuration_end(egc, rdcs, rc); } =20 +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 =3D + CONTAINER_OF(qmp, *rdcs, qmp); + + if (rc =3D=3D ERROR_QMP_COMMAND_NOT_FOUND) { + /* Try again, we probably talking to a QEMU older than 2.12 */ + rdcs->qmp.callback =3D retrieve_domain_configuration_cpu_queried; + rc =3D libxl__ev_qmp_send(egc, &rdcs->qmp, "query-cpus", NULL); + if (rc) goto out; + return; + } + + if (rc) goto out; + + rc =3D qmp_parse_query_cpus_fast(gc, qmp->domid, response, &rdcs->qemu= u_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) --=20 Anthony PERARD From nobody Sun May 19 03:02:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620725317; cv=none; d=zohomail.com; s=zohoarc; b=CHmBIk4TFVbXEnyV08s+AKgXhEbhPQNsioaO5PgNZ6s8Pb+wDTa8hlvkdPXqEWf6QeHmNBEMOP/AIN3eOQmaPOKvBHeuynUgOU900yu2K1LtQL9E+B4aJ0Udek6lLgwhXHI+HlvyceLoXKeEasesQAQHFavg4GDwn8j1OAnVLB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620725317; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4gHehOHDwnexFmbbRZb1l1JPk0vqQHOQ/pgPiAIH5R4=; b=bKoDrUgN/Cq8WdjP25UJMSHZ9mnnPmMUJMqVC8g0yCZDP/DVq79nUzdzgov6l04ZOdhP5SMQCNj4IO6LzPhtq6Rir4LMtUbX4OiHZFiVQ6RMcCZ9F0RCwulHDxzR+KeOMc1vqYrKY9d6Sk9uebQOPH7hbdFISziMupNFw4JjXKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620725316915740.3821117698003; Tue, 11 May 2021 02:28:36 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" 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 =3D GCSPRINTF("%s,addr=3D%s", opt, spice->host); if (libxl_defbool_val(spice->disable_ticketing)) - opt =3D GCSPRINTF("%s,disable-ticketing", opt); + opt =3D GCSPRINTF("%s,disable-ticketing=3Don", opt); else opt =3D GCSPRINTF("%s,password=3D%s", opt, spice->passwd); opt =3D GCSPRINTF("%s,agent-mouse=3D%s", opt, libxl_defbool_val(spice->agent_mouse) ? "on" : "off"); =20 if (!libxl_defbool_val(spice->clipboard_sharing)) - opt =3D GCSPRINTF("%s,disable-copy-paste", opt); + opt =3D GCSPRINTF("%s,disable-copy-paste=3Don", opt); =20 if (spice->image_compression) opt =3D GCSPRINTF("%s,image-compression=3D%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 >=3D 0) { flexarray_append(dm_args, - GCSPRINTF("socket,id=3Dlibxl-cmd,fd=3D%d,server,nowait", + GCSPRINTF("socket,id=3Dlibxl-cmd,fd=3D%d,server=3Don,wait= =3Doff", state->dm_monitor_fd)); =20 /* @@ -1237,7 +1237,7 @@ static int libxl__build_device_model_args_new(libxl__= gc *gc, } else { flexarray_append(dm_args, GCSPRINTF("socket,id=3Dlibxl-cmd," - "path=3D%s,server,nowait", + "path=3D%s,server=3Don,wait=3Doff", libxl__qemu_qmp_path(gc, guest_domi= d))); } =20 @@ -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=3Dlibxenstat-cmd," - "path=3D%s/qmp-libxenstat-%d,serve= r,nowait", + "path=3D%s/qmp-libxenstat-%d,serve= r=3Don,wait=3Doff", libxl__run_dir_path(), guest_domid= )); =20 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 =3D guest_config->channels[i].u.socket.path; chardev =3D GCSPRINTF("socket,id=3Dlibxl-channel%d,path=3D= %s," - "server,nowait", devid, path); + "server=3Don,wait=3Doff", 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=3D%s,host=3D%s,port=3D%s,server,nowait", = \ + GCSPRINTF("socket,id=3D%s,host=3D%s,port=3D%s,server=3Don,wait= =3Doff", \ nics[i].colo_##sock_id, = \ nics[i].colo_##sock_ip, = \ nics[i].colo_##sock_port)); = \ --=20 Anthony PERARD From nobody Sun May 19 03:02:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620725321; cv=none; d=zohomail.com; s=zohoarc; b=XN/y0O6Ncx3vO9IGSyv6xf+7pyVYymGe6dXIhMTCt+r3jDsMRsZxo2rUKCAzLwg6+0a+pBX6epBQvWjI8TzHT1bLvavk0zBgcarg1EogKEd6zdVunzVblWjhBU8Eotejaf9Jzx9QF6HvkJRzz8JYL7jb0EoGolNKIebKQQ9BSjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620725321; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=40T6fNa8Dy4ZpCvoxgtgpxCg3MbMJ+YGnS2D3iz5WJg=; b=maohMGMdTu4hLzksp1dvALRklW9Ab3ed5ykf/fy67r86Q2AqF6oh3dgyKgRvT9MCUpoBZS9EKOmCb4UA4fMZh2646CH3dajoeJhw4lQ+iTBIY/mRIfpV7uvrmq5XbaG/JrH1gkOYd6YBb/ybmnWlRUuGnhixLpm6vHy8bKl4yt4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 162072532180919.365478897063326; Tue, 11 May 2021 02:28:41 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" 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_domai= n.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; =20 static void set_vcpuonline_qmp_cpus_fast_queried(libxl__egc *, @@ -1814,6 +1815,10 @@ static void set_vcpuonline_qmp_cpus_queried(libxl__e= gc *, 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(lib= xl__egc *egc, libxl_bitmap_reset(final_map, i); } =20 + qmp->callback =3D set_vcpuonline_qmp_query_hotpluggable_cpus; + rc =3D 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 =3D CONTAINER_OF(qmp, *svos, qmp); + const libxl__json_object *cpu; + const libxl__json_object *cpu_driver; + + if (rc =3D=3D 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 =3D -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=3D0, thread-id=3D0 and + * socket-id=3D$cpu_index, as we start qemu with "-smp %d,maxcpus=3D%d= ", so + * we don't parse the properties listed for each hotpluggable cpus. + */ + + cpu =3D libxl__json_array_get(response, 0); + cpu_driver =3D libxl__json_map_get("type", cpu, JSON_STRING); + svos->cpu_driver =3D libxl__json_object_get_string(cpu_driver); + + if (!svos->cpu_driver) + rc =3D ERROR_QEMU_API; + +out: svos->index =3D -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= */ } =20 -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 *e= gc, =20 if (rc) goto out; =20 + while (libxl_bitmap_cpu_valid(map, ++svos->index)) { + if (libxl_bitmap_test(map, svos->index)) { + qmp->callback =3D 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_dri= ver); + /* We'll assume that we start QEMU with -smp %d,maxcpus=3D%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->ind= ex); + libxl__qmp_param_add_integer(gc, &args, "core-id", 0); + libxl__qmp_param_add_integer(gc, &args, "thread-id", 0); + rc =3D 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 =3D CONTAINER_OF(qmp, *svos, qmp); + libxl__json_object *args =3D NULL; + + /* Convenience aliases */ + libxl_bitmap *map =3D &svos->final_map; + + if (rc) goto out; + while (libxl_bitmap_cpu_valid(map, ++svos->index)) { if (libxl_bitmap_test(map, svos->index)) { qmp->callback =3D set_vcpuonline_qmp_add_cpu; --=20 Anthony PERARD From nobody Sun May 19 03:02:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620725317; cv=none; d=zohomail.com; s=zohoarc; b=iqF0FKAxtXFd5Ny9OvZ0n6TusvVSx76JRzUif2oAq3FdiqnseuL+LVeW2/YXbIaiU+cOBmpgUbm5g7Wl3xbZM+PGHIoaRXt9CWfo/tk2VnTZJ1QKThO03YNSLHxi6++C7HfD+2R7d/Nt1Q5dskUD9j0jupDyCPK5YoxWd+OGo1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620725317; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FkJgPFfkBVdNfLc9y8OT+yI24HgeyuyGxuFuhVfMSYo=; b=YY4RveRhUY+pcuKZ7EaMZvgosjwaoeZBb39seaKSZak6ptRbszp/76TO772voeuGFbG1wlenb5BHEK7iy9/suedxcDayfuABk7ahrGAR2xbXB8hRbgAPX1NWtEuqiKV0AG2oHYWROHleAopbMauGJYnGYZLuEDODhI76nwSGLsw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620725317871382.60751639778664; Tue, 11 May 2021 02:28:37 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" 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=3D$id" or "eject device=3D$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=3Dide,index=3D2" or "-drive ide-cd,bus=3Dide.1,unit=3D0". 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, } =20 if (disks[i].is_cdrom) { + const char *drive_id; if (disk > 4) { LOGD(WARN, guest_domid, "Emulated CDROM can be only on= e 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 =3D libxl__sprintf(gc, - "if=3Dide,index=3D%d,readonly=3Don,media=3Dcdrom,= id=3Dide-%i", - disk, dev_number); + + drive_id =3D GCSPRINTF("ide-%i", dev_number); + drive =3D GCSPRINTF("if=3Dnone,readonly=3Don,id=3D%s", dri= ve_id); =20 if (target_path) drive =3D libxl__sprintf(gc, "%s,file=3D%s,format=3D%s= ", drive, target_path, format); + + flexarray_vappend(dm_args, + "-drive", drive, + "-device", + GCSPRINTF("ide-cd,id=3D%s,drive=3D%s,bus=3Dide.%u,unit= =3D%u", + drive_id, drive_id, + disk / 2, disk % 2), + NULL); + continue; } else { /* * Explicit sd disks are passed through as is. --=20 Anthony PERARD From nobody Sun May 19 03:02:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620725326; cv=none; d=zohomail.com; s=zohoarc; b=iLi5+zxYLiHNR5E6IwbdjDcWezoKGSK39e/tPW6+EjC9g67hMbhs4jPlxdnFXg4Y7q0k0wjJp6BR12IDqTOyzfmR8YCmdHE2U2+yqFzFW7rapsqhWSPxwH1vMGXf7vsvedsnAHcqdAUAc6sDFugQbtACjrovQyYHp6BbqYOxoiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620725326; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l+Jst61zw/MsXhwA3o+OpAKeWUxgI7GBsFXZt0ll5fM=; b=AbtpYnBpocSXzXwNQZEkLm938Nh9U27xEHJkdxBdI8R9YHmWTb8nWjS8ScvgbkXfumEOVgTrobNA9bIhq8oBDPr96TPNEJdaL37MYlwIO5GiThXQNoEnHTbrv2bPXmlTNiV6bowVrYfJk0+xzElCGV0EbkWfJo+GzWkFI5gzOlM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 162072532680334.87903418119072; Tue, 11 May 2021 02:28:46 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" We are supposed to read the version information only when qmp_ev is in state "Connected" (that correspond to state=3D=3Dqmp_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__qm= p_handler *qmp, static int qmp_ev_qemu_compare_version(libxl__ev_qmp *ev, int major, int minor, int micro) { + assert(ev->state =3D=3D qmp_state_connected); + #define CHECK_VERSION(level) do { \ if (ev->qemu_version.level > (level)) return +1; \ if (ev->qemu_version.level < (level)) return -1; \ --=20 Anthony PERARD From nobody Sun May 19 03:02:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620725330; cv=none; d=zohomail.com; s=zohoarc; b=G64FawGenBkwQecwACxGFyIETHAr5p/AK5oMC2UwC8ry7jm5zAq4Wc/M2M2V9E2EaB62Dc50155HH8dzD4wphJQEVlXCo0fDuiy7AWN9v710CiFauAJIGNgW0X+FM7wr4IyLWzek9deww+fTdjT/L53TmN+84d0c9DO3LtwGySI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620725330; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eMaU6kzgadQT4s7AdfUk2KJ1zJoydFN+PWx1oMW1Jkc=; b=dm88cUEUNEXoq/MFUnnRQVNSkM+cWn4WLw46rCFRoSv9ea0sSG+5JY7Lx5ZEvdC1B6h/Jucq79xscyX7aWEH2aHOnKkQ5N9shTqntQm4m76RmL+6AIYjROnm+m3W/+12Tj79sG63rDZ5119QEA9UsDIkQTH6F6foExjx54CWNOQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 162072533086220.911905726417558; Tue, 11 May 2021 02:28:50 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" 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_int= ernal.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); =20 +/* return values: + * < 0 if qemu's version < asked version + * =3D 0 if qemu's version =3D=3D asked version + * > 0 if qemu's version > asked version + */ +_hidden int libxl__qmp_ev_qemu_compare_version(libxl__ev_qmp *ev, int majo= r, + int minor, int micro); + typedef enum { /* initial state */ qmp_state_disconnected =3D 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__qm= p_handler *qmp, * =3D 0 if qemu's version =3D=3D 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 =3D=3D qmp_state_connected); @@ -1073,7 +1073,7 @@ static void dm_state_save_to_fdset(libxl__egc *egc, l= ibxl__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) >=3D 0) + if (libxl__qmp_ev_qemu_compare_version(ev, 2, 11, 0) >=3D 0) libxl__qmp_param_add_bool(gc, &args, "live", dsps->live); QMP_PARAMETERS_SPRINTF(&args, "filename", "/dev/fdset/%d", fdset); rc =3D libxl__ev_qmp_send(egc, ev, "xen-save-devices-state", args); --=20 Anthony PERARD From nobody Sun May 19 03:02:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620725350; cv=none; d=zohomail.com; s=zohoarc; b=LUWVBR6x1G+n4K9TJmDYsthQ+xwNarMlVRE3SBSRR8F5kuxgEeOVGdsSb48a+flQBfnuSpDkTllfh/XGFtgmVsl2l5vBKoEYjeXMybJAuzMYL+4jIu5//HRkWF+9y7ZJC1mOSRHaUg7vTzYTdZKpeQOeqZpLeIAoRXVVlU14FKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620725350; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C8uYwNIQRnURRW13o40sNdqWEzlPRAFUeFL1rH44Gdc=; b=TYeLRAxtbUl5o+3U+z01+/op8NAoYhx5Z1rxnZ3U8c9aOZeCGFjqbTgRm8zaR4F3WKPVlZ5di6CHlD6PBt4879OT5/ZrPGBrpIYx8jFeZaP5qNBDthO7Aq36I49vr4PZeR49SQ5/bRBg7UzPccG2dJDQVg3EG7NgVZccwp4V8Bw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620725350368856.5462624948625; Tue, 11 May 2021 02:29:10 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" `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 { =20 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 *eg= c, */ =20 if (cis->dm_ver =3D=3D LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) { - libxl__json_object *args =3D NULL; - int devid =3D libxl__device_disk_dev_number(cis->disk->vdev, - NULL, NULL); - - QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", devid); - cis->qmp.callback =3D cdrom_insert_ejected; - rc =3D 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 =3D cdrom_insert_qmp_connected; + rc =3D 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 */ } =20 +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 =3D CONTAINER_OF(qmp, *cis, qmp); + STATE_AO_GC(cis->ao); + libxl__json_object *args =3D NULL; + int devid =3D 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) >=3D 0) + QMP_PARAMETERS_SPRINTF(&args, "id", "ide-%i", devid); + else + QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", devid); + qmp->callback =3D cdrom_insert_ejected; + rc =3D 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, --=20 Anthony PERARD From nobody Sun May 19 03:02:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1620725336; cv=none; d=zohomail.com; s=zohoarc; b=HYRR8EMTEHST1AL4eLuvwLziG1dn2ugNuxs9c9Q0MTpPKcdyIw4Gd4TQcPrugM/5mzHsgj0+gnkrSvHb1/jAwr2HOVnEzHVYXrO4MMSHQ4MzdnFiFVotNULcLWfO4MiCM2iFe7Sv6YG5/i4Bvu7lwXgdexdpiwzID0Fg95axM00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620725336; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8XIvJRzw4t/RzytM035tlpZXibxjRuuOI31iZVVch8Q=; b=KaT3r0xwPDVl+RUOaQqJ5vHgl9f9nccuVwjHDWEwXKhdQPL3Kgm5+3yDErxgxZLz7KaoERx7p2JlNYJZLTbno+OxBjERQXQf7NC4lQDfXjxvbMy2mWrWN7OZyt+tP0D9fLEY0ULeMOkPGsEVU89UTe+FWxKt4sVEAOj0MUUR+s4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620725336944760.3217370719179; Tue, 11 May 2021 02:28:56 -0700 (PDT) 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 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-Outflank-Mailman: Message body and most headers restored to incoming version 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 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) Content-Type: text/plain; charset="utf-8" "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 =3D libxl__json_object_get_integer(o); =20 devid =3D 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 =3D cdrom_insert_inserted; - rc =3D 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) >=3D 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 =3D 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 =3D libxl__ev_qmp_send(egc, qmp, "change", args); + } out: if (rc) cdrom_insert_done(egc, cis, rc); /* must be last */ --=20 Anthony PERARD