VBoxInternalManage.cpp revision c8befbec2916e0bba4d254c81d87e5b0e78013ba
/* $Id$ */
/** @file
* VBoxManage - The 'internalcommands' command.
*
* 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-2010 Oracle Corporation
*
* 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 (GPL) 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBoxManage.h"
/* Includes for the raw disk stuff. */
#ifdef RT_OS_WINDOWS
# include <windows.h>
# include <winioctl.h>
|| defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
# include <errno.h>
# include <fcntl.h>
# include <unistd.h>
#endif
#ifdef RT_OS_LINUX
# include <stdlib.h> /* atoi() */
#endif /* RT_OS_LINUX */
#ifdef RT_OS_DARWIN
#endif /* RT_OS_DARWIN */
#ifdef RT_OS_SOLARIS
# include <stropts.h>
#endif /* RT_OS_SOLARIS */
#ifdef RT_OS_FREEBSD
#endif /* RT_OS_FREEBSD */
using namespace com;
/** Macro for checking whether a partition is of extended type or not. */
/** Maximum number of partitions we can deal with.
* Ridiculously large number, but the memory consumption is rather low so who
* cares about never using most entries. */
#define HOSTPARTITION_MAX 100
typedef struct HOSTPARTITION
{
unsigned uIndex;
/** partition type */
unsigned uType;
unsigned uStartCylinder;
unsigned uStartHead;
unsigned uStartSector;
unsigned uEndCylinder;
unsigned uEndHead;
unsigned uEndSector;
/** start sector of this partition relative to the beginning of the hard
* disk or relative to the beginning of the extended partition table */
/** numer of sectors of the partition */
/** start sector of this partition _table_ */
/** numer of sectors of this partition _table_ */
typedef struct HOSTPARTITIONS
{
unsigned cPartitions;
/** flag whether we're in internal mode */
bool g_fInternalMode;
/**
* Print the usage info.
*/
{
"Usage: VBoxManage internalcommands <command> [command arguments]\n"
"\n"
"Commands:\n"
"\n"
"%s%s%s%s%s%s%s%s%s%s%s%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",
(u64Cmd & 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"
: "",
? " unloadsyms <vmname>|<uuid> <symfile>\n"
" Removes <symfile> from the list of symbol files that\n"
" should be loaded during DBF initialization.\n"
"\n"
: "",
? " sethduuid <filepath> [<uuid>]\n"
" Assigns a new UUID to the given image file. This way, multiple copies\n"
" of a container can be registered.\n"
"\n"
: "",
? " sethdparentuuid <filepath> <uuid>\n"
" Assigns a new parent UUID to the given image file.\n"
"\n"
: "",
? " dumphdinfo <filepath>\n"
" Prints information about the image at the given location.\n"
"\n"
: "",
? " listpartitions -rawdisk <diskname>\n"
" Lists all partitions on <diskname>.\n"
"\n"
: "",
? " createrawvmdk -filename <filename> -rawdisk <diskname>\n"
" [-partitions <list of partition numbers> [-mbr <filename>] ]\n"
" [-register] [-relative]\n"
" Creates a new VMDK image which gives access to an entite host disk (if\n"
" the parameter -partitions is not specified) or some partitions of a\n"
" host disk. If access to individual partitions is granted, then the\n"
" parameter -mbr can be used to specify an alternative MBR to be used\n"
" (the partitioning information in the MBR file is ignored).\n"
" \\\\.\\PhysicalDrive0).\n"
" On Linux host the parameter -relative causes a VMDK file to be created\n"
" which refers to individual partitions instead to the entire disk.\n"
" Optionally the created image can be immediately registered.\n"
" The necessary partition numbers can be queried with\n"
" VBoxManage internalcommands listpartitions\n"
"\n"
: "",
? " renamevmdk -from <filename> -to <filename>\n"
" Renames an existing VMDK image, including the base file and all its extents.\n"
"\n"
: "",
? " converttoraw [-format <fileformat>] <filename> <outputfile>"
#ifdef ENABLE_CONVERT_RAW_TO_STDOUT
"|stdout"
#endif /* ENABLE_CONVERT_RAW_TO_STDOUT */
"\n"
" Convert image to raw, writing to file"
#ifdef ENABLE_CONVERT_RAW_TO_STDOUT
" or stdout"
#endif /* ENABLE_CONVERT_RAW_TO_STDOUT */
".\n"
"\n"
: "",
? " converthd [-srcformat VDI|VMDK|VHD|RAW]\n"
" [-dstformat VDI|VMDK|VHD|RAW]\n"
" <inputfile> <outputfile>\n"
" converts hard disk images between formats\n"
"\n"
: "",
#ifdef RT_OS_WINDOWS
? " modinstall\n"
" Installs the neccessary driver for the host OS\n"
"\n"
: "",
? " moduninstall\n"
" Deinstalls the driver\n"
"\n"
: "",
#else
"",
"",
#endif
(u64Cmd & USAGE_DEBUGLOG)
? " debuglog <vmname>|<uuid> [--enable|--disable] [--flags todo]\n"
" [--groups todo] [--destinations todo]\n"
" Controls debug logging.\n"
"\n"
: "",
? " passwordhash <passsword>\n"
" Generates a password hash.\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 (RT_SUCCESS(rc))
{
/* locate it */
while (psz)
{
)
break;
}
if (psz)
{
/* remove it */
if (*pszNext)
else
*psz = '\0';
/* update */
}
return hrc;
}
else
RTMsgError("Failed to delete key '%s' from '%s', string conversion error %Rrc!",
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)
{
RTMsgError("Failed to set '%s/%s/%s' to '%s'! hrc=%#x",
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 (RT_FAILURE(irc))
}
/* pszModule */
if (argc >= 4)
/* ModuleAddress */
if (argc >= 5)
{
if (RT_FAILURE(irc))
}
/* ModuleSize */
if (argc >= 6)
{
if (RT_FAILURE(irc))
}
/*
* Add extra data.
*/
hrc = SetUInt64(machine, "VBoxInternal/DBGF/loadsyms", KeyStr.c_str(), "ModuleAddress", ModuleAddress);
}
static DECLCALLBACK(void) handleVDError(void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
{
}
{
}
static int CmdSetHDUUID(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
enum eUuidType {
} uuidType;
{
/* if specified, take UUID, otherwise generate a new one */
if (argc == 3)
{
} else
}
{
if (argc != 3)
}
else
/* just try it */
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
/* Open the image */
if (RT_FAILURE(rc))
{
return 1;
}
else
if (RT_FAILURE(rc))
else
return RT_FAILURE(rc);
}
static int CmdDumpHDInfo(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
/* we need exactly one parameter: the image file */
if (argc != 1)
{
}
/* just try it */
if (RT_FAILURE(rc))
{
return 1;
}
if (RT_FAILURE(rc))
{
return 1;
}
/* Open the image */
if (RT_FAILURE(rc))
{
return 1;
}
return RT_FAILURE(rc);
}
{
int rc;
pPart->cPartitions = 0;
if (RT_FAILURE(rc))
return rc;
return VERR_INVALID_PARAMETER;
unsigned uExtended = (unsigned)-1;
for (unsigned i = 0; i < 4; i++)
{
if (p[4] == 0)
continue;
pCP->cPartDataSectors = 0;
if (PARTTYPE_IS_EXTENDED(p[4]))
{
if (uExtended == (unsigned)-1)
else
{
RTMsgError("More than one extended partition");
return VERR_INVALID_PARAMETER;
}
}
}
if (uExtended != (unsigned)-1)
{
unsigned uIndex = 5;
if (!uStart)
{
RTMsgError("Inconsistency for logical partition start");
return VERR_INVALID_PARAMETER;
}
do
{
if (RT_FAILURE(rc))
return rc;
{
RTMsgError("Logical partition without magic");
return VERR_INVALID_PARAMETER;
}
if (p[4] == 0)
{
RTMsgError("Logical partition with type 0 encountered");
return VERR_INVALID_PARAMETER;
}
if (!uStartOffset)
{
RTMsgError("Invalid partition start offset");
return VERR_INVALID_PARAMETER;
}
/* Fill out partitioning location info for EBR. */
p += 16;
if (p[4] == 0)
uExtended = (unsigned)-1;
else if (PARTTYPE_IS_EXTENDED(p[4]))
{
}
else
{
RTMsgError("Logical partition chain broken");
return VERR_INVALID_PARAMETER;
}
} while (uExtended != (unsigned)-1);
}
/* Sort partitions in ascending order of start sector, plus a trivial
* bit of consistency checking. */
{
unsigned uMinIdx = i;
{
{
uMinIdx = j;
}
{
RTMsgError("Two partitions start at the same place");
return VERR_INVALID_PARAMETER;
}
{
RTMsgError("Partition starts at sector 0");
return VERR_INVALID_PARAMETER;
}
}
if (uMinIdx != i)
{
/* Swap entries at index i and uMinIdx. */
}
}
/* Fill out partitioning location info for MBR. */
/* Now do a some partition table consistency checking, to reject the most
* obvious garbage which can lead to trouble later. */
{
{
RTMsgError("Overlapping partitions");
return VERR_INVALID_PARAMETER;
}
}
return VINF_SUCCESS;
}
static int CmdListPartitions(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
/* let's have a closer look at the arguments */
for (int i = 0; i < argc; i++)
{
{
if (argc <= i + 1)
{
}
i++;
}
else
{
}
}
int vrc = RTFileOpen(&RawFile, rawdisk.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
if (RT_FAILURE(vrc))
{
return vrc;
}
/* Don't bail out on errors, print the table and return the result code. */
RTPrintf("Number Type StartCHS EndCHS Size (MiB) Start (Sect)\n");
for (unsigned i = 0; i < partitions.cPartitions; i++)
{
/* Don't show the extended partition, otherwise users might think they
* can add it to the list of partitions for raw partition access. */
continue;
RTPrintf("%-7u %#04x %-4u/%-3u/%-2u %-4u/%-3u/%-2u %10llu %10llu\n",
}
return vrc;
}
{
(*pcPartDescs)++;
*pcPartDescs * sizeof(VBOXHDDRAWPARTDESC));
*ppPartDescs = p;
if (p)
{
p = p + *pcPartDescs - 1;
}
return p;
}
static int CmdCreateRawVMDK(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
const char *pszMBRFilename = NULL;
const char *pszPartitions = NULL;
bool fRegister = false;
bool fRelative = false;
/* let's have a closer look at the arguments */
for (int i = 0; i < argc; i++)
{
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
pszMBRFilename = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
pszPartitions = argv[i];
}
{
fRegister = true;
}
#ifdef RT_OS_LINUX
{
fRelative = true;
}
#endif /* RT_OS_LINUX */
else
}
if (!pszPartitions && pszMBRFilename)
return errorSyntax(USAGE_CREATERAWVMDK, "The parameter -mbr is only valid when the parameter -partitions is also present");
#ifdef RT_OS_DARWIN
fRelative = true;
#endif /* RT_OS_DARWIN */
int vrc = RTFileOpen(&RawFile, rawdisk.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
if (RT_FAILURE(vrc))
{
goto out;
}
#ifdef RT_OS_WINDOWS
/* Windows NT has no IOCTL_DISK_GET_LENGTH_INFORMATION ioctl. This was
* added to Windows XP, so we have to use the available info from DriveGeo.
* Note that we cannot simply use IOCTL_DISK_GET_DRIVE_GEOMETRY as it
* yields a slightly different result than IOCTL_DISK_GET_LENGTH_INFO.
* We call IOCTL_DISK_GET_DRIVE_GEOMETRY first as we need to check the media
* type anyway, and if IOCTL_DISK_GET_LENGTH_INFORMATION is supported
* we will later override cbSize.
*/
{
{
}
else
{
goto out;
}
{
/* IOCTL_DISK_GET_LENGTH_INFO is supported -- override cbSize. */
}
}
else
{
goto out;
}
#elif defined(RT_OS_LINUX)
{
#ifdef BLKGETSIZE64
/* BLKGETSIZE64 is broken up to 2.4.17 and in many 2.5.x. In 2.6.0
* it works without problems. */
{
}
#endif /* BLKGETSIZE64 */
if (!cbSize)
{
long cBlocks;
else
{
goto out;
}
}
}
else
{
goto out;
}
#elif defined(RT_OS_DARWIN)
{
{
else
{
goto out;
}
}
else
{
goto out;
}
}
else
{
goto out;
}
#elif defined(RT_OS_SOLARIS)
{
else
{
goto out;
}
}
else
{
goto out;
}
#elif defined(RT_OS_FREEBSD)
{
{
}
else
{
goto out;
}
}
else
{
goto out;
}
#else /* all unrecognized OSes */
/* Hopefully this works on all other hosts. If it doesn't, it'll just fail
* creating the VMDK, so no real harm done. */
if (RT_FAILURE(vrc))
{
goto out;
}
#endif
/* Check whether cbSize is actually sensible. */
{
goto out;
}
if (!pszPartitions)
{
RawDescriptor.fRawDisk = true;
}
else
{
RawDescriptor.fRawDisk = false;
RawDescriptor.cPartDescs = 0;
uint32_t uPartitions = 0;
const char *p = pszPartitions;
char *pszNext;
while (*p != '\0')
{
if (RT_FAILURE(vrc))
{
RTMsgError("Incorrect value in partitions parameter");
goto out;
}
p = pszNext;
if (*p == ',')
p++;
else if (*p != '\0')
{
RTMsgError("Incorrect separator in partitions parameter");
goto out;
}
}
if (RT_FAILURE(vrc))
{
goto out;
}
for (unsigned i = 0; i < partitions.cPartitions; i++)
{
{
/* Some ignorant user specified an extended partition.
* Bad idea, as this would trigger an overlapping
* partitions error later during VMDK creation. So warn
* here and ignore what the user requested. */
RTMsgWarning("It is not possible (and necessary) to explicitly give access to the "
"extended partition %u. If required, enable access to all logical "
"partitions inside this extended partition.",
}
}
for (unsigned i = 0; i < partitions.cPartitions; i++)
{
{
if (!pPartDesc)
{
goto out;
}
/** @todo the clipping below isn't 100% accurate, as it should
* actually clip to the track size. However that's easier said
* than done as figuring out the track size is heuristics. In
* any case the clipping is adjusted later after sorting, to
* prevent overlapping data areas on the resulting image. */
if (!pPartData)
{
goto out;
}
if (RT_FAILURE(vrc))
{
goto out;
}
/* Splice in the replacement MBR code if specified. */
&& pszMBRFilename)
{
if (RT_FAILURE(vrc))
{
goto out;
}
if (RT_FAILURE(vrc))
{
goto out;
}
}
}
{
/* Suppress exporting the actual extended partition. Only
* logical partitions should be processed. However completely
* ignoring it leads to leaving out the EBR data. */
continue;
}
/* set up values for non-relative device names */
if (!pPartDesc)
{
goto out;
}
{
if (fRelative)
{
#ifdef RT_OS_LINUX
/* Refer to the correct partition and use offset 0. */
char *psz;
if (RT_FAILURE(vrc))
{
RTMsgError("Cannot create reference to individual partition %u, rc=%Rrc",
goto out;
}
pszRawName = psz;
uStartOffset = 0;
#elif defined(RT_OS_DARWIN)
/* Refer to the correct partition and use offset 0. */
char *psz;
if (RT_FAILURE(vrc))
{
RTMsgError("Cannot create reference to individual partition %u, rc=%Rrc",
goto out;
}
pszRawName = psz;
uStartOffset = 0;
#else
/** @todo not implemented for other hosts. Treat just like
* not specified (this code is actually never reached). */
#endif
}
}
else
{
pPartDesc->uStartOffset = 0;
}
}
/* Sort data areas in ascending order of start. */
{
unsigned uMinIdx = i;
{
{
uMinIdx = j;
}
}
if (uMinIdx != i)
{
/* Swap entries at index i and uMinIdx. */
}
}
* are sorted this is much easier to get 100% right. */
{
{
RawDescriptor.pPartDescs[i].cbData = RT_MIN(RawDescriptor.pPartDescs[i+1].uStart - RawDescriptor.pPartDescs[i].uStart, RawDescriptor.pPartDescs[i].cbData);
{
RTMsgError("MBR/EPT overlaps with data area");
goto out;
}
}
}
}
#ifdef DEBUG_klaus
RTPrintf("# start length startoffset partdataptr device\n");
for (unsigned i = 0; i < RawDescriptor.cPartDescs; i++)
{
RTPrintf("%2u %14RU64 %14RU64 %14RU64 %#18p %s\n", i,
}
#endif
if (RT_FAILURE(vrc))
{
goto out;
}
LCHS.cCylinders = 0;
if (RT_FAILURE(vrc))
{
goto out;
}
/* Clean up allocated memory etc. */
if (pszPartitions)
{
for (unsigned i = 0; i < RawDescriptor.cPartDescs; i++)
{
/* Free memory allocated for relative device name. */
}
if (RawDescriptor.pPartDescs)
}
if (fRegister)
{
hardDisk.asOutParam()));
}
out:
RTMsgError("The raw disk vmdk file was not created");
}
static int CmdRenameVMDK(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
/* Parse the arguments. */
for (int i = 0; i < argc; i++)
{
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
else
{
}
}
if (RT_FAILURE(vrc))
{
return vrc;
}
else
{
if (RT_FAILURE(vrc))
{
}
else
{
if (RT_FAILURE(vrc))
{
}
}
}
return vrc;
}
static int CmdConvertToRaw(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
bool fWriteToStdOut = false;
/* Parse the arguments. */
for (int i = 0; i < argc; i++)
{
{
if (argc <= i + 1)
{
}
i++;
}
{
}
{
#ifdef ENABLE_CONVERT_RAW_TO_STDOUT
fWriteToStdOut = true;
#endif /* ENABLE_CONVERT_RAW_TO_STDOUT */
}
else
{
}
}
if (RT_FAILURE(vrc))
{
return 1;
}
/* Open raw output file. */
vrc = VINF_SUCCESS;
if (fWriteToStdOut)
outFile = 1;
else
if (RT_FAILURE(vrc))
{
return 1;
}
{
if (RT_FAILURE(vrc))
{
if (!fWriteToStdOut)
{
}
return 1;
}
}
if (RT_FAILURE(vrc))
{
if (!fWriteToStdOut)
{
}
return 1;
}
#define RAW_BUFFER_SIZE _128K
if (pvBuf)
{
RTStrmPrintf(g_pStdErr, "Converting image \"%s\" with size %RU64 bytes (%RU64MB) to raw...\n", src.c_str(), cbSize, (cbSize + _1M - 1) / _1M);
{
if (RT_FAILURE(vrc))
break;
if (RT_FAILURE(vrc))
break;
}
if (RT_FAILURE(vrc))
{
if (!fWriteToStdOut)
{
}
return 1;
}
}
else
{
if (!fWriteToStdOut)
{
}
RTMsgError("Out of memory allocating read buffer");
return 1;
}
if (!fWriteToStdOut)
return 0;
}
static int CmdConvertHardDisk(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
int vrc;
/* Parse the arguments. */
for (int i = 0; i < argc; i++)
{
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
}
{
}
else
{
}
}
do
{
/* Try to determine input image format */
{
if (RT_FAILURE(vrc))
{
break;
}
}
if (RT_FAILURE(vrc))
{
break;
}
/* Open the input image */
if (RT_FAILURE(vrc))
{
break;
}
/* Output format defaults to VDI */
dstformat = "VDI";
if (RT_FAILURE(vrc))
{
break;
}
RTStrmPrintf(g_pStdErr, "Converting image \"%s\" with size %RU64 bytes (%RU64MB)...\n", src.c_str(), cbSize, (cbSize + _1M - 1) / _1M);
/* Create the output image */
if (RT_FAILURE(vrc))
{
break;
}
}
while (0);
if (pDstDisk)
if (pSrcDisk)
}
/**
* Unloads the neccessary driver.
*
* @returns VBox status code
*/
int CmdModUninstall(void)
{
int rc;
rc = SUPR3Uninstall();
if (RT_SUCCESS(rc))
return 0;
if (rc == VERR_NOT_IMPLEMENTED)
return 0;
return E_FAIL;
}
/**
* Loads the neccessary driver.
*
* @returns VBox status code
*/
int CmdModInstall(void)
{
int rc;
rc = SUPR3Install();
if (RT_SUCCESS(rc))
return 0;
if (rc == VERR_NOT_IMPLEMENTED)
return 0;
return E_FAIL;
}
{
/*
* The first parameter is the name or UUID of a VM with a direct session
* that we wish to open.
*/
if (argc < 1)
ptrMachine.asOutParam());
/*
* Get the debugger interface.
*/
/*
* Parse the command.
*/
bool fEnablePresent = false;
bool fEnable = false;
bool fFlagsPresent = false;
bool fGroupsPresent = false;
bool fDestsPresent = false;
static const RTGETOPTDEF s_aOptions[] =
{
};
int ch;
{
switch (ch)
{
case 'e':
fEnablePresent = true;
fEnable = true;
break;
case 'E':
fEnablePresent = true;
fEnable = false;
break;
case 'f':
fFlagsPresent = true;
if (*ValueUnion.psz)
{
if (strFlags.isNotEmpty())
}
break;
case 'g':
fGroupsPresent = true;
if (*ValueUnion.psz)
{
if (strGroups.isNotEmpty())
}
break;
case 'd':
fDestsPresent = true;
if (*ValueUnion.psz)
{
if (strDests.isNotEmpty())
}
break;
default:
}
}
/*
* Do the job.
*/
if (fEnablePresent && !fEnable)
/** @todo flags, groups destination. */
RTMsgWarning("One or more of the requested features are not implemented! Feel free to do this.");
if (fEnablePresent && fEnable)
return 0;
}
/**
* Generate a SHA-256 password hash
*/
int CmdGeneratePasswordHash(int argc, char **argv, ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
/* one parameter, the password to hash */
if (argc != 1)
return 0;
}
/**
* Wrapper for handling internal commands
*/
int handleInternalCommands(HandlerArg *a)
{
g_fInternalMode = true;
/* at least a command is required */
if (a->argc < 1)
/*
* The 'string switch' on command name.
*/
//if (!strcmp(pszCmd, "unloadsyms"))
// return CmdUnloadSyms(argc - 1 , &a->argv[1]);
return CmdModInstall();
return CmdModUninstall();
/* default: */
}