libxl: only a CDROM type disk can be empty.
authorIan Campbell <ian.campbell@citrix.com>
Fri, 8 Apr 2011 15:39:19 +0000 (16:39 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 8 Apr 2011 15:39:19 +0000 (16:39 +0100)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.c

index 4f6cb8b157ebbdc964cb64972810e53f0fe4ae1c..80660dccb776a2b07a50f5fb8414f3e47b0f1790 100644 (file)
@@ -908,8 +908,13 @@ static int validate_virtual_disk(libxl__gc *gc, char *file_name,
     struct stat stat_buf;
     char *delimiter;
 
-    if (disk->format == DISK_FORMAT_EMPTY)
-        return 0;
+    if (disk->format == DISK_FORMAT_EMPTY) {
+        if (disk->is_cdrom)
+            return 0;
+        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Empty disk %s is not a CDROM device\n",
+                   disk->vdev);
+        return ERROR_INVAL;
+    }
 
     if (disk->format == DISK_FORMAT_RAW) {
         delimiter = strchr(file_name, ':');