qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] xen_disk: cope with missing xenstore "params" node
@ 2011-06-24 14:50 stefano.stabellini
  2011-06-24 14:50 ` [Qemu-devel] [PATCH] xen_disk: treat "aio" as "raw" stefano.stabellini
  2011-06-24 15:06 ` [Qemu-devel] [PATCH] xen_disk: cope with missing xenstore "params" node Peter Maydell
  0 siblings, 2 replies; 14+ messages in thread
From: stefano.stabellini @ 2011-06-24 14:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: xen-devel, agraf, Stefano Stabellini

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

When disk is a cdrom and the drive is empty the "params" node in
xenstore might be missing completely: cope with it instead of
segfaulting.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 hw/xen_disk.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 096d1c9..801da58 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -616,11 +616,13 @@ static int blk_init(struct XenDevice *xendev)
 {
     struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
     int index, qflags, have_barriers, info = 0;
-    char *h;
+    char *h = NULL;
 
     /* read xenstore entries */
     if (blkdev->params == NULL) {
         blkdev->params = xenstore_read_be_str(&blkdev->xendev, "params");
+        if (blkdev->params != NULL)
+            h = strchr(blkdev->params, ':');
         h = strchr(blkdev->params, ':');
         if (h != NULL) {
             blkdev->fileproto = blkdev->params;
@@ -672,11 +674,15 @@ static int blk_init(struct XenDevice *xendev)
         /* setup via xenbus -> create new block driver instance */
         xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
         blkdev->bs = bdrv_new(blkdev->dev);
-        if (bdrv_open(blkdev->bs, blkdev->filename, qflags,
-                      bdrv_find_whitelisted_format(blkdev->fileproto)) != 0) {
-            bdrv_delete(blkdev->bs);
-            return -1;
+        if (blkdev->bs) {
+            if (bdrv_open(blkdev->bs, blkdev->filename, qflags,
+                        bdrv_find_whitelisted_format(blkdev->fileproto)) != 0) {
+                bdrv_delete(blkdev->bs);
+                blkdev->bs = NULL;
+            }
         }
+        if (!blkdev->bs)
+            return -1;
     } else {
         /* setup via qemu cmdline -> already setup for us */
         xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n");
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH] xen_disk: cope with missing xenstore "params" node
@ 2011-02-11 12:38 Stefano Stabellini
  2011-02-11 12:49 ` Kevin Wolf
  0 siblings, 1 reply; 14+ messages in thread
From: Stefano Stabellini @ 2011-02-11 12:38 UTC (permalink / raw)
  To: qemu-devel

When disk is a cdrom and the drive is empty the "params" node in
xenstore might be missing completely: cope with it instead of
segfaulting.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>


diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 134ac33..e553c4c 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -577,12 +577,13 @@ static int blk_init(struct XenDevice *xendev)
 {
     struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
     int index, qflags, have_barriers, info = 0;
-    char *h;
+    char *h = NULL;
 
     /* read xenstore entries */
     if (blkdev->params == NULL) {
 	blkdev->params = xenstore_read_be_str(&blkdev->xendev, "params");
-        h = strchr(blkdev->params, ':');
+        if (blkdev->params != NULL)
+            h = strchr(blkdev->params, ':');
 	if (h != NULL) {
 	    blkdev->fileproto = blkdev->params;
 	    blkdev->filename  = h+1;

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

end of thread, other threads:[~2011-06-30 14:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-24 14:50 [Qemu-devel] [PATCH] xen_disk: cope with missing xenstore "params" node stefano.stabellini
2011-06-24 14:50 ` [Qemu-devel] [PATCH] xen_disk: treat "aio" as "raw" stefano.stabellini
2011-06-30 11:47   ` Alexander Graf
2011-06-30 12:47     ` Kevin Wolf
2011-06-30 12:45       ` Alexander Graf
2011-06-30 14:20         ` Stefano Stabellini
2011-06-30 14:32           ` Alexander Graf
2011-06-30 14:39             ` Stefano Stabellini
2011-06-24 15:06 ` [Qemu-devel] [PATCH] xen_disk: cope with missing xenstore "params" node Peter Maydell
2011-06-24 16:34   ` Stefano Stabellini
  -- strict thread matches above, loose matches on Subject: below --
2011-02-11 12:38 Stefano Stabellini
2011-02-11 12:49 ` Kevin Wolf
2011-02-11 12:59   ` Stefano Stabellini
2011-02-11 13:08     ` Kevin Wolf

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