VirtualBox

Changeset 70685 in vbox


Ignore:
Timestamp:
Jan 22, 2018 7:27:21 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120421
Message:

pdmstorageifs.h,DevAHCI,DrvHostDVD: Restore ability to overwrite the INQUIRY data of attached CD/DVD drives (was lost when converting the AHCI emulation to make use of the VSCSI driver instead of using its own ATAPI emulation)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmstorageifs.h

    r69475 r70685  
    227227                                                       uint32_t *piInstance, uint32_t *piLUN));
    228228
     229
     230    /**
     231     * Queries the vendor and product ID and revision to report for INQUIRY commands in underlying devices.
     232     *
     233     * @returns VBox status code.
     234     * @param   pInterface      Pointer to this interface.
     235     * @param   ppszVendorId    Where to store the pointer to the vendor ID string to report.
     236     * @param   ppszProductId   Where to store the pointer to the product ID string to report.
     237     * @param   ppszRevision    Where to store the pointer to the revision string to report.
     238     *
     239     * @note The strings for the inquiry data are stored in the storage controller rather than in the device
     240     *       because if device attachments change (virtual CD/DVD drive versus host drive) there is currently no
     241     *       way to keep the INQUIRY data in extradata keys without causing trouble when the attachment is changed.
     242     *       Also Main currently doesn't has any settings for the attachment to store such information in the settings
     243     *       properly. Last reason (but not the most important one) is to stay compatible with older versions
     244     *       where the drive emulation was in AHCI but it now uses VSCSI and the settings overwrite should still work.
     245     */
     246    DECLR3CALLBACKMEMBER(int, pfnQueryScsiInqStrings, (PPDMIMEDIAPORT pInterface, const char **ppszVendorId,
     247                                                       const char **ppszProductId, const char **ppszRevision));
     248
    229249} PDMIMEDIAPORT;
    230250/** PDMIMEDIAPORT interface ID. */
    231 #define PDMIMEDIAPORT_IID                           "9f7e8c9e-6d35-4453-bbef-1f78033174d6"
     251#define PDMIMEDIAPORT_IID                           "77180ab8-6485-454f-b440-efca322b7bd7"
    232252
    233253/** Pointer to a media interface. */
  • trunk/src/VBox/Devices/Storage/DevAHCI.cpp

    r69500 r70685  
    128128#define AHCI_FIRMWARE_REVISION_LENGTH         8
    129129#define AHCI_MODEL_NUMBER_LENGTH             40
     130#define AHCI_ATAPI_INQUIRY_VENDOR_ID_LENGTH   8
     131#define AHCI_ATAPI_INQUIRY_PRODUCT_ID_LENGTH 16
     132#define AHCI_ATAPI_INQUIRY_REVISION_LENGTH    4
    130133
    131134/** ATAPI sense info size. */
     
    431434    /** The model number to use for IDENTIFY DEVICE commands. */
    432435    char                            szModelNumber[AHCI_MODEL_NUMBER_LENGTH+1]; /** < one extra byte for termination */
     436    /** The vendor identification string for SCSI INQUIRY commands. */
     437    char                            szInquiryVendorId[AHCI_ATAPI_INQUIRY_VENDOR_ID_LENGTH+1];
     438    /** The product identification string for SCSI INQUIRY commands. */
     439    char                            szInquiryProductId[AHCI_ATAPI_INQUIRY_PRODUCT_ID_LENGTH+1];
     440    /** The revision string for SCSI INQUIRY commands. */
     441    char                            szInquiryRevision[AHCI_ATAPI_INQUIRY_REVISION_LENGTH+1];
    433442    /** Error counter */
    434443    uint32_t                        cErrors;
     
    26152624    *piLUN = pAhciPort->iLUN;
    26162625
     2626    return VINF_SUCCESS;
     2627}
     2628
     2629/**
     2630 * @interface_method_impl{PDMIMEDIAPORT,pfnQueryScsiInqStrings}
     2631 */
     2632static DECLCALLBACK(int) ahciR3PortQueryScsiInqStrings(PPDMIMEDIAPORT pInterface, const char **ppszVendorId,
     2633                                                       const char **ppszProductId, const char **ppszRevision)
     2634{
     2635    PAHCIPort pAhciPort = PDMIMEDIAPORT_2_PAHCIPORT(pInterface);
     2636
     2637    if (ppszVendorId)
     2638        *ppszVendorId = &pAhciPort->szInquiryVendorId[0];
     2639    if (ppszProductId)
     2640        *ppszProductId = &pAhciPort->szInquiryProductId[0];
     2641    if (ppszRevision)
     2642        *ppszRevision = &pAhciPort->szInquiryRevision[0];
    26172643    return VINF_SUCCESS;
    26182644}
     
    55105536                    N_("AHCI configuration error: \"LogicalSectorsPerPhysical\" must be between 0 and 15"));
    55115537
     5538    /* There are three other identification strings for CD drives used for INQUIRY */
     5539    if (pAhciPort->fATAPI)
     5540    {
     5541        rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIVendorId", pAhciPort->szInquiryVendorId, sizeof(pAhciPort->szInquiryVendorId),
     5542                                  "VBOX");
     5543        if (RT_FAILURE(rc))
     5544        {
     5545            if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
     5546                return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
     5547                                N_("AHCI configuration error: \"ATAPIVendorId\" is longer than 16 bytes"));
     5548            return PDMDEV_SET_ERROR(pDevIns, rc,
     5549                    N_("AHCI configuration error: failed to read \"ATAPIVendorId\" as string"));
     5550        }
     5551
     5552        rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIProductId", pAhciPort->szInquiryProductId, sizeof(pAhciPort->szInquiryProductId),
     5553                                  "CD-ROM");
     5554        if (RT_FAILURE(rc))
     5555        {
     5556            if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
     5557                return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
     5558                                N_("AHCI configuration error: \"ATAPIProductId\" is longer than 16 bytes"));
     5559            return PDMDEV_SET_ERROR(pDevIns, rc,
     5560                    N_("AHCI configuration error: failed to read \"ATAPIProductId\" as string"));
     5561        }
     5562
     5563        rc = CFGMR3QueryStringDef(pCfgNode, "ATAPIRevision", pAhciPort->szInquiryRevision, sizeof(pAhciPort->szInquiryRevision),
     5564                                  "1.0");
     5565        if (RT_FAILURE(rc))
     5566        {
     5567            if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
     5568                return PDMDEV_SET_ERROR(pDevIns, VERR_INVALID_PARAMETER,
     5569                                N_("AHCI configuration error: \"ATAPIRevision\" is longer than 4 bytes"));
     5570            return PDMDEV_SET_ERROR(pDevIns, rc,
     5571                    N_("AHCI configuration error: failed to read \"ATAPIRevision\" as string"));
     5572        }
     5573    }
     5574
    55125575    return rc;
    55135576}
     
    60526115        pAhciPort->IMediaExPort.pfnMediumEjected           = ahciR3MediumEjected;
    60536116        pAhciPort->IPort.pfnQueryDeviceLocation            = ahciR3PortQueryDeviceLocation;
     6117        pAhciPort->IPort.pfnQueryScsiInqStrings            = ahciR3PortQueryScsiInqStrings;
    60546118        pAhciPort->fWrkThreadSleeping                      = true;
    60556119
  • trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp

    r69500 r70685  
    5353    /** ATAPI sense data. */
    5454    uint8_t                 abATAPISense[ATAPI_SENSE_SIZE];
     55    /** Flag whether to overwrite the inquiry data with our emulated settings. */
     56    bool                    fInquiryOverwrite;
    5557} DRVHOSTDVD;
    5658/** Pointer to the host DVD driver instance data. */
     
    347349               Assert(cbXferCur <= cbXfer);
    348350
    349                 if (pbCdb[0] == SCSI_INQUIRY)
     351                if (   pbCdb[0] == SCSI_INQUIRY
     352                    && pThis->fInquiryOverwrite)
    350353                {
     354                    const char *pszInqVendorId  = "VBOX";
     355                    const char *pszInqProductId = "CD-ROM";
     356                    const char *pszInqRevision  = "1.0";
     357
     358                    if (pThis->Core.pDrvMediaPort->pfnQueryScsiInqStrings)
     359                    {
     360                        rc = pThis->Core.pDrvMediaPort->pfnQueryScsiInqStrings(pThis->Core.pDrvMediaPort, &pszInqVendorId,
     361                                                                               &pszInqProductId, &pszInqRevision);
     362                        AssertRC(rc);
     363                    }
    351364                    /* Make sure that the real drive cannot be identified.
    352365                     * Motivation: changing the VM configuration should be as
    353366                     *             invisible as possible to the guest. */
    354367                    if (cbXferCur >= 8 + 8)
    355                         scsiPadStr((uint8_t *)pvBuf + 8, "VBOX", 8);
     368                        scsiPadStr((uint8_t *)pvBuf + 8, pszInqVendorId, 8);
    356369                    if (cbXferCur >= 16 + 16)
    357                         scsiPadStr((uint8_t *)pvBuf + 16, "CD-ROM", 16);
     370                        scsiPadStr((uint8_t *)pvBuf + 16, pszInqProductId, 16);
    358371                    if (cbXferCur >= 32 + 4)
    359                         scsiPadStr((uint8_t *)pvBuf + 32, "1.0", 4);
     372                        scsiPadStr((uint8_t *)pvBuf + 32, pszInqRevision, 4);
    360373                }
    361374
     
    433446    LogFlow(("drvHostDvdConstruct: iInstance=%d\n", pDrvIns->iInstance));
    434447
     448    int rc = CFGMR3QueryBoolDef(pCfg, "InquiryOverwrite", &pThis->fInquiryOverwrite, true);
     449    if (RT_FAILURE(rc))
     450        return PDMDRV_SET_ERROR(pDrvIns, rc,
     451                                N_("HostDVD configuration error: failed to read \"InquiryOverwrite\" as boolean"));
     452
    435453    bool fPassthrough;
    436     int rc = CFGMR3QueryBool(pCfg, "Passthrough", &fPassthrough);
     454    rc = CFGMR3QueryBool(pCfg, "Passthrough", &fPassthrough);
    437455    if (RT_SUCCESS(rc) && fPassthrough)
    438456    {
     
    448466     * Init instance data.
    449467     */
    450     rc = DRVHostBaseInit(pDrvIns, pCfg, "Path\0Interval\0Locked\0BIOSVisible\0AttachFailError\0Passthrough\0",
     468    rc = DRVHostBaseInit(pDrvIns, pCfg, "Path\0Interval\0Locked\0BIOSVisible\0AttachFailError\0Passthrough\0InquiryOverwrite\0",
    451469                         PDMMEDIATYPE_DVD);
    452470    LogFlow(("drvHostDvdConstruct: returns %Rrc\n", rc));
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette