[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Provide the use of SCSI disks in HVM domains. Currently there is a
# HG changeset patch # User kfraser@xxxxxxxxxxxxxxxxxxxxx # Date 1176302629 -3600 # Node ID 0d92cd901f809ce898c7c62008cf446a0b295c1c # Parent 6cd828db1a5defcc6267e502d946a47929a8c0a9 Provide the use of SCSI disks in HVM domains. Currently there is a maximum of 7 scsi disks and an ide disk must still be used to boot. Signed-off-by: Natasha Jarymowycz <natasha@xxxxxxxxxx> Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> --- tools/ioemu/hw/pc.c | 12 ++ tools/ioemu/vl.c | 2 tools/ioemu/vl.h | 5 - tools/ioemu/xenstore.c | 214 ++++++++++++++++++++++++------------------------- 4 files changed, 123 insertions(+), 110 deletions(-) diff -r 6cd828db1a5d -r 0d92cd901f80 tools/ioemu/hw/pc.c --- a/tools/ioemu/hw/pc.c Wed Apr 11 15:36:04 2007 +0100 +++ b/tools/ioemu/hw/pc.c Wed Apr 11 15:43:49 2007 +0100 @@ -902,7 +902,6 @@ static void pc_init1(uint64_t ram_size, if (pci_enabled && acpi_enabled) { piix4_pm_init(pci_bus, piix3_devfn + 3); } -#endif /* !CONFIG_DM */ #if 0 /* ??? Need to figure out some way for the user to @@ -921,6 +920,17 @@ static void pc_init1(uint64_t ram_size, lsi_scsi_attach(scsi, bdrv, -1); } #endif +#else + if (pci_enabled) { + void *scsi; + + scsi = lsi_scsi_init(pci_bus, -1); + for (i = 0; i < MAX_SCSI_DISKS ; i++) { + if (bs_table[i + MAX_DISKS]) + lsi_scsi_attach(scsi, bs_table[i + MAX_DISKS], -1); + } + } +#endif /* !CONFIG_DM */ /* must be done after all PCI devices are instanciated */ /* XXX: should be done in the Bochs BIOS */ if (pci_enabled) { diff -r 6cd828db1a5d -r 0d92cd901f80 tools/ioemu/vl.c --- a/tools/ioemu/vl.c Wed Apr 11 15:36:04 2007 +0100 +++ b/tools/ioemu/vl.c Wed Apr 11 15:43:49 2007 +0100 @@ -116,7 +116,7 @@ void *ioport_opaque[MAX_IOPORTS]; void *ioport_opaque[MAX_IOPORTS]; IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS]; IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS]; -BlockDriverState *bs_table[MAX_DISKS], *fd_table[MAX_FD]; +BlockDriverState *bs_table[MAX_DISKS+MAX_SCSI_DISKS], *fd_table[MAX_FD]; int vga_ram_size; int bios_size; static DisplayState display_state; diff -r 6cd828db1a5d -r 0d92cd901f80 tools/ioemu/vl.h --- a/tools/ioemu/vl.h Wed Apr 11 15:36:04 2007 +0100 +++ b/tools/ioemu/vl.h Wed Apr 11 15:43:49 2007 +0100 @@ -818,8 +818,9 @@ int vnc_start_viewer(int port); /* ide.c */ #define MAX_DISKS 4 - -extern BlockDriverState *bs_table[MAX_DISKS]; +#define MAX_SCSI_DISKS 7 + +extern BlockDriverState *bs_table[MAX_DISKS+MAX_SCSI_DISKS]; void isa_ide_init(int iobase, int iobase2, int irq, BlockDriverState *hd0, BlockDriverState *hd1); diff -r 6cd828db1a5d -r 0d92cd901f80 tools/ioemu/xenstore.c --- a/tools/ioemu/xenstore.c Wed Apr 11 15:36:04 2007 +0100 +++ b/tools/ioemu/xenstore.c Wed Apr 11 15:43:49 2007 +0100 @@ -30,11 +30,11 @@ static int pasprintf(char **buf, const c int ret = 0; if (*buf) - free(*buf); + free(*buf); va_start(ap, fmt); if (vasprintf(buf, fmt, ap) == -1) { - buf = NULL; - ret = -1; + buf = NULL; + ret = -1; } va_end(ap); return ret; @@ -45,11 +45,11 @@ static void insert_media(void *opaque) int i; for (i = 0; i < MAX_DISKS; i++) { - if (media_filename[i] && bs_table[i]) { - do_change(bs_table[i]->device_name, media_filename[i]); - free(media_filename[i]); - media_filename[i] = NULL; - } + if (media_filename[i] && bs_table[i]) { + do_change(bs_table[i]->device_name, media_filename[i]); + free(media_filename[i]); + media_filename[i] = NULL; + } } } @@ -57,7 +57,7 @@ void xenstore_check_new_media_present(in { if (insert_timer == NULL) - insert_timer = qemu_new_timer(rt_clock, insert_media, NULL); + insert_timer = qemu_new_timer(rt_clock, insert_media, NULL); qemu_mod_timer(insert_timer, qemu_get_clock(rt_clock) + timeout); } @@ -82,8 +82,8 @@ void xenstore_parse_domain_config(int do char **e = NULL; char *buf = NULL, *path; char *fpath = NULL, *bpath = NULL, - *dev = NULL, *params = NULL, *type = NULL; - int i; + *dev = NULL, *params = NULL, *type = NULL; + int i, is_scsi; unsigned int len, num, hd_index; for(i = 0; i < MAX_DISKS; i++) @@ -91,8 +91,8 @@ void xenstore_parse_domain_config(int do xsh = xs_daemon_open(); if (xsh == NULL) { - fprintf(logfile, "Could not contact xenstore for domain config\n"); - return; + fprintf(logfile, "Could not contact xenstore for domain config\n"); + return; } path = xs_get_domain_path(xsh, domid); @@ -102,59 +102,60 @@ void xenstore_parse_domain_config(int do } if (pasprintf(&buf, "%s/device/vbd", path) == -1) - goto out; + goto out; e = xs_directory(xsh, XBT_NULL, buf, &num); if (e == NULL) - goto out; + goto out; for (i = 0; i < num; i++) { - /* read the backend path */ - if (pasprintf(&buf, "%s/device/vbd/%s/backend", path, e[i]) == -1) - continue; - free(bpath); + /* read the backend path */ + if (pasprintf(&buf, "%s/device/vbd/%s/backend", path, e[i]) == -1) + continue; + free(bpath); bpath = xs_read(xsh, XBT_NULL, buf, &len); - if (bpath == NULL) - continue; - /* read the name of the device */ - if (pasprintf(&buf, "%s/dev", bpath) == -1) - continue; - free(dev); - dev = xs_read(xsh, XBT_NULL, buf, &len); - if (dev == NULL) - continue; - if (strncmp(dev, "hd", 2) || strlen(dev) != 3) - continue; - hd_index = dev[2] - 'a'; - if (hd_index >= MAX_DISKS) - continue; - /* read the type of the device */ - if (pasprintf(&buf, "%s/device/vbd/%s/device-type", path, e[i]) == -1) - continue; - free(type); - type = xs_read(xsh, XBT_NULL, buf, &len); - if (pasprintf(&buf, "%s/params", bpath) == -1) - continue; - free(params); - params = xs_read(xsh, XBT_NULL, buf, &len); - if (params == NULL) - continue; + if (bpath == NULL) + continue; + /* read the name of the device */ + if (pasprintf(&buf, "%s/dev", bpath) == -1) + continue; + free(dev); + dev = xs_read(xsh, XBT_NULL, buf, &len); + if (dev == NULL) + continue; + is_scsi = !strncmp(dev, "sd", 2); + if ((strncmp(dev, "hd", 2) && !is_scsi) || strlen(dev) != 3 ) + continue; + hd_index = dev[2] - 'a'; + if (hd_index >= (is_scsi ? MAX_SCSI_DISKS : MAX_DISKS)) + continue; + /* read the type of the device */ + if (pasprintf(&buf, "%s/device/vbd/%s/device-type", path, e[i]) == -1) + continue; + free(type); + type = xs_read(xsh, XBT_NULL, buf, &len); + if (pasprintf(&buf, "%s/params", bpath) == -1) + continue; + free(params); + params = xs_read(xsh, XBT_NULL, buf, &len); + if (params == NULL) + continue; /* * check if device has a phantom vbd; the phantom is hooked * to the frontend device (for ease of cleanup), so lookup * the frontend device, and see if there is a phantom_vbd * if there is, we will use resolution as the filename */ - if (pasprintf(&buf, "%s/device/vbd/%s/phantom_vbd", path, e[i]) == -1) - continue; - free(fpath); + if (pasprintf(&buf, "%s/device/vbd/%s/phantom_vbd", path, e[i]) == -1) + continue; + free(fpath); fpath = xs_read(xsh, XBT_NULL, buf, &len); - if (fpath) { - if (pasprintf(&buf, "%s/dev", fpath) == -1) - continue; - free(params); + if (fpath) { + if (pasprintf(&buf, "%s/dev", fpath) == -1) + continue; + free(params); params = xs_read(xsh, XBT_NULL, buf , &len); - if (params) { + if (params) { /* * wait for device, on timeout silently fail because we will * fail to open below @@ -163,19 +164,20 @@ void xenstore_parse_domain_config(int do } } - bs_table[hd_index] = bdrv_new(dev); - /* check if it is a cdrom */ - if (type && !strcmp(type, "cdrom")) { - bdrv_set_type_hint(bs_table[hd_index], BDRV_TYPE_CDROM); - if (pasprintf(&buf, "%s/params", bpath) != -1) - xs_watch(xsh, buf, dev); - } - /* open device now if media present */ - if (params[0]) { - if (bdrv_open(bs_table[hd_index], params, 0 /* snapshot */) < 0) + bs_table[hd_index + (is_scsi ? MAX_DISKS : 0)] = bdrv_new(dev); + /* check if it is a cdrom */ + if (type && !strcmp(type, "cdrom")) { + bdrv_set_type_hint(bs_table[hd_index], BDRV_TYPE_CDROM); + if (pasprintf(&buf, "%s/params", bpath) != -1) + xs_watch(xsh, buf, dev); + } + /* open device now if media present */ + if (params[0]) { + if (bdrv_open(bs_table[hd_index + (is_scsi ? MAX_DISKS : 0)], + params, 0 /* snapshot */) < 0) fprintf(stderr, "qemu: could not open hard disk image '%s'\n", params); - } + } } /* Set a watch for log-dirty requests from the migration tools */ @@ -199,7 +201,7 @@ int xenstore_fd(void) int xenstore_fd(void) { if (xsh) - return xs_fileno(xsh); + return xs_fileno(xsh); return -1; } @@ -316,7 +318,7 @@ void xenstore_process_event(void *opaque vec = xs_read_watch(xsh, &num); if (!vec) - return; + return; if (!strcmp(vec[XS_WATCH_TOKEN], "logdirty")) { xenstore_process_logdirty_event(); @@ -324,23 +326,23 @@ void xenstore_process_event(void *opaque } if (strncmp(vec[XS_WATCH_TOKEN], "hd", 2) || - strlen(vec[XS_WATCH_TOKEN]) != 3) - goto out; + strlen(vec[XS_WATCH_TOKEN]) != 3) + goto out; hd_index = vec[XS_WATCH_TOKEN][2] - 'a'; image = xs_read(xsh, XBT_NULL, vec[XS_WATCH_PATH], &len); if (image == NULL || !strcmp(image, bs_table[hd_index]->filename)) - goto out; /* gone or identical */ + goto out; /* gone or identical */ do_eject(0, vec[XS_WATCH_TOKEN]); bs_table[hd_index]->filename[0] = 0; if (media_filename[hd_index]) { - free(media_filename[hd_index]); - media_filename[hd_index] = NULL; + free(media_filename[hd_index]); + media_filename[hd_index] = NULL; } if (image[0]) { - media_filename[hd_index] = strdup(image); - xenstore_check_new_media_present(5000); + media_filename[hd_index] = strdup(image); + xenstore_check_new_media_present(5000); } out: @@ -354,7 +356,7 @@ void xenstore_write_vncport(int display) char *portstr = NULL; if (xsh == NULL) - return; + return; path = xs_get_domain_path(xsh, domid); if (path == NULL) { @@ -363,10 +365,10 @@ void xenstore_write_vncport(int display) } if (pasprintf(&buf, "%s/console/vnc-port", path) == -1) - goto out; + goto out; if (pasprintf(&portstr, "%d", 5900 + display) == -1) - goto out; + goto out; if (xs_write(xsh, XBT_NULL, buf, portstr, strlen(portstr)) == 0) fprintf(logfile, "xs_write() vncport failed\n"); @@ -383,41 +385,41 @@ int xenstore_read_vncpasswd(int domid) unsigned int i, len, rc = 0; if (xsh == NULL) { - return -1; + return -1; } path = xs_get_domain_path(xsh, domid); if (path == NULL) { - fprintf(logfile, "xs_get_domain_path() error. domid %d.\n", domid); - return -1; + fprintf(logfile, "xs_get_domain_path() error. domid %d.\n", domid); + return -1; } pasprintf(&buf, "%s/vm", path); uuid = xs_read(xsh, XBT_NULL, buf, &len); if (uuid == NULL) { - fprintf(logfile, "xs_read(): uuid get error. %s.\n", buf); - free(path); - return -1; + fprintf(logfile, "xs_read(): uuid get error. %s.\n", buf); + free(path); + return -1; } pasprintf(&buf, "%s/vncpasswd", uuid); passwd = xs_read(xsh, XBT_NULL, buf, &len); if (passwd == NULL) { - fprintf(logfile, "xs_read(): vncpasswd get error. %s.\n", buf); - free(uuid); - free(path); - return rc; + fprintf(logfile, "xs_read(): vncpasswd get error. %s.\n", buf); + free(uuid); + free(path); + return rc; } for (i=0; i<len && i<63; i++) { - vncpasswd[i] = passwd[i]; - passwd[i] = '\0'; + vncpasswd[i] = passwd[i]; + passwd[i] = '\0'; } vncpasswd[len] = '\0'; pasprintf(&buf, "%s/vncpasswd", uuid); if (xs_write(xsh, XBT_NULL, buf, passwd, len) == 0) { - fprintf(logfile, "xs_write() vncpasswd failed.\n"); - rc = -1; + fprintf(logfile, "xs_write() vncpasswd failed.\n"); + rc = -1; } free(passwd); @@ -443,7 +445,7 @@ char **xenstore_domain_get_devices(struc goto out; if (pasprintf(&buf, "%s/device/%s", path,devtype) == -1) - goto out; + goto out; e = xs_directory(handle, XBT_NULL, buf, num); @@ -496,13 +498,13 @@ char *xenstore_backend_read_variable(str buf = get_device_variable_path(devtype, inst, var); if (NULL == buf) - goto out; + goto out; value = xs_read(handle, XBT_NULL, buf, &len); free(buf); -out: + out: return value; } @@ -569,27 +571,27 @@ char *xenstore_vm_read(int domid, char * char *buf = NULL, *path = NULL, *value = NULL; if (xsh == NULL) - goto out; + goto out; path = xs_get_domain_path(xsh, domid); if (path == NULL) { - fprintf(logfile, "xs_get_domain_path(%d): error\n", domid); - goto out; + fprintf(logfile, "xs_get_domain_path(%d): error\n", domid); + goto out; } pasprintf(&buf, "%s/vm", path); free(path); path = xs_read(xsh, XBT_NULL, buf, NULL); if (path == NULL) { - fprintf(logfile, "xs_read(%s): read error\n", buf); - goto out; + fprintf(logfile, "xs_read(%s): read error\n", buf); + goto out; } pasprintf(&buf, "%s/%s", path, key); value = xs_read(xsh, XBT_NULL, buf, len); if (value == NULL) { - fprintf(logfile, "xs_read(%s): read error\n", buf); - goto out; + fprintf(logfile, "xs_read(%s): read error\n", buf); + goto out; } out: @@ -604,27 +606,27 @@ int xenstore_vm_write(int domid, char *k int rc = -1; if (xsh == NULL) - goto out; + goto out; path = xs_get_domain_path(xsh, domid); if (path == NULL) { - fprintf(logfile, "xs_get_domain_path: error\n"); - goto out; + fprintf(logfile, "xs_get_domain_path: error\n"); + goto out; } pasprintf(&buf, "%s/vm", path); free(path); path = xs_read(xsh, XBT_NULL, buf, NULL); if (path == NULL) { - fprintf(logfile, "xs_read(%s): read error\n", buf); - goto out; + fprintf(logfile, "xs_read(%s): read error\n", buf); + goto out; } pasprintf(&buf, "%s/%s", path, key); rc = xs_write(xsh, XBT_NULL, buf, value, strlen(value)); if (rc) { - fprintf(logfile, "xs_write(%s, %s): write error\n", buf, key); - goto out; + fprintf(logfile, "xs_write(%s, %s): write error\n", buf, key); + goto out; } out: _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |