xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Jason Andryuk <jandryuk@gmail.com>,
	Ian Jackson <iwj@xenproject.org>, Wei Liu <wl@xen.org>
Subject: [XEN PATCH v2 8/8] libxl: Replace QMP command "change" by "blockdev-change-media"
Date: Tue, 11 May 2021 10:28:10 +0100	[thread overview]
Message-ID: <20210511092810.13759-9-anthony.perard@citrix.com> (raw)
In-Reply-To: <20210511092810.13759-1-anthony.perard@citrix.com>

"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 <anthony.perard@citrix.com>
Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 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 */
-- 
Anthony PERARD



  parent reply	other threads:[~2021-05-11  9:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11  9:28 [XEN PATCH v2 0/8] Fix libxl with QEMU 6.0 + remove some more deprecated usages Anthony PERARD
2021-05-11  9:28 ` [XEN PATCH v2 1/8] libxl: Replace deprecated QMP command by "query-cpus-fast" Anthony PERARD
2021-05-11  9:28 ` [XEN PATCH v2 2/8] libxl: Replace QEMU's command line short-form boolean option Anthony PERARD
2021-05-11  9:28 ` [XEN PATCH v2 3/8] libxl: Replace deprecated "cpu-add" QMP command by "device_add" Anthony PERARD
2021-05-11  9:28 ` [XEN PATCH v2 4/8] libxl: Use -device for cd-rom drives Anthony PERARD
2021-05-11  9:28 ` [XEN PATCH v2 5/8] libxl: Assert qmp_ev's state in qmp_ev_qemu_compare_version Anthony PERARD
2021-05-11  9:28 ` [XEN PATCH v2 6/8] libxl: Export libxl__qmp_ev_qemu_compare_version Anthony PERARD
2021-05-11  9:28 ` [XEN PATCH v2 7/8] libxl: Use `id` with the "eject" QMP command Anthony PERARD
2021-05-11  9:28 ` Anthony PERARD [this message]
2021-06-15 13:02 ` [XEN PATCH v2 0/8] Fix libxl with QEMU 6.0 + remove some more deprecated usages Julien Grall
2021-06-29  7:59 ` Olaf Hering

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210511092810.13759-9-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jandryuk@gmail.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    --subject='Re: [XEN PATCH v2 8/8] libxl: Replace QMP command "change" by "blockdev-change-media"' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).