xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: Xen Devel <xen-devel@lists.xen.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH 1/3] libxl_qmp, Introduce libxl__qmp_insert_cdrom.
Date: Fri, 27 Jul 2012 18:17:29 +0100	[thread overview]
Message-ID: <1343409451-30136-2-git-send-email-anthony.perard@citrix.com> (raw)
In-Reply-To: <1343409451-30136-1-git-send-email-anthony.perard@citrix.com>

This function can eject or change the CDROM for a guest that use qemu-xen as a
device-model.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_internal.h |    1 +
 tools/libxl/libxl_qmp.c      |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c369fd3..eb8786c 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1389,6 +1389,7 @@ _hidden int libxl__qmp_resume(libxl__gc *gc, int domid);
 _hidden int libxl__qmp_save(libxl__gc *gc, int domid, const char *filename);
 /* Set dirty bitmap logging status */
 _hidden int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable);
+_hidden int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid, const libxl_device_disk *disk);
 /* close and free the QMP handler */
 _hidden void libxl__qmp_close(libxl__qmp_handler *qmp);
 /* remove the socket file, if the file has already been removed,
diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index 2c5559f..aebc733 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -1024,6 +1024,41 @@ out:
     return rc;
 }
 
+int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid,
+                            const libxl_device_disk *disk)
+{
+    libxl__qmp_handler *qmp = NULL;
+    char *device_id;
+    int rc = 0;
+
+    device_id = libxl__sprintf(gc, "ide-%s", disk->vdev);
+    if (!device_id)
+        return ERROR_NOMEM;
+
+    qmp = libxl__qmp_initialize(gc, domid);
+    if (!qmp)
+        return ERROR_FAIL;
+
+    if (disk->format == LIBXL_DISK_FORMAT_EMPTY) {
+        libxl__json_object *args = NULL;
+
+        args = qmp_parameters_add_string(gc, NULL, "device", device_id);
+        if (!args) {
+            rc = ERROR_NOMEM;
+            goto out;
+        }
+        rc = qmp_synchronous_send(qmp, "eject", args, NULL, NULL, qmp->timeout);
+        libxl__json_object_free(gc, args);
+    } else {
+        char *file = disk->pdev_path;
+        rc = qmp_change(gc, qmp, device_id, file, NULL);
+    }
+
+out:
+    libxl__qmp_close(qmp);
+    return rc;
+}
+
 int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid,
                                const libxl_domain_config *guest_config)
 {
-- 
Anthony PERARD

  reply	other threads:[~2012-07-27 17:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-27 17:17 [PATCH 0/3] libxl cd-insert/eject with qemu-xen Anthony PERARD
2012-07-27 17:17 ` Anthony PERARD [this message]
2012-07-31 12:44   ` [PATCH 1/3] libxl_qmp, Introduce libxl__qmp_insert_cdrom Ian Jackson
2012-07-27 17:17 ` [PATCH 2/3] libxl_dm: Set an id to cdrom drives with qemuu Anthony PERARD
2012-07-31 12:45   ` Ian Jackson
2012-07-27 17:17 ` [PATCH 3/3] libxl: Fix cd-insert with qemu-xen Anthony PERARD
2012-07-31 12:47   ` Ian Jackson
2012-07-27 17:22 ` [PATCH 0/3] libxl cd-insert/eject " Anthony PERARD
2012-07-31 12:47   ` Ian Jackson
2012-07-31 12:39 ` Ian Jackson

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=1343409451-30136-2-git-send-email-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).