VirtualBox

Changeset 92538 in vbox


Ignore:
Timestamp:
Nov 22, 2021 1:53:20 AM (3 years ago)
Author:
vboxsync
Message:

VBoxManage/modifyvm,showvminfo: Added --testing-enabled=bool, --testing-mmio=bool and --testing-cfg-dwordN=val switches to modifyvm for easy VMMDev/Testing config. Display these settings in showvminfo.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/man_VBoxManage-modifyvm.xml

    r92534 r92538  
    617617      <arg>--pci-detach=<replaceable>host-PCI-address</replaceable></arg>
    618618    </cmdsynopsis>
     619
     620    <cmdsynopsis id="synopsis-vboxmanage-modifyvm-testing">
     621      <command>VBoxManage modifyvm</command>
     622      <group choice="req">
     623        <arg choice="plain"><replaceable>uuid</replaceable></arg>
     624        <arg choice="plain"><replaceable>vmname</replaceable></arg>
     625      </group>
     626      <arg>--testing-enabled=<group choice="plain"><arg choice="plain">on</arg><arg choice="plain">off</arg></group></arg>
     627      <arg>--testing-mmio=<group choice="plain"><arg choice="plain">on</arg><arg choice="plain">off</arg></group></arg>
     628      <arg>--testing-cfg-dword<replaceable>idx</replaceable>=<replaceable>value</replaceable></arg>
     629    </cmdsynopsis>
    619630  </refsynopsisdiv>
    620631
     
    26522663      </variablelist>
    26532664    </refsect2>
     2665    <refsect2 id="vboxmanage-modifyvm-testing">
     2666      <title>Testing (ValidationKit / Bootsector)</title>
     2667      <para>
     2668        These options are for configuring the testing functionality of the VMM
     2669        device and almost exclusively used by the bootsector testcases in the
     2670        ValidationKit.
     2671      </para>
     2672      <remark role="help-copy-synopsis"/>
     2673      <variablelist>
     2674        <varlistentry>
     2675          <term><option>--testing-enabled=on | off</option></term>
     2676          <listitem><para>Enabled the testing functionality of the VMMDev. See VMMDevTesting.h for details. </para></listitem>
     2677        </varlistentry>
     2678        <varlistentry>
     2679          <term><option>--testing-mmio=on | off</option></term>
     2680          <listitem><para>Enabled the MMIO region of the VMMDev testing feature.</para></listitem>
     2681        </varlistentry>
     2682        <varlistentry>
     2683          <term><option>--testing-cfg-dword<replaceable>idx</replaceable>=<replaceable>value</replaceable></option></term>
     2684          <listitem><para>
     2685                This sets one of the 10 dword configuration values. The
     2686                <replaceable>idx</replaceable> must be in the range 0 thru 9.
     2687                The <replaceable>value</replaceable> is limited to 32 bits (dword).
     2688            </para></listitem>
     2689        </varlistentry>
     2690      </variablelist>
     2691    </refsect2>
     2692
    26542693  </refsect1>
    26552694
     
    26722711    <title>See Also</title>
    26732712    <para>
     2713      <xref linkend="vboxmanage-showvminfo" />,
    26742714      <xref linkend="vboxmanage-controlvm" />,
    26752715      <xref linkend="vboxmanage-createvm" />,
    2676       <xref linkend="vboxmanage-list" />,
    26772716      <xref linkend="vboxmanage-startvm" />
     2717      <xref linkend="vboxmanage-list" />
    26782718    </para>
    26792719  </refsect1>
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r92404 r92538  
    296296 * react a little slower than in the ideal case).
    297297 */
    298 HRESULT showProgress(ComPtr<IProgress> progress, unsigned int fFlags)
     298HRESULT showProgress(ComPtr<IProgress> progress, uint32_t fFlags)
    299299{
    300300    using namespace com;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r92534 r92538  
    238238RTEXITCODE errorGetOpt(USAGECATEGORY enmCommand, int rc, union RTGETOPTUNION const *pValueUnion);
    239239RTEXITCODE errorGetOptEx(USAGECATEGORY enmCommand, uint64_t fSubcommandScope, int rc, union RTGETOPTUNION const *pValueUnion);
    240 RTEXITCODE errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
    241240
    242241void printUsageInternal(USAGECATEGORY enmCommand, PRTSTREAM pStrm);
     
    253252RTEXITCODE  errorGetOpt(int rcGetOpt, union RTGETOPTUNION const *pValueUnion);
    254253RTEXITCODE  errorFetchValue(int iValueNo, const char *pszOption, int rcGetOptFetchValue, union RTGETOPTUNION const *pValueUnion);
    255 RTEXITCODE  errorSyntax(const char *pszFormat, ...);
    256 
    257 
    258 #define SHOW_PROGRESS_NONE      0
    259 #define SHOW_PROGRESS_DESC      (1u << 0)
    260 #define SHOW_PROGRESS           (1u << 1)
    261 #define SHOW_PROGRESS_DETAILS   (1u << 2)
    262 HRESULT showProgress(ComPtr<IProgress> progress, unsigned int fFlags = SHOW_PROGRESS);
     254RTEXITCODE  errorSyntax(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
     255RTEXITCODE  errorSyntaxV(const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(1, 0);
     256HRESULT     errorSyntaxHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
     257RTEXITCODE  errorArgument(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
     258HRESULT     errorArgumentHr(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
     259
     260# define SHOW_PROGRESS_NONE     0
     261# define SHOW_PROGRESS_DESC     RT_BIT_32(0)
     262# define SHOW_PROGRESS          RT_BIT_32(1)
     263# define SHOW_PROGRESS_DETAILS  RT_BIT_32(2)
     264HRESULT showProgress(ComPtr<IProgress> progress, uint32_t fFlags = SHOW_PROGRESS);
    263265#endif
    264266
     
    309311HRESULT showBandwidthGroups(ComPtr<IBandwidthControl> &bwCtrl,
    310312                            VMINFO_DETAILS details);
    311 void outputMachineReadableString(const char *pszName, const char *pszValue);
    312 void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue);
     313void outputMachineReadableString(const char *pszName, const char *pszValue, bool fQuoteName = false);
     314void outputMachineReadableString(const char *pszName, com::Bstr const *pbstrValue, bool fQuoteName = false);
     315void outputMachineReadableStringWithFmtName(const char *pszValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
     316void outputMachineReadableStringWithFmtName(com::Bstr const *pbstrValue, bool fQuoteName, const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(3, 4);
    313317void outputMachineReadableBool(const char *pszName, BOOL const *pfValue);
    314318void outputMachineReadableBool(const char *pszName, bool const *pfValue);
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r92432 r92538  
    247247 * @returns RTEXITCODE_SYNTAX.
    248248 * @param   pszFormat           Custom error message format string.
    249  * @param   ...                 Format arguments.
    250  */
    251 RTEXITCODE errorSyntax(const char *pszFormat, ...)
     249 * @param   va                  Format arguments.
     250 */
     251RTEXITCODE errorSyntaxV(const char *pszFormat, va_list va)
    252252{
    253253    Assert(g_enmCurCommand != HELP_CMD_VBOXMANAGE_INVALID);
     
    255255    showLogo(g_pStdErr);
    256256
    257     va_list va;
    258     va_start(va, pszFormat);
    259     RTMsgErrorV(pszFormat, va);
    260     va_end(va);
     257    va_list vaCopy;
     258    va_copy(vaCopy, va);
     259    RTMsgErrorV(pszFormat, vaCopy);
     260    va_end(vaCopy);
    261261
    262262    RTStrmPutCh(g_pStdErr, '\n');
     
    266266        /* Usage was very long, repeat the error message. */
    267267        RTStrmPutCh(g_pStdErr, '\n');
    268         va_start(va, pszFormat);
    269268        RTMsgErrorV(pszFormat, va);
    270         va_end(va);
    271269    }
    272270    return RTEXITCODE_SYNTAX;
     271}
     272
     273
     274/**
     275 * Display current (sub)command usage and the custom error message.
     276 *
     277 * @returns RTEXITCODE_SYNTAX.
     278 * @param   pszFormat           Custom error message format string.
     279 * @param   ...                 Format arguments.
     280 */
     281RTEXITCODE errorSyntax(const char *pszFormat, ...)
     282{
     283    va_list va;
     284    va_start(va, pszFormat);
     285    RTEXITCODE rcExit = errorSyntaxV(pszFormat, va);
     286    va_end(va);
     287    return rcExit;
     288}
     289
     290
     291/**
     292 * Display current (sub)command usage and the custom error message.
     293 *
     294 * @returns E_INVALIDARG
     295 * @param   pszFormat           Custom error message format string.
     296 * @param   ...                 Format arguments.
     297 */
     298HRESULT errorSyntaxHr(const char *pszFormat, ...)
     299{
     300    va_list va;
     301    va_start(va, pszFormat);
     302    errorSyntaxV(pszFormat, va);
     303    va_end(va);
     304    return E_INVALIDARG;
     305}
     306
     307
     308/**
     309 * Print an error message without the syntax stuff.
     310 *
     311 * @returns RTEXITCODE_SYNTAX.
     312 */
     313RTEXITCODE errorArgument(const char *pszFormat, ...)
     314{
     315    va_list args;
     316    va_start(args, pszFormat);
     317    RTMsgErrorV(pszFormat, args);
     318    va_end(args);
     319    return RTEXITCODE_SYNTAX;
     320}
     321
     322
     323/**
     324 * Print an error message without the syntax stuff.
     325 *
     326 * @returns E_INVALIDARG.
     327 */
     328HRESULT errorArgumentHr(const char *pszFormat, ...)
     329{
     330    va_list args;
     331    va_start(args, pszFormat);
     332    RTMsgErrorV(pszFormat, args);
     333    va_end(args);
     334    return E_INVALIDARG;
    273335}
    274336
     
    10601122}
    10611123
     1124
    10621125/**
    10631126 * errorSyntax for RTGetOpt users.
     
    10741137}
    10751138
    1076 /**
    1077  * Print an error message without the syntax stuff.
    1078  *
    1079  * @returns RTEXITCODE_SYNTAX.
    1080  */
    1081 RTEXITCODE errorArgument(const char *pszFormat, ...)
    1082 {
    1083     va_list args;
    1084     va_start(args, pszFormat);
    1085     RTMsgErrorV(pszFormat, args);
    1086     va_end(args);
    1087     return RTEXITCODE_SYNTAX;
    1088 }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r92537 r92538  
    613613{
    614614    RTPrintf("%s=\"%llu\"\n", pszName, *puValue);
     615}
     616
     617
     618/**
     619 * Helper for parsing extra data config.
     620 * @returns true, false, or -1 if invalid.
     621 */
     622static int parseCfgmBool(Bstr const *pbstr)
     623{
     624    /* GetExtraData returns empty strings if the requested data wasn't
     625       found, so fend that off first: */
     626    size_t cwcLeft = pbstr->length();
     627    if (!cwcLeft)
     628        return false;
     629    PCRTUTF16 pwch = pbstr->raw();
     630
     631    /* Skip type prefix: */
     632    if (   cwcLeft >= 8
     633        && pwch[0] == 'i'
     634        && pwch[1] == 'n'
     635        && pwch[2] == 't'
     636        && pwch[3] == 'e'
     637        && pwch[4] == 'g'
     638        && pwch[5] == 'e'
     639        && pwch[6] == 'r'
     640        && pwch[7] == ':')
     641    {
     642        pwch    += 8;
     643        cwcLeft -= 8;
     644    }
     645
     646    /* Hex prefix? */
     647    bool fHex = false;
     648    if (   cwcLeft >= 2
     649        && pwch[0] == '0'
     650        && (pwch[1] == 'x' || pwch[1] == 'X'))
     651    {
     652        pwch    += 2;
     653        cwcLeft -= 2;
     654        fHex     = true;
     655    }
     656
     657    /* Empty string is wrong: */
     658    if (cwcLeft == 0)
     659        return -1;
     660
     661    /* Check that it's all digits and return when we find a non-zero
     662       one or reaches the end: */
     663    do
     664    {
     665        RTUTF16 const wc = *pwch++;
     666        if (!RT_C_IS_DIGIT(wc) && (!fHex || !RT_C_IS_XDIGIT(wc)))
     667            return -1;
     668        if (wc != '0')
     669            return true;
     670    } while (--cwcLeft > 0);
     671    return false;
    615672}
    616673
     
    27732830    }
    27742831
     2832    /* VMMDev testing config (extra data) */
     2833    if (details != VMINFO_MACHINEREADABLE)
     2834    {
     2835        Bstr bstr;
     2836        CHECK_ERROR2I_RET(machine, GetExtraData(Bstr("VBoxInternal/Devices/VMMDev/0/Config/TestingEnabled").raw(),
     2837                                                bstr.asOutParam()), hrcCheck);
     2838        int const fEnabled = parseCfgmBool(&bstr);
     2839
     2840        CHECK_ERROR2I_RET(machine, GetExtraData(Bstr("VBoxInternal/Devices/VMMDev/0/Config/TestingMMIO").raw(),
     2841                                                bstr.asOutParam()), hrcCheck);
     2842        int const fMmio = parseCfgmBool(&bstr);
     2843        if (fEnabled || fMmio)
     2844        {
     2845            RTPrintf("%-28s %s, %s %s\n",
     2846                     Info::tr("VMMDev Testing"),
     2847                     fEnabled > 0 ? Info::tr("enabled") : fEnabled == 0 ? Info::tr("disabled") : Info::tr("misconfigured"),
     2848                     Info::tr("MMIO:"),
     2849                     fMmio    > 0 ? Info::tr("enabled") : fMmio    == 0 ? Info::tr("disabled") : Info::tr("misconfigured"));
     2850            for (uint32_t i = 0; i < 10; i++)
     2851            {
     2852                BstrFmt bstrName("VBoxInternal/Devices/VMMDev/0/Config/TestingCfgDword%u", i);
     2853                CHECK_ERROR2I_RET(machine, GetExtraData(bstrName.raw(), bstr.asOutParam()), hrcCheck);
     2854                if (bstr.isNotEmpty())
     2855                    RTPrintf("%-28s %ls\n", FmtNm(szNm, "VMMDev Testing Cfg Dword%u:", i), bstr.raw());
     2856            }
     2857        }
     2858    }
     2859
    27752860    /*
    27762861     * Snapshots.
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageModifyVM.cpp

    r92534 r92538  
    249249#endif
    250250    MODIFYVM_DEFAULTFRONTEND,
    251     MODIFYVM_VMPROC_PRIORITY
     251    MODIFYVM_VMPROC_PRIORITY,
     252    MODIFYVM_TESTING_ENABLED,
     253    MODIFYVM_TESTING_MMIO,
     254    MODIFYVM_TESTING_CFG_DWORD,
    252255};
    253256
     
    452455    OPT2("--default-frontend",              "--defaultfrontend",        MODIFYVM_DEFAULTFRONTEND,           RTGETOPT_REQ_STRING),
    453456    OPT1("--vm-process-priority",                                       MODIFYVM_VMPROC_PRIORITY,           RTGETOPT_REQ_STRING),
     457    OPT1("--testing-enabled",                                           MODIFYVM_TESTING_ENABLED,           RTGETOPT_REQ_BOOL_ONOFF),
     458    OPT1("--testing-mmio",                                              MODIFYVM_TESTING_MMIO,              RTGETOPT_REQ_BOOL_ONOFF),
     459    OPT1("--testing-cfg-dword",                                         MODIFYVM_TESTING_CFG_DWORD,         RTGETOPT_REQ_UINT32 | RTGETOPT_FLAG_INDEX),
    454460};
    455461
     
    458464    RTStrmPrintf(g_pStdErr, ModifyVM::tr("Warning: '--vrdp%s' is deprecated. Use '--vrde%s'.\n"), pszOption, pszOption);
    459465}
     466
     467
     468/**
     469 * Wrapper around IMachine::SetExtraData that does the error reporting.
     470 *
     471 * @returns COM result code.
     472 * @param   rSessionMachine The IMachine.
     473 * @param   pszVariable     The variable to set.
     474 * @param   pszValue        The value to set.  To delete pass empty string, not
     475 *                          NULL.
     476 */
     477static HRESULT setExtraData(ComPtr<IMachine> &rSessionMachine, const char *pszVariable, const char *pszValue)
     478{
     479    HRESULT hrc = rSessionMachine->SetExtraData(Bstr(pszVariable).raw(), Bstr(pszValue).raw());
     480    if (FAILED(hrc))
     481    {
     482        char *pszContext = RTStrAPrintf2(ModifyVM::tr("IMachine::SetExtraData('%s', '%s')"), pszVariable, pszValue);
     483        com::GlueHandleComError(rSessionMachine, pszContext, hrc, __FILE__, __LINE__);
     484        RTStrFree(pszContext);
     485    }
     486    return hrc;
     487}
     488
    460489
    461490#ifdef VBOX_WITH_PCI_PASSTHROUGH
     
    34133442            }
    34143443
     3444            case MODIFYVM_TESTING_ENABLED:
     3445                rc = setExtraData(sessionMachine, "VBoxInternal/Devices/VMMDev/0/Config/TestingEnabled", ValueUnion.f ? "1" : "");
     3446                break;
     3447
     3448            case MODIFYVM_TESTING_MMIO:
     3449                rc = setExtraData(sessionMachine, "VBoxInternal/Devices/VMMDev/0/Config/TestingMMIO", ValueUnion.f ? "1" : "");
     3450                break;
     3451
     3452            case MODIFYVM_TESTING_CFG_DWORD:
     3453                if (GetOptState.uIndex <= 9)
     3454                {
     3455                    char szVar[128];
     3456                    RTStrPrintf(szVar, sizeof(szVar), "VBoxInternal/Devices/VMMDev/0/Config/TestingCfgDword%u",
     3457                                GetOptState.uIndex);
     3458                    char szValue[32];
     3459                    RTStrPrintf(szValue, sizeof(szValue), "%u", ValueUnion.u32);
     3460                    rc = setExtraData(sessionMachine, szVar, szValue);
     3461                }
     3462                else
     3463                    rc = errorArgumentHr(ModifyVM::tr("--testing-cfg-dword index %u is out of range: 0 thru 9"),
     3464                                         GetOptState.uIndex);
     3465                break;
     3466
    34153467            default:
    3416             {
    34173468                errorGetOpt(USAGE_MODIFYVM, c, &ValueUnion);
    34183469                rc = E_FAIL;
    34193470                break;
    3420             }
    34213471        }
    34223472    }
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