VirtualBox

Changeset 78255 in vbox for trunk


Ignore:
Timestamp:
Apr 23, 2019 7:27:17 AM (6 years ago)
Author:
vboxsync
Message:

bugref:9416. Added new API function \'IAppliance::createVirtualSystemDescriptions\'

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r78148 r78255  
    33043304    uuid="86a98347-7619-41aa-aece-b21ac5c1a7e6"
    33053305    wsmap="managed"
    3306     reservedMethods="8" reservedAttributes="8"
     3306    reservedMethods="7" reservedAttributes="8"
    33073307    >
    33083308    <desc>
     
    36063606      <param name="passwords" type="wstring" dir="in" safearray="yes">
    36073607        <desc>List of matching passwords.</desc>
     3608      </param>
     3609    </method>
     3610
     3611    <method name="createVirtualSystemDescriptions">
     3612      <desc>Creates a number of <link to="IVirtualSystemDescription" /> objects and store them
     3613      in the <link to="#virtualSystemDescriptions" /> array.
     3614      </desc>
     3615
     3616      <param name="requested" type="unsigned long" dir="in">
     3617        <desc>Requested number of new virtual system description objects</desc>
     3618      </param>
     3619
     3620      <param name="created" type="unsigned long" dir="return">
     3621        <desc>Actually created number of virtual system description objects</desc>
    36083622      </param>
    36093623    </method>
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r76562 r78255  
    102102    HRESULT createVFSExplorer(const com::Utf8Str &aURI,
    103103                              ComPtr<IVFSExplorer> &aExplorer);
     104    HRESULT createVirtualSystemDescriptions(ULONG aRequested, ULONG *aCreated);
    104105    HRESULT write(const com::Utf8Str &aFormat,
    105106                  const std::vector<ExportOptions_T> &aOptions,
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r78101 r78255  
    615615}
    616616
     617
     618/**
     619 * Public method implementation.
     620 * Add the "aRequested" numbers of new empty objects of VSD into the list
     621 * "virtualSystemDescriptions".
     622 * The parameter "aCreated" keeps the actual number of the added objects.
     623 * In case of exception all added objects are removed from the list.
     624 */
     625HRESULT Appliance::createVirtualSystemDescriptions(ULONG aRequested, ULONG *aCreated)
     626{
     627    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     628
     629    HRESULT rc = S_OK;
     630    uint32_t lQuantity = aRequested;
     631    uint32_t oldSize = m->virtualSystemDescriptions.size();
     632    uint32_t i=0;
     633
     634    if (lQuantity < 1)
     635        return setError(E_FAIL, tr("The number of VirtualSystemDescription objects must be at least 1 or more."));
     636    try
     637    {
     638        for (; i<lQuantity; ++i)
     639        {
     640            ComObjPtr<VirtualSystemDescription> opVSD;
     641            rc = opVSD.createObject();
     642            if (SUCCEEDED(rc))
     643            {
     644                rc = opVSD->init();
     645                if (SUCCEEDED(rc))
     646                    m->virtualSystemDescriptions.push_back(opVSD);
     647                else
     648                    break;
     649            }
     650            else
     651                break;
     652        }
     653
     654        if (i<lQuantity)
     655            LogRel(("Number of created VirtualSystemDescription objects is less than requested"
     656                    "(Requested %d, Created %d)",lQuantity, i));
     657
     658        *aCreated = i;
     659    }
     660    catch (HRESULT aRC)
     661    {
     662        for (; i>0; --i)
     663        {
     664            if (!m->virtualSystemDescriptions.empty())
     665                m->virtualSystemDescriptions.pop_back();
     666            else
     667                break;
     668        }
     669        rc = aRC;
     670    }
     671
     672    return rc;
     673}
     674
    617675/**
    618676 * Public method implementation.
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