Revision 9230eaf6 qemu-img.c

b/qemu-img.c
25 25
#include "osdep.h"
26 26
#include "block_int.h"
27 27
#include <assert.h>
28
#include <stdio.h>
28 29

  
29 30
#ifdef _WIN32
30 31
#include <windows.h>
......
57 58
           "QEMU disk image utility\n"
58 59
           "\n"
59 60
           "Command syntax:\n"
60
           "  create [-e] [-6] [-b base_image] [-f fmt] filename [size]\n"
61
           "  create [-e] [-6] [-F fmt] [-b base_image] [-f fmt] filename [size]\n"
61 62
           "  commit [-f fmt] filename\n"
62 63
           "  convert [-c] [-e] [-6] [-f fmt] [-O output_fmt] [-B output_base_image] filename [filename2 [...]] output_filename\n"
63 64
           "  info [-f fmt] filename\n"
......
217 218
{
218 219
    int c, ret, flags;
219 220
    const char *fmt = "raw";
221
    const char *base_fmt = NULL;
220 222
    const char *filename;
221 223
    const char *base_filename = NULL;
222 224
    uint64_t size;
......
226 228

  
227 229
    flags = 0;
228 230
    for(;;) {
229
        c = getopt(argc, argv, "b:f:he6");
231
        c = getopt(argc, argv, "F:b:f:he6");
230 232
        if (c == -1)
231 233
            break;
232 234
        switch(c) {
233 235
        case 'h':
234 236
            help();
235 237
            break;
238
        case 'F':
239
            base_fmt = optarg;
240
            break;
236 241
        case 'b':
237 242
            base_filename = optarg;
238 243
            break;
......
253 258
    size = 0;
254 259
    if (base_filename) {
255 260
        BlockDriverState *bs;
256
        bs = bdrv_new_open(base_filename, NULL);
261
        BlockDriver *base_drv = NULL;
262

  
263
        if (base_fmt) {
264
            base_drv = bdrv_find_format(base_fmt);
265
            if (base_drv == NULL)
266
                error("Unknown basefile format '%s'", base_fmt);
267
        }
268

  
269
        bs = bdrv_new_open(base_filename, base_fmt);
257 270
        bdrv_get_geometry(bs, &size);
258 271
        size *= 512;
259 272
        bdrv_delete(bs);
......
284 297
    if (base_filename) {
285 298
        printf(", backing_file=%s",
286 299
               base_filename);
300
         if (base_fmt)
301
             printf(", backing_fmt=%s",
302
                    base_fmt);
287 303
    }
288 304
    printf(", size=%" PRIu64 " kB\n", size / 1024);
289
    ret = bdrv_create(drv, filename, size / 512, base_filename, flags);
305
    ret = bdrv_create2(drv, filename, size / 512, base_filename, base_fmt, flags);
290 306
    if (ret < 0) {
291 307
        if (ret == -ENOTSUP) {
292 308
            error("Formatting or formatting option not supported for file format '%s'", fmt);

Also available in: Unified diff