1 From 5483df4df2729a5d1e4888a48039b1cd90438480 Mon Sep 17 00:00:00 2001
2 From: Othmar Pasteka <pasteka@kabsi.at>
3 Date: Wed, 30 Jan 2013 00:26:52 +0100
4 Subject: [PATCH 12/12] vmdk: Allow selecting SCSI adapter in image creation
6 Introduce a new option "adapter_type" when converting to vmdk images.
7 It can be one of the following: ide (default), buslogic, lsilogic
8 or legacyESX (according to the vmdk spec from vmware).
10 In case of a non-ide adapter, heads is set to 255 instead of the 16.
11 The latter is used for "ide".
15 Signed-off-by: Othmar Pasteka <pasteka@kabsi.at>
16 Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
18 block/vmdk.c | 31 ++++++++++++++++++++++++++++---
20 2 files changed, 29 insertions(+), 3 deletions(-)
24 @@ -1089,6 +1089,7 @@ static int vmdk_create(const char *filen
27 int64_t total_size = 0, filesize;
28 + const char *adapter_type = NULL;
29 const char *backing_file = NULL;
30 const char *fmt = NULL;
32 @@ -1100,6 +1101,7 @@ static int vmdk_create(const char *filen
33 const char *desc_extent_line;
34 char parent_desc_line[BUF_SIZE] = "";
35 uint32_t parent_cid = 0xffffffff;
36 + uint32_t number_heads = 16;
37 const char desc_template[] =
38 "# Disk DescriptorFile\n"
40 @@ -1116,9 +1118,9 @@ static int vmdk_create(const char *filen
42 "ddb.virtualHWVersion = \"%d\"\n"
43 "ddb.geometry.cylinders = \"%" PRId64 "\"\n"
44 - "ddb.geometry.heads = \"16\"\n"
45 + "ddb.geometry.heads = \"%d\"\n"
46 "ddb.geometry.sectors = \"63\"\n"
47 - "ddb.adapterType = \"ide\"\n";
48 + "ddb.adapterType = \"%s\"\n";
50 if (filename_decompose(filename, path, prefix, postfix, PATH_MAX)) {
52 @@ -1127,6 +1129,8 @@ static int vmdk_create(const char *filen
53 while (options && options->name) {
54 if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
55 total_size = options->value.n;
56 + } else if (!strcmp(options->name, BLOCK_OPT_ADAPTER_TYPE)) {
57 + adapter_type = options->value.s;
58 } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) {
59 backing_file = options->value.s;
60 } else if (!strcmp(options->name, BLOCK_OPT_COMPAT6)) {
61 @@ -1136,6 +1140,20 @@ static int vmdk_create(const char *filen
65 + if (!adapter_type) {
66 + adapter_type = "ide";
67 + } else if (strcmp(adapter_type, "ide") &&
68 + strcmp(adapter_type, "buslogic") &&
69 + strcmp(adapter_type, "lsilogic") &&
70 + strcmp(adapter_type, "legacyESX")) {
71 + fprintf(stderr, "VMDK: Unknown adapter type: '%s'.\n", adapter_type);
74 + if (strcmp(adapter_type, "ide") != 0) {
75 + /* that's the number of heads with which vmware operates when
76 + creating, exporting, etc. vmdk files with a non-ide adapter type */
80 /* Default format to monolithicSparse */
81 fmt = "monolithicSparse";
82 @@ -1222,7 +1240,8 @@ static int vmdk_create(const char *filen
85 (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
86 - total_size / (int64_t)(63 * 16 * 512));
87 + total_size / (int64_t)(63 * number_heads * 512), number_heads,
92 @@ -1281,6 +1300,12 @@ static QEMUOptionParameter vmdk_create_o
93 .help = "Virtual disk size"
96 + .name = BLOCK_OPT_ADAPTER_TYPE,
98 + .help = "Virtual adapter type, can be one of "
99 + "ide (default), lsilogic, buslogic or legacyESX"
102 .name = BLOCK_OPT_BACKING_FILE,
104 .help = "File name of a base image"
108 #define BLOCK_OPT_TABLE_SIZE "table_size"
109 #define BLOCK_OPT_PREALLOC "preallocation"
110 #define BLOCK_OPT_SUBFMT "subformat"
111 +#define BLOCK_OPT_ADAPTER_TYPE "adapter_type"
113 typedef struct AIOPool {
114 void (*cancel)(BlockDriverAIOCB *acb);