Changeset 31461 in vbox
- Timestamp:
- Aug 9, 2010 8:13:58 AM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxManage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r31257 r31461 154 154 : "", 155 155 (u64Cmd & USAGE_SETHDUUID) 156 ? " sethduuid <filepath> \n"156 ? " sethduuid <filepath> [<uuid>]\n" 157 157 " Assigns a new UUID to the given image file. This way, multiple copies\n" 158 158 " of a container can be registered.\n" 159 159 "\n" 160 : "", 161 (u64Cmd & USAGE_SETHDPARENTUUID) 162 ? " sethdparentuuid <filepath> <uuid>\n" 163 " Assigns a new parent UUID to the given image file.\n" 164 "\n" 160 165 : "", 161 166 (u64Cmd & USAGE_DUMPHDINFO) … … 515 520 static int CmdSetHDUUID(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession) 516 521 { 517 /* we need exactly one parameter: the image file */518 if (argc != 1)519 {520 return errorSyntax(USAGE_SETHDUUID, "Not enough parameters");521 }522 523 /* generate a new UUID */524 522 Guid uuid; 525 uuid.create(); 523 RTUUID rtuuid; 524 enum eUuidType { 525 HDUUID, 526 HDPARENTUUID 527 } uuidType; 528 529 if (!strcmp(argv[0], "sethduuid")) 530 { 531 uuidType = HDUUID; 532 if (argc != 3 && argc != 2) 533 return errorSyntax(USAGE_SETHDUUID, "Not enough parameters"); 534 /* if specified, take UUID, otherwise generate a new one */ 535 if (argc == 3) 536 { 537 if (RT_FAILURE(RTUuidFromStr(&rtuuid, argv[2]))) 538 return errorSyntax(USAGE_SETHDUUID, "Invalid UUID parameter"); 539 uuid = argv[2]; 540 } else 541 uuid.create(); 542 } 543 else if (!strcmp(argv[0], "sethdparentuuid")) 544 { 545 uuidType = HDPARENTUUID; 546 if (argc != 3) 547 return errorSyntax(USAGE_SETHDPARENTUUID, "Not enough parameters"); 548 if (RT_FAILURE(RTUuidFromStr(&rtuuid, argv[2]))) 549 return errorSyntax(USAGE_SETHDPARENTUUID, "Invalid UUID parameter"); 550 uuid = argv[2]; 551 } 552 else 553 return errorSyntax(USAGE_SETHDUUID, "Invalid invocation"); 526 554 527 555 /* just try it */ 528 556 char *pszFormat = NULL; 529 int rc = VDGetFormat(NULL, argv[ 0], &pszFormat);557 int rc = VDGetFormat(NULL, argv[1], &pszFormat); 530 558 if (RT_FAILURE(rc)) 531 559 { … … 556 584 557 585 /* Open the image */ 558 rc = VDOpen(pDisk, pszFormat, argv[ 0], VD_OPEN_FLAGS_NORMAL, NULL);586 rc = VDOpen(pDisk, pszFormat, argv[1], VD_OPEN_FLAGS_NORMAL, NULL); 559 587 if (RT_FAILURE(rc)) 560 588 { … … 563 591 } 564 592 565 rc = VDSetUuid(pDisk, VD_LAST_IMAGE, uuid.raw()); 593 if (uuidType == HDUUID) 594 rc = VDSetUuid(pDisk, VD_LAST_IMAGE, uuid.raw()); 595 else 596 rc = VDSetParentUuid(pDisk, VD_LAST_IMAGE, uuid.raw()); 566 597 if (RT_FAILURE(rc)) 567 598 RTPrintf("Error while setting a new UUID: %Rrc\n", rc); … … 1983 2014 //if (!strcmp(pszCmd, "unloadsyms")) 1984 2015 // return CmdUnloadSyms(argc - 1 , &a->argv[1]); 1985 if (!strcmp(pszCmd, "sethduuid") || !strcmp(pszCmd, "set vdiuuid"))1986 return CmdSetHDUUID(a->argc - 1, &a->argv[1], a->virtualBox, a->session);2016 if (!strcmp(pszCmd, "sethduuid") || !strcmp(pszCmd, "sethdparentuuid")) 2017 return CmdSetHDUUID(a->argc, &a->argv[0], a->virtualBox, a->session); 1987 2018 if (!strcmp(pszCmd, "dumphdinfo")) 1988 2019 return CmdDumpHDInfo(a->argc - 1, &a->argv[1], a->virtualBox, a->session); -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r30319 r31461 94 94 #endif /* VBOX_WITH_GUEST_CONTROL defined */ 95 95 #define USAGE_DEBUGLOG RT_BIT_64(52) 96 #define USAGE_SETHDPARENTUUID RT_BIT_64(53) 96 97 #define USAGE_ALL (~(uint64_t)0) 97 98 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.