- if (flags & BLOCK_FLAG_COMPRESS && strcmp(drv->format_name, "qcow") && strcmp(drv->format_name, "qcow2"))
- error("Compression not supported for this file format");
- if (flags & BLOCK_FLAG_ENCRYPT && strcmp(drv->format_name, "qcow") && strcmp(drv->format_name, "qcow2"))
- error("Encryption not supported for this file format");
- if (flags & BLOCK_FLAG_COMPAT6 && strcmp(drv->format_name, "vmdk"))
- error("Alternative compatibility level not supported for this file format");
- if (flags & BLOCK_FLAG_ENCRYPT && flags & BLOCK_FLAG_COMPRESS)
- error("Compression and encryption not supported at the same time");
-
- ret = bdrv_create2(drv, out_filename, total_sectors, out_baseimg, NULL, flags);
+
+ if (options) {
+ param = parse_option_parameters(options, drv->create_options, param);
+ if (param == NULL) {
+ error("Invalid options for file format '%s'.", out_fmt);
+ }
+ } else {
+ param = parse_option_parameters("", drv->create_options, param);
+ }
+
+ set_option_parameter_int(param, BLOCK_OPT_SIZE, total_sectors * 512);
+ add_old_style_options(out_fmt, param, flags, out_baseimg, NULL);
+
+ /* Check if compression is supported */
+ if (flags & BLOCK_FLAG_COMPRESS) {
+ QEMUOptionParameter *encryption =
+ get_option_parameter(param, BLOCK_OPT_ENCRYPT);
+
+ if (!drv->bdrv_write_compressed) {
+ error("Compression not supported for this file format");
+ }
+
+ if (encryption && encryption->value.n) {
+ error("Compression and encryption not supported at the same time");
+ }
+ }
+
+ /* Create the new image */
+ ret = bdrv_create(drv, out_filename, param);
+ free_option_parameters(param);
+