Revision 0e7e1989 block.c
b/block.c | ||
---|---|---|
189 | 189 |
const char *backing_file, const char *backing_format, |
190 | 190 |
int flags) |
191 | 191 |
{ |
192 |
if (drv->bdrv_create2) |
|
193 |
return drv->bdrv_create2(filename, size_in_sectors, backing_file, |
|
194 |
backing_format, flags); |
|
195 |
if (drv->bdrv_create) |
|
196 |
return drv->bdrv_create(filename, size_in_sectors, backing_file, |
|
197 |
flags); |
|
198 |
return -ENOTSUP; |
|
192 |
QEMUOptionParameter *options; |
|
193 |
|
|
194 |
options = parse_option_parameters("", drv->create_options, NULL); |
|
195 |
|
|
196 |
// Process flags |
|
197 |
if (flags & ~(BLOCK_FLAG_ENCRYPT | BLOCK_FLAG_COMPAT6 | BLOCK_FLAG_COMPRESS)) { |
|
198 |
return -ENOTSUP; |
|
199 |
} |
|
200 |
|
|
201 |
if (flags & BLOCK_FLAG_ENCRYPT) { |
|
202 |
set_option_parameter_int(options, BLOCK_OPT_ENCRYPT, 1); |
|
203 |
} |
|
204 |
if (flags & BLOCK_FLAG_COMPAT6) { |
|
205 |
set_option_parameter_int(options, BLOCK_OPT_COMPAT6, 1); |
|
206 |
} |
|
207 |
|
|
208 |
// Add size to options |
|
209 |
set_option_parameter_int(options, BLOCK_OPT_SIZE, size_in_sectors * 512); |
|
210 |
|
|
211 |
// Backing files |
|
212 |
if ((backing_file != NULL && set_option_parameter(options, |
|
213 |
BLOCK_OPT_BACKING_FILE, backing_file)) |
|
214 |
|| (backing_format != NULL && set_option_parameter(options, |
|
215 |
BLOCK_OPT_BACKING_FMT, backing_format))) |
|
216 |
{ |
|
217 |
return -ENOTSUP; |
|
218 |
} |
|
219 |
|
|
220 |
return bdrv_create(drv, filename, options); |
|
199 | 221 |
} |
200 | 222 |
|
201 |
int bdrv_create(BlockDriver *drv, |
|
202 |
const char *filename, int64_t size_in_sectors, |
|
203 |
const char *backing_file, int flags) |
|
223 |
int bdrv_create(BlockDriver *drv, const char* filename, |
|
224 |
QEMUOptionParameter *options) |
|
204 | 225 |
{ |
205 | 226 |
if (!drv->bdrv_create) |
206 | 227 |
return -ENOTSUP; |
207 |
return drv->bdrv_create(filename, size_in_sectors, backing_file, flags); |
|
228 |
|
|
229 |
return drv->bdrv_create(filename, options); |
|
208 | 230 |
} |
209 | 231 |
|
210 | 232 |
#ifdef _WIN32 |
Also available in: Unified diff