VirtualBox

Changeset 72511 in vbox for trunk


Ignore:
Timestamp:
Jun 11, 2018 2:12:17 PM (7 years ago)
Author:
vboxsync
Message:

Main/Appliance: Correctly handle appliance import when the VM is already in a group (i.e. created by VirtualBox, having <Machine> tag in the OVF file). Additionally use the usual root group notation instead of empty strings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r72476 r72511  
    199199                                 nameVBox);
    200200
     201            /* VM Primary Group */
     202            Utf8Str strPrimaryGroup;
     203            if (pNewDesc->m->pConfig->machineUserData.llGroups.size())
     204                strPrimaryGroup = pNewDesc->m->pConfig->machineUserData.llGroups.front();
     205            if (strPrimaryGroup.isEmpty())
     206                strPrimaryGroup = "/";
     207            pNewDesc->i_addEntry(VirtualSystemDescriptionType_PrimaryGroup,
     208                                 "",
     209                                 "" /* no direct OVF correspondence */,
     210                                 strPrimaryGroup);
     211
    201212            /* Based on the VM name, create a target machine path. */
    202213            Bstr bstrSettingsFilename;
    203214            rc = mVirtualBox->ComposeMachineFilename(Bstr(nameVBox).raw(),
    204                                                      NULL /* aGroup */,
     215                                                     Bstr(strPrimaryGroup).raw(),
    205216                                                     NULL /* aCreateFlags */,
    206217                                                     NULL /* aBaseFolder */,
     
    212223#if 1
    213224            /* The import logic should work exactly the same whether the
    214              * following 3 items are present or not, but of course it may have
     225             * following 2 items are present or not, but of course it may have
    215226             * an influence on the exact presentation of the import settings
    216227             * of an API client. */
     
    226237                                 "" /* no direct OVF correspondence */,
    227238                                 strBaseFolder);
    228             pNewDesc->i_addEntry(VirtualSystemDescriptionType_PrimaryGroup,
    229                                  "",
    230                                  "" /* no direct OVF correspondence */,
    231                                  "");
    232239#endif
    233240
     
    26752682    /* Create the machine */
    26762683    SafeArray<BSTR> groups; /* no groups, or maybe one group... */
    2677     if (!stack.strPrimaryGroup.isEmpty())
     2684    if (!stack.strPrimaryGroup.isEmpty() && stack.strPrimaryGroup != "/")
    26782685        Bstr(stack.strPrimaryGroup).detachTo(groups.appendedRaw());
    26792686    rc = mVirtualBox->CreateMachine(Bstr(stack.strSettingsFilename).raw(),
     
    34433450    config.machineUserData.strOsType = stack.strOsTypeVBox;
    34443451    /* Groups */
    3445     if (!stack.strPrimaryGroup.isEmpty())
     3452    if (stack.strPrimaryGroup.isEmpty() || stack.strPrimaryGroup == "/")
    34463453    {
    34473454        config.machineUserData.llGroups.clear();
    3448         config.machineUserData.llGroups.push_back(stack.strPrimaryGroup);
     3455        config.machineUserData.llGroups.push_back("/");
     3456    }
     3457    else
     3458    {
     3459        /* Replace the primary group if there is one, otherwise add it. */
     3460        if (config.machineUserData.llGroups.size())
     3461            config.machineUserData.llGroups.pop_front();
     3462        config.machineUserData.llGroups.push_front(stack.strPrimaryGroup);
    34493463    }
    34503464    /* Description */
     
    40034017        std::list<VirtualSystemDescriptionEntry*> vsdePrimaryGroup = vsdescThis->i_findByType(VirtualSystemDescriptionType_PrimaryGroup);
    40044018        if (vsdePrimaryGroup.size() >= 1)
     4019        {
    40054020            stack.strPrimaryGroup = vsdePrimaryGroup.front()->strVBoxCurrent;
     4021            if (stack.strPrimaryGroup.isEmpty())
     4022                stack.strPrimaryGroup = "/";
     4023        }
    40064024
    40074025        // Draw the right conclusions from the (possibly modified) VM settings
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