VirtualBox

vbox的更動 11187 路徑 trunk/src/VBox/Devices/Storage


忽略:
時間撮記:
2008-8-6 下午05:44:20 (16 年 以前)
作者:
vboxsync
訊息:

DrvBlock: Report failures! Use CFGMR3*Def().

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/Storage/DrvBlock.cpp

    r10715 r11187  
    758758    pData->pDrvBlockPort = (PPDMIBLOCKPORT)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_BLOCK_PORT);
    759759    if (!pData->pDrvBlockPort)
    760     {
    761         AssertMsgFailed(("Configuration error: No block port interface above!\n"));
    762         return VERR_PDM_MISSING_INTERFACE_ABOVE;
    763     }
     760        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
     761                                N_("No block port interface above"));
    764762
    765763    /* Try to get the optional async block port interface above. */
     
    775773    int rc = CFGMR3QueryStringAlloc(pCfgHandle, "Type", &psz);
    776774    if (VBOX_FAILURE(rc))
    777     {
    778         AssertMsgFailed(("Configuration error: Failed to obtain the type, rc=%Vrc.\n", rc));
    779         return VERR_PDM_BLOCK_NO_TYPE;
    780     }
     775        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the type"));
    781776    if (!strcmp(psz, "HardDisk"))
    782777        pData->enmType = PDMBLOCKTYPE_HARD_DISK;
     
    797792    else
    798793    {
    799         AssertMsgFailed(("Configuration error: Unknown type \"%s\".\n", psz));
     794        PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_BLOCK_UNKNOWN_TYPE, RT_SRC_POS,
     795                            N_("Unknown type \"%s\""), psz);
    800796        MMR3HeapFree(psz);
    801797        return VERR_PDM_BLOCK_UNKNOWN_TYPE;
     
    805801
    806802    /* Mountable */
    807     rc = CFGMR3QueryBool(pCfgHandle, "Mountable", &pData->fMountable);
    808     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    809         pData->fMountable = false;
    810     else if (VBOX_FAILURE(rc))
    811     {
    812         AssertMsgFailed(("Configuration error: Query \"Mountable\" resulted in %Vrc.\n", rc));
    813         return rc;
    814     }
     803    rc = CFGMR3QueryBoolDef(pCfgHandle, "Mountable", &pData->fMountable, false);
     804    if (VBOX_FAILURE(rc))
     805        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Mountable\" from the config"));
    815806
    816807    /* Locked */
    817     rc = CFGMR3QueryBool(pCfgHandle, "Locked", &pData->fLocked);
    818     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    819         pData->fLocked = false;
    820     else if (VBOX_FAILURE(rc))
    821     {
    822         AssertMsgFailed(("Configuration error: Query \"Locked\" resulted in %Vrc.\n", rc));
    823         return rc;
    824     }
     808    rc = CFGMR3QueryBoolDef(pCfgHandle, "Locked", &pData->fLocked, false);
     809    if (VBOX_FAILURE(rc))
     810        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Locked\" from the config"));
    825811
    826812    /* BIOS visible */
    827     rc = CFGMR3QueryBool(pCfgHandle, "BIOSVisible", &pData->fBiosVisible);
    828     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    829         pData->fBiosVisible = true;
    830     else if (VBOX_FAILURE(rc))
    831     {
    832         AssertMsgFailed(("Configuration error: Query \"BIOSVisible\" resulted in %Vrc.\n", rc));
    833         return rc;
    834     }
     813    rc = CFGMR3QueryBoolDef(pCfgHandle, "BIOSVisible", &pData->fBiosVisible, true);
     814    if (VBOX_FAILURE(rc))
     815        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"BIOSVisible\" from the config"));
    835816
    836817    /** @todo AttachFailError is currently completely ignored. */
    837818
    838819    /* Cylinders */
    839     rc = CFGMR3QueryU32(pCfgHandle, "Cylinders", &pData->LCHSGeometry.cCylinders);
    840     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    841         pData->LCHSGeometry.cCylinders = 0;
    842     else if (VBOX_FAILURE(rc))
    843     {
    844         AssertMsgFailed(("Configuration error: Query \"Cylinders\" resulted in %Vrc.\n", rc));
    845         return rc;
    846     }
     820    rc = CFGMR3QueryU32Def(pCfgHandle, "Cylinders", &pData->LCHSGeometry.cCylinders, 0);
     821    if (VBOX_FAILURE(rc))
     822        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Cylinders\" from the config"));
    847823
    848824    /* Heads */
    849     rc = CFGMR3QueryU32(pCfgHandle, "Heads", &pData->LCHSGeometry.cHeads);
    850     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    851         pData->LCHSGeometry.cHeads = 0;
    852     else if (VBOX_FAILURE(rc))
    853     {
    854         AssertMsgFailed(("Configuration error: Query \"Heads\" resulted in %Vrc.\n", rc));
    855         return rc;
    856     }
     825    rc = CFGMR3QueryU32Def(pCfgHandle, "Heads", &pData->LCHSGeometry.cHeads, 0);
     826    if (VBOX_FAILURE(rc))
     827        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Heads\" from the config"));
    857828
    858829    /* Sectors */
    859     rc = CFGMR3QueryU32(pCfgHandle, "Sectors", &pData->LCHSGeometry.cSectors);
    860     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    861         pData->LCHSGeometry.cSectors = 0;
    862     else if (VBOX_FAILURE(rc))
    863     {
    864         AssertMsgFailed(("Configuration error: Query \"Sectors\" resulted in %Vrc.\n", rc));
    865         return rc;
    866     }
     830    rc = CFGMR3QueryU32Def(pCfgHandle, "Sectors", &pData->LCHSGeometry.cSectors, 0);
     831    if (VBOX_FAILURE(rc))
     832        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Sectors\" from the config"));
    867833
    868834    /* Uuid */
     
    875841        if (VBOX_FAILURE(rc))
    876842        {
    877             AssertMsgFailed(("Configuration error: Uuid from string failed on \"%s\", rc=%Vrc.\n", psz, rc));
     843            PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, "%s",
     844                                N_("Uuid from string failed on \"%s\""), psz);
    878845            MMR3HeapFree(psz);
    879846            return rc;
     
    882849    }
    883850    else
    884     {
    885         AssertMsgFailed(("Configuration error: Failed to obtain the type, rc=%Vrc.\n", rc));
    886         return VERR_PDM_BLOCK_NO_TYPE;
    887     }
     851        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Uuid\" from the config"));
    888852
    889853#ifdef VBOX_PERIODIC_FLUSH
    890     rc = CFGMR3QueryU32(pCfgHandle, "FlushInterval", &pData->cbFlushInterval);
    891     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    892         pData->cbFlushInterval = 0;
    893     else if (VBOX_FAILURE(rc))
    894     {
    895         AssertMsgFailed(("Configuration error: Query \"FlushInterval\" resulted in %Vrc.\n", rc));
    896         return rc;
    897     }
     854    rc = CFGMR3QueryU32Def(pCfgHandle, "FlushInterval", &pData->cbFlushInterval, 0);
     855    if (VBOX_FAILURE(rc))
     856        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"FlushInterval\" from the config"));
    898857#endif /* VBOX_PERIODIC_FLUSH */
    899858
    900859#ifdef VBOX_IGNORE_FLUSH
    901     rc = CFGMR3QueryBool(pCfgHandle, "IgnoreFlush", &pData->fIgnoreFlush);
    902     if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    903         pData->fIgnoreFlush = true;     /* The default is to ignore flushes. */
    904     else if (VBOX_FAILURE(rc))
    905     {
    906         AssertMsgFailed(("Configuration error: Query \"IgnoreFlush\" resulted in %Vrc.\n", rc));
    907         return rc;
    908     }
     860    rc = CFGMR3QueryBoolDef(pCfgHandle, "IgnoreFlush", &pData->fIgnoreFlush, true);
     861    if (VBOX_FAILURE(rc))
     862        return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"IgnoreFlush\" from the config"));
    909863#endif /* VBOX_IGNORE_FLUSH */
    910864
     
    919873    if (VBOX_FAILURE(rc))
    920874    {
    921         AssertMsgFailed(("Failed to attach driver below us! rc=%Vra\n", rc));
     875        AssertLogRelMsgFailed(("Failed to attach driver below us! rc=%Vra\n", rc));
    922876        return rc;
    923877    }
    924878    pData->pDrvMedia = (PPDMIMEDIA)pBase->pfnQueryInterface(pBase, PDMINTERFACE_MEDIA);
    925879    if (!pData->pDrvMedia)
    926     {
    927             AssertMsgFailed(("Configuration error: No media or async media interface below!\n"));
    928             return VERR_PDM_MISSING_INTERFACE_BELOW;
    929     }
     880        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_BELOW,
     881                                N_("No media or async media interface below"));
    930882
    931883    /* Try to get the optional async interface. */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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