All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] qemu: fix cdrom handling issues
Date: Thu, 21 May 2009 17:31:06 +0100	[thread overview]
Message-ID: <4A1581CA.8090007@eu.citrix.com> (raw)

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@eu.citrix.com>

---

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);
     }

                 reply	other threads:[~2009-05-21 16:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4A1581CA.8090007@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.