libxl_qmp: Introduce libxl__qmp_insert_cdrom.
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 9 Oct 2012 10:08:19 +0000 (11:08 +0100)
committerAnthony PERARD <anthony.perard@citrix.com>
Tue, 9 Oct 2012 10:08:19 +0000 (11:08 +0100)
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>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_internal.h
tools/libxl/libxl_qmp.c

index afa36a76ec8c31b71bfa68e000416c5058ff991a..4240ef2b0e7f855a96d9dfb761263d0b29579fc0 100644 (file)
@@ -1406,6 +1406,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,
index 3f617de36a7f7f2d1a906a86d2120f95a741c1c2..2ae4c64bbcccb542e0928f5448c7a951ae320d81 100644 (file)
@@ -913,6 +913,22 @@ int libxl__qmp_set_global_dirty_log(libxl__gc *gc, int domid, bool enable)
                            NULL, NULL);
 }
 
+int libxl__qmp_insert_cdrom(libxl__gc *gc, int domid,
+                            const libxl_device_disk *disk)
+{
+    libxl__json_object *args = NULL;
+    int dev_number = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
+
+    QMP_PARAMETERS_SPRINTF(&args, "device", "ide-%i", dev_number);
+
+    if (disk->format == LIBXL_DISK_FORMAT_EMPTY) {
+        return qmp_run_command(gc, domid, "eject", args, NULL, NULL);
+    } else {
+        qmp_parameters_add_string(gc, &args, "target", disk->pdev_path);
+        return qmp_run_command(gc, domid, "change", args, NULL, NULL);
+    }
+}
+
 int libxl__qmp_initializations(libxl__gc *gc, uint32_t domid,
                                const libxl_domain_config *guest_config)
 {