From patchwork Thu Jan 26 23:46:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Praveen_Paladugu@Dell.com X-Patchwork-Id: 138102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1E2F6B6F68 for ; Fri, 27 Jan 2012 12:50:27 +1100 (EST) Received: from localhost ([::1]:59066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqaHF-0008CT-Oc for incoming@patchwork.ozlabs.org; Thu, 26 Jan 2012 20:06:53 -0500 Received: from eggs.gnu.org ([140.186.70.92]:34830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqZ17-0000q4-Jc for Qemu-devel@nongnu.org; Thu, 26 Jan 2012 18:46:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RqZ16-00036Q-FN for Qemu-devel@nongnu.org; Thu, 26 Jan 2012 18:46:09 -0500 Received: from ausxippc101.us.dell.com ([143.166.85.207]:46695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RqZ16-00036C-C5 for Qemu-devel@nongnu.org; Thu, 26 Jan 2012 18:46:08 -0500 X-Loopcount0: from 10.170.28.39 From: To: Date: Thu, 26 Jan 2012 17:46:01 -0600 Thread-Topic: [PATCH] To support scsi Virtual Adapter while creating VMDK images Thread-Index: AczchKibR+HCLw5OQuGyqvsb114FFg== Message-ID: <0F7A61B0A6ABAD4A82DDEF8CCA0ADA2B4E0906614F@AUSX7MCPS301.AMER.DELL.COM> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 143.166.85.207 X-Mailman-Approved-At: Thu, 26 Jan 2012 20:06:39 -0500 Subject: [Qemu-devel] [PATCH] To support scsi Virtual Adapter while creating VMDK images 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 According to VMDK specification, while using virtual scsi adapter, the value of adapterType has to be set to "lsilogic" or "buslogic". When the user adds "scsi" to the list of qemu-img options (Example: qemu-img create -f vmdk foo -o scsi,size=100M) this patch will set the value of adapterType to "lsilogic". When the "scsi" is not passed, the default "ide" value is used. Signed-off-by: Praveen K Paladugu diff --git a/block.c b/block.c index 3f072f6..2a2e725 100644 --- a/block.c +++ b/block.c @@ -3690,7 +3690,7 @@ int bdrv_img_create(const char *filename, const char *fmt, char *options, uint64_t img_size, int flags) { QEMUOptionParameter *param = NULL, *create_options = NULL; - QEMUOptionParameter *backing_fmt, *backing_file, *size; + QEMUOptionParameter *backing_fmt, *backing_file, *size, *scsi; BlockDriverState *bs = NULL; BlockDriver *drv, *proto_drv; BlockDriver *backing_drv = NULL; @@ -3797,6 +3797,12 @@ int bdrv_img_create(const char *filename, const char *fmt, goto out; } } + scsi = get_option_parameter(param, BLOCK_OPT_SCSI); + if (scsi && scsi->value.n && strcmp(drv->format_name, "vmdk")) { + error_report("SCSI devices not supported for this file format"); + ret = -1; + goto out; + } printf("Formatting '%s', fmt=%s ", filename, fmt); print_option_parameters(param); diff --git a/block/vmdk.c b/block/vmdk.c index 5623ac1..fc1ac65 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1377,7 +1377,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"; if (filename_decompose(filename, path, prefix, postfix, PATH_MAX)) { return -EINVAL; @@ -1390,6 +1390,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; } else if (!strcmp(options->name, BLOCK_OPT_SUBFMT)) { fmt = options->value.s; } @@ -1482,7 +1484,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 * 16 * 512), + (flags & BLOCK_FLAG_SCSI ? "lsilogic" : "ide")); if (split || flat) { fd = open( filename, @@ -1585,6 +1588,12 @@ static QEMUOptionParameter vmdk_create_options[] = { "VMDK flat extent format, can be one of " "{monolithicSparse (default) | monolithicFlat | twoGbMaxExtentSparse | twoGbMaxExtentFlat | streamOptimized} " }, + { + .name = BLOCK_OPT_SCSI, + .type = OPT_FLAG, + .help = "Virtual SCSI Adapter" + }, + { NULL } }; diff --git a/block_int.h b/block_int.h index 311bd2a..5e332fb 100644 --- a/block_int.h +++ b/block_int.h @@ -33,6 +33,7 @@ #define BLOCK_FLAG_ENCRYPT 1 #define BLOCK_FLAG_COMPAT6 4 +#define BLOCK_FLAG_SCSI 8 #define BLOCK_IO_LIMIT_READ 0 #define BLOCK_IO_LIMIT_WRITE 1 @@ -44,6 +45,7 @@ #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"