From: Kevin Wolf Subject: [PATCH 5/6] ioemu: Fail on too small blktap disks Date: Fri, 13 Mar 2009 10:16:42 +0100 Message-ID: <1236935803-32548-6-git-send-email-kwolf@suse.de> References: <1236935803-32548-1-git-send-email-kwolf@suse.de> Return-path: In-Reply-To: <1236935803-32548-1-git-send-email-kwolf@suse.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Ian.Jackson@eu.citrix.com, Kevin Wolf List-Id: xen-devel@lists.xenproject.org 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 --- 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