summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Hecht <uli@suse.de>2009-04-14 16:37:42 +0200
committerAnas Nashif <anas.nashif@intel.com>2013-01-15 13:32:15 -0800
commitd661571f8c20270d520e6bc845d865e15414e6b5 (patch)
tree8ae23b1632f3c742b845da7f6d988de4e2967e48
parent9262ab02ab21302f8d187256033247497a9a2561 (diff)
downloadqemu-d661571f8c20270d520e6bc845d865e15414e6b5.tar.gz
qemu-d661571f8c20270d520e6bc845d865e15414e6b5.tar.bz2
qemu-d661571f8c20270d520e6bc845d865e15414e6b5.zip
block/vmdk: Support creation of SCSI VMDK images in qemu-img
Signed-off-by: Ulrich Hecht <uli@suse.de> [AF: Changed BLOCK_FLAG_SCSI from 8 to 16 for v1.2] Signed-off-by: Andreas Färber <afaerber@suse.de>
-rw-r--r--block.c5
-rw-r--r--block/vmdk.c12
-rw-r--r--block_int.h2
-rw-r--r--qemu-img.c8
4 files changed, 23 insertions, 4 deletions
diff --git a/block.c b/block.c
index c05875fe3..07e271ceb 100644
--- a/block.c
+++ b/block.c
@@ -4413,7 +4413,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
char *options, uint64_t img_size, int flags)
{
QEMUOptionParameter *param = NULL, *create_options = NULL;
- QEMUOptionParameter *backing_fmt, *backing_file, *size;
+ QEMUOptionParameter *backing_fmt, *backing_file, *size, *scsi;
BlockDriverState *bs = NULL;
BlockDriver *drv, *proto_drv;
BlockDriver *backing_drv = NULL;
@@ -4528,6 +4528,9 @@ int bdrv_img_create(const char *filename, const char *fmt,
printf("Formatting '%s', fmt=%s ", filename, fmt);
print_option_parameters(param);
+ scsi = get_option_parameter(param, BLOCK_OPT_SCSI);
+ if (scsi && scsi->value.n)
+ printf(", SCSI");
puts("");
ret = bdrv_create(drv, filename, param);
diff --git a/block/vmdk.c b/block/vmdk.c
index 51398c0c0..580e4b3bb 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1471,7 +1471,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options)
"ddb.geometry.cylinders = \"%" PRId64 "\"\n"
"ddb.geometry.heads = \"16\"\n"
"ddb.geometry.sectors = \"63\"\n"
- "ddb.adapterType = \"ide\"\n";
+ "ddb.adapterType = \"%s\"\n";
if (filename_decompose(filename, path, prefix, postfix, PATH_MAX)) {
return -EINVAL;
@@ -1486,6 +1486,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options)
flags |= options->value.n ? BLOCK_FLAG_COMPAT6 : 0;
} else if (!strcmp(options->name, BLOCK_OPT_SUBFMT)) {
fmt = options->value.s;
+ } else if (!strcmp(options->name, BLOCK_OPT_SCSI)) {
+ flags |= options->value.n ? BLOCK_FLAG_SCSI: 0;
}
options++;
}
@@ -1576,7 +1578,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options)
parent_desc_line,
ext_desc_lines,
(flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
- total_size / (int64_t)(63 * 16 * 512));
+ total_size / (int64_t)(63 * 16 * 512),
+ flags & BLOCK_FLAG_SCSI ? "lsilogic" : "ide");
if (split || flat) {
fd = qemu_open(filename,
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
@@ -1677,6 +1680,11 @@ static QEMUOptionParameter vmdk_create_options[] = {
"VMDK flat extent format, can be one of "
"{monolithicSparse (default) | monolithicFlat | twoGbMaxExtentSparse | twoGbMaxExtentFlat | streamOptimized} "
},
+ {
+ .name = BLOCK_OPT_SCSI,
+ .type = OPT_FLAG,
+ .help = "SCSI image"
+ },
{ NULL }
};
diff --git a/block_int.h b/block_int.h
index 9deedb811..8274c89cd 100644
--- a/block_int.h
+++ b/block_int.h
@@ -36,6 +36,7 @@
#define BLOCK_FLAG_ENCRYPT 1
#define BLOCK_FLAG_COMPAT6 4
#define BLOCK_FLAG_LAZY_REFCOUNTS 8
+#define BLOCK_FLAG_SCSI 16
#define BLOCK_IO_LIMIT_READ 0
#define BLOCK_IO_LIMIT_WRITE 1
@@ -47,6 +48,7 @@
#define BLOCK_OPT_SIZE "size"
#define BLOCK_OPT_ENCRYPT "encryption"
#define BLOCK_OPT_COMPAT6 "compat6"
+#define BLOCK_OPT_SCSI "scsi"
#define BLOCK_OPT_BACKING_FILE "backing_file"
#define BLOCK_OPT_BACKING_FMT "backing_fmt"
#define BLOCK_OPT_CLUSTER_SIZE "cluster_size"
diff --git a/qemu-img.c b/qemu-img.c
index e29e01b72..8040a41f8 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -671,7 +671,7 @@ static int img_convert(int argc, char **argv)
const uint8_t *buf1;
BlockDriverInfo bdi;
QEMUOptionParameter *param = NULL, *create_options = NULL;
- QEMUOptionParameter *out_baseimg_param;
+ QEMUOptionParameter *out_baseimg_param, *scsi;
char *options = NULL;
const char *snapshot_name = NULL;
float local_progress = 0;
@@ -864,6 +864,12 @@ static int img_convert(int argc, char **argv)
}
}
+ if ((scsi = get_option_parameter(param, BLOCK_OPT_SCSI)) && scsi->value.n && strcmp(drv->format_name, "vmdk")) {
+ error_report("SCSI devices not supported for this file format");
+ ret = -1;
+ goto out;
+ }
+
/* Create the new image */
ret = bdrv_create(drv, out_filename, param);
if (ret < 0) {