2015-04-08 16:42:13 +02:00
|
|
|
From 32f2ddd6a79a72b99d885d117e4297ef4b6cc2d3 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
|
2013-02-10 19:32:29 +01: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]
|
2013-02-10 19:32:29 +01:00
|
|
|
[AF: Rebased onto upstream VMDK SCSI support]
|
2013-12-08 06:19:09 +01:00
|
|
|
[AF: Rebased onto skipping of image creation in v1.7]
|
2014-02-06 17:09:22 +01:00
|
|
|
[AF: Simplified in preparation for v1.7.1/v2.0]
|
2014-07-11 18:51:43 +02:00
|
|
|
[AF: Rebased onto QemuOpts conversion for v2.1]
|
2012-08-17 18:42:52 +02:00
|
|
|
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
2011-02-16 20:30:51 +01:00
|
|
|
---
|
2014-07-11 18:51:43 +02:00
|
|
|
block.c | 3 +++
|
|
|
|
block/vmdk.c | 10 +++++++++-
|
|
|
|
include/block/block_int.h | 2 ++
|
|
|
|
qemu-img.c | 7 +++++++
|
|
|
|
4 files changed, 21 insertions(+), 1 deletion(-)
|
2011-02-16 20:30:51 +01:00
|
|
|
|
|
|
|
diff --git a/block.c b/block.c
|
2015-04-08 16:42:13 +02:00
|
|
|
index f2f8ae7..0d32442 100644
|
2011-02-16 20:30:51 +01:00
|
|
|
--- a/block.c
|
|
|
|
+++ b/block.c
|
2015-04-08 16:42:13 +02:00
|
|
|
@@ -5813,6 +5813,9 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
2013-05-14 22:46:08 +02:00
|
|
|
if (!quiet) {
|
2015-03-21 12:46:36 +01:00
|
|
|
printf("Formatting '%s', fmt=%s", filename, fmt);
|
|
|
|
qemu_opts_print(opts, " ");
|
2014-07-11 18:51:43 +02:00
|
|
|
+ if (qemu_opt_get_bool(opts, BLOCK_OPT_SCSI, false)) {
|
2013-05-14 22:46:08 +02:00
|
|
|
+ printf(", SCSI");
|
|
|
|
+ }
|
|
|
|
puts("");
|
|
|
|
}
|
2014-07-11 18:51:43 +02:00
|
|
|
|
2011-02-16 20:30:51 +01:00
|
|
|
diff --git a/block/vmdk.c b/block/vmdk.c
|
2015-03-21 12:46:36 +01:00
|
|
|
index 8410a15..2a34dd0 100644
|
2011-02-16 20:30:51 +01:00
|
|
|
--- a/block/vmdk.c
|
|
|
|
+++ b/block/vmdk.c
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -1848,9 +1848,12 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
|
2014-07-11 18:51:43 +02:00
|
|
|
if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ZEROED_GRAIN, false)) {
|
|
|
|
zeroed_grain = true;
|
2011-02-16 20:30:51 +01:00
|
|
|
}
|
2014-07-11 18:51:43 +02:00
|
|
|
+ if (qemu_opt_get_bool_del(opts, BLOCK_OPT_SCSI, false)) {
|
|
|
|
+ flags |= BLOCK_FLAG_SCSI;
|
|
|
|
+ }
|
|
|
|
|
2014-02-06 17:09:22 +01:00
|
|
|
if (!adapter_type) {
|
2014-07-11 18:51:43 +02:00
|
|
|
- adapter_type = g_strdup("ide");
|
|
|
|
+ adapter_type = g_strdup(flags & BLOCK_FLAG_SCSI ? "lsilogic" : "ide");
|
2014-02-06 17:09:22 +01:00
|
|
|
} else if (strcmp(adapter_type, "ide") &&
|
|
|
|
strcmp(adapter_type, "buslogic") &&
|
|
|
|
strcmp(adapter_type, "lsilogic") &&
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -2265,6 +2268,11 @@ static QemuOptsList vmdk_create_opts = {
|
2014-07-11 18:51:43 +02:00
|
|
|
.help = "Enable efficient zero writes "
|
|
|
|
"using the zeroed-grain GTE feature"
|
|
|
|
},
|
|
|
|
+ {
|
|
|
|
+ .name = BLOCK_OPT_SCSI,
|
|
|
|
+ .type = QEMU_OPT_BOOL,
|
|
|
|
+ .help = "SCSI image"
|
|
|
|
+ },
|
|
|
|
{ /* end of list */ }
|
|
|
|
}
|
2011-12-11 03:42:09 +01:00
|
|
|
};
|
2013-02-10 19:32:29 +01:00
|
|
|
diff --git a/include/block/block_int.h b/include/block/block_int.h
|
2015-03-21 12:46:36 +01:00
|
|
|
index dccb092..decca62 100644
|
2013-02-10 19:32:29 +01:00
|
|
|
--- a/include/block/block_int.h
|
|
|
|
+++ b/include/block/block_int.h
|
2015-01-12 19:27:43 +01:00
|
|
|
@@ -41,10 +41,12 @@
|
2012-08-17 18:42:52 +02:00
|
|
|
#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-08-17 18:42:52 +02:00
|
|
|
#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
|
2015-03-21 12:46:36 +01:00
|
|
|
index 9dddfbe..cc8e976 100644
|
2011-02-16 20:30:51 +01:00
|
|
|
--- a/qemu-img.c
|
|
|
|
+++ b/qemu-img.c
|
2015-03-21 12:46:36 +01:00
|
|
|
@@ -1602,6 +1602,13 @@ static int img_convert(int argc, char **argv)
|
2011-02-16 20:30:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-11 18:51:43 +02:00
|
|
|
+ if (qemu_opt_get_bool(opts, BLOCK_OPT_SCSI, false)
|
|
|
|
+ && strcmp(drv->format_name, "vmdk")) {
|
2011-02-16 20:30:51 +01:00
|
|
|
+ error_report("SCSI devices not supported for this file format");
|
|
|
|
+ ret = -1;
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
2013-12-08 06:19:09 +01:00
|
|
|
if (!skip_create) {
|
|
|
|
/* Create the new image */
|
2014-07-11 18:51:43 +02:00
|
|
|
ret = bdrv_create(drv, out_filename, opts, &local_err);
|