VirtualBox

Changeset 5292 in vbox for trunk/src


Ignore:
Timestamp:
Oct 15, 2007 12:04:26 PM (17 years ago)
Author:
vboxsync
Message:

API change to allow VM to be created with predefined UUID.

Location:
trunk/src/VBox
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r5280 r5292  
    302302                 "                            [-register]\n"
    303303                 "                            [-basefolder <path> | -settingsfile <path>]\n"
     304                 "                            [-uuid <uuid>]\n"
    304305                 "                            \n"
    305306                 "\n");
     
    34343435    Bstr settingsFile;
    34353436    Bstr name;
     3437    RTUUID id;
    34363438    bool fRegister = false;
    34373439
     
    34653467            name = argv[i];
    34663468        }
     3469        else if (strcmp(argv[i], "-uuid") == 0)
     3470        {
     3471            if (argc <= i + 1)
     3472            {
     3473                return errorArgument("Missing argument to '%s'", argv[i]);
     3474            }
     3475            i++;
     3476            if (VBOX_FAILURE(RTUuidFromStr(&id, argv[i])))
     3477            {
     3478                return errorArgument("Invalid UUID format %s\n", argv[i]);
     3479            }
     3480        }
    34673481        else if (strcmp(argv[i], "-register") == 0)
    34683482        {
     
    34893503        if (!settingsFile)
    34903504            CHECK_ERROR_BREAK(virtualBox,
    3491                 CreateMachine(baseFolder, name, machine.asOutParam()));
     3505                CreateMachine(baseFolder, name, Guid(id), machine.asOutParam()));
    34923506        else
    34933507            CHECK_ERROR_BREAK(virtualBox,
    3494                 CreateLegacyMachine(settingsFile, name, machine.asOutParam()));
     3508                CreateLegacyMachine(settingsFile, name, Guid(id), machine.asOutParam()));
    34953509
    34963510        CHECK_ERROR_BREAK(machine, SaveSettings());
  • trunk/src/VBox/Frontends/VirtualBox/ui/VBoxNewVMWzd.ui.h

    r4071 r5292  
    311311    if (cmachine.isNull())
    312312    {
    313         cmachine = vbox.CreateMachine (QString(), leName->text());
     313        cmachine = vbox.CreateMachine (QString(), leName->text(), QUuid());
    314314        if (!vbox.isOk())
    315315        {
  • trunk/src/VBox/Main/MachineImpl.cpp

    r5235 r5292  
    337337 *                      user and should never change. Used only in Init_New
    338338 *                      mode (ignored otherwise).
    339  *  @param aId          UUID of the machine (used only for consistency
     339 *  @param aId          UUID of the machine. Required for aMode==Init_Registered
     340 *                      and optional for aMode==Init_New. Used for consistency
    340341 *                      check when aMode is Init_Registered; must match UUID
    341  *                      stored in the settings file).
     342 *                      stored in the settings file. Used for predefining the
     343 *                      UUID of a VM when aMode is Init_New.
    342344 *
    343345 *  @return  Success indicator. if not S_OK, the machine object is invalid
     
    454456            {
    455457                /* create the machine UUID */
    456                 unconst (mData->mUuid).create();
     458                if (aId)
     459                    unconst (mData->mUuid) = *aId;
     460                else
     461                    unconst (mData->mUuid).create();
    457462
    458463                /* memorize the provided new machine's name */
     
    26182623 *  Returns @c true if the given DVD image is attached to this machine either
    26192624 *  in the current state or in any of the snapshots.
    2620  * 
     2625 *
    26212626 *  @param aId          Image ID to check.
    26222627 *  @param aUsage       Type of the check.
     
    26912696}
    26922697
    2693 /** 
     2698/**
    26942699 *  Returns @c true if the given Floppy image is attached to this machine either
    26952700 *  in the current state or in any of the snapshots.
    2696  * 
     2701 *
    26972702 *  @param aId          Image ID to check.
    26982703 *  @param aUsage       Type of the check.
     
    34233428/////////////////////////////////////////////////////////////////////////////
    34243429
    3425 /** 
     3430/**
    34263431 *  Performs machine state checks based on the @a aDepType value. If a check
    34273432 *  fails, this method will set extended error info, otherwise it will return
     
    34363441 *  and not saved). It is useful to call this method from Machine setters
    34373442 *  before performing any change.
    3438  * 
     3443 *
    34393444 *  When @a aDepType is MutableOrSavedStateDep, this method behaves the same
    34403445 *  as for MutableStateDep except that if the machine is saved, S_OK is also
     
    64706475                           !!mNetworkAdapters [slot]->data()->mCableConnected);
    64716476
    6472             CFGLDRSetUInt32 (networkAdapterNode, "speed", 
     6477            CFGLDRSetUInt32 (networkAdapterNode, "speed",
    64736478                             mNetworkAdapters [slot]->data()->mLineSpeed);
    64746479
     
    67186723                         mHWData->mMemoryBalloonSize);
    67196724        CFGLDRSetUInt32 (guestNode, "StatisticsUpdateInterval",
    6720                          mHWData->mStatisticsUpdateInterval);               
     6725                         mHWData->mStatisticsUpdateInterval);
    67216726
    67226727        CFGLDRReleaseNode (guestNode);
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r5236 r5292  
    626626STDMETHODIMP VirtualBox::CreateMachine (INPTR BSTR aBaseFolder,
    627627                                        INPTR BSTR aName,
     628                                        INPTR GUIDPARAM aId,
    628629                                        IMachine **aMachine)
    629630{
     
    669670    if (SUCCEEDED (rc))
    670671    {
     672        /* Create UUID if an empty one was specified. */
     673        Guid id = aId;
     674        if (id.isEmpty())
     675            id.create();
     676
    671677        /* initialize the machine object */
    672         rc = machine->init (this, settingsFile, Machine::Init_New, aName);
     678        rc = machine->init (this, settingsFile, Machine::Init_New, aName, TRUE, &id);
    673679        if (SUCCEEDED (rc))
    674680        {
     
    687693STDMETHODIMP VirtualBox::CreateLegacyMachine (INPTR BSTR aSettingsFile,
    688694                                              INPTR BSTR aName,
     695                                              INPTR GUIDPARAM aId,
    689696                                              IMachine **aMachine)
    690697{
     
    717724    if (SUCCEEDED (rc))
    718725    {
     726        /* Create UUID if an empty one was specified. */
     727        Guid id = aId;
     728        if (id.isEmpty())
     729            id.create();
     730
    719731        /* initialize the machine object */
    720732        rc = machine->init (this, Bstr (settingsFile), Machine::Init_New,
    721                             aName, FALSE /* aNameSync */);
     733                            aName, FALSE /* aNameSync */, &id);
    722734        if (SUCCEEDED (rc))
    723735        {
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r5252 r5292  
    808808  <interface
    809809     name="IVirtualBox" extends="$dispatched"
    810      uuid="76b25f3c-15d4-4785-a9d3-adc6a462beec"
     810     uuid="e1606565-8954-4703-b22a-620941b85a1c"
    811811     wsmap="global"
    812812     >
     
    915915          &lt;base_folder&gt;/&lt;machine_name&gt;/&lt;machine_name&gt;.xml</pre>
    916916
     917        Optionally the UUID of the machine can be predefined. If this is
     918        not desired (i.e. a new UUID should be generated), pass just an
     919        empty or null UUID.
     920
    917921        Note that the configuration of the newly created machine is not
    918922        saved to disk (and therefore no settings subfolder and file are
     
    940944        <desc>Machine name.</desc>
    941945      </param>
     946      <param name="id" type="uuid" dir="in">
     947        <desc>
     948          UUID of the newly created VM, when non-null or non-empty.
     949          Otherwise a UUID is automatically generated.
     950        </desc>
     951      </param>
    942952      <param name="machine" type="IMachine" dir="return">
    943953        <desc>Created machine object.</desc>
     
    962972        appended.
    963973
     974        Optionally the UUID of the machine can be predefined. If this is
     975        not desired (i.e. a new UUID should be generated), pass just an
     976        empty or null UUID.
     977
    964978        Note that the configuration of the newly created machine is not
    965979        saved to disk (and therefore no settings file is created)
     
    9901004      <param name="name" type="wstring" dir="in">
    9911005        <desc>Machine name.</desc>
     1006      </param>
     1007      <param name="id" type="uuid" dir="in">
     1008        <desc>
     1009          UUID of the newly created VM, when non-null or non-empty.
     1010          Otherwise a UUID is automatically generated.
     1011        </desc>
    9921012      </param>
    9931013      <param name="machine" type="IMachine" dir="return">
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r5218 r5292  
    124124
    125125    STDMETHOD(CreateMachine) (INPTR BSTR aBaseFolder, INPTR BSTR aName,
    126                               IMachine **aMachine);
     126                              INPTR GUIDPARAM aId, IMachine **aMachine);
    127127    STDMETHOD(CreateLegacyMachine) (INPTR BSTR aSettingsFile, INPTR BSTR aName,
    128                                     IMachine **aMachine);
     128                                    INPTR GUIDPARAM aId, IMachine **aMachine);
    129129    STDMETHOD(OpenMachine) (INPTR BSTR aSettingsFile, IMachine **aMachine);
    130130    STDMETHOD(RegisterMachine) (IMachine *aMachine);
  • trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp

    r4246 r5292  
    140140     * in the configuration until we explicitely choose to do so.
    141141     */
     142    nsID VMuuid = {0};
    142143    nsCOMPtr <IMachine> machine;
    143144    rc = virtualBox->CreateMachine(nsnull, NS_LITERAL_STRING("A brand new name").get(),
    144                                    getter_AddRefs(machine));
     145                                   VMuuid, getter_AddRefs(machine));
    145146    if (NS_FAILED(rc))
    146147    {
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