2012-09-06 02:28:20 +02:00
|
|
|
From c6a8d6d888cacb6e480539f0b2ffbac84d937845 Mon Sep 17 00:00:00 2001
|
2011-02-16 20:30:51 +01:00
|
|
|
From: Ulrich Hecht <uli@suse.de>
|
|
|
|
Date: Tue, 14 Apr 2009 16:37:42 +0200
|
2012-08-17 18:42:52 +02:00
|
|
|
Subject: [PATCH] block/vmdk: Support creation of SCSI VMDK images in qemu-img
|
|
|
|
MIME-Version: 1.0
|
2012-10-10 19:32:24 +02:00
|
|
|
Content-Type: text/plain; charset=utf-8
|
2012-08-17 18:42:52 +02:00
|
|
|
Content-Transfer-Encoding: 8bit
|
2011-02-16 20:30:51 +01:00
|
|
|
|
|
|
|
Signed-off-by: Ulrich Hecht <uli@suse.de>
|
2012-08-17 18:42:52 +02:00
|
|
|
[AF: Changed BLOCK_FLAG_SCSI from 8 to 16 for v1.2]
|
|
|
|
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
2011-02-16 20:30:51 +01:00
|
|
|
---
|
|
|
|
block.c | 5 ++++-
|
2011-12-11 03:42:09 +01:00
|
|
|
block/vmdk.c | 12 ++++++++++--
|
2011-02-16 20:30:51 +01:00
|
|
|
block_int.h | 2 ++
|
|
|
|
qemu-img.c | 8 +++++++-
|
2011-12-11 03:42:09 +01:00
|
|
|
4 files changed, 23 insertions(+), 4 deletions(-)
|
2011-02-16 20:30:51 +01:00
|
|
|
|
|
|
|
diff --git a/block.c b/block.c
|
2012-08-17 18:42:52 +02:00
|
|
|
index 470bdcc..b27622b 100644
|
2011-02-16 20:30:51 +01:00
|
|
|
--- a/block.c
|
|
|
|
+++ b/block.c
|
2012-08-17 18:42:52 +02:00
|
|
|
@@ -3902,7 +3902,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
|
2011-02-16 20:30:51 +01:00
|
|
|
char *options, uint64_t img_size, int flags)
|
|
|
|
{
|
|
|
|
QEMUOptionParameter *param = NULL, *create_options = NULL;
|
2011-12-11 03:42:09 +01:00
|
|
|
- QEMUOptionParameter *backing_fmt, *backing_file, *size;
|
|
|
|
+ QEMUOptionParameter *backing_fmt, *backing_file, *size, *scsi;
|
2011-02-16 20:30:51 +01:00
|
|
|
BlockDriverState *bs = NULL;
|
|
|
|
BlockDriver *drv, *proto_drv;
|
|
|
|
BlockDriver *backing_drv = NULL;
|
2012-08-17 18:42:52 +02:00
|
|
|
@@ -4017,6 +4017,9 @@ int bdrv_img_create(const char *filename, const char *fmt,
|
2011-02-16 20:30:51 +01:00
|
|
|
|
|
|
|
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
|
2012-08-29 15:26:28 +02:00
|
|
|
index bba4c61..7db59b0 100644
|
2011-02-16 20:30:51 +01:00
|
|
|
--- a/block/vmdk.c
|
|
|
|
+++ b/block/vmdk.c
|
2012-08-29 15:26:28 +02:00
|
|
|
@@ -1432,7 +1432,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options)
|
2011-02-16 20:30:51 +01:00
|
|
|
"ddb.geometry.cylinders = \"%" PRId64 "\"\n"
|
|
|
|
"ddb.geometry.heads = \"16\"\n"
|
|
|
|
"ddb.geometry.sectors = \"63\"\n"
|
|
|
|
- "ddb.adapterType = \"ide\"\n";
|
|
|
|
+ "ddb.adapterType = \"%s\"\n";
|
2011-12-11 03:42:09 +01:00
|
|
|
|
|
|
|
if (filename_decompose(filename, path, prefix, postfix, PATH_MAX)) {
|
|
|
|
return -EINVAL;
|
2012-08-29 15:26:28 +02:00
|
|
|
@@ -1447,6 +1447,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options)
|
2011-12-11 03:42:09 +01:00
|
|
|
flags |= options->value.n ? BLOCK_FLAG_COMPAT6 : 0;
|
|
|
|
} else if (!strcmp(options->name, BLOCK_OPT_SUBFMT)) {
|
|
|
|
fmt = options->value.s;
|
2011-02-16 20:30:51 +01:00
|
|
|
+ } else if (!strcmp(options->name, BLOCK_OPT_SCSI)) {
|
|
|
|
+ flags |= options->value.n ? BLOCK_FLAG_SCSI: 0;
|
|
|
|
}
|
|
|
|
options++;
|
|
|
|
}
|
2012-08-29 15:26:28 +02:00
|
|
|
@@ -1537,7 +1539,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options)
|
2011-12-11 03:42:09 +01:00
|
|
|
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) {
|
2012-08-17 18:42:52 +02:00
|
|
|
fd = qemu_open(filename,
|
|
|
|
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
|
2012-08-29 15:26:28 +02:00
|
|
|
@@ -1638,6 +1641,11 @@ static QEMUOptionParameter vmdk_create_options[] = {
|
2011-12-11 03:42:09 +01:00
|
|
|
"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 }
|
|
|
|
};
|
2011-02-16 20:30:51 +01:00
|
|
|
|
|
|
|
diff --git a/block_int.h b/block_int.h
|
2012-08-17 18:42:52 +02:00
|
|
|
index 4452f6f..92a75c8 100644
|
2011-02-16 20:30:51 +01:00
|
|
|
--- a/block_int.h
|
|
|
|
+++ b/block_int.h
|
2012-08-17 18:42:52 +02:00
|
|
|
@@ -35,6 +35,7 @@
|
|
|
|
#define BLOCK_FLAG_ENCRYPT 1
|
|
|
|
#define BLOCK_FLAG_COMPAT6 4
|
|
|
|
#define BLOCK_FLAG_LAZY_REFCOUNTS 8
|
|
|
|
+#define BLOCK_FLAG_SCSI 16
|
2011-02-16 20:30:51 +01:00
|
|
|
|
2012-05-15 14:58:40 +02:00
|
|
|
#define BLOCK_IO_LIMIT_READ 0
|
|
|
|
#define BLOCK_IO_LIMIT_WRITE 1
|
2012-08-17 18:42:52 +02:00
|
|
|
@@ -46,6 +47,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"
|
2011-02-16 20:30:51 +01:00
|
|
|
diff --git a/qemu-img.c b/qemu-img.c
|
2012-08-17 18:42:52 +02:00
|
|
|
index b41e670..e34d88a 100644
|
2011-02-16 20:30:51 +01:00
|
|
|
--- a/qemu-img.c
|
|
|
|
+++ b/qemu-img.c
|
2012-08-17 18:42:52 +02:00
|
|
|
@@ -665,7 +665,7 @@ static int img_convert(int argc, char **argv)
|
2011-02-16 20:30:51 +01:00
|
|
|
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;
|
2011-12-11 03:42:09 +01:00
|
|
|
float local_progress;
|
2012-08-17 18:42:52 +02:00
|
|
|
@@ -858,6 +858,12 @@ static int img_convert(int argc, char **argv)
|
2011-02-16 20:30:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ 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) {
|