From patchwork Mon Jan 28 22:56:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Othmar Pasteka X-Patchwork-Id: 216391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 262732C0098 for ; Tue, 29 Jan 2013 10:00:31 +1100 (EST) Received: from localhost ([::1]:48663 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tzxgj-0006oa-UE for incoming@patchwork.ozlabs.org; Mon, 28 Jan 2013 18:00:29 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tzxga-0006n6-Hp for qemu-devel@nongnu.org; Mon, 28 Jan 2013 18:00:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TzxgX-0006wy-Bb for qemu-devel@nongnu.org; Mon, 28 Jan 2013 18:00:20 -0500 Received: from fep28.mx.upcmail.net ([62.179.121.48]:44946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzxgX-0006w6-0u for qemu-devel@nongnu.org; Mon, 28 Jan 2013 18:00:17 -0500 Received: from edge02.upcmail.net ([192.168.13.237]) by viefep28-int.chello.at (InterMail vM.8.01.05.05 201-2260-151-110-20120111) with ESMTP id <20130128230013.RKPX29590.viefep28-int.chello.at@edge02.upcmail.net>; Tue, 29 Jan 2013 00:00:13 +0100 Received: from raffael.tron.at ([212.17.108.125]) by edge02.upcmail.net with edge id tb2t1k02C2iMpaC01b2uZp; Tue, 29 Jan 2013 00:02:54 +0100 X-SourceIP: 212.17.108.125 Received: by raffael.tron.at (Postfix, from userid 1000) id 9798B3002E5; Mon, 28 Jan 2013 23:57:10 +0100 (CET) From: Othmar Pasteka To: qemu-devel@nongnu.org Date: Mon, 28 Jan 2013 23:56:47 +0100 Message-Id: <1359413807-5139-1-git-send-email-pasteka@kabsi.at> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 62.179.121.48 Cc: kwolf@redhat.com, Othmar Pasteka , stefanha@redhat.com Subject: [Qemu-devel] [PATCH] vmdk: Allow selecting SCSI adapter in image creation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Introduce a new option "adapter_type" when converting to vmdk images. It can be one of the following: ide (default), buslogic, lsilogic or legacyESX (according to the vmdk spec from vmware). In case of a non-ide adapter, heads is set to 255 instead of the 16. The latter is used for "ide". Also see LP#545089 Signed-off-by: Othmar Pasteka --- block/vmdk.c | 31 ++++++++++++++++++++++++++++--- include/block/block_int.h | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 19298c2..2a84e1d 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1442,6 +1442,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) int fd, idx = 0; char desc[BUF_SIZE]; int64_t total_size = 0, filesize; + const char *adapter_type = NULL; const char *backing_file = NULL; const char *fmt = NULL; int flags = 0; @@ -1453,6 +1454,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) const char *desc_extent_line; char parent_desc_line[BUF_SIZE] = ""; uint32_t parent_cid = 0xffffffff; +uint32_t number_heads = 16; const char desc_template[] = "# Disk DescriptorFile\n" "version=1\n" @@ -1469,9 +1471,9 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) "\n" "ddb.virtualHWVersion = \"%d\"\n" "ddb.geometry.cylinders = \"%" PRId64 "\"\n" - "ddb.geometry.heads = \"16\"\n" + "ddb.geometry.heads = \"%d\"\n" "ddb.geometry.sectors = \"63\"\n" - "ddb.adapterType = \"ide\"\n"; + "ddb.adapterType = \"%s\"\n"; if (filename_decompose(filename, path, prefix, postfix, PATH_MAX)) { return -EINVAL; @@ -1480,6 +1482,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { total_size = options->value.n; + } else if (!strcmp(options->name, BLOCK_OPT_ADAPTER_TYPE)) { + adapter_type = options->value.s; } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) { backing_file = options->value.s; } else if (!strcmp(options->name, BLOCK_OPT_COMPAT6)) { @@ -1489,6 +1493,20 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) } options++; } + if (!adapter_type) { + adapter_type = "ide"; + } else if (strcmp(adapter_type, "ide") && + strcmp(adapter_type, "buslogic") && + strcmp(adapter_type, "lsilogic") && + strcmp(adapter_type, "legacyESX")) { + fprintf(stderr, "VMDK: Unknown adapter type: '%s'.\n", adapter_type); + return -EINVAL; + } + if (strcmp(adapter_type, "ide") != 0) { + /* that's the number of heads with which vmware operates when + creating, exporting, etc. vmdk files with a non-ide adapter type */ + number_heads = 255; + } if (!fmt) { /* Default format to monolithicSparse */ fmt = "monolithicSparse"; @@ -1576,7 +1594,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) parent_desc_line, ext_desc_lines, (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), - total_size / (int64_t)(63 * 16 * 512)); + total_size / (int64_t)(63 * number_heads * 512), number_heads, + adapter_type); if (split || flat) { fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, @@ -1661,6 +1680,12 @@ static QEMUOptionParameter vmdk_create_options[] = { .help = "Virtual disk size" }, { + .name = BLOCK_OPT_ADAPTER_TYPE, + .type = OPT_STRING, + .help = "Virtual adapter type can be one of " + "ide (default), lsilogic, buslogic or legacyESX" + }, + { .name = BLOCK_OPT_BACKING_FILE, .type = OPT_STRING, .help = "File name of a base image" diff --git a/include/block/block_int.h b/include/block/block_int.h index f83ffb8..6040c67 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -55,6 +55,7 @@ #define BLOCK_OPT_SUBFMT "subformat" #define BLOCK_OPT_COMPAT_LEVEL "compat" #define BLOCK_OPT_LAZY_REFCOUNTS "lazy_refcounts" +#define BLOCK_OPT_ADAPTER_TYPE "adapter_type" typedef struct BdrvTrackedRequest BdrvTrackedRequest;