qemu/0010-block-vmdk-Support-creation-of-SCSI.patch
Andreas Färber 04929fcdcd Accepting request 221154 from home:a_faerber:branches:Virtualization
Add xen_disk discard support (olh), backport VMDK SCSI change from v1.6.2 maintenance update and update syscall numbers

OBS-URL: https://build.opensuse.org/request/show/221154
OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=179
2014-02-06 16:09:22 +00:00

120 lines
4.4 KiB
Diff

From d281dbef7cffee850d5445357affb5e0420ceffe Mon Sep 17 00:00:00 2001
From: Ulrich Hecht <uli@suse.de>
Date: Tue, 14 Apr 2009 16:37:42 +0200
Subject: [PATCH] block/vmdk: Support creation of SCSI VMDK images in qemu-img
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Ulrich Hecht <uli@suse.de>
[AF: Changed BLOCK_FLAG_SCSI from 8 to 16 for v1.2]
[AF: Rebased onto upstream VMDK SCSI support]
[AF: Rebased onto skipping of image creation in v1.7]
[AF: Simplified in preparation for v1.7.1/v2.0]
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
block.c | 6 +++++-
block/vmdk.c | 9 ++++++++-
include/block/block_int.h | 2 ++
qemu-img.c | 8 +++++++-
4 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index 382ea71..7c89d4e 100644
--- a/block.c
+++ b/block.c
@@ -4503,7 +4503,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
Error **errp, bool quiet)
{
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;
@@ -4617,6 +4617,10 @@ void bdrv_img_create(const char *filename, const char *fmt,
if (!quiet) {
printf("Formatting '%s', fmt=%s ", filename, fmt);
print_option_parameters(param);
+ scsi = get_option_parameter(param, BLOCK_OPT_SCSI);
+ if (scsi && scsi->value.n) {
+ printf(", SCSI");
+ }
puts("");
}
ret = bdrv_create(drv, filename, param, &local_err);
diff --git a/block/vmdk.c b/block/vmdk.c
index a7ebd0f..818f7a0 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1641,11 +1641,13 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
fmt = options->value.s;
} else if (!strcmp(options->name, BLOCK_OPT_ZEROED_GRAIN)) {
zeroed_grain |= options->value.n;
+ } else if (!strcmp(options->name, BLOCK_OPT_SCSI)) {
+ flags |= options->value.n ? BLOCK_FLAG_SCSI: 0;
}
options++;
}
if (!adapter_type) {
- adapter_type = "ide";
+ adapter_type = flags & BLOCK_FLAG_SCSI ? "lsilogic" : "ide";
} else if (strcmp(adapter_type, "ide") &&
strcmp(adapter_type, "buslogic") &&
strcmp(adapter_type, "lsilogic") &&
@@ -1926,6 +1928,11 @@ static QEMUOptionParameter vmdk_create_options[] = {
.type = OPT_FLAG,
.help = "Enable efficient zero writes using the zeroed-grain GTE feature"
},
+ {
+ .name = BLOCK_OPT_SCSI,
+ .type = OPT_FLAG,
+ .help = "SCSI image"
+ },
{ NULL }
};
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 1666066..9895b61 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -40,10 +40,12 @@
#define BLOCK_FLAG_ENCRYPT 1
#define BLOCK_FLAG_COMPAT6 4
#define BLOCK_FLAG_LAZY_REFCOUNTS 8
+#define BLOCK_FLAG_SCSI 16
#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"
diff --git a/qemu-img.c b/qemu-img.c
index b6b5644..98ee71a 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1133,7 +1133,7 @@ static int img_convert(int argc, char **argv)
const uint8_t *buf1;
BlockDriverInfo bdi;
QEMUOptionParameter *param = NULL, *create_options = NULL;
- QEMUOptionParameter *out_baseimg_param;
+ QEMUOptionParameter *out_baseimg_param, *scsi;
char *options = NULL;
const char *snapshot_name = NULL;
float local_progress = 0;
@@ -1340,6 +1340,12 @@ static int img_convert(int argc, char **argv)
}
}
+ if ((scsi = get_option_parameter(param, BLOCK_OPT_SCSI)) && scsi->value.n && strcmp(drv->format_name, "vmdk")) {
+ error_report("SCSI devices not supported for this file format");
+ ret = -1;
+ goto out;
+ }
+
if (!skip_create) {
/* Create the new image */
ret = bdrv_create(drv, out_filename, param, &local_err);