Index: /trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp
===================================================================
--- /trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp	(revision 79374)
+++ /trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp	(revision 79375)
@@ -36,5 +36,5 @@
 *   Structures and Typedefs                                                                                                      *
 *********************************************************************************************************************************/
-#define VIRTIOSCSI_MAX_DEVICES  16
+#define VIRTIOSCSI_MAX_DEVICES  1
 
 /**
@@ -54,17 +54,4 @@
     /** LUN of the device. */
     RTUINT                        iLUN;
-
-    PDMIMEDIAPORT                 IMediaPort;
-    /** Extended media port interface. */
-
-    PDMIMEDIAEXPORT               IMediaExPort;
-    /** Led interface. */
-
-    R3PTRTYPE(PPDMIMEDIA)         pDrvMedia;
-    /** Pointer to the attached driver's extended media interface. */
-
-    R3PTRTYPE(PPDMIMEDIAEX)       pDrvMediaEx;
-    /** The status LED state for this device. */
-
 
     /** Flag whether device is present. */
@@ -95,4 +82,11 @@
     PPDMDEVINSRC                    pDevInsRC;
 
+    /** Queue to send tasks to R3. - HC ptr */
+    R3PTRTYPE(PPDMQUEUE)            pNotifierQueueR3;
+    /** Queue to send tasks to R3. - HC ptr */
+    R0PTRTYPE(PPDMQUEUE)            pNotifierQueueR0;
+    /** Queue to send tasks to R3. - RC ptr */
+    RCPTRTYPE(PPDMQUEUE)            pNotifierQueueRC;
+
     /** The base interface.
      * @todo use PDMDEVINS::IBase  */
@@ -112,4 +106,7 @@
     RTGCPHYS                        MMIOBase;
 
+    /** Partner of ILeds. */
+    R3PTRTYPE(PPDMILEDCONNECTORS)   pLedsConnector;
+
 } VIRTIOSCSI, *PVIRTIOSCSI;
 
@@ -120,8 +117,6 @@
 typedef struct VIRTIOSCSIREQ
 {
-    /** PDM extended media interface I/O request hande. */
-    PDMMEDIAEXIOREQ                hIoReq;
     /** Device this task is assigned to. */
-    PVIRTIOSCSIDEV               pTargetDevice;
+    PVIRTIOSCSIDEV                 pTargetDevice;
     /** The command control block from the guest. */
 //    CCBU                           CCBGuest;
@@ -140,7 +135,7 @@
 
 #define VIRTIOSCSI_SAVED_STATE_MINOR_VERSION        0x01
-
-
+/*********************************************************************************************************************************/
 #if 0
+
 /** @callback_method_impl{FNSSMDEVLIVEEXEC}  */
 static DECLCALLBACK(int) virtioScsiR3LiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
@@ -149,4 +144,5 @@
     NOREF(pSSM);
     PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
+    LogFunc(("callback"));
     NOREF(pThis);
     return VINF_SSM_DONT_CALL_AGAIN;
@@ -160,4 +156,5 @@
     NOREF(uVersion);
     PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
+    LogFunc(("callback"));
     NOREF(pThis);
     return VINF_SSM_DONT_CALL_AGAIN;
@@ -169,4 +166,5 @@
     RT_NOREF(pSSM);
     PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
+    LogFunc(("callback"));
     NOREF(pThis);
     return VINF_SUCCESS;
@@ -178,4 +176,5 @@
     RT_NOREF(pSSM);
     PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
+    LogFunc(("callback"));
     NOREF(pThis);
     return VINF_SUCCESS;
@@ -282,4 +281,29 @@
     return rc;
 }
+
+/**
+ * BusLogic debugger info callback.
+ *
+ * @param   pDevIns     The device instance.
+ * @param   pHlp        The output helpers.
+ * @param   pszArgs     The arguments.
+ */
+static DECLCALLBACK(void) virtioScsiR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
+{
+    PVIRTIOSCSI   pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
+    bool        fVerbose = false;
+
+    /* Parse arguments. */
+    if (pszArgs)
+        fVerbose = strstr(pszArgs, "verbose") != NULL;
+
+    /* Show basic information. */
+    pHlp->pfnPrintf(pHlp, "%s#%d: virtio-scsci ",
+                    pDevIns->pReg->szName,
+                    pDevIns->iInstance);
+    pHlp->pfnPrintf(pHlp, "GC=%RTbool R0=%RTbool\n",
+                    !!pThis->fGCEnabled, !!pThis->fR0Enabled);
+}
+
 /**
  * @callback_method_impl{FNPCIIOREGIONMAP}
@@ -355,7 +379,4 @@
 
 
-
-
-
 /**
  * @copydoc FNPDMDEVRESET
@@ -372,5 +393,4 @@
 //    {
 //        ASMAtomicWriteBool(&pThis->fSignalIdle, false);
-//        virtioScsiR3HwReset(pThis, true);
 //   }
 }
@@ -378,18 +398,17 @@
 static DECLCALLBACK(void) virtioScsiR3Relocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
 {
+LogFunc(("Relocating virtio-scsci"));
     RT_NOREF(offDelta);
     PVIRTIOSCSI pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
-    NOREF(pThis);
-
-//    pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
+
+    pThis->pDevInsR3 = pDevIns;
 //    pThis->pNotifierQueueRC = PDMQueueRCPtr(pThis->pNotifierQueueR3);
-//
-//    for (uint32_t i = 0; i < VIRTIOSCSI_MAX_DEVICES; i++)
-//   {
-//        PVIRTIOSCSIDEVICE pDevice = &pThis->aDevInstances[i];
-//
-//        pDevice->pvirtio-scsiRC = PDMINS_2_DATA_RCPTR(pDevIns);
-//
-//    }
+
+    for (uint32_t i = 0; i < VIRTIOSCSI_MAX_DEVICES; i++)
+    {
+        PVIRTIOSCSIDEV pDevice = &pThis->aDevInstances[i];
+        pDevice->pVirtioScsiR3 = pThis;;
+
+  }
 
 }
@@ -472,12 +491,12 @@
         return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register with PCI bus"));
 
-//    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 32, PCI_ADDRESS_SPACE_IO, devVirtioScsiR3MmioMap);
-//    if (RT_FAILURE(rc))
-//        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI I/O address space"));
-
-//    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 32, PCI_ADDRESS_SPACE_MEM, devVirtioScsiR3MmioMap);
-//    if (RT_FAILURE(rc))
-//        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI mmio address space"));
-    NOREF(devVirtioScsiR3MmioMap);
+    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 32, PCI_ADDRESS_SPACE_IO, devVirtioScsiR3MmioMap);
+    if (RT_FAILURE(rc))
+        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI I/O address space"));
+
+    rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, 32, PCI_ADDRESS_SPACE_MEM, devVirtioScsiR3MmioMap);
+    if (RT_FAILURE(rc))
+        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register PCI mmio address space"));
+
 #if 0
     if (fBootable)
@@ -491,28 +510,16 @@
             return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register BIOS I/O handlers"));
     }
+#endif
+
+
+#if 0
+    /* Initialize task queue. */
+    rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 5, 0,
+                              buslogicR3NotifyQueueConsumer, true, "BusLogicTask", &pThis->pNotifierQueueR3);
+    if (RT_FAILURE(rc))
+        return rc;
 
     pThis->pNotifierQueueR0 = PDMQueueR0Ptr(pThis->pNotifierQueueR3);
     pThis->pNotifierQueueRC = PDMQueueRCPtr(pThis->pNotifierQueueR3);
-
-    rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSectIntr, RT_SRC_POS, "virtio-scsi-Intr#%u", pDevIns->iInstance);
-    if (RT_FAILURE(rc))
-        return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi: cannot create critical section"));
-
-    /*
-     * Create event semaphore and worker thread.
-     */
-    rc = SUPSemEventCreate(pThis->pSupDrvSession, &pThis->hEvtProcess);
-    if (RT_FAILURE(rc))
-        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
-                                   N_("virtio-scsi: Failed to create SUP event semaphore"));
-
-    char szDevTag[20];
-    RTStrPrintf(szDevTag, sizeof(szDevTag), "VIRTIOSCSI-%u", iInstance);
-
-    rc = PDMDevHlpThreadCreate(pDevIns, &pThis->pThreadWrk, pThis, virtioScsiR3Worker,
-                               virtioScsiR3WorkerWakeUp, 0, RTTHREADTYPE_IO, szDevTag);
-    if (RT_FAILURE(rc))
-        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
-                                   N_("virtio-scsi: Failed to create worker thread %s"), szDevTag);
 #endif
 
@@ -529,37 +536,14 @@
         pDevice->iLUN = i;
         pDevice->pVirtioScsiR3 = pThis;
-LogFunc(("Attaching: Lun=%d, pszName=%s\n",  pDevice->iLUN, pszName));
+
+        LogFunc(("Attaching: Lun=%d, pszName=%s\n",  pDevice->iLUN, pszName));
         /* Attach SCSI driver. */
         rc = PDMDevHlpDriverAttach(pDevIns, pDevice->iLUN, &pDevice->IBase, &pDevice->pDrvBase, pszName);
         if (RT_SUCCESS(rc))
-        {
-#if 0
-            /* Query the media interface. */
-            pDevice->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pDevice->pDrvBase, PDMIMEDIA);
-            AssertMsgReturn(VALID_PTR(pDevice->pDrvMedia),
-                            ("virtio-scsi configuration error: LUN#%d misses the basic media interface!\n", pDevice->iLUN),
-                            VERR_PDM_MISSING_INTERFACE);
-
-            /* Get the extended media interface. */
-            pDevice->pDrvMediaEx = PDMIBASE_QUERY_INTERFACE(pDevice->pDrvBase, PDMIMEDIAEX);
-            AssertMsgReturn(VALID_PTR(pDevice->pDrvMediaEx),
-                            ("virtio-scsi configuration error: LUN#%d misses the extended media interface!\n", pDevice->iLUN),
-                            VERR_PDM_MISSING_INTERFACE);
-
-#endif
-            rc = pDevice->pDrvMediaEx->pfnIoReqAllocSizeSet(pDevice->pDrvMediaEx, sizeof(VIRTIOSCSIREQ));
-            if (RT_FAILURE(rc))
-                return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
-                                           N_("virtio-scsi configuration error: LUN#%u: Failed to set I/O request size!"),
-                                           pDevice->iLUN);
-
             pDevice->fPresent = true;
-        }
         else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
         {
             pDevice->fPresent    = false;
             pDevice->pDrvBase    = NULL;
-//            pDevice->pDrvMedia   = NULL;
-//            pDevice->pDrvMediaEx = NULL;
             rc = VINF_SUCCESS;
             Log(("virtio-scsi: no driver attached to device %s\n", pszName));
@@ -571,15 +555,12 @@
         }
     }
-#if 0
     /*
      * Attach status driver (optional).
      */
+#if 0
     PPDMIBASE pBase;
     rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port");
     if (RT_SUCCESS(rc))
-    {
-//        pThis->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
-//        pThis->pMediaNotify = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIANOTIFY);
-    }
+        pThis->pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
     else if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
     {
@@ -594,6 +575,5 @@
     if (RT_FAILURE(rc))
         return PDMDEV_SET_ERROR(pDevIns, rc, N_("virtio-scsi cannot register save state handlers"));
-
-//#if 0
+#endif
     /*
      * Register the debugger info callback.
@@ -603,10 +583,34 @@
     PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "virtio-scsi HBA info", virtioScsiR3Info);
 
-
-    rc = virtioScsiR3HwReset(pThis, true);
-    AssertMsgRC(rc, ("hardware reset of virtio-scsi host adapter failed rc=%Rrc\n", rc));
-#endif
-
     return rc;
+}
+
+
+/**
+ * Detach notification.
+ *
+ * One harddisk at one port has been unplugged.
+ * The VM is suspended at this point.
+ *
+ * @param   pDevIns     The device instance.
+ * @param   iLUN        The logical unit which is being detached.
+ * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
+ */
+static DECLCALLBACK(void) devVirtioScsiR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
+{
+    RT_NOREF(fFlags);
+    PVIRTIOSCSI       pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
+    PVIRTIOSCSIDEV pDevice = &pThis->aDevInstances[iLUN];
+
+    Log(("%s:\n", __FUNCTION__));
+
+    AssertMsg(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
+              ("virtio-scsi: Device does not support hotplugging\n"));
+
+    /*
+     * Zero some important members.
+     */
+    pDevice->fPresent    = false;
+    pDevice->pDrvBase    = NULL;
 }
 
@@ -636,6 +640,4 @@
     /* the usual paranoia */
     AssertRelease(!pDevice->pDrvBase);
-    AssertRelease(!pDevice->pDrvMedia);
-    AssertRelease(!pDevice->pDrvMediaEx);
     Assert(pDevice->iLUN == iLUN);
 
@@ -646,22 +648,5 @@
     rc = PDMDevHlpDriverAttach(pDevIns, pDevice->iLUN, &pDevice->IBase, &pDevice->pDrvBase, NULL);
     if (RT_SUCCESS(rc))
-    {
-        /* Query the media interface. */
-        pDevice->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pDevice->pDrvBase, PDMIMEDIA);
-        AssertMsgReturn(VALID_PTR(pDevice->pDrvMedia),
-                        ("virtio-scsi configuration error: LUN#%d misses the basic media interface!\n", pDevice->iLUN),
-                        VERR_PDM_MISSING_INTERFACE);
-
-        /* Get the extended media interface. */
-        pDevice->pDrvMediaEx = PDMIBASE_QUERY_INTERFACE(pDevice->pDrvBase, PDMIMEDIAEX);
-        AssertMsgReturn(VALID_PTR(pDevice->pDrvMediaEx),
-                        ("virtio-scsi configuration error: LUN#%d misses the extended media interface!\n", pDevice->iLUN),
-                        VERR_PDM_MISSING_INTERFACE);
-
-        rc = pDevice->pDrvMediaEx->pfnIoReqAllocSizeSet(pDevice->pDrvMediaEx, sizeof(VIRTIOSCSIREQ));
-        AssertMsgRCReturn(rc, ("virtio-scsi configuration error: LUN#%u: Failed to set I/O request size!", pDevice->iLUN),
-                          rc);
         pDevice->fPresent = true;
-    }
     else
         AssertMsgFailed(("Failed to attach LUN#%d. rc=%Rrc\n", pDevice->iLUN, rc));
@@ -671,40 +656,6 @@
         pDevice->fPresent    = false;
         pDevice->pDrvBase    = NULL;
-        pDevice->pDrvMedia   = NULL;
-        pDevice->pDrvMediaEx = NULL;
     }
     return rc;
-}
-
-
-/**
- * Detach notification.
- *
- * One harddisk at one port has been unplugged.
- * The VM is suspended at this point.
- *
- * @param   pDevIns     The device instance.
- * @param   iLUN        The logical unit which is being detached.
- * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
- */
-static DECLCALLBACK(void) devVirtioScsiR3Detach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags)
-{
-    RT_NOREF(fFlags);
-    PVIRTIOSCSI       pThis = PDMINS_2_DATA(pDevIns, PVIRTIOSCSI);
-    PVIRTIOSCSIDEV pDevice = &pThis->aDevInstances[iLUN];
-
-    Log(("%s:\n", __FUNCTION__));
-
-    AssertMsg(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,
-              ("virtio-scsi: Device does not support hotplugging\n"));
-
-    /*
-     * Zero some important members.
-     */
-    pDevice->fPresent    = false;
-    pDevice->pDrvBase    = NULL;
-//    pDevice->pDrvMedia   = NULL;
-//    pDevice->pDrvMediaEx = NULL;
-
 }
 
