VirtualBox

Changeset 14224

Show
Ignore:
Timestamp:
11/14/08 17:17:20 (2 months ago)
Author:
vboxsync
Message:

Main: Added ISystemProperties::defaultHardDiskFormat.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/Main/HardDisk2Impl.cpp

    r14164 r14224  
    472472                         const BSTR aLocation) 
    473473{ 
    474     AssertReturn (aVirtualBox, E_INVALIDARG); 
    475     AssertReturn (aLocation, E_INVALIDARG); 
     474    AssertReturn (aVirtualBox != NULL, E_INVALIDARG); 
     475    AssertReturn (aLocation != NULL, E_INVALIDARG); 
     476    AssertReturn (aFormat != NULL && *aFormat != '\0', E_INVALIDARG); 
    476477 
    477478    /* Enclose the state transition NotReady->InInit->Ready */ 
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r13837 r14224  
    7575    setDefaultMachineFolder (NULL); 
    7676    setDefaultHardDiskFolder (NULL); 
     77    setDefaultHardDiskFormat (NULL); 
     78 
    7779    setRemoteDisplayAuthLibrary (NULL); 
    7880 
     
    362364} 
    363365 
     366STDMETHODIMP SystemProperties::COMGETTER(DefaultHardDiskFormat) (BSTR *aDefaultHardDiskFormat) 
     367{ 
     368    if (!aDefaultHardDiskFormat) 
     369        return E_POINTER; 
     370 
     371    AutoCaller autoCaller (this); 
     372    CheckComRCReturnRC (autoCaller.rc()); 
     373 
     374    AutoReadLock alock (this); 
     375 
     376    mDefaultHardDiskFormat.cloneTo (aDefaultHardDiskFormat); 
     377 
     378    return S_OK; 
     379} 
     380 
     381STDMETHODIMP SystemProperties::COMSETTER(DefaultHardDiskFormat) (INPTR BSTR aDefaultHardDiskFormat) 
     382{ 
     383    AutoCaller autoCaller (this); 
     384    CheckComRCReturnRC (autoCaller.rc()); 
     385 
     386    /* VirtualBox::saveSettings() needs a write lock */ 
     387    AutoMultiWriteLock2 alock (mParent, this); 
     388 
     389    HRESULT rc = setDefaultHardDiskFormat (aDefaultHardDiskFormat); 
     390    if (SUCCEEDED (rc)) 
     391        rc = mParent->saveSettings(); 
     392 
     393    return rc; 
     394} 
     395 
    364396STDMETHODIMP SystemProperties::COMGETTER(RemoteDisplayAuthLibrary) (BSTR *aRemoteDisplayAuthLibrary) 
    365397{ 
     
    508540    bstr = properties.stringValue ("defaultHardDiskFolder"); 
    509541    rc = setDefaultHardDiskFolder (bstr); 
     542    CheckComRCReturnRC (rc); 
     543 
     544    bstr = properties.stringValue ("defaultHardDiskFormat"); 
     545    rc = setDefaultHardDiskFormat (bstr); 
    510546    CheckComRCReturnRC (rc); 
    511547 
     
    549585    if (mDefaultHardDiskFolder) 
    550586        properties.setValue <Bstr> ("defaultHardDiskFolder", mDefaultHardDiskFolder); 
     587 
     588    if (mDefaultHardDiskFormat) 
     589        properties.setValue <Bstr> ("defaultHardDiskFormat", mDefaultHardDiskFormat); 
    551590 
    552591    if (mRemoteDisplayAuthLibrary) 
     
    610649} 
    611650 
     651HRESULT SystemProperties::setDefaultHardDiskFormat (const BSTR aFormat) 
     652{ 
     653    if (aFormat && *aFormat) 
     654        mDefaultHardDiskFormat = aFormat; 
     655    else 
     656        mDefaultHardDiskFormat = "VDI"; 
     657 
     658    return S_OK; 
     659} 
     660 
    612661HRESULT SystemProperties::setRemoteDisplayAuthLibrary (const BSTR aPath) 
    613662{ 
    614     Utf8Str path; 
    615663    if (aPath && *aPath) 
    616         path = aPath; 
     664        mRemoteDisplayAuthLibrary = aPath; 
    617665    else 
    618         path = "VRDPAuth"; 
    619  
    620     mRemoteDisplayAuthLibrary = path; 
     666        mRemoteDisplayAuthLibrary = "VRDPAuth"; 
    621667 
    622668    return S_OK; 
     
    625671HRESULT SystemProperties::setWebServiceAuthLibrary (const BSTR aPath) 
    626672{ 
    627     Utf8Str path; 
    628673    if (aPath && *aPath) 
    629         path = aPath; 
     674        mWebServiceAuthLibrary = aPath; 
    630675    else 
    631         path = "VRDPAuth"; 
    632  
    633     mWebServiceAuthLibrary = path; 
    634  
    635     return S_OK; 
    636 
     676        mWebServiceAuthLibrary = "VRDPAuth"; 
     677 
     678    return S_OK; 
     679
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r13842 r14224  
    10601060    /* we don't access non-const data members so no need to lock */ 
    10611061 
     1062    Bstr format = aFormat; 
     1063    if (format.isEmpty()) 
     1064    { 
     1065        AutoReadLock propsLock (systemProperties()); 
     1066        format = systemProperties()->defaultHardDiskFormat(); 
     1067    } 
     1068 
    10621069    HRESULT rc = E_FAIL; 
    10631070 
    10641071    ComObjPtr <HardDisk2> hardDisk; 
    10651072    hardDisk.createObject(); 
    1066     rc = hardDisk->init (this, aFormat, aLocation); 
     1073    rc = hardDisk->init (this, format, aLocation); 
    10671074 
    10681075    if (SUCCEEDED (rc)) 
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r14107 r14224  
    13861386        the <link to="#hardDisks2"/> array. See IHardDisk2 for more details. 
    13871387 
    1388         The list of all <link to="IHardDisk2::format">storage formats</link> 
    1389         supported by this VirtualBox installation can be obtained using 
    1390         <link to="ISystemProperties::hardDiskFormats"/>. 
     1388        The list of all storage formats supported by this VirtualBox 
     1389        installation can be obtained using 
     1390        <link to="ISystemProperties::hardDiskFormats"/>. If the @a format 
     1391        attribute is empty or <tt>null</tt> then the default storage format 
     1392        specified by <link to="ISystemProperties::defaultHardDiskFormat"/> will 
     1393        be used for creating a storage unit of the hard disk. 
    13911394 
    13921395        Note that the format of the location string is storage format specific. 
     
    13961399      <param name="format" type="wstring" dir="in"> 
    13971400        <desc> 
    1398           Storage format to use for the new hard disk. 
     1401          Idetifier of the torage format to use for the new hard disk. 
    13991402        </desc> 
    14001403      </param> 
     
    52695272     name="ISystemProperties" 
    52705273     extends="$unknown" 
    5271      uuid="c7c060a9-91af-4e74-9188-a6b15a725e49
     5274     uuid="604afeba-5963-4d12-a577-902ffb96352a
    52725275     wsmap="managed" 
    52735276     > 
     
    54155418        <see> 
    54165419          <link to="IHardDiskFormat"/>, 
     5420        </see> 
     5421      </desc> 
     5422    </attribute> 
     5423 
     5424    <attribute name="defaultHardDiskFormat" type="wstring"> 
     5425      <desc> 
     5426        Identifier of the default hard disk format used by VirtualBox. 
     5427 
     5428        The hard disk format set by this attribute is used by VirtualBox 
     5429        when the hard disk format was not specified explicitly. One example is 
     5430        <link to="IVirtualBox::createHardDisk2()"/> with the <tt>null</tt> 
     5431        format argument. A more complex example is implicit creation of 
     5432        differencing hard disks when taking a snapshot of a virtual machine: 
     5433        this operation will try to use a format of the parent hard disk first 
     5434        and if this format does not support differencing hard disks the default 
     5435        format specified by this argument will be used. 
     5436 
     5437        The list of supported hard disk formats may be obtained by the 
     5438        <link  to="#defaultHardDiskFormats"/> call. Note that the default 
     5439        hard disk format must have a capability to create differencing hard 
     5440        disks; otherwise opeartions that create hard disks implicitly may fail 
     5441        unexpectedly. 
     5442 
     5443        The initial value of this property is <tt>VDI</tt> in the current 
     5444        version of the VirtualBox product, but may change in the future. 
     5445 
     5446        <note> 
     5447          Setting this property to <tt>null</tt> will restore the 
     5448          initial value. 
     5449        </note> 
     5450 
     5451        <see> 
     5452          <link to="#hardDiskFormats"/>, 
     5453          <link to="IHardDiskFormat:id"/>, 
     5454          <link to="IVirtualBox::createHardDisk2()"/> 
    54175455        </see> 
    54185456      </desc> 
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r13606 r14224  
    8080    STDMETHOD(COMSETTER(DefaultHardDiskFolder)) (INPTR BSTR aDefaultHardDiskFolder); 
    8181    STDMETHOD(COMGETTER(HardDiskFormats)) (ComSafeArrayOut (IHardDiskFormat *, aHardDiskFormats)); 
     82    STDMETHOD(COMGETTER(DefaultHardDiskFormat)) (BSTR *aDefaultHardDiskFolder); 
     83    STDMETHOD(COMSETTER(DefaultHardDiskFormat)) (INPTR BSTR aDefaultHardDiskFolder); 
    8284    STDMETHOD(COMGETTER(RemoteDisplayAuthLibrary)) (BSTR *aRemoteDisplayAuthLibrary); 
    8385    STDMETHOD(COMSETTER(RemoteDisplayAuthLibrary)) (INPTR BSTR aRemoteDisplayAuthLibrary); 
     
    103105    const Bstr &defaultHardDiskFolderFull() const { return mDefaultHardDiskFolderFull; } 
    104106 
     107    /** Default hard disk format. Not thread safe (use object lock). */ 
     108    const Bstr &defaultHardDiskFormat() const { return mDefaultHardDiskFormat; } 
     109 
    105110    // for VirtualBoxSupportErrorInfoImpl 
    106111    static const wchar_t *getComponentName() { return L"SystemProperties"; } 
     
    112117    HRESULT setDefaultMachineFolder (const BSTR aPath); 
    113118    HRESULT setDefaultHardDiskFolder (const BSTR aPath); 
     119    HRESULT setDefaultHardDiskFormat (const BSTR aFormat); 
     120 
    114121    HRESULT setRemoteDisplayAuthLibrary (const BSTR aPath); 
    115122    HRESULT setWebServiceAuthLibrary (const BSTR aPath); 
     
    121128    Bstr mDefaultHardDiskFolder; 
    122129    Bstr mDefaultHardDiskFolderFull; 
     130    Bstr mDefaultHardDiskFormat; 
    123131 
    124132    HardDiskFormatList mHardDiskFormats; 
  • trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd

    r13966 r14224  
    305305  <xsd:attribute name="defaultMachineFolder" type="TLocalFile"/> 
    306306  <xsd:attribute name="defaultHardDiskFolder" type="TLocalFile"/> 
     307  <xsd:attribute name="defaultHardDiskFormat" type="TNonEmptyString"/> 
    307308  <xsd:attribute name="remoteDisplayAuthLibrary" type="TLocalFile"/> 
    308309  <xsd:attribute name="webServiceAuthLibrary" type="TLocalFile"/> 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy