Skip to contentSkip to conversation

SCSI disks in FullVirt Domains

PATCH New Natasha Jarymowycz 1 participant 1 message Apr 10, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SCSI disks in FullVirt Domains

This is a resend of my March 14 patch re-based to current unstable tree.

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.

tools/ioemu/hw/pc.c +11 -1
diff -ruN xen-unstable.hg/tools/ioemu/hw/pc.c use-scsi/tools/ioemu/hw/pc.c
@@ -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) {
tools/ioemu/vl.c +1 -1
diff -ruN xen-unstable.hg/tools/ioemu/vl.c use-scsi/tools/ioemu/vl.c
@@ -116,7 +116,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;
tools/ioemu/vl.h +2 -1
diff -ruN xen-unstable.hg/tools/ioemu/vl.h use-scsi/tools/ioemu/vl.h
@@ -818,8 +818,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);
tools/ioemu/xenstore.c +20 -5
diff -ruN xen-unstable.hg/tools/ioemu/xenstore.c use-scsi/tools/ioemu/xenstore.c
@@ -83,7 +83,7 @@
     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++)
@@ -123,10 +123,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)
@@ -163,7 +168,10 @@
             }
         }
 
-	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);
 	/* check if it is a cdrom */
 	if (type && !strcmp(type, "cdrom")) {
 	    bdrv_set_type_hint(bs_table[hd_index], BDRV_TYPE_CDROM);
@@ -172,9 +180,16 @@
 	}
 	/* open device now if media present */
 	if (params[0]) {
-            if (bdrv_open(bs_table[hd_index], params, 0 /* snapshot */) < 0)
+            if ((is_scsi == 0) && 
+	        (bdrv_open(bs_table[hd_index], params, 0 /* snapshot */) < 0))
                 fprintf(stderr, "qemu: could not open hard disk image '%s'\n",
                         params);
+	    else
+	        if ((is_scsi == 1) && 
+		    (bdrv_open(bs_table[hd_index + MAX_DISKS], params, 
+		               0 /* snapshot */) < 0))
+	            fprintf(stderr, "qemu: could not open hard disk image "
+		            "'%s'\n", params);
 	}
     }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel