From afdac5e4c878653b9f4a038bebdcf98a01397a39 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Tue, 14 Apr 2009 16:37:42 +0200 Subject: [PATCH 11/16] qemu-img-vmdk-scsi Support creation of SCSI VMDK images in qemu-img. Signed-off-by: Ulrich Hecht --- 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 9a3b2e0..85e8a72 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 641bd87..949ae97 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -16,9 +16,9 @@ STEXI ETEXI DEF("create", img_create, - "create [-f fmt] [-o options] filename [size]") + "create [-s] [-f fmt] [-o options] filename [size]") STEXI -@item create [-f @var{fmt}] [-o @var{options}] @var{filename} [@var{size}] +@item create [-s] [-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] filename [filename2 [...]] output_filename") + "convert [-c] [-s] [-f fmt] [-O output_fmt] [-o options] filename [filename2 [...]] output_filename") STEXI -@item convert [-c] [-f @var{fmt}] [-O @var{output_fmt}] [-o @var{options}] @var{filename} [@var{filename2} [...]] @var{output_filename} +@item convert [-c] [-s] [-f @var{fmt}] [-O @var{output_fmt}] [-o @var{options}] @var{filename} [@var{filename2} [...]] @var{output_filename} ETEXI DEF("info", img_info, diff --git a/qemu-img.c b/qemu-img.c index 2824178..4b6663f 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -253,7 +253,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) { @@ -272,6 +272,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; @@ -354,6 +357,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); @@ -548,7 +553,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) { @@ -570,6 +575,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; @@ -637,6 +645,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.4.2