From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MWXyg-0006Kd-5D for qemu-devel@nongnu.org; Thu, 30 Jul 2009 11:55:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MWXyb-00069i-IL for qemu-devel@nongnu.org; Thu, 30 Jul 2009 11:55:33 -0400 Received: from [199.232.76.173] (port=40651 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MWXyb-00069V-EC for qemu-devel@nongnu.org; Thu, 30 Jul 2009 11:55:29 -0400 Received: from mail-ew0-f210.google.com ([209.85.219.210]:59170) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MWXya-0006YZ-T8 for qemu-devel@nongnu.org; Thu, 30 Jul 2009 11:55:29 -0400 Received: by ewy6 with SMTP id 6so849580ewy.34 for ; Thu, 30 Jul 2009 08:55:27 -0700 (PDT) From: Pantelis Koukousoulas Date: Thu, 30 Jul 2009 18:55:19 +0300 Message-Id: <1248969319-8704-1-git-send-email-pktoss@gmail.com> Subject: [Qemu-devel] [PATCH] Add support for vmware vmdk scsi images to qemu-img List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Pantelis Koukousoulas This adds support to qemu-img for creating vmdk scsi images. (It currently creates only IDE ones). Original version was from Soren Hansen. I just updated it for latest qemu. Tested with latest vmware player (2.5.2) and seems to work well. Signed-off-by: Pantelis Koukousoulas --- block/vmdk.c | 12 ++++++++++-- block_int.h | 2 ++ qemu-img.c | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index f21f02b..6381aa4 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -709,7 +709,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; @@ -724,6 +724,8 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options) backing_file = options->value.s; } else if (!strcmp(options->name, BLOCK_OPT_COMPAT6)) { flags |= options->value.n ? BLOCK_FLAG_COMPAT6: 0; + } else if (!strcmp(options->name, BLOCK_OPT_SCSI)) { + flags |= options->value.n ? BLOCK_FLAG_SCSI: 0; } options++; } @@ -799,7 +801,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); @@ -843,6 +846,11 @@ static QEMUOptionParameter vmdk_create_options[] = { .type = OPT_FLAG, .help = "VMDK version 6 image" }, + { + .name = BLOCK_OPT_SCSI, + .type = OPT_FLAG, + .help = "VMDK scsi image" + }, { NULL } }; diff --git a/block_int.h b/block_int.h index 830b7e9..0311198 100644 --- a/block_int.h +++ b/block_int.h @@ -30,10 +30,12 @@ #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" #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" -- 1.6.3.3