VBoxInternalManage.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/** @file
*
* VBox frontends: VBoxManage (command-line interface):
* VBoxInternalManage
*
* VBoxInternalManage used to be a second CLI for doing special tricks,
* not intended for general usage, only for assisting VBox developers.
* It is now integrated into VBoxManage.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBoxManage.h"
using namespace com;
/** flag whether we're in internal mode */
bool fInternalMode;
/**
* Print the usage info.
*/
{
RTPrintf("Usage: VBoxManage internalcommands <command> [command arguments]\n"
"\n"
"Commands:\n"
"\n"
"%s%s%s"
"WARNING: This is a development tool and shall only be used to analyse\n"
" problems. It is completely unsupported and will change in\n"
" incompatible ways without warning.\n",
(enmCmd & USAGE_LOADSYMS) ?
" loadsyms <vmname>|<uuid> <symfile> [delta] [module] [module address]\n"
" This will instruct DBGF to load the given symbolfile\n"
" during initialization.\n"
"\n"
: "",
(enmCmd & USAGE_UNLOADSYMS) ?
" unloadsyms <vmname>|<uuid> <symfile>\n"
" Removes <symfile> from the list of symbol files that\n"
" should be loaded during DBF initialization.\n"
"\n"
: "",
(enmCmd & USAGE_SETVDIUUID) ?
" setvdiuuid <filepath>\n"
" Assigns a new UUID to the given VDI file. This way, multiple copies\n"
" of VDI containers can be registered.\n"
"\n"
: ""
);
}
/** @todo this is no longer necessary, we can enumerate extra data */
/**
* Finds a new unique key name.
*
* I don't think this is 100% race condition proof, but we assumes
* the user is not trying to push this point.
*
* @returns Result from the insert.
* @param pMachine The Machine object.
* @param pszKeyBase The base key.
* @param rKey Reference to the string object in which we will return the key.
*/
{
return hrc;
/* if there are no keys, it's simple. */
{
rKey = "1";
}
/* find a unique number - brute force rulez. */
for (unsigned i = 1; i < 1000000; i++)
{
char szKey[32];
while (psz)
{
)
break;
}
if (!psz)
{
}
}
return E_FAIL;
}
#if 0
/**
* Remove a key.
*
* I don't think this isn't 100% race condition proof, but we assumes
* the user is not trying to push this point.
*
* @returns Result from the insert.
* @param pMachine The machine object.
* @param pszKeyBase The base key.
* @param pszKey The key to remove.
*/
{
return hrc;
/* if there are no keys, it's simple. */
return S_OK;
char *pszKeys;
if (VBOX_SUCCESS(rc))
{
/* locate it */
while (psz)
{
)
break;
}
if (psz)
{
/* remove it */
if (*pszNext)
else
*psz = '\0';
/* update */
}
return hrc;
}
else
RTPrintf("error: failed to delete key '%s' from '%s', string conversion error %Vrc!\n",
return E_FAIL;
}
#endif
/**
* Sets a key value, does necessary error bitching.
*
* @returns COM status code.
* @param pMachine The Machine object.
* @param pszKeyBase The key base.
* @param pszKey The key.
* @param pszAttribute The attribute name.
* @param pszValue The string value.
*/
static HRESULT SetString(ComPtr<IMachine> pMachine, const char *pszKeyBase, const char *pszKey, const char *pszAttribute, const char *pszValue)
{
HRESULT hrc = pMachine->SetExtraData(Bstr(Utf8StrFmt("%s/%s/%s", pszKeyBase, pszKey, pszAttribute)), Bstr(pszValue));
RTPrintf("error: Failed to set '%s/%s/%s' to '%s'! hrc=%#x\n",
return hrc;
}
/**
* Sets a key value, does necessary error bitching.
*
* @returns COM status code.
* @param pMachine The Machine object.
* @param pszKeyBase The key base.
* @param pszKey The key.
* @param pszAttribute The attribute name.
* @param u64Value The value.
*/
static HRESULT SetUInt64(ComPtr<IMachine> pMachine, const char *pszKeyBase, const char *pszKey, const char *pszAttribute, uint64_t u64Value)
{
char szValue[64];
}
/**
* Sets a key value, does necessary error bitching.
*
* @returns COM status code.
* @param pMachine The Machine object.
* @param pszKeyBase The key base.
* @param pszKey The key.
* @param pszAttribute The attribute name.
* @param i64Value The value.
*/
static HRESULT SetInt64(ComPtr<IMachine> pMachine, const char *pszKeyBase, const char *pszKey, const char *pszAttribute, int64_t i64Value)
{
char szValue[64];
}
/**
* Identical to the 'loadsyms' command.
*/
static int CmdLoadSyms(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
/*
* Get the VM
*/
/* assume it's a UUID */
{
/* must be a name */
}
/*
* Parse the command.
*/
const char *pszFilename;
uint64_t ModuleAddress = ~0;
uint64_t ModuleSize = 0;
/* filename */
if (argc < 2)
return errorArgument("Missing the filename argument!\n");
/* offDelta */
if (argc >= 3)
{
if (VBOX_FAILURE(rc))
}
/* pszModule */
if (argc >= 4)
/* ModuleAddress */
if (argc >= 5)
{
if (VBOX_FAILURE(rc))
}
/* ModuleSize */
if (argc >= 6)
{
if (VBOX_FAILURE(rc))
}
/*
* Add extra data.
*/
}
static int handleSetVDIUUID(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
/* we need exactly one parameter: the vdi file */
if (argc != 1)
{
}
/* generate a new UUID */
/* just try it */
if (VBOX_FAILURE(rc))
{
}
else
{
}
return 0;
}
/**
* Wrapper for handling internal commands
*/
{
fInternalMode = true;
/* at least a command is required */
if (argc < 1)
/*
* The 'string switch' on command name.
*/
//if (!strcmp(pszCmd, "unloadsyms"))
// return CmdUnloadSyms(argc - 1 , &argv[1]);
/* default: */
}