Changeset 42176 in vbox for trunk/src/VBox
- Timestamp:
- Jul 17, 2012 12:23:50 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 79173
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r41347 r42176 24 24 #include <VBox/com/VirtualBox.h> 25 25 #include <VBox/com/string.h> 26 #include <VBox/com/array.h> 26 27 #endif /* !VBOX_ONLY_DOCS */ 27 28 … … 171 172 172 173 /* VBoxManageModifyVM.cpp */ 174 #ifndef VBOX_ONLY_DOCS 175 void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups); 176 #endif 173 177 int handleModifyVM(HandlerArg *a); 174 178 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r42129 r42176 137 137 RTStrmPrintf(pStrm, 138 138 "VBoxManage createvm --name <name>\n" 139 " [--groups <group>, ...]\n" 139 140 " [--ostype <ostype>]\n" 140 141 " [--register]\n" … … 148 149 "VBoxManage modifyvm <uuid|name>\n" 149 150 " [--name <name>]\n" 151 " [--groups <group>, ...]\n" 150 152 " [--ostype <ostype>]\n" 151 153 " [--memory <memorysize in MB>]\n" … … 355 357 " keepdisknames]\n" 356 358 " [--name <name>]\n" 359 " [--groups <group>, ...]\n" 357 360 " [--basefolder <basefolder>]\n" 358 361 " [--uuid <uuid>]\n" -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r42131 r42176 191 191 Bstr bstrBaseFolder; 192 192 Bstr bstrName; 193 Bstr bstrGroups;194 193 Bstr bstrOsTypeId; 195 194 Bstr bstrUuid; 196 195 bool fRegister = false; 196 com::SafeArray<BSTR> groups; 197 197 198 198 int c; … … 211 211 212 212 case 'g': // --groups 213 bstrGroups = ValueUnion.psz; 214 /// @todo implement group string parsing to safearray 213 parseGroups(ValueUnion.psz, &groups); 215 214 break; 216 215 … … 242 241 do 243 242 { 243 Bstr bstrPrimaryGroup; 244 if (groups.size()) 245 bstrPrimaryGroup = groups[0]; 244 246 Bstr bstrSettingsFile; 245 247 CHECK_ERROR_BREAK(a->virtualBox, 246 248 ComposeMachineFilename(bstrName.raw(), 247 NULL /* aGroup */,249 bstrPrimaryGroup.raw(), 248 250 bstrBaseFolder.raw(), 249 251 bstrSettingsFile.asOutParam())); 250 252 ComPtr<IMachine> machine; 251 com::SafeArray<BSTR> groups; /* no groups */252 253 CHECK_ERROR_BREAK(a->virtualBox, 253 254 CreateMachine(bstrSettingsFile.raw(), … … 347 348 com::SafeArray<CloneOptions_T> options; 348 349 const char *pszTrgName = NULL; 349 const char *pszTrgGroups = NULL;350 350 const char *pszTrgBaseFolder = NULL; 351 351 bool fRegister = false; 352 352 Bstr bstrUuid; 353 com::SafeArray<BSTR> groups; 353 354 354 355 int c; … … 371 372 372 373 case 'g': // --groups 373 pszTrgGroups = ValueUnion.psz; 374 /// @todo implement group string parsing to safearray 374 parseGroups(ValueUnion.psz, &groups); 375 375 break; 376 376 … … 435 435 pszTrgName = RTStrAPrintf2("%s Clone", pszSrcName); 436 436 437 Bstr bstrPrimaryGroup; 438 if (groups.size()) 439 bstrPrimaryGroup = groups[0]; 437 440 Bstr bstrSettingsFile; 438 441 CHECK_ERROR_RET(a->virtualBox, 439 442 ComposeMachineFilename(Bstr(pszTrgName).raw(), 440 NULL /* aGroup */,443 bstrPrimaryGroup.raw(), 441 444 Bstr(pszTrgBaseFolder).raw(), 442 445 bstrSettingsFile.asOutParam()), … … 444 447 445 448 ComPtr<IMachine> trgMachine; 446 com::SafeArray<BSTR> groups; /* no groups */447 449 CHECK_ERROR_RET(a->virtualBox, CreateMachine(bstrSettingsFile.raw(), 448 450 Bstr(pszTrgName).raw(), -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp
r41925 r42176 53 53 { 54 54 MODIFYVM_NAME = 1000, 55 MODIFYVM_GROUPS, 55 56 MODIFYVM_OSTYPE, 56 57 MODIFYVM_MEMORY, … … 196 197 { 197 198 { "--name", MODIFYVM_NAME, RTGETOPT_REQ_STRING }, 199 { "--groups", MODIFYVM_GROUPS, RTGETOPT_REQ_STRING }, 198 200 { "--ostype", MODIFYVM_OSTYPE, RTGETOPT_REQ_STRING }, 199 201 { "--memory", MODIFYVM_MEMORY, RTGETOPT_REQ_UINT32 }, … … 364 366 } 365 367 368 void parseGroups(const char *pcszGroups, com::SafeArray<BSTR> *pGroups) 369 { 370 while (pcszGroups) 371 { 372 char *pComma = RTStrStr(pcszGroups, ","); 373 if (pComma) 374 { 375 Bstr(pcszGroups, pComma - pcszGroups).detachTo(pGroups->appendedRaw()); 376 pcszGroups = pComma + 1; 377 } 378 else 379 { 380 Bstr(pcszGroups).detachTo(pGroups->appendedRaw()); 381 pcszGroups = NULL; 382 } 383 } 384 } 385 366 386 int handleModifyVM(HandlerArg *a) 367 387 { … … 405 425 { 406 426 CHECK_ERROR(machine, COMSETTER(Name)(Bstr(ValueUnion.psz).raw())); 427 break; 428 } 429 case MODIFYVM_GROUPS: 430 { 431 com::SafeArray<BSTR> groups; 432 parseGroups(ValueUnion.psz, &groups); 433 CHECK_ERROR(machine, COMSETTER(Groups)(ComSafeArrayAsInParam(groups))); 407 434 break; 408 435 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r42133 r42176 491 491 <desc>Settings version "1.13", written by VirtualBox 4.2.x.</desc> 492 492 <!-- 493 Machine changes: tracing config; 493 Machine changes: tracing config, groups, autostart; 494 NetworkAdapter changes: unit for bandwidth group limits. 494 495 --> 495 496 </const> -
trunk/src/VBox/Main/xml/Settings.cpp
r41914 r42176 17 17 * 18 18 * Certainly ConfigFileBase::ConfigFileBase() will. Change VBOX_XML_VERSION below as well. 19 * VBOX_XML_VERSION does not have to be changed if the settings for a default VM do not 20 * touch newly introduced attributes or tags. It has the benefit that older VirtualBox 21 * versions do not trigger their "newer" code path. 19 22 * 20 23 * Once a new settings version has been added, these are the rules for introducing a new … … 323 326 else if (ulMinor == 12) 324 327 m->sv = SettingsVersion_v1_12; 325 else if (ulMinor > 12) 328 else if (ulMinor == 13) 329 m->sv = SettingsVersion_v1_13; 330 else if (ulMinor > 13) 326 331 m->sv = SettingsVersion_Future; 327 332 } … … 3224 3229 3225 3230 /** 3231 * Called for reading the <Groups> element under <Machine>. 3232 */ 3233 void MachineConfigFile::readGroups(const xml::ElementNode *pElmGroups, StringsList *pllGroups) 3234 { 3235 pllGroups->clear(); 3236 if (!pElmGroups || m->sv < SettingsVersion_v1_13) 3237 { 3238 pllGroups->push_back("/"); 3239 return; 3240 } 3241 3242 xml::NodesLoop nlGroups(*pElmGroups); 3243 const xml::ElementNode *pelmGroup; 3244 while ((pelmGroup = nlGroups.forAllNodes())) 3245 { 3246 if (pelmGroup->nameEquals("Group")) 3247 { 3248 Utf8Str strGroup; 3249 if (!pelmGroup->getAttributeValue("name", strGroup)) 3250 throw ConfigFileError(this, pelmGroup, N_("Required Group/@name attribute is missing")); 3251 pllGroups->push_back(strGroup); 3252 } 3253 } 3254 } 3255 3256 /** 3226 3257 * Called initially for the <Snapshot> element under <Machine>, if present, 3227 3258 * to store the snapshot's data into the given Snapshot structure (which is … … 3298 3329 readDebugging(elmSnapshot.findChildElement("Debugging"), &snap.debugging); 3299 3330 readAutostart(elmSnapshot.findChildElement("Autostart"), &snap.autostart); 3331 // note: Groups exist only for Machine, not for Snapshot 3300 3332 } 3301 3333 … … 3450 3482 else if (pelmMachineChild->nameEquals("Autostart")) 3451 3483 readAutostart(pelmMachineChild, &autostart); 3484 else if (pelmMachineChild->nameEquals("Groups")) 3485 readGroups(pelmMachineChild, &machineUserData.llGroups); 3452 3486 } 3453 3487 … … 4431 4465 4432 4466 /** 4467 * Creates a <Groups> node under elmParent and then writes out the XML 4468 * keys under that. Called for the <Machine> node only. 4469 * 4470 * @param pElmParent Pointer to the parent element. 4471 * @param pllGroups Pointer to the groups list. 4472 */ 4473 void MachineConfigFile::buildGroupsXML(xml::ElementNode *pElmParent, const StringsList *pllGroups) 4474 { 4475 if ( m->sv < SettingsVersion_v1_13 || pllGroups->size() == 0 4476 || (pllGroups->size() == 1 && pllGroups->front() == "/")) 4477 return; 4478 4479 xml::ElementNode *pElmGroups = pElmParent->createChild("Groups"); 4480 for (StringsList::const_iterator it = pllGroups->begin(); 4481 it != pllGroups->end(); 4482 ++it) 4483 { 4484 const Utf8Str &group = *it; 4485 xml::ElementNode *pElmGroup = pElmGroups->createChild("Group"); 4486 pElmGroup->setAttribute("name", group); 4487 } 4488 } 4489 4490 /** 4433 4491 * Writes a single snapshot into the DOM tree. Initially this gets called from MachineConfigFile::write() 4434 4492 * for the root snapshot of a machine, if present; elmParent then points to the <Snapshots> node under the … … 4461 4519 buildDebuggingXML(pelmSnapshot, &snap.debugging); 4462 4520 buildAutostartXML(pelmSnapshot, &snap.autostart); 4521 // note: Groups exist only for Machine, not for Snapshot 4463 4522 4464 4523 if (snap.llChildSnapshots.size()) … … 4610 4669 buildDebuggingXML(&elmMachine, &debugging); 4611 4670 buildAutostartXML(&elmMachine, &autostart); 4671 buildGroupsXML(&elmMachine, &machineUserData.llGroups); 4612 4672 } 4613 4673 … … 4727 4787 if (m->sv < SettingsVersion_v1_13) 4728 4788 { 4729 // VirtualBox 4.2 adds tracing and autostart.4789 // VirtualBox 4.2 adds tracing, autostart and groups. 4730 4790 if ( !debugging.areDefaultSettings() 4731 || !autostart.areDefaultSettings()) 4791 || !autostart.areDefaultSettings() 4792 || machineUserData.llGroups.size() > 1 4793 || machineUserData.llGroups.front() != "/") 4732 4794 m->sv = SettingsVersion_v1_13; 4733 4795 }
Note:
See TracChangeset
for help on using the changeset viewer.