qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Automatically eject CD-ROM disk in Linux host system
@ 2007-03-05  3:47 Yu, Xiaoyang
  2007-03-19 16:22 ` Thiemo Seufer
  0 siblings, 1 reply; 2+ messages in thread
From: Yu, Xiaoyang @ 2007-03-05  3:47 UTC (permalink / raw)
  To: qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 414 bytes --]

Hi,

 

I wrote a patch to automatically eject a physical CD-ROM disk when:

* Issue "eject" command in monitor console, or

* Issue "eject" command in Linux guest system, or

* In Windows guest system, press the right mouse button above CD-ROM
icon, then select "eject".

 

This is patch is based on QEMU 0.8.2 in Xen 3.0.3, and works on Linux
host system. 

 

Thanks
Xiaoyang

 

 


[-- Attachment #1.2: Type: text/html, Size: 3117 bytes --]

[-- Attachment #2: eject_cdrom.patch --]
[-- Type: application/octet-stream, Size: 1625 bytes --]

diff -urN xen-3.0.3_0-src.orig/tools/ioemu/block.c xen-3.0.3_0-src/tools/ioemu/block.c
--- xen-3.0.3_0-src.orig/tools/ioemu/block.c	2007-03-05 20:46:05.000000000 +0800
+++ xen-3.0.3_0-src/tools/ioemu/block.c	2007-03-05 20:49:33.000000000 +0800
@@ -755,11 +755,21 @@
     return 0;
 }
 
+int do_change_eject = 0; 
+
 static void raw_close(BlockDriverState *bs)
 {
     BDRVRawState *s = bs->opaque;
     bs->total_sectors = 0;
     close(s->fd);
+
+    if(do_change_eject == 0)
+    {
+    	    /* Eject the CD-ROM disk in host Linux system */
+            char buf[1024];
+            sprintf(buf, "eject %s", bs->filename);
+            system(buf);
+    }
 }
 
 #ifdef _WIN32
diff -urN xen-3.0.3_0-src.orig/tools/ioemu/monitor.c xen-3.0.3_0-src/tools/ioemu/monitor.c
--- xen-3.0.3_0-src.orig/tools/ioemu/monitor.c	2007-03-05 20:46:05.000000000 +0800
+++ xen-3.0.3_0-src/tools/ioemu/monitor.c	2007-03-05 20:51:53.000000000 +0800
@@ -343,10 +343,13 @@
     eject_device(bs, force);
 }
 
+extern int do_change_eject;
+
 void do_change(const char *device, const char *filename)
 {
     BlockDriverState *bs;
-    int i;
+    int i; 
+    int retval;
     char password[256];
 
     bs = bdrv_find(device);
@@ -354,7 +357,12 @@
         term_printf("device not found\n");
         return;
     }
-    if (eject_device(bs, 0) < 0)
+
+    /* When issue "change" command in monitor, the CD-ROM disk should not be ejected in raw_close() */
+    do_change_eject = 1;
+    retval = eject_device(bs, 0);
+    do_change_eject = 0;
+    if (retval < 0)
         return;
     bdrv_open(bs, filename, 0);
     if (bdrv_is_encrypted(bs)) {

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-19 16:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-05  3:47 [Qemu-devel] [PATCH] Automatically eject CD-ROM disk in Linux host system Yu, Xiaoyang
2007-03-19 16:22 ` Thiemo Seufer

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).