|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/4] Allow disk= to specify their emulated bus address
This allows more disks to be suported via emulation.
This can help with Windows finding disks at boot time.
This allows changing config file:
builder = "hvm"
device_model_args_hvm = [
"-device",
"pci-bridge,chassis_nr=4,msi=on,id=pciBridge7.0,multifunction=on,addr=0x17.0",
"-device",
"pvscsi,id=sas1,bus=pciBridge7.0,addr=0x1.0x0",
"-drive",
"if=none,id=disk1-1,format=raw,file=/dev/etherd/e500.2",
"-device",
"scsi-disk,vendor=VMware,ver=1.0,product=Virtual
disk,bus=sas1.0,scsi-id=1,drive=disk1-1",
]
disk = [
]
to:
builder = "hvm"
device_model_args_hvm = [
"-device",
"pci-bridge,chassis_nr=4,msi=on,id=pciBridge7.0,multifunction=on,addr=0x17.0",
"-device",
"pvscsi,id=sas1,bus=pciBridge7.0,addr=0x1.0x0",
]
disk = [
"vdev=xvdb,bus=sas1.0,target=/dev/etherd/e500.2",
]
which allows usage of xen-blkback.
Signed-off-by: Don Slutz <dslutz@xxxxxxxxxxx>
CC: Don Slutz <dslutz@xxxxxxxxxxx>
---
docs/misc/xl-disk-configuration.txt | 25 ++++++
tools/libxl/libxl_dm.c | 171 ++++++++++++++++++++++++++++--------
tools/libxl/libxl_types.idl | 4 +
tools/libxl/libxlu_disk_l.l | 4 +
4 files changed, 167 insertions(+), 37 deletions(-)
diff --git a/docs/misc/xl-disk-configuration.txt
b/docs/misc/xl-disk-configuration.txt
index 6a2118d..99a06b2 100644
--- a/docs/misc/xl-disk-configuration.txt
+++ b/docs/misc/xl-disk-configuration.txt
@@ -178,6 +178,31 @@ information to be interpreted by the executable program
<script>,
These scripts are normally called "block-<script>".
+bus=<bus>
+---------
+
+Specifies that this disk is also to be placed on an emulated
+controller that is configured in 'device_model_args_hvm'.
+
+
+vendor=<vendor>
+---------
+
+Specifies this scsi disk's Vendor string.
+
+
+ver=<ver>
+---------
+
+Specifies this scsi disk's Rev string.
+
+
+product=<product>
+---------
+
+Specifies this scsi disk's Model string.
+
+
direct-io-safe
--------------
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 2bf4dab..1e104d8 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -851,8 +851,6 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
int dev_number =
libxl__device_disk_dev_number(disks[i].vdev, &disk, &part);
const char *format = qemu_disk_format_string(disks[i].format);
- char *drive;
- const char *pdev_path;
if (dev_number == -1) {
LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "unable to determine"
@@ -860,56 +858,155 @@ static int libxl__build_device_model_args_new(libxl__gc
*gc,
continue;
}
- if (disks[i].is_cdrom) {
- if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
- drive = libxl__sprintf
- (gc,
"if=ide,index=%d,media=cdrom,cache=writeback,id=ide-%i",
- disk, dev_number);
- else
- drive = libxl__sprintf
- (gc,
"file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback,id=ide-%i",
- disks[i].pdev_path, disk, format, dev_number);
- } else {
- if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
- LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "cannot support"
- " empty disk format for %s", disks[i].vdev);
- continue;
- }
+ if ((disks[i].bus && disks[i].bus[0]) ||
+ (disks[i].vendor && disks[i].vendor[0]) ||
+ (disks[i].ver && disks[i].ver[0]) ||
+ (disks[i].product && disks[i].product[0])) {
+ char *drive, *device;
+ const char *pdev_path, *bus, *vendor, *ver, *product;
- if (format == NULL) {
- LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "unable to determine"
- " disk image format %s", disks[i].vdev);
- continue;
+ if (disks[i].bus && disks[i].bus[0]) {
+ bus = disks[i].bus;
+ } else {
+ bus = "";
+ }
+ if (disks[i].vendor && disks[i].vendor[0]) {
+ vendor = disks[i].vendor;
+ } else {
+ vendor = "";
+ }
+ if (disks[i].ver && disks[i].ver[0]) {
+ ver = disks[i].ver;
+ } else {
+ ver = "";
+ }
+ if (disks[i].product && disks[i].product[0]) {
+ product = disks[i].product;
+ } else {
+ product = "";
}
- if (disks[i].backend == LIBXL_DISK_BACKEND_TAP) {
- format = qemu_disk_format_string(LIBXL_DISK_FORMAT_RAW);
- pdev_path = libxl__blktap_devpath(gc, disks[i].pdev_path,
- disks[i].format);
+ if (disks[i].is_cdrom) {
+ if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
+ drive = libxl__sprintf
+ (gc,
"if=none,media=cdrom,cache=writeback,id=disk-%i",
+ dev_number);
+ else
+ drive = libxl__sprintf
+ (gc,
"if=none,media=cdrom,format=%s,cache=writeback,id=disk-%i,file=%s",
+ format, dev_number, disks[i].pdev_path);
} else {
- pdev_path = disks[i].pdev_path;
+ if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
+ LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "cannot support"
+ " empty disk format for %s", disks[i].vdev);
+ continue;
+ }
+
+ if (format == NULL) {
+ LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "unable to
determine"
+ " disk image format %s", disks[i].vdev);
+ continue;
+ }
+
+ if (disks[i].backend == LIBXL_DISK_BACKEND_TAP) {
+ format =
qemu_disk_format_string(LIBXL_DISK_FORMAT_RAW);
+ pdev_path = libxl__blktap_devpath(gc,
disks[i].pdev_path,
+ disks[i].format);
+ } else {
+ pdev_path = disks[i].pdev_path;
+ }
+ drive = libxl__sprintf
+ (gc,
"if=none,format=%s,cache=writeback,id=disk-%i,file=%s",
+ format, dev_number, pdev_path);
}
/*
- * Explicit sd disks are passed through as is.
+ * Explicit sd and xvd disks are passed through as is.
*
* For other disks we translate devices 0..3 into
* hd[a-d] and ignore the rest.
*/
- if (strncmp(disks[i].vdev, "sd", 2) == 0)
- drive = libxl__sprintf
- (gc,
"file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=writeback",
- pdev_path, disk, format);
+ if (strncmp(disks[i].vdev, "sd", 2) == 0 ||
+ strncmp(disks[i].vdev, "xvd", 3) == 0)
+ device = libxl__sprintf
+ (gc,
"scsi-hd%s%s%s%s%s%s%s%s,scsi-id=%d,drive=disk-%i",
+ bus[0] ? ",bus=" : "",
+ bus,
+ vendor[0] ? ",vendor=" : "",
+ vendor,
+ ver[0] ? ",ver=" : "",
+ ver,
+ product[0] ? ",product=" : "",
+ product,
+ disk, dev_number);
else if (disk < 4)
- drive = libxl__sprintf
- (gc,
"file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",
- pdev_path, disk, format);
+ device = libxl__sprintf
+ (gc, "ide-hd%s%s,unit=%d,drive=disk-%i",
+ ver[0] ? ",ver=" : "",
+ ver,
+ disk, dev_number);
else
continue; /* Do not emulate this disk */
- }
- flexarray_append(dm_args, "-drive");
- flexarray_append(dm_args, drive);
+ flexarray_append(dm_args, "-drive");
+ flexarray_append(dm_args, drive);
+ flexarray_append(dm_args, "-device");
+ flexarray_append(dm_args, device);
+ } else {
+ char *drive;
+ const char *pdev_path;
+
+ if (disks[i].is_cdrom) {
+ if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
+ drive = libxl__sprintf
+ (gc,
"if=ide,index=%d,media=cdrom,cache=writeback,id=ide-%i",
+ disk, dev_number);
+ else
+ drive = libxl__sprintf
+ (gc,
"file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback,id=ide-%i",
+ disks[i].pdev_path, disk, format, dev_number);
+ } else {
+ if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
+ LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "cannot support"
+ " empty disk format for %s", disks[i].vdev);
+ continue;
+ }
+
+ if (format == NULL) {
+ LIBXL__LOG(ctx, LIBXL__LOG_WARNING, "unable to
determine"
+ " disk image format %s", disks[i].vdev);
+ continue;
+ }
+
+ if (disks[i].backend == LIBXL_DISK_BACKEND_TAP) {
+ format =
qemu_disk_format_string(LIBXL_DISK_FORMAT_RAW);
+ pdev_path = libxl__blktap_devpath(gc,
disks[i].pdev_path,
+ disks[i].format);
+ } else {
+ pdev_path = disks[i].pdev_path;
+ }
+
+ /*
+ * Explicit sd disks are passed through as is.
+ *
+ * For other disks we translate devices 0..3 into
+ * hd[a-d] and ignore the rest.
+ */
+ if (strncmp(disks[i].vdev, "sd", 2) == 0)
+ drive = libxl__sprintf
+ (gc,
"file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=writeback",
+ pdev_path, disk, format);
+ else if (disk < 4)
+ drive = libxl__sprintf
+ (gc,
"file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",
+ pdev_path, disk, format);
+ else
+ continue; /* Do not emulate this disk */
+ }
+
+ flexarray_append(dm_args, "-drive");
+ flexarray_append(dm_args, drive);
+ }
}
switch (b_info->u.hvm.vendor_device) {
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 6d3b058..b2da390 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -507,6 +507,10 @@ libxl_device_disk = Struct("device_disk", [
("backend", libxl_disk_backend),
("format", libxl_disk_format),
("script", string),
+ ("bus", string),
+ ("vendor", string),
+ ("ver", string),
+ ("product", string),
("removable", integer),
("readwrite", integer),
("is_cdrom", integer),
diff --git a/tools/libxl/libxlu_disk_l.l b/tools/libxl/libxlu_disk_l.l
index 1a5deb5..95f1769 100644
--- a/tools/libxl/libxlu_disk_l.l
+++ b/tools/libxl/libxlu_disk_l.l
@@ -173,6 +173,10 @@ backendtype=[^,]*,? { STRIP(',');
setbackendtype(DPC,FROMEQUALS); }
vdev=[^,]*,? { STRIP(','); SAVESTRING("vdev", vdev, FROMEQUALS); }
script=[^,]*,? { STRIP(','); SAVESTRING("script", script, FROMEQUALS); }
+bus=[^,]*,? { STRIP(','); SAVESTRING("bus", bus, FROMEQUALS); }
+vendor=[^,]*,? { STRIP(','); SAVESTRING("vendor", vendor, FROMEQUALS); }
+ver=[^,]*,? { STRIP(','); SAVESTRING("ver", ver, FROMEQUALS); }
+product=[^,]*,? { STRIP(','); SAVESTRING("product", product,
FROMEQUALS); }
direct-io-safe,? { DPC->disk->direct_io_safe = 1; }
discard,? { libxl_defbool_set(&DPC->disk->discard_enable, true); }
no-discard,? { libxl_defbool_set(&DPC->disk->discard_enable, false); }
--
1.8.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |