VirtualBox

Changeset 31461 in vbox


Ignore:
Timestamp:
Aug 9, 2010 8:13:58 AM (15 years ago)
Author:
vboxsync
Message:

added VBoxManage internalcommands sethdparentuuid

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
2 edited

Legend:

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

    r31257 r31461  
    154154             : "",
    155155             (u64Cmd & USAGE_SETHDUUID)
    156              ? "  sethduuid <filepath>\n"
     156             ? "  sethduuid <filepath> [<uuid>]\n"
    157157               "       Assigns a new UUID to the given image file. This way, multiple copies\n"
    158158               "       of a container can be registered.\n"
    159159               "\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"
    160165             : "",
    161166             (u64Cmd & USAGE_DUMPHDINFO)
     
    515520static int CmdSetHDUUID(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
    516521{
    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 */
    524522    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");
    526554
    527555    /* just try it */
    528556    char *pszFormat = NULL;
    529     int rc = VDGetFormat(NULL, argv[0], &pszFormat);
     557    int rc = VDGetFormat(NULL, argv[1], &pszFormat);
    530558    if (RT_FAILURE(rc))
    531559    {
     
    556584
    557585    /* 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);
    559587    if (RT_FAILURE(rc))
    560588    {
     
    563591    }
    564592
    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());
    566597    if (RT_FAILURE(rc))
    567598        RTPrintf("Error while setting a new UUID: %Rrc\n", rc);
     
    19832014    //if (!strcmp(pszCmd, "unloadsyms"))
    19842015    //    return CmdUnloadSyms(argc - 1 , &a->argv[1]);
    1985     if (!strcmp(pszCmd, "sethduuid") || !strcmp(pszCmd, "setvdiuuid"))
    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);
    19872018    if (!strcmp(pszCmd, "dumphdinfo"))
    19882019        return CmdDumpHDInfo(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r30319 r31461  
    9494#endif  /* VBOX_WITH_GUEST_CONTROL defined */
    9595#define USAGE_DEBUGLOG              RT_BIT_64(52)
     96#define USAGE_SETHDPARENTUUID       RT_BIT_64(53)
    9697#define USAGE_ALL                   (~(uint64_t)0)
    9798/** @} */
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