VirtualBox

Changeset 43041 in vbox


Ignore:
Timestamp:
Aug 28, 2012 1:58:40 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
80375
Message:

Main/VirtualBox: final API change, cleans up optional parameters to IVirtualBox::createMachine, preparing for adding more flags.

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/SDKRef.xml

    r43036 r43041  
    36383638          adjusted accordingly, the former taking an array of groups as an
    36393639          additional parameter and the latter taking a group as an additional
    3640           parameter.</para>
     3640          parameter. The create option handling has been changed for those two
     3641          methods, too.</para>
    36413642        </listitem>
    36423643
  • trunk/include/VBox/settings.h

    r42838 r43041  
    10161016{
    10171017    MachineUserData()
    1018         : fNameSync(true),
     1018        : fDirectoryIncludesUUID(false),
     1019          fNameSync(true),
    10191020          fTeleporterEnabled(false),
    10201021          uTeleporterPort(0),
     
    10301031    {
    10311032        return    (strName                    == c.strName)
     1033               && (fDirectoryIncludesUUID     == c.fDirectoryIncludesUUID)
    10321034               && (fNameSync                  == c.fNameSync)
    10331035               && (strDescription             == c.strDescription)
     
    10481050
    10491051    com::Utf8Str            strName;
     1052    bool                    fDirectoryIncludesUUID;
    10501053    bool                    fNameSync;
    10511054    com::Utf8Str            strDescription;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r42178 r43041  
    241241    do
    242242    {
     243        Bstr createFlags;
     244        if (!bstrUuid.isEmpty())
     245            createFlags = BstrFmt("UUID=%ls", bstrUuid.raw());
    243246        Bstr bstrPrimaryGroup;
    244247        if (groups.size())
     
    248251                          ComposeMachineFilename(bstrName.raw(),
    249252                                                 bstrPrimaryGroup.raw(),
     253                                                 createFlags.raw(),
    250254                                                 bstrBaseFolder.raw(),
    251255                                                 bstrSettingsFile.asOutParam()));
     
    256260                                        ComSafeArrayAsInParam(groups),
    257261                                        bstrOsTypeId.raw(),
    258                                         bstrUuid.raw(),
    259                                         FALSE /* forceOverwrite */,
     262                                        createFlags.raw(),
    260263                                        machine.asOutParam()));
    261264
     
    435438        pszTrgName = RTStrAPrintf2("%s Clone", pszSrcName);
    436439
     440    Bstr createFlags;
     441    if (!bstrUuid.isEmpty())
     442        createFlags = BstrFmt("UUID=%ls", bstrUuid.raw());
    437443    Bstr bstrPrimaryGroup;
    438444    if (groups.size())
     
    442448                    ComposeMachineFilename(Bstr(pszTrgName).raw(),
    443449                                           bstrPrimaryGroup.raw(),
     450                                           createFlags.raw(),
    444451                                           Bstr(pszTrgBaseFolder).raw(),
    445452                                           bstrSettingsFile.asOutParam()),
     
    451458                                                 ComSafeArrayAsInParam(groups),
    452459                                                 NULL,
    453                                                  bstrUuid.raw(),
    454                                                  FALSE,
     460                                                 createFlags.raw(),
    455461                                                 trgMachine.asOutParam()),
    456462                    RTEXITCODE_FAILURE);
  • trunk/src/VBox/Frontends/VBoxShell/vboxshell.py

    r42904 r43041  
    219219    mgr = ctx['mgr']
    220220    vb = ctx['vb']
    221     mach = vb.createMachine("", name, [], kind, "", False)
     221    mach = vb.createMachine("", name, [], kind, "")
    222222    mach.saveSettings()
    223223    print "created machine with UUID",mach.id
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp

    r42129 r43041  
    113113
    114114    /* Create a new machine object. */
    115     const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null /**< @todo group support */, QString::null);
    116     CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QVector<QString>(), QString::null, QString::null, false);
     115    const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null /**< @todo group support */, QString::null, QString::null);
     116    CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QVector<QString>(), QString::null, QString::null);
    117117    if (!vbox.isOk())
    118118    {
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r42616 r43041  
    6666        if (!m_strGroup.isEmpty())
    6767            groups << m_strGroup;
    68         m_machine = vbox.CreateMachine(QString(), field("name").toString(), groups, strTypeId, QString(), false);
     68        m_machine = vbox.CreateMachine(QString(), field("name").toString(), groups, strTypeId, QString::null);
    6969        if (!vbox.isOk())
    7070        {
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp

    r42616 r43041  
    184184    QString strDefaultMachinesFolder = vbox.GetSystemProperties().GetDefaultMachineFolder();
    185185    /* Compose machine filename: */
    186     QString strMachineFilename = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(), m_strGroup, strDefaultMachinesFolder);
     186    QString strMachineFilename = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(), m_strGroup, QString::null, strDefaultMachinesFolder);
    187187    /* Compose machine folder/basename: */
    188188    QFileInfo fileInfo(strMachineFilename);
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r43036 r43041  
    14241424  <interface
    14251425    name="IVirtualBox" extends="$unknown"
    1426     uuid="5c8814a1-2a35-402d-8680-68e5cb4e72aa"
     1426    uuid="3b2f08eb-b810-4715-bee0-bb06b9880ad2"
    14271427    wsmap="managed"
    14281428    >
     
    16641664        used to determine the right subdirectory.</desc>
    16651665      </param>
     1666      <param name="createFlags" type="wstring" dir="in">
     1667        <desc>Machine creation flags, see <link to="#createMachine" /> (optional).</desc>
     1668      </param>
    16661669      <param name="baseFolder" type="wstring" dir="in">
    16671670        <desc>Base machine folder (optional).</desc>
     
    17231726        array.
    17241727
    1725         Optionally, you may specify an UUID of to assign to the created machine.
    1726         However, this is not recommended and you should normally pass an empty
    1727         (@c null) UUID to this method so that a new UUID will be automatically
    1728         generated for every created machine. You can use UUID
    1729         00000000-0000-0000-0000-000000000000 as @c null value.
    1730 
    17311728        <note>
    17321729          There is no way to change the name of the settings file or
     
    17631760        <desc>Guest OS Type ID.</desc>
    17641761      </param>
    1765       <param name="id" type="uuid" mod="string" dir="in">
    1766         <desc>Machine UUID (optional).</desc>
    1767       </param>
    1768       <param name="forceOverwrite" type="boolean" dir="in">
    1769         <desc>If true, an existing machine settings file will be overwritten.</desc>
     1762      <param name="flags" type="wstring" dir="in">
     1763        <desc>
     1764          Additional property parameters, passed as a comma-separated list of
     1765          "name=value" type entries. The following ones are recognized:
     1766          <tt>forceOverwrite=1</tt> to overwrite an existing machine settings
     1767          file, and <tt>UUID=&lt;uuid&gt;</tt> to specify a machine UUID.
     1768        </desc>
    17701769      </param>
    17711770      <param name="machine" type="IMachine" dir="return">
  • trunk/src/VBox/Main/include/MachineImpl.h

    r42890 r43041  
    353353                 GuestOSType *aOsType,
    354354                 const Guid &aId,
    355                  bool fForceOverwrite);
     355                 bool fForceOverwrite,
     356                 bool fDirectoryIncludesUUID);
    356357
    357358    // initializer for loading existing machine XML (either registered or not)
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r42888 r43041  
    127127
    128128    /* IVirtualBox methods */
    129     STDMETHOD(ComposeMachineFilename)(IN_BSTR aName, IN_BSTR aGroup, IN_BSTR aBaseFolder, BSTR *aFilename);
     129    STDMETHOD(ComposeMachineFilename)(IN_BSTR aName, IN_BSTR aGroup, IN_BSTR aCreateFlags, IN_BSTR aBaseFolder, BSTR *aFilename);
    130130    STDMETHOD(CreateMachine)(IN_BSTR aSettingsFile,
    131131                             IN_BSTR aName,
    132132                             ComSafeArrayIn(IN_BSTR, aGroups),
    133133                             IN_BSTR aOsTypeId,
    134                              IN_BSTR aId,
    135                              BOOL forceOverwrite,
     134                             IN_BSTR aCreateFlags,
    136135                             IMachine **aMachine);
    137136    STDMETHOD(OpenMachine)(IN_BSTR aSettingsFile, IMachine **aMachine);
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r42708 r43041  
    206206            rc = mVirtualBox->ComposeMachineFilename(Bstr(nameVBox).raw(),
    207207                                                     NULL /* aGroup */,
     208                                                     NULL /* aCreateFlags */,
    208209                                                     NULL /* aBaseFolder */,
    209210                                                     bstrMachineFilename.asOutParam());
     
    19541955                                    ComSafeArrayAsInParam(groups),
    19551956                                    Bstr(stack.strOsTypeVBox).raw(),
    1956                                     NULL, /* uuid */
    1957                                     FALSE, /* fForceOverwrite */
     1957                                    NULL, /* aCreateFlags */
    19581958                                    pNewMachine.asOutParam());
    19591959    if (FAILED(rc)) throw rc;
     
    28682868        rc = mVirtualBox->ComposeMachineFilename(Bstr(stack.strNameVBox).raw(),
    28692869                                                 NULL /* aGroup */,
     2870                                                 NULL /* aCreateFlags */,
    28702871                                                 NULL /* aBaseFolder */,
    28712872                                                 bstrMachineFilename.asOutParam());
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r43023 r43041  
    290290                      GuestOSType *aOsType,
    291291                      const Guid &aId,
    292                       bool fForceOverwrite)
     292                      bool fForceOverwrite,
     293                      bool fDirectoryIncludesUUID)
    293294{
    294295    LogFlowThisFuncEnter();
     
    324325        mUserData->s.llGroups = llGroups;
    325326
     327        mUserData->s.fDirectoryIncludesUUID = fDirectoryIncludesUUID;
    326328        // the "name sync" flag determines whether the machine directory gets renamed along
    327329        // with the machine file; say so if the settings file name is the same as the
     
    1094610948    strConfigFileOnly.stripPath()                           // vmname.vbox
    1094710949                     .stripExt();                           // vmname
     10950    /** @todo hack, make somehow use of ComposeMachineFilename */
     10951    if (mUserData->s.fDirectoryIncludesUUID)
     10952        strConfigFileOnly += Utf8StrFmt(" (%RTuuid)", mData->mUuid.raw());
    1094810953
    1094910954    AssertReturn(!strMachineDirName.isEmpty(), false);
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r42957 r43041  
    14061406STDMETHODIMP VirtualBox::ComposeMachineFilename(IN_BSTR aName,
    14071407                                                IN_BSTR aGroup,
     1408                                                IN_BSTR aCreateFlags,
    14081409                                                IN_BSTR aBaseFolder,
    14091410                                                BSTR *aFilename)
     
    14171418    AutoCaller autoCaller(this);
    14181419    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1420
     1421    Utf8Str strCreateFlags(aCreateFlags);
     1422    Guid id;
     1423    bool fDirectoryIncludesUUID = false;
     1424    if (!strCreateFlags.isEmpty())
     1425    {
     1426        const char *pcszNext = strCreateFlags.c_str();
     1427        while (*pcszNext != '\0')
     1428        {
     1429            Utf8Str strFlag;
     1430            const char *pcszComma = RTStrStr(pcszNext, ",");
     1431            if (!pcszComma)
     1432                strFlag = pcszNext;
     1433            else
     1434                strFlag = Utf8Str(pcszNext, pcszComma - pcszNext);
     1435
     1436            const char *pcszEqual = RTStrStr(strFlag.c_str(), "=");
     1437            /* skip over everything which doesn't contain '=' */
     1438            if (pcszEqual && pcszEqual != strFlag.c_str())
     1439            {
     1440                Utf8Str strKey(strFlag.c_str(), pcszEqual - strFlag.c_str());
     1441                Utf8Str strValue(strFlag.c_str() + (pcszEqual - strFlag.c_str() + 1));
     1442
     1443                if (strKey == "UUID")
     1444                    id = strValue.c_str();
     1445                else if (strKey == "directoryIncludesUUID")
     1446                    fDirectoryIncludesUUID = (strValue == "1");
     1447            }
     1448
     1449            if (!pcszComma)
     1450                pcszNext += strFlag.length();
     1451            else
     1452                pcszNext += strFlag.length() + 1;
     1453        }
     1454    }
     1455    if (id.isEmpty())
     1456        fDirectoryIncludesUUID = false;
    14191457
    14201458    Utf8Str strGroup(aGroup);
     
    14361474    Utf8Str strBase = aBaseFolder;
    14371475    Utf8Str strName = aName;
     1476    Utf8Str strDirName(strName);
     1477    if (fDirectoryIncludesUUID)
     1478        strDirName += Utf8StrFmt(" (%RTuuid)", id.raw());
    14381479    sanitiseMachineFilename(strName);
     1480    sanitiseMachineFilename(strDirName);
    14391481
    14401482    if (strBase.isEmpty())
     
    15511593                                       ComSafeArrayIn(IN_BSTR, aGroups),
    15521594                                       IN_BSTR aOsTypeId,
    1553                                        IN_BSTR aId,
    1554                                        BOOL forceOverwrite,
     1595                                       IN_BSTR aCreateFlags,
    15551596                                       IMachine **aMachine)
    15561597{
    15571598    LogFlowThisFuncEnter();
    1558     LogFlowThisFunc(("aSettingsFile=\"%ls\", aName=\"%ls\", aOsTypeId =\"%ls\"\n", aSettingsFile, aName, aOsTypeId));
     1599    LogFlowThisFunc(("aSettingsFile=\"%ls\", aName=\"%ls\", aOsTypeId =\"%ls\", aCreateFlags=\"%ls\"\n", aSettingsFile, aName, aOsTypeId, aCreateFlags));
    15591600
    15601601    CheckComArgStrNotEmptyOrNull(aName);
     
    15701611        return rc;
    15711612
     1613    Utf8Str strCreateFlags(aCreateFlags);
     1614    Guid id;
     1615    bool fForceOverwrite = false;
     1616    bool fDirectoryIncludesUUID = false;
     1617    if (!strCreateFlags.isEmpty())
     1618    {
     1619        const char *pcszNext = strCreateFlags.c_str();
     1620        while (*pcszNext != '\0')
     1621        {
     1622            Utf8Str strFlag;
     1623            const char *pcszComma = RTStrStr(pcszNext, ",");
     1624            if (!pcszComma)
     1625                strFlag = pcszNext;
     1626            else
     1627                strFlag = Utf8Str(pcszNext, pcszComma - pcszNext);
     1628
     1629            const char *pcszEqual = RTStrStr(strFlag.c_str(), "=");
     1630            /* skip over everything which doesn't contain '=' */
     1631            if (pcszEqual && pcszEqual != strFlag.c_str())
     1632            {
     1633                Utf8Str strKey(strFlag.c_str(), pcszEqual - strFlag.c_str());
     1634                Utf8Str strValue(strFlag.c_str() + (pcszEqual - strFlag.c_str() + 1));
     1635
     1636                if (strKey == "UUID")
     1637                    id = strValue.c_str();
     1638                else if (strKey == "forceOverwrite")
     1639                    fForceOverwrite = (strValue == "1");
     1640                else if (strKey == "directoryIncludesUUID")
     1641                    fDirectoryIncludesUUID = (strValue == "1");
     1642            }
     1643
     1644            if (!pcszComma)
     1645                pcszNext += strFlag.length();
     1646            else
     1647                pcszNext += strFlag.length() + 1;
     1648        }
     1649    }
     1650    /* Create UUID if none was specified. */
     1651    if (id.isEmpty())
     1652        id.create();
     1653
    15721654    /* NULL settings file means compose automatically */
    15731655    Bstr bstrSettingsFile(aSettingsFile);
    15741656    if (bstrSettingsFile.isEmpty())
    15751657    {
     1658        Utf8Str strNewCreateFlags(Utf8StrFmt("UUID=%RTuuid", id.raw()));
     1659        if (fDirectoryIncludesUUID)
     1660            strNewCreateFlags += ",directoryIncludesUUID=1";
     1661
    15761662        rc = ComposeMachineFilename(aName,
    15771663                                    Bstr(llGroups.front()).raw(),
     1664                                    Bstr(strNewCreateFlags).raw(),
    15781665                                    NULL /* aBaseFolder */,
    15791666                                    bstrSettingsFile.asOutParam());
     
    15851672    rc = machine.createObject();
    15861673    if (FAILED(rc)) return rc;
    1587 
    1588     /* Create UUID if an empty one was specified. */
    1589     Guid id(aId);
    1590     if (id.isEmpty())
    1591         id.create();
    15921674
    15931675    GuestOSType *osType = NULL;
     
    16021684                       osType,
    16031685                       id,
    1604                        !!forceOverwrite);
     1686                       fForceOverwrite,
     1687                       fDirectoryIncludesUUID);
    16051688    if (SUCCEEDED(rc))
    16061689    {
  • trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp

    r42131 r43041  
    193193                                   0, nsnull,   /* groups (safearray)*/
    194194                                   nsnull,      /* ostype */
    195                                    nsnull,      /* machine uuid */
    196                                    false,       /* forceOverwrite */
     195                                   nsnull,      /* create flags */
    197196                                   getter_AddRefs(machine));
    198197    if (NS_FAILED(rc))
  • trunk/src/VBox/Main/xml/Settings.cpp

    r42838 r43041  
    34373437        parseUUID(uuid, strUUID);
    34383438
     3439        elmMachine.getAttributeValue("directoryIncludesUUID", machineUserData.fDirectoryIncludesUUID);
    34393440        elmMachine.getAttributeValue("nameSync", machineUserData.fNameSync);
    34403441
     
    46434644    elmMachine.setAttribute("uuid", uuid.toStringCurly());
    46444645    elmMachine.setAttribute("name", machineUserData.strName);
     4646    if (machineUserData.fDirectoryIncludesUUID)
     4647        elmMachine.setAttribute("directoryIncludesUUID", machineUserData.fDirectoryIncludesUUID);
    46454648    if (!machineUserData.fNameSync)
    46464649        elmMachine.setAttribute("nameSync", machineUserData.fNameSync);
     
    48424845    if (m->sv < SettingsVersion_v1_13)
    48434846    {
    4844         // VirtualBox 4.2 adds tracing, autostart and groups.
     4847        // VirtualBox 4.2 adds tracing, autostart, UUID in directory and groups.
    48454848        if (   !debugging.areDefaultSettings()
    48464849            || !autostart.areDefaultSettings()
     4850            || machineUserData.fDirectoryIncludesUUID
    48474851            || machineUserData.llGroups.size() > 1
    48484852            || machineUserData.llGroups.front() != "/")
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