qemu-img: Print available options with -o ?
[qemu] / block / raw-win32.c
index ab3abd6..1e95153 100644 (file)
@@ -210,13 +210,18 @@ static int64_t raw_getlength(BlockDriverState *bs)
     return l.QuadPart;
 }
 
-static int raw_create(const char *filename, int64_t total_size,
-                      const char *backing_file, int flags)
+static int raw_create(const char *filename, QEMUOptionParameter *options)
 {
     int fd;
+    int64_t total_size = 0;
 
-    if (flags || backing_file)
-        return -ENOTSUP;
+    /* Read out options */
+    while (options && options->name) {
+        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
+            total_size = options->value.n / 512;
+        }
+        options++;
+    }
 
     fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
               0644);
@@ -228,6 +233,15 @@ static int raw_create(const char *filename, int64_t total_size,
     return 0;
 }
 
+static QEMUOptionParameter raw_create_options[] = {
+    {
+        .name = BLOCK_OPT_SIZE,
+        .type = OPT_SIZE,
+        .help = "Virtual disk size"
+    },
+    { NULL }
+};
+
 static BlockDriver bdrv_raw = {
     .format_name       = "raw",
     .instance_size     = sizeof(BDRVRawState),
@@ -239,6 +253,8 @@ static BlockDriver bdrv_raw = {
     .bdrv_write                = raw_write,
     .bdrv_truncate     = raw_truncate,
     .bdrv_getlength    = raw_getlength,
+
+    .create_options = raw_create_options,
 };
 
 /***********************************************/
@@ -388,7 +404,6 @@ static void bdrv_raw_init(void)
 {
     bdrv_register(&bdrv_raw);
     bdrv_register(&bdrv_host_device);
-    return 0;
 }
 
 block_init(bdrv_raw_init);