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 5/6] ioemu: Fail on too small blktap disks

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 5/6] ioemu: Fail on too small blktap disks
From: Kevin Wolf <kwolf@xxxxxxx>
Date: Fri, 13 Mar 2009 10:16:42 +0100
Cc: Ian.Jackson@xxxxxxxxxxxxx, Kevin Wolf <kwolf@xxxxxxx>
Delivery-date: Fri, 13 Mar 2009 02:10:31 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1236935803-32548-1-git-send-email-kwolf@xxxxxxx>
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>
References: <1236935803-32548-1-git-send-email-kwolf@xxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
The blktap infrastructure doesn't seems to be able to cope with images
that are smaller than a sector, it produced hangs for me. Such an
image isn't really useful anyway, so just fail gracefully.

Signed-off-by: Kevin Wolf <kwolf@xxxxxxx>
---
 hw/xen_blktap.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/hw/xen_blktap.c b/hw/xen_blktap.c
index 9cb2a45..f04f30d 100644
--- a/hw/xen_blktap.c
+++ b/hw/xen_blktap.c
@@ -258,6 +258,12 @@ static int open_disk(struct td_state *s, char *path, int 
driver, int readonly)
        s->size = bs->total_sectors;
        s->sector_size = 512;
 
+       if (s->size == 0) {
+               fprintf(stderr, "Error: Disk image %s is too small\n",
+                       path);
+               return -ENOMEM;
+       }
+
        s->info = ((s->flags & TD_RDONLY) ? VDISK_READONLY : 0);
 
 #ifndef QEMU_TOOL
-- 
1.6.0.2


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