[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] SCSI disks in FullVirt Domains



This patch provides 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>


diff -ruN xen-unstable.hg/tools/ioemu/hw/pc.c patched/tools/ioemu/hw/pc.c
--- xen-unstable.hg/tools/ioemu/hw/pc.c 2007-03-13 09:41:39.000000000 -0500
+++ patched/tools/ioemu/hw/pc.c 2007-03-14 09:21:15.000000000 -0500
@@ -902,7 +902,6 @@
     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 @@
         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 -ruN xen-unstable.hg/tools/ioemu/vl.c patched/tools/ioemu/vl.c
--- xen-unstable.hg/tools/ioemu/vl.c    2007-03-14 08:57:56.000000000 -0500
+++ patched/tools/ioemu/vl.c    2007-03-14 09:21:15.000000000 -0500
@@ -115,7 +115,7 @@
 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 -ruN xen-unstable.hg/tools/ioemu/vl.h patched/tools/ioemu/vl.h
--- xen-unstable.hg/tools/ioemu/vl.h    2007-03-13 09:41:39.000000000 -0500
+++ patched/tools/ioemu/vl.h    2007-03-14 09:21:15.000000000 -0500
@@ -833,8 +833,9 @@
 
 /* ide.c */
 #define MAX_DISKS 4
+#define MAX_SCSI_DISKS 7
 
-extern BlockDriverState *bs_table[MAX_DISKS];
+extern BlockDriverState *bs_table[MAX_DISKS+MAX_SCSI_DISKS];
 
 void isa_ide_init(int iobase, int iobase2, int irq,
                   BlockDriverState *hd0, BlockDriverState *hd1);
diff -ruN xen-unstable.hg/tools/ioemu/xenstore.c patched/tools/ioemu/xenstore.c
--- xen-unstable.hg/tools/ioemu/xenstore.c      2007-03-13 09:41:39.000000000 
-0500
+++ patched/tools/ioemu/xenstore.c      2007-03-14 09:28:54.000000000 -0500
@@ -13,7 +13,7 @@
 #include <unistd.h>
 
 static struct xs_handle *xsh = NULL;
-static char *hd_filename[MAX_DISKS];
+static char *hd_filename[MAX_DISKS], *sd_filename[MAX_SCSI_DISKS];
 static QEMUTimer *insert_timer = NULL;
 
 #define UWAIT_MAX (30*1000000) /* thirty seconds */
@@ -78,12 +78,15 @@
     char *buf = NULL, *path;
     char *fpath = NULL, *bpath = NULL,
          *dev = NULL, *params = NULL, *type = NULL;
-    int i;
+    int i, is_scsi;
     unsigned int len, num, hd_index;
 
     for(i = 0; i < MAX_DISKS; i++)
         hd_filename[i] = NULL;
 
+    for(i = 0; i < MAX_SCSI_DISKS; i++)
+        sd_filename[i] = NULL;
+
     xsh = xs_daemon_open();
     if (xsh == NULL) {
        fprintf(logfile, "Could not contact xenstore for domain config\n");
@@ -118,10 +121,15 @@
        dev = xs_read(xsh, XBT_NULL, buf, &len);
        if (dev == NULL)
            continue;
-       if (strncmp(dev, "hd", 2) || strlen(dev) != 3)
+       if (strncmp(dev, "sd", 2))
+           is_scsi = 0;
+       else
+           is_scsi = 1;
+       if ((strncmp(dev, "hd", 2) && (is_scsi == 0)) || strlen(dev) != 3 )
            continue;
        hd_index = dev[2] - 'a';
-       if (hd_index >= MAX_DISKS)
+       if ((hd_index >= MAX_DISKS && (is_scsi == 0)) || 
+           (hd_index >= MAX_SCSI_DISKS && (is_scsi == 1)))
            continue;
        /* read the type of the device */
        if (pasprintf(&buf, "%s/device/vbd/%s/device-type", path, e[i]) == -1)
@@ -137,10 +145,16 @@
        params = xs_read(xsh, XBT_NULL, buf, &len);
        if (params == NULL)
            continue;
-       if (params[0]) {
+       if (params[0] && (is_scsi == 0)) {
            hd_filename[hd_index] = params;     /* strdup() */
            params = NULL;              /* don't free params on re-use */
        }
+       else {
+           if (params[0] && (is_scsi == 1)) {
+               sd_filename[hd_index] = params; /* strdup() */
+               params = NULL;          /* don't free params on re-use */
+           }
+       }
         /* 
          * check if device has a phantom vbd; the phantom is hooked
          * to the frontend device (for ease of cleanup), so lookup 
@@ -155,7 +169,7 @@
            if (pasprintf(&buf, "%s/dev", fpath) == -1)
                continue;
             params = xs_read(xsh, XBT_NULL, buf , &len);
-           if (params != NULL) {
+           if ((params != NULL) && (is_scsi == 0)) {
                 free(hd_filename[hd_index]);
                 hd_filename[hd_index] = params;
                 params = NULL;              /* don't free params on re-use */
@@ -165,8 +179,23 @@
                  */
                 waitForDevice(hd_filename[hd_index]);
             }
+           else {
+               if ((params != NULL) && (is_scsi == 1)) {
+                   free(sd_filename[hd_index]);
+                   sd_filename[hd_index] = params;
+                   params = NULL;      /* don't free params on re-use */
+                    /*
+                     * wait for device, on timeout silently fail because
+                     * we will fail to open below
+                     */
+                     waitForDevice(sd_filename[hd_index]);
+               }
+           }
         }
-       bs_table[hd_index] = bdrv_new(dev);
+        if (is_scsi == 0)
+           bs_table[hd_index] = bdrv_new(dev);
+       else
+           bs_table[hd_index + MAX_DISKS] = bdrv_new(dev);
         /* re-establish buf */
        if (pasprintf(&buf, "%s/params", bpath) == -1)
            continue;
@@ -175,12 +204,20 @@
            bdrv_set_type_hint(bs_table[hd_index], BDRV_TYPE_CDROM);
            xs_watch(xsh, buf, dev);
        }
-       if (hd_filename[hd_index]) {
+       if ((is_scsi == 0) && hd_filename[hd_index]) {
             if (bdrv_open(bs_table[hd_index], hd_filename[hd_index],
                          0 /* snapshot */) < 0)
                 fprintf(stderr, "qemu: could not open hard disk image '%s'\n",
                         hd_filename[hd_index]);
        }
+       else {
+           if ((is_scsi == 1) && sd_filename[hd_index]) {
+               if (bdrv_open(bs_table[hd_index+MAX_DISKS], 
+                             sd_filename[hd_index], 0 /* snapshot */) < 0)
+                   fprintf(stderr, "qemu: could not open hard disk image "
+                                   "'%s'\n", sd_filename[hd_index]);
+           }
+        }
     }
 
  out:

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.