Skip to contentSkip to conversation

Fix to eject cdrom on HVM Domain

PATCH New Kasai Takanori 1 participant 1 message Sep 2, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix to eject cdrom on HVM Domain

Hi All,

We tried to eject cdrom(/dev/hdc) on HVM Domain.
But, cdrom media are not ejected from the cdrom device on HostOS.

The module to eject the cdrom device has already been implemented in qemu-dm.
But, all devices are opened as raw device for VBD.
Therefore, the module to eject the cdrom device is not work.

The cdrom device was corrected to open as a physical device on HostOS. When eject is executed on HVM Domain, cdrom media are ejected from the cdrom device on HostOS.

This patch corrected the problem.

Best Regards,

---
Takanori Kasai

xenstore.c +13 -2
index 8222df4..7b23635 100644
@@ -107,7 +107,14 @@ static void insert_media(void *opaque)
     for (i = 0; i < MAX_DRIVES + 1; i++) {
         bs = drives_table[i].bdrv;
         if (media_filename[i] && bs && bs->filename[0] == '\0') {
-            bdrv_open2(bs, media_filename[i], 0, &bdrv_raw);
+            BlockDriver *format;
+            if ( strstart(media_filename[i], "/dev/cd", NULL) 
+              || strstart(media_filename[i], "/dev/scd", NULL)) 
+                format = &bdrv_host_device;
+            else 
+                format = &bdrv_raw;
+
+            bdrv_open2(bs, media_filename[i], 0, format);
             pstrcpy(bs->filename, sizeof(bs->filename), media_filename[i]);
             free(media_filename[i]);
             media_filename[i] = NULL;
@@ -533,7 +540,11 @@ void xenstore_parse_domain_config(int hvm_domid)
 		} else if (!strcmp(drv,"file")) {
 		    format = &bdrv_raw;
 		} else if (!strcmp(drv,"phy")) {
-		    format = &bdrv_raw;
+                    if (strstart(params, "/dev/cd", NULL) 
+                     || strstart(params, "/dev/scd", NULL)) 
+                        format = &bdrv_host_device;
+                    else
+                        format = &bdrv_raw;
 		} else {
 		    format = bdrv_find_format(drv);
 		    if (!format) {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel