WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] qemu: fix cdrom handling issues

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] qemu: fix cdrom handling issues
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Thu, 21 May 2009 17:31:06 +0100
Delivery-date: Thu, 21 May 2009 09:29:37 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.14 (X11/20080505)
Hi all,
this patch fixes few cdrom handling issues:

- when a cdrom medium event occurs and the new filename is NULL,
  we should eject the emulated cdrom instead of just ignoring the event;

- when a cdrom medium event occurs and we are in a stubdom, we have to
  pass the xenstore path of the frontend to bdrv_open instead of the
  filename;

- when we try and fail to open a cdrom (or disk) in a stubdom we should
  not fall back to the usual "non-stubdom" code path because is useless
  and wrong.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

---

diff --git a/xenstore.c b/xenstore.c
index 9360771..3db3531 100644
--- a/xenstore.c
+++ b/xenstore.c
@@ -476,9 +476,8 @@ void xenstore_parse_domain_config(int hvm_domid)
             continue;
        if (bdrv_open2(bs, danger_buf, BDRV_O_CACHE_WB /* snapshot and 
write-back */, &bdrv_raw) == 0) {
            pstrcpy(bs->filename, sizeof(bs->filename), params);
-       } else
-#endif
-
+       }
+#else
         if (params[0]) {
            if (!format) {
                if (!drv) {
@@ -504,6 +503,8 @@ void xenstore_parse_domain_config(int hvm_domid)
                 fprintf(stderr, "qemu: could not open vbd '%s' or hard disk 
image '%s' (drv '%s' format '%s')\n", buf, params, drv ? drv : "?", format ? 
format->format_name : "0");
         }
 
+#endif
+
        drives_table[nb_drives].bdrv = bs;
        drives_table[nb_drives].used = 1;
        nb_drives++;
@@ -955,23 +956,22 @@ void xenstore_process_event(void *opaque)
     fprintf(stderr,"medium change watch on `%s' (index: %d): %s\n",
            vec[XS_WATCH_TOKEN], hd_index, image ? image : "<none>");
 
-    if (image == NULL)
-        goto out;  /* gone */
-
-    /* Strip off blktap sub-type prefix */
-    bpath = strdup(vec[XS_WATCH_PATH]); 
-    if (bpath == NULL)
-        goto out;
-    if ((offset = strrchr(bpath, '/')) != NULL) 
-        *offset = '\0';
-    if (pasprintf(&buf, "%s/type", bpath) == -1) 
-        goto out;
-    drv = xs_read(xsh, XBT_NULL, buf, &len);
-    if (drv && !strcmp(drv, "tap") && ((offset = strchr(image, ':')) != NULL))
-        memmove(image, offset+1, strlen(offset+1)+1);
+    if (image != NULL) {
+        /* Strip off blktap sub-type prefix */
+        bpath = strdup(vec[XS_WATCH_PATH]); 
+        if (bpath == NULL)
+            goto out;
+        if ((offset = strrchr(bpath, '/')) != NULL) 
+            *offset = '\0';
+        if (pasprintf(&buf, "%s/type", bpath) == -1) 
+            goto out;
+        drv = xs_read(xsh, XBT_NULL, buf, &len);
+        if (drv && !strcmp(drv, "tap") && ((offset = strchr(image, ':')) != 
NULL))
+            memmove(image, offset+1, strlen(offset+1)+1);
 
-    if (!strcmp(image, drives_table[hd_index].bdrv->filename))
-        goto out;  /* identical */
+        if (!strcmp(image, drives_table[hd_index].bdrv->filename))
+            goto out;  /* identical */
+    }
 
     drives_table[hd_index].bdrv->filename[0] = '\0';
     bdrv_close(drives_table[hd_index].bdrv);
@@ -980,8 +980,16 @@ void xenstore_process_event(void *opaque)
         media_filename[hd_index] = NULL;
     }
 
-    if (image[0]) {
+    if (image && image[0]) {
+#ifdef CONFIG_STUBDOM
+        char path[strlen(vec[XS_WATCH_PATH]) - 6 + 8];
+        path[0] = '\0';
+        strncat(path, vec[XS_WATCH_PATH], strlen(vec[XS_WATCH_PATH]) - 6);
+        strcat(path, "frontend");
+        media_filename[hd_index] = xs_read(xsh, XBT_NULL, path, &len);
+#else
         media_filename[hd_index] = strdup(image);
+#endif
         xenstore_check_new_media_present(5000);
     }
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] qemu: fix cdrom handling issues, Stefano Stabellini <=