VBoxManageMisc.cpp revision c9c91b1b6bb3645b0877a8e50e356cd254f8d6d5
/* $Id$ */
/** @file
* VBoxManage - VirtualBox's command-line interface.
*/
/*
* Copyright (C) 2006-2009 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 *
*******************************************************************************/
#ifndef VBOX_ONLY_DOCS
#include <vector>
#include <list>
#endif /* !VBOX_ONLY_DOCS */
#include <iprt/buildconfig.h>
#include <iprt/initterm.h>
#include "VBoxManage.h"
using namespace com;
int handleRegisterVM(HandlerArg *a)
{
if (a->argc != 1)
/** @todo Ugly hack to get both the API interpretation of relative paths
* and the client's interpretation of relative paths. Remove after the API
* has been redesigned. */
if (rc == VBOX_E_FILE_ERROR)
{
if (RT_FAILURE(vrc))
{
return 1;
}
}
{
}
}
static const RTGETOPTDEF g_aUnregisterVMOptions[] =
{
};
int handleUnregisterVM(HandlerArg *a)
{
bool fDelete = false;
int c;
// start at 0 because main() has hacked both the argc and argv given to us
RTGetOptInit(&GetState, a->argc, a->argv, g_aUnregisterVMOptions, RT_ELEMENTS(g_aUnregisterVMOptions),
{
switch (c)
{
case 'd': // --delete
fDelete = true;
break;
case VINF_GETOPT_NOT_OPTION:
if (!VMName)
else
break;
default:
if (c > 0)
{
if (RT_C_IS_PRINT(c))
else
}
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
else if (ValueUnion.pDef)
else
}
}
/* check for required options */
if (!VMName)
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
{
for (size_t u = 0;
u < abstrFiles.size();
++u)
{
if (fDelete)
{
}
else
}
if (fDelete)
{
}
}
}
}
int handleCreateVM(HandlerArg *a)
{
bool fRegister = false;
RTUuidClear(&id);
for (int i = 0; i < a->argc; i++)
{
{
if (a->argc <= i + 1)
i++;
baseFolder = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
settingsFile = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
fRegister = true;
}
else
}
if (!name)
do
{
if (settingsFile.isEmpty())
else
if (fRegister)
{
}
RTPrintf("Virtual machine '%ls' is created%s.\n"
"UUID: %s\n"
"Settings file: '%ls'\n",
}
while (0);
}
int handleStartVM(HandlerArg *a)
{
static const RTGETOPTDEF s_aStartVMOptions[] =
{
};
int c;
// start at 0 because main() has hacked both the argc and argv given to us
{
switch (c)
{
case 't': // --type
{
sessionType = "gui";
}
#ifdef VBOX_WITH_VBOXSDL
{
sessionType = "sdl";
}
#endif
#ifdef VBOX_WITH_VRDP
{
sessionType = "vrdp";
}
#endif
#ifdef VBOX_WITH_HEADLESS
{
sessionType = "capture";
}
{
sessionType = "headless";
}
#endif
else
break;
case VINF_GETOPT_NOT_OPTION:
if (!VMName)
else
break;
default:
if (c > 0)
{
if (RT_C_IS_PRINT(c))
else
}
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
else if (ValueUnion.pDef)
else
}
}
/* check for required options */
if (!VMName)
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
/* make sure the VM process will start on the same display as VBoxManage */
if (pszDisplay)
if (pszXAuth)
#endif
RTPrintf("Waiting for the VM to power on...\n");
{
}
else
{
RTPrintf("VM has been successfully started.\n");
}
}
/* it's important to always close sessions */
a->session->UnlockMachine();
}
int handleDiscardState(HandlerArg *a)
{
if (a->argc != 1)
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
do
{
/* we have to open a session for this task */
do
{
} while (0);
} while (0);
}
}
int handleAdoptState(HandlerArg *a)
{
if (a->argc != 2)
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
do
{
/* we have to open a session for this task */
do
{
} while (0);
} while (0);
}
}
int handleGetExtraData(HandlerArg *a)
{
if (a->argc != 2)
/* global data? */
{
/* enumeration? */
{
for (size_t i = 0;
++i)
{
}
}
else
{
else
RTPrintf("No value set!\n");
}
}
else
{
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
/* enumeration? */
{
for (size_t i = 0;
++i)
{
}
}
else
{
else
RTPrintf("No value set!\n");
}
}
}
}
int handleSetExtraData(HandlerArg *a)
{
if (a->argc < 2)
/* global data? */
{
if (a->argc < 3)
else if (a->argc == 3)
else
}
else
{
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
if (a->argc < 3)
else if (a->argc == 3)
else
}
}
}
int handleSetProperty(HandlerArg *a)
{
/* there must be two arguments: property name and value */
if (a->argc != 2)
{
/* reset to default? */
else
}
{
/* reset to default? */
else
}
{
/* reset to default? */
else
}
{
/* reset to default? */
else
}
{
int vrc;
if (vrc != VINF_SUCCESS)
}
else
}
int handleSharedFolder(HandlerArg *a)
{
/* we need at least a command and target */
if (a->argc < 2)
/* assume it's a UUID */
{
/* must be a name */
}
if (!machine)
return 1;
{
/* we need at least four more parameters */
if (a->argc < 5)
bool fTransient = false;
bool fWritable = true;
bool fAutoMount = false;
for (int i = 2; i < a->argc; i++)
{
{
i++;
}
{
i++;
}
{
fWritable = false;
}
{
fTransient = true;
}
{
fAutoMount = true;
}
else
}
/* required arguments */
{
}
if (fTransient)
{
/* open an existing session for the VM */
/* get the session machine */
/* get the session console */
fWritable, fAutoMount));
if (console)
a->session->UnlockMachine();
}
else
{
/* open a session for the VM */
/* get the mutable session machine */
fWritable, fAutoMount));
a->session->UnlockMachine();
}
}
{
/* we need at least two more parameters */
if (a->argc < 3)
bool fTransient = false;
for (int i = 2; i < a->argc; i++)
{
{
i++;
}
{
fTransient = true;
}
else
}
/* required arguments */
if (!name)
if (fTransient)
{
/* open an existing session for the VM */
/* get the session machine */
/* get the session console */
if (console)
a->session->UnlockMachine();
}
else
{
/* open a session for the VM */
/* get the mutable session machine */
/* commit and close the session */
a->session->UnlockMachine();
}
}
else
return 0;
}
int handleVMStatistics(HandlerArg *a)
{
/* at least one option: the UUID or name of the VM */
if (a->argc < 1)
/* try to find the given machine */
else
{
}
return 1;
/* parse arguments. */
bool fReset = false;
bool fWithDescriptions = false;
for (int i = 1; i < a->argc; i++)
{
{
if (pszPattern)
if (i + 1 >= a->argc)
pszPattern = a->argv[++i];
}
fWithDescriptions = true;
/* add: --file <filename> and --formatted */
fReset = true;
else
}
if (fReset && fWithDescriptions)
/* open an existing session for the VM. */
{
/* get the session console. */
{
/* get the machine debugger. */
{
if (fReset)
else
{
{
/* if (fFormatted)
{ big mess }
else
*/
}
}
}
a->session->UnlockMachine();
}
}
}