Skip to contentSkip to conversation

-disk patch

Qemu-devel [email protected] 1 participant 1 message Jul 24, 2007

lore
Share & tools
lore
#0 lore raw

Lets try this again. (forgot to attach patch! )

the attached patch is a re-hash of the old "-disk" patch against current CVS.

things it does(on X86):
adds a "-disk scsi,hba=ADAPTER_NO,id=SCSI_ID,img=DISK_IMAGE,type=disk" syntax, for specifying scsi devices.
supports the old -hd[a-d] arguments.
supports using -cdrom twice, creating two cdrom devices on the second IDE channel.
supports multiple adapters. i coded for four, but can only get 3 working under linux, due to the driver in linux not supporting sharing the IRQ.

things it dosent do:
bochbios and linuxbios don't support booting off of a scsi disk.
-cdrom can't create a device on the primary controller. i'm suspecting irq routing, or somesuch. the scsi driver still dosent support devices [8..15].

with this patch, i'm running a qemu session with one IDE disk, two cdroms, and 21[!] scsi disks.

comments, suggestions, etc welcome.

Julia Longtin <[email protected]>

pc.c 2007-06-30 13:38:50.000000000 -0500 renamed from pc.c.orig 2006-10-09 10:30:32.000000000 -0400 +16 -14
@@ -913,23 +913,25 @@
     if (i440fx_state) {
         i440fx_init_memory_mappings(i440fx_state);
     }
-#if 0
-    /* ??? Need to figure out some way for the user to
-       specify SCSI devices.  */
     if (pci_enabled) {
-        void *scsi;
-        BlockDriverState *bdrv;
+        void *scsi[MAX_SCSI_CONTROLLERS];;
+        int id, hba;
 
-        scsi = lsi_scsi_init(pci_bus, -1);
-        bdrv = bdrv_new("scsidisk");
-        bdrv_open(bdrv, "scsi_disk.img", 0);
-        lsi_scsi_attach(scsi, bdrv, -1);
-        bdrv = bdrv_new("scsicd");
-        bdrv_open(bdrv, "scsi_cd.iso", 0);
-        bdrv_set_type_hint(bdrv, BDRV_TYPE_CDROM);
-        lsi_scsi_attach(scsi, bdrv, -1);
+        if (scsi_disks > 0) {
+            for (i=0; i<scsi_hba_lsi; i++) {
+                if (!(scsi[i] = lsi_scsi_init(pci_bus, -1))){
+                    exit(1);
+                }
+            }
+            for (i=0; i<MAX_SCSI_DISKS; i++) {
+                if (bs_scsi_table[i]!=NULL) {
+                    id=scsi_disks_info[i].id;
+                    hba=scsi_disks_info[i].hba;
+                    lsi_scsi_attach(scsi[hba], bs_scsi_table[i],id);
+                }
+            }
+        }
     }
-#endif
 }
 
 static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
vl.c 2006-12-05 15:12:11.000000000 -0500 renamed from vl.c.orig 2006-11-29 14:34:33.000000000 -0500 +342 -40

472 lines not on this page · raw message

vl.h 2006-12-04 10:38:01.000000000 -0500 renamed from vl.h.orig 2006-10-09 10:30:32.000000000 -0400 +28 -0
@@ -1396,10 +1396,38 @@
 void scsi_cancel_io(SCSIDevice *s, uint32_t tag);
 uint8_t *scsi_get_buf(SCSIDevice *s, uint32_t tag);
 
+enum scsi_host_adapters {           
+    SCSI_LSI_53C895A
+};
+enum scsi_devices {          
+    SCSI_CDROM,
+    SCSI_DISK,
+    SCSI_NONE
+};
+typedef enum scsi_host_adapters scsi_host_adapters;
+typedef enum scsi_devices scsi_devices;
+typedef struct SCSIDiskInfo{
+    scsi_host_adapters adapter; 
+    int hba;
+    int id;
+    scsi_devices device_type;
+    } SCSIDiskInfo;
+
+#define MAX_SCSI_CONTROLLERS 4
+#define MAX_SCSI_DISKS 7*MAX_SCSI_CONTROLLERS
+/* cdroms start at C, end at D. primary controller dosent support cdrom drives? */
+#define FIRST_IDE_CDROM_DRIVE 2
+#define MAX_IDE_CDROMS 2
+extern BlockDriverState *bs_scsi_table[MAX_SCSI_DISKS];
+extern SCSIDiskInfo scsi_disks_info[MAX_SCSI_DISKS];
+
 /* lsi53c895a.c */
 void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id);
 void *lsi_scsi_init(PCIBus *bus, int devfn);
+extern int scsi_hba_lsi; /* Count of scsi lsi adapters */
+extern int scsi_disks; /* Count of scsi disks/cdroms */
+extern int cdrom_drives; /* Count of total cdroms */ 
 
 /* integratorcp.c */
 extern QEMUMachine integratorcp_machine;