From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kamala Narasimhan Subject: Re: [PATCH] xl: Perform minimal validation of virtual disk file while parsing config file Date: Wed, 26 Jan 2011 13:02:05 -0500 Message-ID: <4D40619D.40806@gmail.com> References: <1294995912.8240.86.camel@zakaz.uk.xensource.com> <1295024348.12018.222.camel@qabil.uk.xensource.com> <19768.22912.878633.622270@mariner.uk.xensource.com> <19769.31094.274199.464586@mariner.uk.xensource.com> <1295616468.12018.352.camel@qabil.uk.xensource.com> <4D3A4203.2050706@gmail.com> <19775.4623.927492.247420@mariner.uk.xensource.com> <19776.2283.897281.370509@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <19776.2283.897281.370509@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: Ian Campbell , "xen-devel@lists.xensource.com" , Gianni Tedesco , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Here is a patch that special cases tap/aio during validation. I am not taking into account qcow and qcow2 as I hear they are broken with tap and shouldn't be used for that reason. Signed-off-by: Kamala Narasimhan Kamala diff -r 67d5b8004947 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Wed Jan 26 11:58:45 2011 +0000 +++ b/tools/libxl/libxl.c Wed Jan 26 12:07:54 2011 -0500 @@ -836,22 +836,26 @@ static int validate_virtual_disk(libxl_c static int validate_virtual_disk(libxl_ctx *ctx, char *file_name, libxl_disk_phystype disk_type) { struct stat stat_buf; + int count = 0; if ( (file_name[0] == '\0') && (disk_type == PHYSTYPE_EMPTY) ) return 0; - if ( stat(file_name, &stat_buf) != 0 ) { - LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s", file_name); + if ( disk_type == PHYSTYPE_AIO ) + count = strlen("vhd:"); + + if ( stat(&file_name[count], &stat_buf) != 0 ) { + LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to stat %s", &file_name[count]); return ERROR_INVAL; } if ( disk_type == PHYSTYPE_PHY ) { if ( !(S_ISBLK(stat_buf.st_mode)) ) { LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s is not a block device!\n", - file_name); + &file_name[count]); return ERROR_INVAL; } } else if ( S_ISREG(stat_buf.st_mode) && stat_buf.st_size == 0 ) { - LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s size is 0!\n", file_name); + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s size is 0!\n", &file_name[count]); return ERROR_INVAL; }