143 lines
4.9 KiB
Diff
143 lines
4.9 KiB
Diff
|
From 75e8da1c5ca1b61a9a97fcc385eb5c6b9f83130f Mon Sep 17 00:00:00 2001
|
||
|
From: Ulrich Hecht <uli@suse.de>
|
||
|
Date: Tue, 14 Apr 2009 16:37:42 +0200
|
||
|
Subject: [PATCH 13/33] qemu-img-vmdk-scsi
|
||
|
|
||
|
Support creation of SCSI VMDK images in qemu-img.
|
||
|
|
||
|
Signed-off-by: Ulrich Hecht <uli@suse.de>
|
||
|
---
|
||
|
block/vmdk.c | 5 +++--
|
||
|
block_int.h | 1 +
|
||
|
qemu-img-cmds.hx | 8 ++++----
|
||
|
qemu-img.c | 15 +++++++++++++--
|
||
|
4 files changed, 21 insertions(+), 8 deletions(-)
|
||
|
|
||
|
diff --git a/block/vmdk.c b/block/vmdk.c
|
||
|
index 4e48622..b7a15c7 100644
|
||
|
--- a/block/vmdk.c
|
||
|
+++ b/block/vmdk.c
|
||
|
@@ -710,7 +710,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";
|
||
|
char desc[1024];
|
||
|
const char *real_filename, *temp_str;
|
||
|
int64_t total_size = 0;
|
||
|
@@ -800,7 +800,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options)
|
||
|
snprintf(desc, sizeof(desc), desc_template, (unsigned int)time(NULL),
|
||
|
total_size, real_filename,
|
||
|
(flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
|
||
|
- total_size / (int64_t)(63 * 16));
|
||
|
+ total_size / (int64_t)(63 * 16),
|
||
|
+ flags & BLOCK_FLAG_SCSI ? "lsilogic" : "ide");
|
||
|
|
||
|
/* write the descriptor */
|
||
|
lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET);
|
||
|
diff --git a/block_int.h b/block_int.h
|
||
|
index 8898d91..d482050 100644
|
||
|
--- a/block_int.h
|
||
|
+++ b/block_int.h
|
||
|
@@ -30,6 +30,7 @@
|
||
|
#define BLOCK_FLAG_ENCRYPT 1
|
||
|
#define BLOCK_FLAG_COMPRESS 2
|
||
|
#define BLOCK_FLAG_COMPAT6 4
|
||
|
+#define BLOCK_FLAG_SCSI 8
|
||
|
|
||
|
#define BLOCK_OPT_SIZE "size"
|
||
|
#define BLOCK_OPT_ENCRYPT "encryption"
|
||
|
diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
|
||
|
index ddb86f0..be94d22 100644
|
||
|
--- a/qemu-img-cmds.hx
|
||
|
+++ b/qemu-img-cmds.hx
|
||
|
@@ -16,9 +16,9 @@ STEXI
|
||
|
ETEXI
|
||
|
|
||
|
DEF("create", img_create,
|
||
|
- "create [-F fmt] [-b base_image] [-f fmt] [-o options] filename [size]")
|
||
|
+ "create [-s] [-F fmt] [-b base_image] [-f fmt] [-o options] filename [size]")
|
||
|
STEXI
|
||
|
-@item create [-F @var{base_fmt}] [-b @var{base_image}] [-f @var{fmt}] [-o @var{options}] @var{filename} [@var{size}]
|
||
|
+@item create [-s] [-F @var{base_fmt}] [-b @var{base_image}] [-f @var{fmt}] [-o @var{options}] @var{filename} [@var{size}]
|
||
|
ETEXI
|
||
|
|
||
|
DEF("commit", img_commit,
|
||
|
@@ -28,9 +28,9 @@ STEXI
|
||
|
ETEXI
|
||
|
|
||
|
DEF("convert", img_convert,
|
||
|
- "convert [-c] [-f fmt] [-O output_fmt] [-o options] [-B output_base_image] filename [filename2 [...]] output_filename")
|
||
|
+ "convert [-c] [-s] [-f fmt] [-O output_fmt] [-o options] [-B output_base_image] filename [filename2 [...]] output_filename")
|
||
|
STEXI
|
||
|
-@item convert [-c] [-f @var{fmt}] [-O @var{output_fmt}] [-o @var{options}] [-B @var{output_base_image}] @var{filename} [@var{filename2} [...]] @var{output_filename}
|
||
|
+@item convert [-c] [-s] [-f @var{fmt}] [-O @var{output_fmt}] [-o @var{options}] [-B @var{output_base_image}] @var{filename} [@var{filename2} [...]] @var{output_filename}
|
||
|
ETEXI
|
||
|
|
||
|
DEF("info", img_info,
|
||
|
diff --git a/qemu-img.c b/qemu-img.c
|
||
|
index 070fe2e..2adeb56 100644
|
||
|
--- a/qemu-img.c
|
||
|
+++ b/qemu-img.c
|
||
|
@@ -259,7 +259,7 @@ static int img_create(int argc, char **argv)
|
||
|
|
||
|
flags = 0;
|
||
|
for(;;) {
|
||
|
- c = getopt(argc, argv, "F:b:f:he6o:");
|
||
|
+ c = getopt(argc, argv, "F:b:f:hes6o:");
|
||
|
if (c == -1)
|
||
|
break;
|
||
|
switch(c) {
|
||
|
@@ -278,6 +278,9 @@ static int img_create(int argc, char **argv)
|
||
|
case 'e':
|
||
|
flags |= BLOCK_FLAG_ENCRYPT;
|
||
|
break;
|
||
|
+ case 's':
|
||
|
+ flags |= BLOCK_FLAG_SCSI;
|
||
|
+ break;
|
||
|
case '6':
|
||
|
flags |= BLOCK_FLAG_COMPAT6;
|
||
|
break;
|
||
|
@@ -357,6 +360,8 @@ static int img_create(int argc, char **argv)
|
||
|
|
||
|
printf("Formatting '%s', fmt=%s ", filename, fmt);
|
||
|
print_option_parameters(param);
|
||
|
+ if (flags & BLOCK_FLAG_SCSI)
|
||
|
+ printf(", SCSI");
|
||
|
puts("");
|
||
|
|
||
|
ret = bdrv_create(drv, filename, param);
|
||
|
@@ -551,7 +556,7 @@ static int img_convert(int argc, char **argv)
|
||
|
out_baseimg = NULL;
|
||
|
flags = 0;
|
||
|
for(;;) {
|
||
|
- c = getopt(argc, argv, "f:O:B:hce6o:");
|
||
|
+ c = getopt(argc, argv, "f:O:B:hces6o:");
|
||
|
if (c == -1)
|
||
|
break;
|
||
|
switch(c) {
|
||
|
@@ -573,6 +578,9 @@ static int img_convert(int argc, char **argv)
|
||
|
case 'e':
|
||
|
flags |= BLOCK_FLAG_ENCRYPT;
|
||
|
break;
|
||
|
+ case 's':
|
||
|
+ flags |= BLOCK_FLAG_SCSI;
|
||
|
+ break;
|
||
|
case '6':
|
||
|
flags |= BLOCK_FLAG_COMPAT6;
|
||
|
break;
|
||
|
@@ -639,6 +647,9 @@ static int img_convert(int argc, char **argv)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
+ if (flags & BLOCK_FLAG_SCSI && strcmp(drv->format_name, "vmdk"))
|
||
|
+ error("SCSI devices not supported for this file format");
|
||
|
+
|
||
|
/* Create the new image */
|
||
|
ret = bdrv_create(drv, out_filename, param);
|
||
|
free_option_parameters(param);
|
||
|
--
|
||
|
1.6.2.1
|
||
|
|