From: Kevin Wolf <kwolf@suse.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] qemu-img: Create SCSI VMDK disks
Date: Tue, 22 Apr 2008 17:57:16 +0200 [thread overview]
Message-ID: <480E0ADC.8010000@suse.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 254 bytes --]
This patch introduces a new option to qemu-img: -s indicates for VMDK
images that the image is meant to be used as SCSI disk. Depending on
the switch "ide" or "buslogic" is written to the image as adapter type.
Signed-off-by: Kevin Wolf <kwolf@suse.de>
[-- Attachment #2: qemu-img-vmdk-scsi.patch --]
[-- Type: text/x-patch, Size: 4804 bytes --]
Index: qemu-svn/block-vmdk.c
===================================================================
--- qemu-svn.orig/block-vmdk.c
+++ qemu-svn/block-vmdk.c
@@ -719,7 +719,7 @@ static int vmdk_create(const char *filen
"ddb.geometry.cylinders = \"%lu\"\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;
@@ -792,7 +792,9 @@ static int vmdk_create(const char *filen
if ((temp_str = strrchr(real_filename, ':')) != NULL)
real_filename = temp_str + 1;
sprintf(desc, desc_template, time(NULL), (unsigned long)total_size,
- real_filename, (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), total_size / (63 * 16));
+ real_filename, (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4),
+ total_size / (63 * 16),
+ flags & BLOCK_FLAG_SCSI ? "buslogic" : "ide");
/* write the descriptor */
lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET);
Index: qemu-svn/qemu-img.c
===================================================================
--- qemu-svn.orig/qemu-img.c
+++ qemu-svn/qemu-img.c
@@ -53,9 +53,9 @@ static void help(void)
"QEMU disk image utility\n"
"\n"
"Command syntax:\n"
- " create [-e] [-6] [-b base_image] [-f fmt] filename [size]\n"
+ " create [-e] [-s] [-6] [-b base_image] [-f fmt] filename [size]\n"
" commit [-f fmt] filename\n"
- " convert [-c] [-e] [-6] [-f fmt] [-O output_fmt] filename [filename2 [...]] output_filename\n"
+ " convert [-c] [-e] [-s] [-6] [-f fmt] [-O output_fmt] filename [filename2 [...]] output_filename\n"
" info [-f fmt] filename\n"
"\n"
"Command parameters:\n"
@@ -69,6 +69,7 @@ static void help(void)
" 'output_fmt' is the destination format\n"
" '-c' indicates that target image must be compressed (qcow format only)\n"
" '-e' indicates that the target image must be encrypted (qcow format only)\n"
+ " '-s' indicates that the target image is meant for SCSI (vmdk format only)\n"
" '-6' indicates that the target image must use compatibility level 6 (vmdk format only)\n"
);
printf("\nSupported format:");
@@ -207,7 +208,7 @@ static int img_create(int argc, char **a
flags = 0;
for(;;) {
- c = getopt(argc, argv, "b:f:he6");
+ c = getopt(argc, argv, "b:f:hes6");
if (c == -1)
break;
switch(c) {
@@ -223,6 +224,9 @@ static int img_create(int argc, char **a
case 'e':
flags |= BLOCK_FLAG_ENCRYPT;
break;
+ case 's':
+ flags |= BLOCK_FLAG_SCSI;
+ break;
case '6':
flags |= BLOCK_FLAG_COMPAT6;
break;
@@ -258,6 +262,8 @@ static int img_create(int argc, char **a
error("Unknown file format '%s'", fmt);
printf("Formatting '%s', fmt=%s",
filename, fmt);
+ if (flags & BLOCK_FLAG_SCSI)
+ printf(", SCSI");
if (flags & BLOCK_FLAG_ENCRYPT)
printf(", encrypted");
if (flags & BLOCK_FLAG_COMPAT6)
@@ -386,7 +392,7 @@ static int img_convert(int argc, char **
out_fmt = "raw";
flags = 0;
for(;;) {
- c = getopt(argc, argv, "f:O:hce6");
+ c = getopt(argc, argv, "f:O:hces6");
if (c == -1)
break;
switch(c) {
@@ -405,6 +411,9 @@ static int img_convert(int argc, char **
case 'e':
flags |= BLOCK_FLAG_ENCRYPT;
break;
+ case 's':
+ flags |= BLOCK_FLAG_SCSI;
+ break;
case '6':
flags |= BLOCK_FLAG_COMPAT6;
break;
@@ -436,6 +445,8 @@ static int img_convert(int argc, char **
error("Compression not supported for this file format");
if (flags & BLOCK_FLAG_ENCRYPT && drv != &bdrv_qcow && drv != &bdrv_qcow2)
error("Encryption not supported for this file format");
+ if (flags & BLOCK_FLAG_SCSI && drv != &bdrv_vmdk)
+ error("SCSI devices not supported for this file format");
if (flags & BLOCK_FLAG_COMPAT6 && drv != &bdrv_vmdk)
error("Alternative compatibility level not supported for this file format");
if (flags & BLOCK_FLAG_ENCRYPT && flags & BLOCK_FLAG_COMPRESS)
Index: qemu-svn/block_int.h
===================================================================
--- qemu-svn.orig/block_int.h
+++ qemu-svn/block_int.h
@@ -29,6 +29,7 @@
#define BLOCK_FLAG_ENCRYPT 1
#define BLOCK_FLAG_COMPRESS 2
#define BLOCK_FLAG_COMPAT6 4
+#define BLOCK_FLAG_SCSI 8
struct BlockDriver {
const char *format_name;
next reply other threads:[~2008-04-22 16:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-22 15:57 Kevin Wolf [this message]
2008-04-23 20:18 ` [Qemu-devel] Re: [PATCH] qemu-img: Create SCSI VMDK disks Sebastian Herbszt
2008-04-24 6:05 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=480E0ADC.8010000@suse.de \
--to=kwolf@suse.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).