VirtualBox

Changeset 23418 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Sep 29, 2009 4:18:20 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
52986
Message:

Main/ConsoleImpl2: fix creating CFGM tree creation for DVD/floppy drives with no medium

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r23407 r23418  
    830830        for (size_t j = 0; j < atts.size(); ++ j)
    831831        {
     832            BOOL fHostDrive = FALSE;
     833
    832834            ComPtr<IMedium> medium;
    833835            hrc = atts [j]->COMGETTER(Medium)(medium.asOutParam());             H();
    834             if (medium.isNull())
    835                 continue;
    836 
    837836            LONG lDev;
    838837            hrc = atts[j]->COMGETTER(Device)(&lDev);                            H();
     
    855854            }
    856855
    857             BOOL fHostDrive = false;
    858             hrc = medium->COMGETTER(HostDrive)(&fHostDrive);                    H();
     856            if (!medium.isNull())
     857            {
     858                hrc = medium->COMGETTER(HostDrive)(&fHostDrive);                H();
     859            }
     860
    859861            if (fHostDrive)
    860862            {
     863                Assert(!medium.isNull());
    861864                if (lType == DeviceType_DVD)
    862865                {
     
    902905                }
    903906
    904                 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1);           RC_CHECK();
    905                 rc = CFGMR3InsertString(pLunL1, "Driver", "VD");                    RC_CHECK();
    906                 rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg);                     RC_CHECK();
    907 
    908                 hrc = medium->COMGETTER(Location)(&str);                            H();
    909                 rc = CFGMR3InsertStringW(pCfg, "Path", str);                        RC_CHECK();
    910                 STR_FREE();
    911 
    912                 hrc = medium->COMGETTER(Format)(&str);                              H();
    913                 rc = CFGMR3InsertStringW(pCfg, "Format", str);                      RC_CHECK();
    914                 STR_FREE();
    915 
    916                 /* DVDs are always readonly */
    917                 if (lType == DeviceType_DVD)
     907                if (!medium.isNull())
    918908                {
    919                     rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1);                  RC_CHECK();
    920                 }
    921 
    922                 /* Pass all custom parameters. */
    923                 bool fHostIP = true;
    924                 SafeArray<BSTR> names;
    925                 SafeArray<BSTR> values;
    926                 hrc = medium->GetProperties(NULL,
    927                                             ComSafeArrayAsOutParam(names),
    928                                             ComSafeArrayAsOutParam(values));        H();
    929 
    930                 if (names.size() != 0)
    931                 {
    932                     PCFGMNODE pVDC;
    933                     rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC);                 RC_CHECK();
    934                     for (size_t ii = 0; ii < names.size(); ++ii)
     909                    rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL1);           RC_CHECK();
     910                    rc = CFGMR3InsertString(pLunL1, "Driver", "VD");                    RC_CHECK();
     911                    rc = CFGMR3InsertNode(pLunL1, "Config", &pCfg);                     RC_CHECK();
     912
     913                    hrc = medium->COMGETTER(Location)(&str);                            H();
     914                    rc = CFGMR3InsertStringW(pCfg, "Path", str);                        RC_CHECK();
     915                    STR_FREE();
     916
     917                    hrc = medium->COMGETTER(Format)(&str);                              H();
     918                    rc = CFGMR3InsertStringW(pCfg, "Format", str);                      RC_CHECK();
     919                    STR_FREE();
     920
     921                    /* DVDs are always readonly */
     922                    if (lType == DeviceType_DVD)
    935923                    {
    936                         if (values[ii] && *values[ii])
    937                         {
    938                             Utf8Str name = names[ii];
    939                             Utf8Str value = values[ii];
    940                             rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str());
    941                             if (    name.compare("HostIPStack") == 0
    942                                 &&  value.compare("0") == 0)
    943                                 fHostIP = false;
    944                         }
     924                        rc = CFGMR3InsertInteger(pCfg, "ReadOnly", 1);                  RC_CHECK();
    945925                    }
    946                 }
    947 
    948                 /* Create an inversed tree of parents. */
    949                 ComPtr<IMedium> parentMedium = medium;
    950                 for (PCFGMNODE pParent = pCfg;;)
    951                 {
    952                     hrc = parentMedium->COMGETTER(Parent)(medium.asOutParam());     H();
    953                     if (medium.isNull())
    954                         break;
    955 
    956                     PCFGMNODE pCur;
    957                     rc = CFGMR3InsertNode(pParent, "Parent", &pCur);                RC_CHECK();
    958                     hrc = medium->COMGETTER(Location)(&str);                        H();
    959                     rc = CFGMR3InsertStringW(pCur, "Path", str);                    RC_CHECK();
    960                     STR_FREE();
    961 
    962                     hrc = medium->COMGETTER(Format)(&str);                          H();
    963                     rc = CFGMR3InsertStringW(pCur, "Format", str);                  RC_CHECK();
    964                     STR_FREE();
    965926
    966927                    /* Pass all custom parameters. */
     928                    bool fHostIP = true;
    967929                    SafeArray<BSTR> names;
    968930                    SafeArray<BSTR> values;
    969931                    hrc = medium->GetProperties(NULL,
    970932                                                ComSafeArrayAsOutParam(names),
    971                                                 ComSafeArrayAsOutParam(values));    H();
     933                                                ComSafeArrayAsOutParam(values));        H();
    972934
    973935                    if (names.size() != 0)
    974936                    {
    975937                        PCFGMNODE pVDC;
    976                         rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC);             RC_CHECK();
     938                        rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC);                 RC_CHECK();
    977939                        for (size_t ii = 0; ii < names.size(); ++ii)
    978940                        {
    979                             if (values[ii])
     941                            if (values[ii] && *values[ii])
    980942                            {
    981943                                Utf8Str name = names[ii];
     
    989951                    }
    990952
    991                     /* Custom code: put marker to not use host IP stack to driver
    992                      * configuration node. Simplifies life of DrvVD a bit. */
    993                     if (!fHostIP)
     953                    /* Create an inversed tree of parents. */
     954                    ComPtr<IMedium> parentMedium = medium;
     955                    for (PCFGMNODE pParent = pCfg;;)
    994956                    {
    995                         rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0);           RC_CHECK();
     957                        hrc = parentMedium->COMGETTER(Parent)(medium.asOutParam());     H();
     958                        if (medium.isNull())
     959                            break;
     960
     961                        PCFGMNODE pCur;
     962                        rc = CFGMR3InsertNode(pParent, "Parent", &pCur);                RC_CHECK();
     963                        hrc = medium->COMGETTER(Location)(&str);                        H();
     964                        rc = CFGMR3InsertStringW(pCur, "Path", str);                    RC_CHECK();
     965                        STR_FREE();
     966
     967                        hrc = medium->COMGETTER(Format)(&str);                          H();
     968                        rc = CFGMR3InsertStringW(pCur, "Format", str);                  RC_CHECK();
     969                        STR_FREE();
     970
     971                        /* Pass all custom parameters. */
     972                        SafeArray<BSTR> names;
     973                        SafeArray<BSTR> values;
     974                        hrc = medium->GetProperties(NULL,
     975                                                    ComSafeArrayAsOutParam(names),
     976                                                    ComSafeArrayAsOutParam(values));    H();
     977
     978                        if (names.size() != 0)
     979                        {
     980                            PCFGMNODE pVDC;
     981                            rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC);             RC_CHECK();
     982                            for (size_t ii = 0; ii < names.size(); ++ii)
     983                            {
     984                                if (values[ii])
     985                                {
     986                                    Utf8Str name = names[ii];
     987                                    Utf8Str value = values[ii];
     988                                    rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str());
     989                                    if (    name.compare("HostIPStack") == 0
     990                                        &&  value.compare("0") == 0)
     991                                        fHostIP = false;
     992                                }
     993                            }
     994                        }
     995
     996                        /* Custom code: put marker to not use host IP stack to driver
     997                         * configuration node. Simplifies life of DrvVD a bit. */
     998                        if (!fHostIP)
     999                        {
     1000                            rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0);           RC_CHECK();
     1001                        }
     1002
     1003                        /* next */
     1004                        pParent = pCur;
     1005                        parentMedium = medium;
    9961006                    }
    997 
    998                     /* next */
    999                     pParent = pCur;
    1000                     parentMedium = medium;
    10011007                }
    10021008            }
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