Revision 0e7e1989 block/qcow2.c
b/block/qcow2.c | ||
---|---|---|
1696 | 1696 |
return 0; |
1697 | 1697 |
} |
1698 | 1698 |
|
1699 |
static int qcow_create(const char *filename, int64_t total_size, |
|
1700 |
const char *backing_file, int flags) |
|
1701 |
{ |
|
1702 |
return qcow_create2(filename, total_size, backing_file, NULL, flags); |
|
1699 |
static int qcow_create(const char *filename, QEMUOptionParameter *options) |
|
1700 |
{ |
|
1701 |
const char *backing_file = NULL; |
|
1702 |
const char *backing_fmt = NULL; |
|
1703 |
uint64_t sectors = 0; |
|
1704 |
int flags = 0; |
|
1705 |
|
|
1706 |
/* Read out options */ |
|
1707 |
while (options && options->name) { |
|
1708 |
if (!strcmp(options->name, BLOCK_OPT_SIZE)) { |
|
1709 |
sectors = options->value.n / 512; |
|
1710 |
} else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) { |
|
1711 |
backing_file = options->value.s; |
|
1712 |
} else if (!strcmp(options->name, BLOCK_OPT_BACKING_FMT)) { |
|
1713 |
backing_fmt = options->value.s; |
|
1714 |
} else if (!strcmp(options->name, BLOCK_OPT_ENCRYPT)) { |
|
1715 |
flags |= options->value.n ? BLOCK_FLAG_ENCRYPT : 0; |
|
1716 |
} |
|
1717 |
options++; |
|
1718 |
} |
|
1719 |
|
|
1720 |
return qcow_create2(filename, sectors, backing_file, backing_fmt, flags); |
|
1703 | 1721 |
} |
1704 | 1722 |
|
1705 | 1723 |
static int qcow_make_empty(BlockDriverState *bs) |
... | ... | |
2897 | 2915 |
return ret; |
2898 | 2916 |
} |
2899 | 2917 |
|
2918 |
static QEMUOptionParameter qcow_create_options[] = { |
|
2919 |
{ BLOCK_OPT_SIZE, OPT_SIZE }, |
|
2920 |
{ BLOCK_OPT_BACKING_FILE, OPT_STRING }, |
|
2921 |
{ BLOCK_OPT_BACKING_FMT, OPT_STRING }, |
|
2922 |
{ BLOCK_OPT_ENCRYPT, OPT_FLAG }, |
|
2923 |
{ NULL } |
|
2924 |
}; |
|
2925 |
|
|
2900 | 2926 |
static BlockDriver bdrv_qcow2 = { |
2901 | 2927 |
.format_name = "qcow2", |
2902 | 2928 |
.instance_size = sizeof(BDRVQcowState), |
... | ... | |
2924 | 2950 |
.bdrv_put_buffer = qcow_put_buffer, |
2925 | 2951 |
.bdrv_get_buffer = qcow_get_buffer, |
2926 | 2952 |
|
2927 |
.bdrv_create2 = qcow_create2,
|
|
2953 |
.create_options = qcow_create_options,
|
|
2928 | 2954 |
.bdrv_check = qcow_check, |
2929 | 2955 |
}; |
2930 | 2956 |
|
Also available in: Unified diff