VirtualBox

Changeset 51889 in vbox


Ignore:
Timestamp:
Jul 6, 2014 7:40:14 PM (10 years ago)
Author:
vboxsync
Message:

FE/VBoxManage: Interface for setting, getting and deleting medium properties

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

Legend:

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

    r49621 r51889  
    480480            { "unregistervm",     USAGE_UNREGISTERVM,      handleUnregisterVM },
    481481            { "clonevm",          USAGE_CLONEVM,           handleCloneVM },
     482            { "hdproperty",       USAGE_HDPROPERTY,        handleMediumProperty },
    482483            { "createhd",         USAGE_CREATEHD,          handleCreateHardDisk },
    483484            { "createvdi",        USAGE_CREATEHD,          handleCreateHardDisk }, /* backward compatibility */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r49621 r51889  
    104104#define USAGE_REPAIRHD              RT_BIT_64(58)
    105105#define USAGE_NATNETWORK            RT_BIT_64(59)
     106#define USAGE_HDPROPERTY            RT_BIT_64(60)
    106107#define USAGE_ALL                   (~(uint64_t)0)
    107108/** @} */
     
    260261int handleModifyHardDisk(HandlerArg *a);
    261262int handleCloneHardDisk(HandlerArg *a);
     263int handleMediumProperty(HandlerArg *a);
    262264RTEXITCODE handleConvertFromRaw(int argc, char *argv[]);
    263265HRESULT showMediumInfo(const ComPtr<IVirtualBox> &pVirtualBox,
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r49039 r51889  
    13521352    return SUCCEEDED(rc) ? 0 : 1;
    13531353}
     1354
     1355int handleMediumProperty(HandlerArg *a)
     1356{
     1357    HRESULT rc = S_OK;
     1358    const char *pszAction = NULL;
     1359    const char *pszFilenameOrUuid = NULL;
     1360    const char *pszProperty = NULL;
     1361    ComPtr<IMedium> pMedium;
     1362
     1363    if (a->argc == 0)
     1364        return errorSyntax(USAGE_HDPROPERTY, "Missing action");
     1365
     1366    pszAction = a->argv[0];
     1367    if (   RTStrICmp(pszAction, "set")
     1368        && RTStrICmp(pszAction, "get")
     1369        && RTStrICmp(pszAction, "delete"))
     1370        return errorSyntax(USAGE_HDPROPERTY, "Invalid action given: %s", pszAction);
     1371
     1372    if (   (   !RTStrICmp(pszAction, "set")
     1373            && a->argc != 4)
     1374        || (   RTStrICmp(pszAction, "set")
     1375            && a->argc != 3))
     1376        return errorSyntax(USAGE_HDPROPERTY, "Invalid number of arguments given for action: %s", pszAction);
     1377
     1378    pszFilenameOrUuid = a->argv[1];
     1379    pszProperty       = a->argv[2];
     1380
     1381    rc = openMedium(a, pszFilenameOrUuid, DeviceType_HardDisk,
     1382                    AccessMode_ReadWrite, pMedium,
     1383                    false /* fForceNewUuidOnOpen */, false /* fSilent */);
     1384    if (SUCCEEDED(rc) && !pMedium.isNull())
     1385    {
     1386        if (!RTStrICmp(pszAction, "set"))
     1387        {
     1388            const char *pszValue = a->argv[3];
     1389            CHECK_ERROR(pMedium, SetProperty(Bstr(pszProperty).raw(), Bstr(pszValue).raw()));
     1390        }
     1391        else if (!RTStrICmp(pszAction, "get"))
     1392        {
     1393            Bstr strVal;
     1394            CHECK_ERROR(pMedium, GetProperty(Bstr(pszProperty).raw(), strVal.asOutParam()));
     1395            if (SUCCEEDED(rc))
     1396                RTPrintf("%s=%ls\n", pszProperty, strVal.raw());
     1397        }
     1398        else if (!RTStrICmp(pszAction, "delete"))
     1399        {
     1400            /** @todo */
     1401        }
     1402    }
     1403
     1404    return SUCCEEDED(rc) ? 0 : 1;
     1405}
     1406
    13541407#endif /* !VBOX_ONLY_DOCS */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r50996 r51889  
    615615                     "\n", SEP);
    616616
     617    if (fCategory & USAGE_HDPROPERTY)
     618        RTStrmPrintf(pStrm,
     619                           "%s hdproperty %s      set <uuid|filename>\n"
     620                     "                            <property> <value>\n"
     621                     "\n"
     622                     "                            get <uuid|filename>\n"
     623                     "                            <property>\n"
     624                     "\n"
     625                     "                            delete <uuid|filename>\n"
     626                     "                            <property>\n"
     627                     "\n", SEP);
     628
    617629    if (fCategory & USAGE_CONVERTFROMRAW)
    618630        RTStrmPrintf(pStrm,
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