VirtualBox

Changeset 64093 in vbox


Ignore:
Timestamp:
Sep 29, 2016 3:39:23 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
111048
Message:

Storage: Move the NonRotationalMedium property from the devices and SCSI driver down to the media access driver (VD, HostDVD or HostFloppy) and add callback to PDMIMEDIA to query the flag

Location:
trunk
Files:
8 edited

Legend:

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

    r64078 r64093  
    354354
    355355    /**
     356     * Returns whether the medium should be marked as rotational or not.
     357     *
     358     * @returns true if non rotating medium.
     359     * @returns false if rotating medium.
     360     * @param   pInterface      Pointer to the interface structure containing the called function pointer.
     361     * @thread  Any thread.
     362     */
     363    DECLR3CALLBACKMEMBER(bool, pfnIsNonRotational,(PPDMIMEDIA pInterface));
     364
     365    /**
    356366     * Get stored media geometry (physical CHS, PCHS) - BIOS property.
    357367     * This is an optional feature of a media.
     
    449459} PDMIMEDIA;
    450460/** PDMIMEDIA interface ID. */
    451 #define PDMIMEDIA_IID                           "855b4998-0cd2-45d8-8da3-fe9a47504abb"
     461#define PDMIMEDIA_IID                           "d344aeaa-3ad0-4563-bb03-2733383e9230"
    452462
    453463
  • trunk/src/VBox/Devices/Storage/DevAHCI.cpp

    r64087 r64093  
    373373    /** First D2H FIS was send. */
    374374    bool                            fFirstD2HFisSend;
    375     /** Mark the drive as having a non-rotational medium (i.e. as a SSD). */
    376     bool                            fNonRotational;
    377375    /** Attached device is a CD/DVD drive. */
    378376    bool                            fATAPI;
     
    392390    volatile bool                   fWrkThreadSleeping;
    393391
    394     bool                            afAlignment[3];
     392    bool                            afAlignment[4];
    395393
    396394    /** Number of total sectors. */
     
    30853083    if (   pAhciPort->fTrimEnabled
    30863084        || pAhciPort->cbSector != 512
    3087         || pAhciPort->fNonRotational)
     3085        || pAhciPort->pDrvMedia->pfnIsNonRotational(pAhciPort->pDrvMedia))
    30883086    {
    30893087        p[80] = RT_H2LE_U16(0x1f0); /* support everything up to ATA/ATAPI-8 ACS */
     
    31213119    }
    31223120
    3123     if (pAhciPort->fNonRotational)
     3121    if (pAhciPort->pDrvMedia->pfnIsNonRotational(pAhciPort->pDrvMedia))
    31243122        p[217] = RT_H2LE_U16(1); /* Non-rotational medium */
    31253123
     
    76777675    }
    76787676
    7679     rc = CFGMR3QueryBoolDef(pCfgNode, "NonRotationalMedium", &pAhciPort->fNonRotational, false);
    7680     if (RT_FAILURE(rc))
    7681         return PDMDEV_SET_ERROR(pDevIns, rc,
    7682                     N_("AHCI configuration error: failed to read \"NonRotationalMedium\" as boolean"));
    7683 
    76847677    rc = CFGMR3QueryU8Def(pCfgNode, "LogicalSectorsPerPhysical", &pAhciPort->cLogSectorsPerPhysicalExp, 0);
    76857678    if (RT_FAILURE(rc))
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r63690 r64093  
    261261    STAMPROFILE     StatFlushes;
    262262
    263     /** Mark the drive as having a non-rotational medium (i.e. as a SSD). */
    264     bool            fNonRotational;
    265263    /** Enable passing through commands directly to the ATAPI drive. */
    266264    bool            fATAPIPassthrough;
     
    12961294    if (   s->pDrvMedia->pfnDiscard
    12971295        || s->cbSector != 512
    1298         || s->fNonRotational)
     1296        || s->pDrvMedia->pfnIsNonRotational(s->pDrvMedia))
    12991297    {
    13001298        p[80] = RT_H2LE_U16(0x1f0); /* support everything up to ATA/ATAPI-8 ACS */
     
    13391337    if (s->pDrvMedia->pfnDiscard) /** @todo Set bit 14 in word 69 too? (Deterministic read after TRIM). */
    13401338        p[169] = RT_H2LE_U16(1); /* DATA SET MANAGEMENT command supported. */
    1341     if (s->fNonRotational)
     1339    if (s->pDrvMedia->pfnIsNonRotational(s->pDrvMedia))
    13421340        p[217] = RT_H2LE_U16(1); /* Non-rotational medium */
    13431341    uint32_t uCsum = ataR3Checksum(p, 510);
     
    77607758                    }
    77617759
    7762                     rc = CFGMR3QueryBoolDef(pCfgNode, "NonRotationalMedium", &pIf->fNonRotational, false);
    7763                     if (RT_FAILURE(rc))
    7764                         return PDMDEV_SET_ERROR(pDevIns, rc,
    7765                                     N_("PIIX3 configuration error: failed to read \"NonRotationalMedium\" as boolean"));
    7766 
    77677760                    /* There are three other identification strings for CD drives used for INQUIRY */
    77687761                    if (pIf->fATAPI)
  • trunk/src/VBox/Devices/Storage/DrvHostBase.cpp

    r64019 r64093  
    288288    PDRVHOSTBASE pThis = PDMIMEDIA_2_DRVHOSTBASE(pInterface);
    289289    return pThis->fReadOnly;
     290}
     291
     292
     293/** @interface_method_impl{PDMIMEDIA,pfnIsNonRotational} */
     294static DECLCALLBACK(bool) drvHostBaseIsNonRotational(PPDMIMEDIA pInterface)
     295{
     296    RT_NOREF1(pInterface);
     297    return false;
    290298}
    291299
     
    18741882    pThis->IMedia.pfnFlush                  = drvHostBaseFlush;
    18751883    pThis->IMedia.pfnIsReadOnly             = drvHostBaseIsReadOnly;
     1884    pThis->IMedia.pfnIsNonRotational        = drvHostBaseIsNonRotational;
    18761885    pThis->IMedia.pfnGetSize                = drvHostBaseGetSize;
    18771886    pThis->IMedia.pfnGetType                = drvHostBaseGetType;
  • trunk/src/VBox/Devices/Storage/DrvSCSI.cpp

    r64079 r64093  
    125125    /** Errors printed in the release log. */
    126126    unsigned                cErrors;
    127     /** Mark the drive as having a non-rotational medium (i.e. as a SSD). */
    128     bool                    fNonRotational;
    129127    /** Medium is readonly */
    130128    bool                    fReadonly;
     
    377375        *pfFeatures |= VSCSI_LUN_FEATURE_UNMAP;
    378376
    379     if (pThis->fNonRotational)
     377    if (   pThis->pDrvMedia
     378        && pThis->pDrvMedia->pfnIsNonRotational(pThis->pDrvMedia))
    380379        *pfFeatures |= VSCSI_LUN_FEATURE_NON_ROTATIONAL;
    381380
     
    11171116     * Validate and read configuration.
    11181117     */
    1119     if (!CFGMR3AreValuesValid(pCfg, "NonRotationalMedium\0Readonly\0"))
     1118    if (!CFGMR3AreValuesValid(pCfg, "Readonly\0"))
    11201119        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
    11211120                                N_("SCSI configuration error: unknown option specified"));
    1122 
    1123     rc = CFGMR3QueryBoolDef(pCfg, "NonRotationalMedium", &pThis->fNonRotational, false);
    1124     if (RT_FAILURE(rc))
    1125         return PDMDRV_SET_ERROR(pDrvIns, rc,
    1126                     N_("SCSI configuration error: failed to read \"NonRotationalMedium\" as boolean"));
    11271121
    11281122    rc = CFGMR3QueryBoolDef(pCfg, "Readonly", &pThis->fReadonly, false);
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r64078 r64093  
    323323    /** Visible to the BIOS. */
    324324    bool                    fBiosVisible;
     325    /** Flag whether this medium should be presented as non rotational. */
     326    bool                    fNonRotational;
    325327#ifdef VBOX_PERIODIC_FLUSH
    326328    /** HACK: Configuration value for number of bytes written after which to flush. */
     
    21872189}
    21882190
     2191/** @interface_method_impl{PDMIMEDIA,pfnIsNonRotational} */
     2192static DECLCALLBACK(bool) drvvdIsNonRotational(PPDMIMEDIA pInterface)
     2193{
     2194    LogFlowFunc(("\n"));
     2195    PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
     2196
     2197    return pThis->fNonRotational;
     2198}
     2199
    21892200/** @interface_method_impl{PDMIMEDIA,pfnBiosGetPCHSGeometry} */
    21902201static DECLCALLBACK(int) drvvdBiosGetPCHSGeometry(PPDMIMEDIA pInterface,
     
    43544365    pThis->IMedia.pfnGetSectorSize      = drvvdGetSectorSize;
    43554366    pThis->IMedia.pfnIsReadOnly         = drvvdIsReadOnly;
     4367    pThis->IMedia.pfnIsNonRotational     = drvvdIsNonRotational;
    43564368    pThis->IMedia.pfnBiosGetPCHSGeometry = drvvdBiosGetPCHSGeometry;
    43574369    pThis->IMedia.pfnBiosSetPCHSGeometry = drvvdBiosSetPCHSGeometry;
     
    44744486                                          "SkipConsistencyChecks\0"
    44754487                                          "Locked\0BIOSVisible\0Cylinders\0Heads\0Sectors\0Mountable\0"
    4476                                           "EmptyDrive\0IoBufMax\0"
     4488                                          "EmptyDrive\0IoBufMax\0NonRotationalMedium\0"
    44774489#if defined(VBOX_PERIODIC_FLUSH) || defined(VBOX_IGNORE_FLUSH)
    44784490                                          "FlushInterval\0IgnoreFlush\0IgnoreFlushAsync\0"
     
    47484760            if (RT_FAILURE(rc))
    47494761                return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"IoBufMax\" from the config"));
     4762
     4763            rc = CFGMR3QueryBoolDef(pCfg, "NonRotationalMedium", &pThis->fNonRotational, false);
     4764            if (RT_FAILURE(rc))
     4765                return PDMDRV_SET_ERROR(pDrvIns, rc,
     4766                                        N_("DrvVD configuration error: Querying \"NonRotationalMedium\" as boolean failed"));
    47504767        }
    47514768
  • trunk/src/VBox/Main/include/ConsoleImpl.h

    r63239 r64093  
    646646                       const char *pcszBwGroup,
    647647                       bool fDiscard,
     648                       bool fNonRotational,
    648649                       IMedium *pMedium,
    649650                       MachineState_T aMachineState,
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r63998 r64093  
    265265# endif
    266266#endif
    267 
    268 static const char *const g_apszIDEDrives[4] =
    269     { "PrimaryMaster", "PrimarySlave", "SecondaryMaster", "SecondarySlave" };
    270267
    271268class ConfigError : public RTCError
     
    39253922            *ppLunL0 = pLunL0;
    39263923
    3927         PCFGMNODE pCfg = CFGMR3GetChild(pCtlInst, "Config");
    3928         if (pCfg)
    3929         {
    3930             if (!strcmp(pcszDevice, "piix3ide"))
    3931             {
    3932                 PCFGMNODE pDrive = CFGMR3GetChild(pCfg, g_apszIDEDrives[uLUN]);
    3933                 if (!pDrive)
    3934                     InsertConfigNode(pCfg, g_apszIDEDrives[uLUN], &pDrive);
    3935                 /* Don't use the RemoveConfigValue wrapper above, as we don't
    3936                  * know if the leaf is present or not. */
    3937                 CFGMR3RemoveValue(pDrive,  "NonRotationalMedium");
    3938                 InsertConfigInteger(pDrive, "NonRotationalMedium", !!fNonRotational);
    3939             }
    3940             else if (!strcmp(pcszDevice, "ahci"))
    3941             {
    3942                 Utf8Str strPort = Utf8StrFmt("Port%u", uLUN);
    3943                 PCFGMNODE pDrive = CFGMR3GetChild(pCfg, strPort.c_str());
    3944                 if (!pDrive)
    3945                     InsertConfigNode(pCfg, strPort.c_str(), &pDrive);
    3946                 /* Don't use the RemoveConfigValue wrapper above, as we don't
    3947                  * know if the leaf is present or not. */
    3948                 CFGMR3RemoveValue(pDrive,  "NonRotationalMedium");
    3949                 InsertConfigInteger(pDrive, "NonRotationalMedium", !!fNonRotational);
    3950             }
    3951         }
    3952 
    39533924        Utf8Str devicePath = Utf8StrFmt("%s/%u/LUN#%u", pcszDevice, uInstance, uLUN);
    39543925        mapMediumAttachments[devicePath] = pMediumAtt;
     
    39583929        {
    39593930            InsertConfigString(pLunL0, "Driver", "SCSI");
    3960             PCFGMNODE pL1Cfg = NULL;
    3961             InsertConfigNode(pLunL0, "Config", &pL1Cfg);
    3962             InsertConfigInteger(pL1Cfg, "NonRotationalMedium", !!fNonRotational);
    3963 
    39643931            InsertConfigNode(pLunL0, "AttachedDriver", &pLunL0);
    39653932        }
     
    41964163                            strBwGroup.isEmpty() ? NULL : Utf8Str(strBwGroup).c_str(),
    41974164                            !!fDiscard,
     4165                            !!fNonRotational,
    41984166                            pMedium,
    41994167                            aMachineState,
     
    42754243                            const char *pcszBwGroup,
    42764244                            bool fDiscard,
     4245                            bool fNonRotational,
    42774246                            IMedium *pMedium,
    42784247                            MachineState_T aMachineState,
     
    44644433                if (fDiscard)
    44654434                    InsertConfigInteger(pCfg, "Discard", 1);
     4435
     4436                if (fNonRotational)
     4437                    InsertConfigInteger(pCfg, "NonRotationalMedium", 1);
    44664438
    44674439                /* Pass all custom parameters. */
Note: See TracChangeset for help on using the changeset viewer.

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