VirtualBox

Changeset 30319 in vbox


Ignore:
Timestamp:
Jun 21, 2010 8:29:08 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
62877
Message:

VBoxManage: added internal command: debuglog

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

Legend:

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

    r29651 r30319  
    3939
    4040#include <iprt/file.h>
    41 #include <iprt/initterm.h>
     41#include <iprt/getopt.h>
    4242#include <iprt/stream.h>
    4343#include <iprt/string.h>
     
    8484#define PARTTYPE_IS_EXTENDED(x) ((x) == 0x05 || (x) == 0x0f || (x) == 0x85)
    8585
    86 /* Maximum number of partitions we can deal with. Ridiculously large number,
    87  * but the memory consumption is rather low so who cares about never using
    88  * most entries. */
     86/** Maximum number of partitions we can deal with.
     87 * Ridiculously large number, but the memory consumption is rather low so who
     88 * cares about never using most entries. */
    8989#define HOSTPARTITION_MAX 100
    9090
     
    136136             "Commands:\n"
    137137             "\n"
    138              "%s%s%s%s%s%s%s%s%s"
     138             "%s%s%s%s%s%s%s%s%s%s%s%s"
    139139             "WARNING: This is a development tool and shall only be used to analyse\n"
    140140             "         problems. It is completely unsupported and will change in\n"
    141141             "         incompatible ways without warning.\n",
    142             (u64Cmd & USAGE_LOADSYMS) ?
    143                 "  loadsyms <vmname>|<uuid> <symfile> [delta] [module] [module address]\n"
    144                 "      This will instruct DBGF to load the given symbolfile\n"
    145                 "      during initialization.\n"
    146                 "\n"
    147                 : "",
    148             (u64Cmd & USAGE_UNLOADSYMS) ?
    149                 "  unloadsyms <vmname>|<uuid> <symfile>\n"
    150                 "      Removes <symfile> from the list of symbol files that\n"
    151                 "      should be loaded during DBF initialization.\n"
    152                 "\n"
    153                 : "",
    154             (u64Cmd & USAGE_SETHDUUID) ?
    155                 "  sethduuid <filepath>\n"
    156                 "       Assigns a new UUID to the given image file. This way, multiple copies\n"
    157                 "       of a container can be registered.\n"
    158                 "\n"
    159                 : "",
    160             (u64Cmd & USAGE_DUMPHDINFO) ?
    161                 "  dumphdinfo <filepath>\n"
     142
     143             (u64Cmd & USAGE_LOADSYMS)
     144             ? "  loadsyms <vmname>|<uuid> <symfile> [delta] [module] [module address]\n"
     145               "      This will instruct DBGF to load the given symbolfile\n"
     146               "      during initialization.\n"
     147               "\n"
     148             : "",
     149             (u64Cmd & USAGE_UNLOADSYMS)
     150             ? "  unloadsyms <vmname>|<uuid> <symfile>\n"
     151               "      Removes <symfile> from the list of symbol files that\n"
     152               "      should be loaded during DBF initialization.\n"
     153               "\n"
     154             : "",
     155             (u64Cmd & USAGE_SETHDUUID)
     156             ? "  sethduuid <filepath>\n"
     157               "       Assigns a new UUID to the given image file. This way, multiple copies\n"
     158               "       of a container can be registered.\n"
     159               "\n"
     160             : "",
     161             (u64Cmd & USAGE_DUMPHDINFO)
     162             ?  "  dumphdinfo <filepath>\n"
    162163                "       Prints information about the image at the given location.\n"
    163164                "\n"
    164                 : "",
    165             (u64Cmd & USAGE_LISTPARTITIONS) ?
    166                "  listpartitions -rawdisk <diskname>\n"
    167                 "       Lists all partitions on <diskname>.\n"
    168                 "\n"
    169                 : "",
    170             (u64Cmd & USAGE_CREATERAWVMDK) ?
    171                "  createrawvmdk -filename <filename> -rawdisk <diskname>\n"
    172                 "                [-partitions <list of partition numbers> [-mbr <filename>] ]\n"
    173                 "                [-register] [-relative]\n"
    174                 "       Creates a new VMDK image which gives access to an entite host disk (if\n"
    175                 "       the parameter -partitions is not specified) or some partitions of a\n"
    176                 "       host disk. If access to individual partitions is granted, then the\n"
    177                 "       parameter -mbr can be used to specify an alternative MBR to be used\n"
    178                 "       (the partitioning information in the MBR file is ignored).\n"
    179                 "       The diskname is on Linux e.g. /dev/sda, and on Windows e.g.\n"
    180                 "       \\\\.\\PhysicalDrive0).\n"
    181                 "       On Linux host the parameter -relative causes a VMDK file to be created\n"
    182                 "       which refers to individual partitions instead to the entire disk.\n"
    183                 "       Optionally the created image can be immediately registered.\n"
    184                 "       The necessary partition numbers can be queried with\n"
    185                 "         VBoxManage internalcommands listpartitions\n"
    186                 "\n"
    187                 : "",
    188              (u64Cmd & USAGE_RENAMEVMDK) ?
    189                  "  renamevmdk -from <filename> -to <filename>\n"
    190                  "       Renames an existing VMDK image, including the base file and all its extents.\n"
    191                  "\n"
    192                  : "",
    193              (u64Cmd & USAGE_CONVERTTORAW) ?
    194                  "  converttoraw [-format <fileformat>] <filename> <outputfile>"
     165             : "",
     166             (u64Cmd & USAGE_LISTPARTITIONS)
     167             ? "  listpartitions -rawdisk <diskname>\n"
     168               "       Lists all partitions on <diskname>.\n"
     169               "\n"
     170             : "",
     171             (u64Cmd & USAGE_CREATERAWVMDK)
     172             ? "  createrawvmdk -filename <filename> -rawdisk <diskname>\n"
     173               "                [-partitions <list of partition numbers> [-mbr <filename>] ]\n"
     174               "                [-register] [-relative]\n"
     175               "       Creates a new VMDK image which gives access to an entite host disk (if\n"
     176               "       the parameter -partitions is not specified) or some partitions of a\n"
     177               "       host disk. If access to individual partitions is granted, then the\n"
     178               "       parameter -mbr can be used to specify an alternative MBR to be used\n"
     179               "       (the partitioning information in the MBR file is ignored).\n"
     180               "       The diskname is on Linux e.g. /dev/sda, and on Windows e.g.\n"
     181               "       \\\\.\\PhysicalDrive0).\n"
     182               "       On Linux host the parameter -relative causes a VMDK file to be created\n"
     183               "       which refers to individual partitions instead to the entire disk.\n"
     184               "       Optionally the created image can be immediately registered.\n"
     185               "       The necessary partition numbers can be queried with\n"
     186               "         VBoxManage internalcommands listpartitions\n"
     187               "\n"
     188             : "",
     189             (u64Cmd & USAGE_RENAMEVMDK)
     190             ? "  renamevmdk -from <filename> -to <filename>\n"
     191               "       Renames an existing VMDK image, including the base file and all its extents.\n"
     192               "\n"
     193             : "",
     194             (u64Cmd & USAGE_CONVERTTORAW)
     195             ? "  converttoraw [-format <fileformat>] <filename> <outputfile>"
    195196#ifdef ENABLE_CONVERT_RAW_TO_STDOUT
    196                  "|stdout"
     197               "|stdout"
    197198#endif /* ENABLE_CONVERT_RAW_TO_STDOUT */
    198                  "\n"
    199                  "       Convert image to raw, writing to file"
     199               "\n"
     200               "       Convert image to raw, writing to file"
    200201#ifdef ENABLE_CONVERT_RAW_TO_STDOUT
    201                  " or stdout"
     202               " or stdout"
    202203#endif /* ENABLE_CONVERT_RAW_TO_STDOUT */
    203                  ".\n"
    204                  "\n"
    205                  : "",
    206              (u64Cmd & USAGE_CONVERTHD) ?
    207                  "  converthd [-srcformat VDI|VMDK|VHD|RAW]\n"
    208                  "            [-dstformat VDI|VMDK|VHD|RAW]\n"
    209                  "            <inputfile> <outputfile>\n"
    210                  "       converts hard disk images between formats\n"
    211                  "\n"
    212                  : "",
     204               ".\n"
     205               "\n"
     206             : "",
     207             (u64Cmd & USAGE_CONVERTHD)
     208             ? "  converthd [-srcformat VDI|VMDK|VHD|RAW]\n"
     209               "            [-dstformat VDI|VMDK|VHD|RAW]\n"
     210               "            <inputfile> <outputfile>\n"
     211               "       converts hard disk images between formats\n"
     212               "\n"
     213             : "",
    213214#ifdef RT_OS_WINDOWS
    214             (u64Cmd & USAGE_MODINSTALL) ?
    215                "  modinstall\n"
    216                 "       Installs the neccessary driver for the host OS\n"
    217                 "\n"
    218                 : "",
    219             (u64Cmd & USAGE_MODUNINSTALL) ?
    220                "  moduninstall\n"
    221                 "       Deinstalls the driver\n"
    222                 "\n"
    223                 : ""
     215             (u64Cmd & USAGE_MODINSTALL)
     216             ? "  modinstall\n"
     217               "       Installs the neccessary driver for the host OS\n"
     218               "\n"
     219             : "",
     220             (u64Cmd & USAGE_MODUNINSTALL)
     221             ? "  moduninstall\n"
     222               "       Deinstalls the driver\n"
     223               "\n"
     224             : "",
    224225#else
    225                 "",
    226                 ""
     226             "",
     227             "",
    227228#endif
     229             (u64Cmd & USAGE_DEBUGLOG)
     230             ? "  debuglog <vmname>|<uuid> [--enable|--disable] [--flags todo]\n"
     231               "           [--groups todo] [--destinations todo]\n"
     232               "       Controls debug logging.\n"
     233               "\n"
     234             : ""
    228235             );
    229236}
     
    18431850}
    18441851
     1852int CmdDebugLog(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
     1853{
     1854    /*
     1855     * The first parameter is the name or UUID of a VM with a direct session
     1856     * that we wish to open.
     1857     */
     1858    if (argc < 1)
     1859        return errorSyntax(USAGE_DEBUGLOG, "Missing VM name/UUID");
     1860
     1861    ComPtr<IMachine> ptrMachine;
     1862    HRESULT rc = aVirtualBox->GetMachine(Bstr(argv[0]), ptrMachine.asOutParam());
     1863    if (FAILED(rc) || ptrMachine.isNull())
     1864        CHECK_ERROR_RET(aVirtualBox, FindMachine(Bstr(argv[0]), ptrMachine.asOutParam()), 1);
     1865
     1866    Bstr bstrMachineUuid;
     1867    CHECK_ERROR_RET(ptrMachine, COMGETTER(Id)(bstrMachineUuid.asOutParam()), 1);
     1868    CHECK_ERROR_RET(aVirtualBox, OpenExistingSession(aSession, bstrMachineUuid), 1);
     1869
     1870    /*
     1871     * Get the debugger interface.
     1872     */
     1873    ComPtr<IConsole> ptrConsole;
     1874    CHECK_ERROR_RET(aSession, COMGETTER(Console)(ptrConsole.asOutParam()), 1);
     1875
     1876    ComPtr<IMachineDebugger> ptrDebugger;
     1877    CHECK_ERROR_RET(ptrConsole, COMGETTER(Debugger)(ptrDebugger.asOutParam()), 1);
     1878
     1879    /*
     1880     * Parse the command.
     1881     */
     1882    bool                fEnablePresent = false;
     1883    bool                fEnable        = false;
     1884    bool                fFlagsPresent  = false;
     1885    iprt::MiniString    strFlags;
     1886    bool                fGroupsPresent = false;
     1887    iprt::MiniString    strGroups;
     1888    bool                fDestsPresent  = false;
     1889    iprt::MiniString    strDests;
     1890
     1891    static const RTGETOPTDEF s_aOptions[] =
     1892    {
     1893        { "--disable",      'E', RTGETOPT_REQ_NOTHING },
     1894        { "--enable",       'e', RTGETOPT_REQ_NOTHING },
     1895        { "--flags",        'f', RTGETOPT_REQ_STRING  },
     1896        { "--groups",       'g', RTGETOPT_REQ_STRING  },
     1897        { "--destinations", 'd', RTGETOPT_REQ_STRING  }
     1898    };
     1899
     1900    int ch;
     1901    RTGETOPTUNION ValueUnion;
     1902    RTGETOPTSTATE GetState;
     1903    RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 0);
     1904    while ((ch = RTGetOpt(&GetState, &ValueUnion)))
     1905    {
     1906        switch (ch)
     1907        {
     1908            case 'e':
     1909                fEnablePresent = true;
     1910                fEnable = true;
     1911                break;
     1912
     1913            case 'E':
     1914                fEnablePresent = true;
     1915                fEnable = false;
     1916                break;
     1917
     1918            case 'f':
     1919                fFlagsPresent = true;
     1920                if (*ValueUnion.psz)
     1921                {
     1922                    if (strFlags.isNotEmpty())
     1923                        strFlags.append(' ');
     1924                    strFlags.append(ValueUnion.psz);
     1925                }
     1926                break;
     1927
     1928            case 'g':
     1929                fGroupsPresent = true;
     1930                if (*ValueUnion.psz)
     1931                {
     1932                    if (strGroups.isNotEmpty())
     1933                        strGroups.append(' ');
     1934                    strGroups.append(ValueUnion.psz);
     1935                }
     1936                break;
     1937
     1938            case 'd':
     1939                fDestsPresent = true;
     1940                if (*ValueUnion.psz)
     1941                {
     1942                    if (strDests.isNotEmpty())
     1943                        strDests.append(' ');
     1944                    strDests.append(ValueUnion.psz);
     1945                }
     1946                break;
     1947
     1948            default:
     1949                return errorGetOpt(USAGE_DEBUGLOG , ch, &ValueUnion);
     1950        }
     1951    }
     1952
     1953    /*
     1954     * Do the job.
     1955     */
     1956    if (fEnablePresent && !fEnable)
     1957        CHECK_ERROR_RET(ptrDebugger, COMSETTER(LogEnabled)(FALSE), 1);
     1958
     1959    /** @todo flags, groups destination. */
     1960    if (fFlagsPresent || fGroupsPresent || fDestsPresent)
     1961        RTPrintf("WARNING: One or more of the requested features are not implemented! Feel free to do this... :-)\n");
     1962
     1963    if (fEnablePresent && fEnable)
     1964        CHECK_ERROR_RET(ptrDebugger, COMSETTER(LogEnabled)(FALSE), 1);
     1965    return 0;
     1966}
     1967
    18451968/**
    18461969 * Wrapper for handling internal commands
     
    18761999    if (!strcmp(pszCmd, "converthd"))
    18772000        return CmdConvertHardDisk(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
    1878 
    18792001    if (!strcmp(pszCmd, "modinstall"))
    18802002        return CmdModInstall();
    18812003    if (!strcmp(pszCmd, "moduninstall"))
    18822004        return CmdModUninstall();
     2005    if (!strcmp(pszCmd, "debuglog"))
     2006        return CmdDebugLog(a->argc - 1, &a->argv[1], a->virtualBox, a->session);
    18832007
    18842008    /* default: */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r28800 r30319  
    7878#define USAGE_RENAMEVMDK            RT_BIT_64(39)
    7979#ifdef VBOX_WITH_GUEST_PROPS
    80 #define USAGE_GUESTPROPERTY         RT_BIT_64(40)
     80# define USAGE_GUESTPROPERTY        RT_BIT_64(40)
    8181#endif  /* VBOX_WITH_GUEST_PROPS defined */
    8282#define USAGE_CONVERTTORAW          RT_BIT_64(41)
     
    9191#define USAGE_STORAGECONTROLLER     RT_BIT_64(50)
    9292#ifdef VBOX_WITH_GUEST_CONTROL
    93 #define USAGE_GUESTCONTROL          RT_BIT_64(51)
     93# define USAGE_GUESTCONTROL         RT_BIT_64(51)
    9494#endif  /* VBOX_WITH_GUEST_CONTROL defined */
     95#define USAGE_DEBUGLOG              RT_BIT_64(52)
    9596#define USAGE_ALL                   (~(uint64_t)0)
    9697/** @} */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette