VBoxManage.cpp revision 2f34aff9fb42982aaaebe227a1c2d381ee3a025b
/** @file
*
* VBox frontends: VBoxManage (command-line interface)
*
* VBoxManage is VirtualBox's command-line interface. This is its rather
* long source.
*/
/*
* Copyright (C) 2006-2007 innotek 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 *
*******************************************************************************/
#define CFGLDR_HAVE_COM
#include <stdlib.h>
#include <stdarg.h>
#include <vector>
#include "VBoxManage.h"
using namespace com;
/* missing XPCOM <-> COM wrappers */
#ifndef STDMETHOD_
#endif
#ifndef NS_GET_IID
# define NS_GET_IID(I) IID_##I
#endif
#ifndef __WIN__
#define IUnknown nsISupports
#endif
/** command handler type */
typedef DECLCALLBACK(int) FNHANDLER(int argc, char *argv[], ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession);
typedef FNHANDLER *PFNHANDLER;
/**
* Quick IUSBDevice implementation for detaching / attaching
* devices to the USB Controller.
*/
class MyUSBDevice : public IUSBDevice
{
public:
// public initializer/uninitializer for internal purposes only
MyUSBDevice(uint16_t a_u16VendorId, uint16_t a_u16ProductId, uint16_t a_bcdRevision, uint64_t a_u64SerialHash, const char *a_pszComment)
m_cRefs(0)
{
}
{
return ASMAtomicIncU32(&m_cRefs);
}
{
if (!cRefs)
delete this;
return cRefs;
}
{
*ppvObject = (IUSBDevice *)this;
else
return E_NOINTERFACE;
AddRef();
return S_OK;
}
STDMETHOD(COMGETTER(VendorId))(USHORT *a_pusVendorId) { *a_pusVendorId = m_usVendorId; return S_OK; }
STDMETHOD(COMGETTER(ProductId))(USHORT *a_pusProductId) { *a_pusProductId = m_usProductId; return S_OK; }
STDMETHOD(COMGETTER(Revision))(USHORT *a_pusRevision) { *a_pusRevision = m_bcdRevision; return S_OK; }
STDMETHOD(COMGETTER(SerialHash))(ULONG64 *a_pullSerialHash) { *a_pullSerialHash = m_u64SerialHash; return S_OK; }
private:
/** The vendor id of this USB device. */
/** The product id of this USB device. */
/** The product revision number of this USB device.
* (high byte = integer; low byte = decimal) */
/** The USB serial hash of the device. */
/** The user comment string. */
/** Reference counter. */
};
// types
///////////////////////////////////////////////////////////////////////////////
template <typename T>
class Nullable
{
public:
operator const T&() const { return mValue; }
{
mIsNull = false;
return *this;
}
private:
bool mIsNull;
T mValue;
};
/** helper structure to encapsulate USB filter manipulation commands */
struct USBFilterCmd
{
struct USBFilter
{
USBFilter ()
{}
};
/** flag whether the command target is a global filter */
bool mGlobal;
/** machine this command is targeted at (null for global filters) */
};
// funcs
///////////////////////////////////////////////////////////////////////////////
{
#ifdef __LINUX__
bool fLinux = true;
#else
bool fLinux = false;
#endif
#ifdef __WIN__
bool fWin = true;
#else
bool fWin = false;
#endif
#ifdef __DARWIN__
bool fDarwin = true;
#else
bool fDarwin = false;
#endif
#ifdef VBOX_VRDP
bool fVRDP = true;
#else
bool fVRDP = false;
#endif
if (u64Cmd == USAGE_DUMPOPTS)
{
fLinux = true;
fWin = true;
fVRDP = true;
}
RTPrintf("Usage:\n"
"\n");
if (u64Cmd & USAGE_LIST)
{
RTPrintf("VBoxManage list vms|ostypes|hostdvds|hostfloppies|");
if (fWin)
RTPrintf( "hostifs|");
RTPrintf( "\n"
" hdds|dvds|floppies|usbhost|usbfilters|\n"
" systemproperties\n"
"\n");
}
if (u64Cmd & USAGE_SHOWVMINFO)
{
RTPrintf("VBoxManage showvminfo <uuid>|<name>\n"
" [-details]\n"
"\n");
}
if (u64Cmd & USAGE_REGISTERVM)
{
RTPrintf("VBoxManage registervm <filename>\n"
"\n");
}
if (u64Cmd & USAGE_UNREGISTERVM)
{
RTPrintf("VBoxManage unregistervm <uuid>|<name>\n"
" [-delete]\n"
"\n");
}
if (u64Cmd & USAGE_CREATEVM)
{
RTPrintf("VBoxManage createvm -name <name>\n"
" [-register]\n"
" [-basefolder <path> | -settingsfile <path>]\n"
" \n"
"\n");
}
if (u64Cmd & USAGE_MODIFYVM)
{
RTPrintf("VBoxManage modifyvm <uuid|name>\n"
" [-name <name>]\n"
" [-ostype <ostype>]\n"
" [-memory <memorysize>]\n"
" [-vram <vramsize>]\n"
" [-acpi on|off]\n"
" [-ioapic on|off]\n"
" [-hwvirtex on|off|default]\n"
" [-bioslogofadein on|off]\n"
" [-bioslogofadeout on|off]\n"
" [-bioslogodisplaytime <msec>]\n"
" [-bioslogoimagepath <imagepath>]\n"
" [-biosbootmenu disabled|menuonly|messageandmenu]\n"
" [-biossystemtimeoffset <msec>]\n"
" [-boot<1-4> none|floppy|dvd|disk|net>]\n"
" [-hd<a|b|d> none|<uuid>|<filename>]\n"
" [-dvd none|<uuid>|<filename>|host:<drive>]\n"
" [-dvdpassthrough on|off]\n"
" [-floppy disabled|empty|<uuid>|\n"
" <filename>|host:<drive>]\n"
" [-nic<1-N> none|null|nat|hostif|intnet]\n"
" [-nictype<1-N> Am79C970A|Am79C973]\n"
" [-cableconnected<1-N> on|off]\n"
" [-nictrace<1-N> on|off]\n"
" [-nictracefile<1-N> <filename>]\n"
" [-hostifdev<1-N> none|<devicename>]\n"
" [-intnet<1-N> network]\n"
" [-macaddress<1-N> auto|<mac>\n");
if (fLinux)
{
RTPrintf(" [-tapsetup<1-N> none|<application>]\n"
" [-tapterminate<1-N> none|<application>]\n");
}
RTPrintf(" [-audio none|null");
if (fWin)
{
RTPrintf( "|winmm|dsound");
}
if (fLinux)
{
RTPrintf( "|oss"
#ifdef VBOX_WITH_ALSA
"|alsa"
#endif
);
}
if (fDarwin)
{
RTPrintf( "|coreaudio");
}
RTPrintf( "]\n");
RTPrintf(" [-clipboard disabled|hosttoguest|guesttohost|\n"
" bidirectional]\n");
if (fVRDP)
{
RTPrintf(" [-vrdp on|off]\n"
" [-vrdpport default|<port>]\n"
" [-vrdpaddress <host>]\n"
" [-vrdpauthtype null|external|guest]\n"
" [-vrdpmulticon on|off]\n");
}
RTPrintf(" [-usb on|off]\n"
" [-snapshotfolder default|<path>]\n"
"\n");
}
if (u64Cmd & USAGE_STARTVM)
{
RTPrintf("VBoxManage startvm <uuid>|<name>\n"
" [-type gui|vrdp]\n"
"\n");
}
if (u64Cmd & USAGE_CONTROLVM)
{
RTPrintf("VBoxManage controlvm <uuid>|<name>\n"
" pause|resume|reset|poweroff|savestate|\n"
" acpipowerbutton |\n"
" setlinkstate<1-4> on|off |\n"
" usbattach <uuid>|<address> |\n"
" usbdetach <uuid>|<address> |\n"
" dvdattach none|<uuid>|<filename>|host:<drive> |\n"
" floppyattach none|<uuid>|<filename>|host:<drive> |\n"
" setvideomodehint <xres> <yres> <bpp> |\n"
" setcredentials <username> <password> <domain>\n"
" [-allowlocallogon <yes|no>]\n"
"\n");
}
if (u64Cmd & USAGE_DISCARDSTATE)
{
RTPrintf("VBoxManage discardstate <uuid>|<name>\n"
"\n");
}
if (u64Cmd & USAGE_SNAPSHOT)
{
RTPrintf("VBoxManage snapshot <uuid>|<name>\n"
" take <name> [-desc <desc>] |\n"
" discard <uuid>|<name> |\n"
" discardcurrent -state|-all |\n"
" edit <uuid>|<name>|-current\n"
" [-newname <name>]\n"
" [-newdesc <desc>] |\n"
" showvminfo <uuid>|<name>\n"
"\n");
}
if (u64Cmd & USAGE_REGISTERIMAGE)
{
RTPrintf("VBoxManage registerimage disk|dvd|floppy <filename>\n"
" [-type normal|immutable|writethrough] (disk only)\n"
"\n");
}
if (u64Cmd & USAGE_UNREGISTERIMAGE)
{
RTPrintf("VBoxManage unregisterimage disk|dvd|floppy <uuid>|<filename>\n"
"\n");
}
if (u64Cmd & USAGE_SHOWVDIINFO)
{
RTPrintf("VBoxManage showvdiinfo <uuid>|<filename>\n"
"\n");
}
if (u64Cmd & USAGE_CREATEVDI)
{
RTPrintf("VBoxManage createvdi -filename <filename>\n"
" -size <megabytes>\n"
" [-static]\n"
" [-comment <comment>]\n"
" [-register]\n"
" [-type normal|writethrough] (default: normal)\n"
"\n");
}
if (u64Cmd & USAGE_MODIFYVDI)
{
RTPrintf("VBoxManage modifyvdi <uuid>|<filename>\n"
#if 0 /* doesn't currently work */
" settype normal|writethrough|immutable |\n"
#endif
" compact\n"
"\n");
}
if (u64Cmd & USAGE_CLONEVDI)
{
RTPrintf("VBoxManage clonevdi <uuid>|<filename> <outputfile>\n"
"\n");
}
if (u64Cmd & USAGE_CONVERTDD)
{
RTPrintf("VBoxManage convertdd <filename> <outputfile>\n"
"VBoxManage convertdd stdin <outputfile> <bytes>\n"
"\n");
}
if (u64Cmd & USAGE_ADDISCSIDISK)
{
RTPrintf("VBoxManage addiscsidisk -server <name>|<ip>\n"
" -target <target>\n"
" [-port <port>]\n"
" [-lun <lun>]\n"
" [-encodedlun <lun>]\n"
" [-username <username>]\n"
" [-password <password>]\n"
" [-comment <comment>]\n"
"\n");
}
{
RTPrintf("VBoxManage createhostif <name>\n"
"\n");
}
{
RTPrintf("VBoxManage removehostif <uuid>|<name>\n"
"\n");
}
if (u64Cmd & USAGE_GETEXTRADATA)
{
RTPrintf("VBoxManage getextradata global|<uuid>|<name>\n"
" <key>|enumerate\n"
"\n");
}
if (u64Cmd & USAGE_SETEXTRADATA)
{
RTPrintf("VBoxManage setextradata global|<uuid>|<name>\n"
" <key>\n"
" [<value>] (no value deletes key)\n"
"\n");
}
if (u64Cmd & USAGE_SETPROPERTY)
{
RTPrintf("VBoxManage setproperty vdifolder default|<folder> |\n"
" machinefolder default|<folder> |\n"
" vrdpauthlibrary default|<library> |\n"
" hwvirtexenabled yes|no\n"
"\n");
}
if (u64Cmd & USAGE_USBFILTER_ADD)
{
RTPrintf("VBoxManage usbfilter add <index,0-N>\n"
" -target <uuid>|<name>|global\n"
" -name <string>\n"
" -action ignore|hold (global filters only)\n"
" [-active yes|no] (yes)\n"
" [-vendorid <XXXX>] (null)\n"
" [-productid <XXXX>] (null)\n"
" [-revision <IIFF>] (null)\n"
" [-manufacturer <string>] (null)\n"
" [-product <string>] (null)\n"
" [-remote yes|no] (null, VM filters only)\n"
" [-serialnumber <string>] (null)\n"
"\n");
}
if (u64Cmd & USAGE_USBFILTER_MODIFY)
{
RTPrintf("VBoxManage usbfilter modify <index,0-N>\n"
" -target <uuid>|<name>|global\n"
" [-name <string>]\n"
" [-action ignore|hold] (global filters only)\n"
" [-active yes|no]\n"
" [-vendorid <XXXX>|\"\"]\n"
" [-productid <XXXX>|\"\"]\n"
" [-revision <IIFF>|\"\"]\n"
" [-manufacturer <string>|\"\"]\n"
" [-product <string>|\"\"]\n"
" [-remote yes|no] (null, VM filters only)\n"
" [-serialnumber <string>|\"\"]\n"
"\n");
}
if (u64Cmd & USAGE_USBFILTER_REMOVE)
{
RTPrintf("VBoxManage usbfilter remove <index,0-N>\n"
" -target <uuid>|<name>|global\n"
"\n");
}
if (u64Cmd & USAGE_SHAREDFOLDER_ADD)
{
RTPrintf("VBoxManage sharedfolder add <vmname>|<uuid>\n"
" -name <name> -hostpath <hostpath>\n"
" [-transient]\n"
"\n");
}
if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE)
{
RTPrintf("VBoxManage sharedfolder remove <vmname>|<uuid>\n"
" -name <name> [-transient]\n"
"\n");
}
if (u64Cmd & USAGE_UPDATESETTINGS)
{
RTPrintf("VBoxManage updatesettings [<dir>|<file>] [-apply]\n"
" [-nobackup] [-skipinvalid]\n"
"\n");
}
}
/**
* Print a usage synopsis and the syntax error message.
*/
{
if (fInternalMode)
else
RTPrintf("\n"
return 1;
}
/**
* Print an error message without the syntax stuff.
*/
int errorArgument(const char *pszFormat, ...)
{
return 1;
}
/**
* Print out progress on the console
*/
{
RTPrintf("0%%...");
{
/* did we cross a 10% mark? */
{
/* make sure to also print out missed steps */
for (LONG curVal = (lastPercent / 10) * 10 + 10; curVal <= (currentPercent / 10) * 10; curVal += 10)
{
if (curVal < 100)
{
}
}
}
if (fCompleted)
{
RTPrintf("100%%\n");
break;
}
/* make sure the loop is not too tight */
RTThreadSleep(100);
}
}
{
/* start with the root */
/* print with indentation */
/* get the children */
if (coll)
{
{
if (snapshot)
{
/* recursive call */
}
}
}
}
{
RTTIME t;
RTTimeExplode (&t, &ts);
}
bool fDetails = false)
{
if (!accessible)
{
RTPrintf ("Name: <inaccessible!>\n");
RTPrintf ("Access error details:\n");
RTPrintf ("\n");
return S_OK;
}
RTPrintf("Boot menu mode: ");
switch (bootMenuMode)
{
RTPrintf("disabled\n");
break;
RTPrintf("menu only\n");
break;
default:
RTPrintf("message and menu\n");
}
if (hwVirtExEnabled == TriStateBool_Default)
{
}
else
{
}
switch (machineState)
{
case MachineState_PoweredOff:
pszState = "powered off";
break;
case MachineState_Saved:
pszState = "saved";
break;
case MachineState_Aborted:
pszState = "aborted";
break;
case MachineState_Running:
pszState = "running";
break;
case MachineState_Paused:
pszState = "paused";
break;
case MachineState_Starting:
pszState = "starting";
break;
case MachineState_Stopping:
pszState = "stopping";
break;
case MachineState_Saving:
pszState = "saving";
break;
case MachineState_Restoring:
pszState = "restoring";
break;
default:
pszState = "unknown";
break;
}
char pszTime[30] = {0};
{
if (fFloppyEnabled)
{
switch (floppyState)
{
case DriveState_ImageMounted:
{
{
}
break;
}
{
{
}
break;
}
case DriveState_NotMounted:
{
pszFloppy = "empty";
break;
}
}
}
else
{
pszFloppy = "disabled";
}
}
{
/// @todo (dmik) we temporarily use the location property to
// determine the image file name. This is subject to change
// when iSCSI disks are here (we should either query a
// storage-specific interface from IHardDisk, or "standardize"
// the location property)
}
{
/// @todo (dmik) we temporarily use the location property to
// determine the image file name. This is subject to change
// when iSCSI disks are here (we should either query a
// storage-specific interface from IHardDisk, or "standardize"
// the location property)
}
{
/// @todo (dmik) we temporarily use the location property to
// determine the image file name. This is subject to change
// when iSCSI disks are here (we should either query a
// storage-specific interface from IHardDisk, or "standardize"
// the location property)
}
{
{
{
}
}
else
{
{
}
else
RTPrintf("DVD: empty");
if (fPassthrough)
RTPrintf(" (passthrough enabled)");
RTPrintf("\n");
}
}
/* get the maximum amount of NICS */
{
{
if (!fEnabled)
{
}
else
{
switch (attachment)
{
strAttachment = "none";
break;
strAttachment = "NAT";
break;
strAttachment = "Host Interface";
break;
{
break;
}
default:
strAttachment = "unknown";
break;
}
/* trace stuff */
RTPrintf("NIC %d: MAC: %lS, Attachment: %s, Trace: %s (file: %lS)\n",
}
}
}
{
const char *psz = "Unknown";
{
switch (enmType)
{
default: ; break;
}
}
else
}
/* Shared clipboard */
{
const char *psz = "Unknown";
switch (enmMode)
{
default: ; break;
}
}
if (console)
{
}
/*
* VRDP
*/
{
if (fEnabled)
{
const char *strAuthType;
switch (vrdpAuthType)
{
strAuthType = "null";
break;
strAuthType = "external";
break;
strAuthType = "guest";
break;
default:
strAuthType = "unknown";
break;
}
}
else
RTPrintf("VRDP: disabled\n");
}
/*
* USB.
*/
{
fEnabled = false;
RTPrintf("\nUSB Device Filters:\n\n");
if (!fMore)
{
RTPrintf("<none>\n\n");
}
else
while (fMore)
{
/* Query info. */
index ++;
}
if (console)
{
/* scope */
{
RTPrintf("Available remote USB devices:\n\n");
if (!more)
{
RTPrintf("<none>\n\n");
}
else
while (more)
{
/* Query info. */
RTPrintf("UUID: %S\n"
"VendorId: 0x%04x (%04X)\n"
"ProductId: 0x%04x (%04X)\n"
"Revision: %u.%u (%02u%02u)\n",
/* optional stuff. */
RTPrintf("\n");
}
}
/* scope */
{
RTPrintf ("Currently Attached USB Devices:\n\n");
if (!more)
{
RTPrintf("<none>\n\n");
}
else
while (more)
{
/* Query info. */
RTPrintf("UUID: %S\n"
"VendorId: 0x%04x (%04X)\n"
"ProductId: 0x%04x (%04X)\n"
"Revision: %u.%u (%02u%02u)\n",
/* optional stuff. */
RTPrintf("\n");
}
}
}
} /* USB */
/*
* Shared folders
*/
RTPrintf("Shared folders:\n\n");
uint32_t numSharedFolders = 0;
#if 0 // not yet implemented
/* globally shared folders first */
{
while (fMore)
{
}
}
#endif
/* now VM mappings */
{
while (fMore)
{
}
}
/* transient mappings */
if (console)
{
while (fMore)
{
}
}
if (!numSharedFolders)
RTPrintf("<none>\n");
RTPrintf("\n");
if (console)
{
/*
* Live VRDP info.
*/
if (NumberOfClients > 0)
{
char timestr[128];
if (Active)
{
}
else
{
}
if (Active)
{
}
}
RTPrintf("\n");
}
if (fDetails)
{
if (!description.isEmpty())
{
}
}
/*
* snapshots
*/
{
RTPrintf("Snapshots:\n\n");
}
RTPrintf("\n");
return S_OK;
}
{
/* at least one option: the UUID or name of the VM */
if (argc < 1)
{
}
/* try to find the given machine */
{
}
else
{
}
return 1;
/* 2nd option can be -details */
bool fDetails = false;
fDetails = true;
/* open an existing session for the VM */
/* get the session machine */
/* get the session console */
if (console)
}
{
/* exactly one option: the object */
if (argc != 1)
{
}
/* which object? */
{
/*
* Get the list of all registered VMs
*/
{
/*
* Iterate through the collection
*/
{
{
}
}
}
}
else
{
{
{
}
}
}
else
{
{
{
}
}
}
else
{
{
{
}
}
}
#ifdef __WIN__
else
{
{
{
}
}
}
#endif /* __WIN__ */
else
{
{
const char *storageTypeString = "unknown";
switch (storageType)
{
storageTypeString = "Virtual Disk Image";
break;
storageTypeString = "iSCSI hard disk";
break;
}
/// @todo (dmik) we temporarily use the location property to
// determine the image file name. This is subject to change
// when iSCSI disks are here (we should either query a
// storage-specific interface from IHardDisk, or "standardize"
// the location property)
if (!machineUUID.isEmpty())
{
}
RTPrintf("\n");
}
}
else
{
{
/** @todo usage */
RTPrintf("\n");
}
}
else
{
{
CHECK_ERROR(virtualBox, GetFloppyImageUsage(uuid, ResourceUsage_AllUsage, machineUUIDs.asOutParam()));
/** @todo usage */
RTPrintf("\n");
}
}
else
{
RTPrintf("Host USB Devices:\n\n");
if (!fMore)
{
RTPrintf("<none>\n\n");
}
else
while (fMore)
{
/* Query info. */
RTPrintf("UUID: %S\n"
"VendorId: 0x%04x (%04X)\n"
"ProductId: 0x%04x (%04X)\n"
"Revision: %u.%u (%02u%02u)\n",
/* optional stuff. */
/* current state */
const char *pszState = "?";
switch (state)
{
pszState = "Not supported"; break;
pszState = "Unavailable"; break;
pszState = "Busy"; break;
pszState = "Available"; break;
pszState = "Held"; break;
pszState = "Captured"; break;
default:
ASSERT (false);
break;
}
}
}
else
{
RTPrintf("Global USB Device Filters:\n\n");
if (!more)
{
RTPrintf("<none>\n\n");
}
else
while (more)
{
/* Query info. */
const char *pszAction = "<invalid>";
switch (action)
{
pszAction = "Ignore";
break;
pszAction = "Hold";
break;
default:
break;
}
index ++;
}
}
{
}
else
{
}
}
{
if (argc != 1)
{
}
{
}
}
{
{
}
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
{
/* are we supposed to delete the config file? */
{
}
}
}
}
{
bool fStatic = false;
bool fRegister = false;
const char *type = "normal";
/* 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++;
}
{
fStatic = true;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
fRegister = true;
}
{
if (argc <= i + 1)
{
}
i++;
}
else
{
}
}
/* check the outcome */
{
}
{
}
CHECK_ERROR(virtualBox, CreateHardDisk(HardDiskStorageType_VirtualDiskImage, hardDisk.asOutParam()));
{
if (fStatic)
{
}
else
{
}
{
{
{
if (info.isBasicAvailable())
{
}
else
{
RTPrintf("Error: failed to create disk image. No error message available!\n");
}
}
else
{
{
/* nothing required, default */
}
{
}
}
}
}
{
}
}
}
{
{
RTPrintf(".");
}
return VINF_SUCCESS;
}
{
if (argc < 2)
{
}
/* first guess is that it's a UUID */
/* no? then it must be a filename */
if (!hardDisk)
{
}
else
{
}
/* let's find out which command */
// doesn't currently work if (strcmp(argv[1], "settype") == 0)
if (0)
{
/* hard disk must be registered */
{
if (argc <= 2)
{
return errorArgument("Missing argument to for settype");
}
{
if (hddType != HardDiskType_NormalHardDisk)
}
{
}
{
}
else
{
}
}
else
{
return errorArgument("Hard disk image not registered");
}
}
{
/* the hard disk image might not be registered */
if (!hardDisk)
{
if (!vdi)
{
return errorArgument("Hard disk image not found");
}
}
else
if (!vdi)
return errorArgument("Invalid hard disk type. The command only works on VDI files\n");
/* close the file */
unsigned uProcent;
if (VBOX_FAILURE(vrc))
{
}
}
else
{
}
}
{
/* source VDI and target path */
if (argc != 2)
{
}
/* first guess is that it's a UUID */
if (!hardDisk)
{
/* not successful? Then it must be a filename */
}
if (hardDisk)
{
{
{
if (info.isBasicAvailable())
{
}
else
{
RTPrintf("Error: failed to clone disk image. No error message available!\n");
}
}
}
}
}
{
#ifdef __LINUX__
#else
const bool fReadFromStdIn = false;
#endif
RTPrintf("Converting VDI: from DD image file=\"%s\" to file=\"%s\"...\n",
/* open raw image file. */
int rc = VINF_SUCCESS;
if (fReadFromStdIn)
File = 0;
else
if (VBOX_FAILURE(rc))
{
return rc;
}
/* get image size. */
if (fReadFromStdIn)
else
if (VBOX_SUCCESS(rc))
{
RTPrintf("Creating fixed image with size %RU64Bytes (%RU64MB)...\n", cbFile, (cbFile + _1M - 1) / _1M);
char pszComment[256];
if (VBOX_SUCCESS(rc))
{
if (VBOX_SUCCESS(rc))
{
/* alloc work buffer. */
if (pvBuf)
{
{
unsigned cbRead = 0;
break;
if (VBOX_FAILURE(rc))
break;
}
}
else
rc = VERR_NO_MEMORY;
}
if (VBOX_FAILURE(rc))
{
/* delete image on error */
}
}
else
}
return rc;
}
{
/* at least server and target */
if (argc < 4)
{
}
/* 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++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
/** @todo move the LUN encoding algorithm into IISCSIHardDisk, add decoding */
if (argc <= i + 1)
{
}
i++;
char *pszNext;
if (lun <= 255)
{
/* Assume bus identifier = 0. */
}
else
{
/* Check above already limited the LUN to 14 bits. */
}
}
{
if (argc <= i + 1)
{
}
i++;
char *pszNext;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
else
{
}
}
/* check for required options */
{
}
{
if (port != UINT16_MAX)
if (lun != UINT64_MAX)
{
}
{
}
}
}
{
bool fRegister = false;
for (int i = 0; i < argc; i++)
{
{
if (argc <= i + 1)
{
}
i++;
baseFolder = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
settingsFile = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
}
{
fRegister = true;
}
else
{
}
}
if (!name)
{
}
if (!!baseFolder && !!settingsFile)
{
}
do
{
if (!settingsFile)
else
if (fRegister)
{
}
RTPrintf("Virtual machine '%ls' is created%s.\n"
"UUID: %s\n"
"Settings file: '%ls'\n",
}
while (0);
}
/**
* Parses a NIC number.
*
* @returns Valid nic number on success.
* @returns 0 if invalid nic. All necesary bitching has been done.
* @param psz Pointer to the nic number.
*/
{
char *pszNext;
if ( VBOX_SUCCESS(rc)
&& *pszNext == '\0'
&& u32 >= 1
return (unsigned)u32;
return 0;
}
{
ULONG memorySize = 0;
char *bioslogofadein = NULL;
char *bioslogofadeout = NULL;
uint32_t bioslogodisplaytime = ~0;
char *bioslogoimagepath = NULL;
char *biosbootmenumode = NULL;
char *biossystemtimeoffset = NULL;
int bootDeviceChanged[4] = { false };
char *hdds[4] = {0};
char *dvdpassthrough = NULL;
#ifdef VBOX_VRDP
char *vrdpaddress = NULL;
char *vrdpauthtype = NULL;
char *vrdpmulticon = NULL;
#endif
int fUsbEnabled = -1;
char *snapshotFolder = NULL;
/* VM ID + at least one parameter + value */
if (argc < 3)
{
}
/* Get the number of network adapters */
ULONG NetworkAdapterCount = 0;
{
}
#ifdef __LINUX__
#endif
for (int i = 1; i < argc; i++)
{
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
bioslogofadein = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
bioslogofadeout = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
bioslogoimagepath = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
biosbootmenumode = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
biossystemtimeoffset = argv[i];
}
{
ULONG n = 0;
if (!argv[i][5])
{
}
{
}
if (argc <= i + 1)
{
}
i++;
{
}
{
}
{
}
{
}
{
}
else
{
}
bootDeviceChanged[n - 1] = true;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
dvdpassthrough = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
/* watch for the right order of these -nic* comparisons! */
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
#ifdef __LINUX__
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
#endif /* __LINUX__ */
{
if (!n)
return 1;
if (argc <= i + 1)
{
}
i++;
}
#ifdef VBOX_VRDP
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
vrdpport = 0;
else
}
{
if (argc <= i + 1)
{
}
i++;
vrdpaddress = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
vrdpauthtype = argv[i];
}
{
if (argc <= i + 1)
{
}
i++;
vrdpmulticon = argv[i];
}
#endif /* VBOX_VRDP */
{
if (argc <= i + 1)
{
}
i++;
fUsbEnabled = 1;
fUsbEnabled = 0;
else
}
{
if (argc <= i + 1)
{
}
i++;
snapshotFolder = argv[i];
}
else
{
}
}
/* try to find the given machine */
{
}
else
{
}
return 1;
/* open a session for the VM */
do
{
/* get the mutable session machine */
if (name)
if (ostype)
{
{
}
else
{
break;
}
}
if (memorySize > 0)
if (vramSize > 0)
if (acpi)
{
{
}
{
}
else
{
break;
}
}
if (ioapic)
{
{
}
{
}
else
{
break;
}
}
if (hwvirtex)
{
{
}
{
}
{
}
else
{
break;
}
}
if (bioslogofadein)
{
{
}
{
}
else
{
break;
}
}
if (bioslogofadeout)
{
{
}
{
}
else
{
break;
}
}
if (bioslogodisplaytime != ~0U)
{
}
if (bioslogoimagepath)
{
}
if (biosbootmenumode)
{
else
{
break;
}
}
if (biossystemtimeoffset)
{
}
{
if (bootDeviceChanged[curBootDev])
}
if (hdds[0])
{
{
}
else
{
/* first guess is that it's a UUID */
/* not successful? Then it must be a filename */
if (!hardDisk)
{
{
/* first check if it's already registered */
else
{
/* it has to be registered */
break;
}
}
}
if (hardDisk)
{
}
else
break;
}
}
if (hdds[1])
{
{
}
else
{
/* first guess is that it's a UUID */
/* not successful? Then it must be a filename */
if (!hardDisk)
{
{
/* first check if it's already registered */
else
{
/* it has to be registered */
break;
}
}
}
if (hardDisk)
{
}
else
break;
}
}
if (hdds[2])
{
{
}
else
{
/* first guess is that it's a UUID */
/* not successful? Then it must be a filename */
if (!hardDisk)
{
{
/* first check if it's already registered */
else
{
/* it has to be registered */
break;
}
}
}
if (hardDisk)
{
}
else
break;
}
}
if (dvd)
{
/* unmount? */
{
}
/* host drive? */
{
if (!hostDVDDrive)
{
errorArgument("Invalid host DVD drive name");
break;
}
}
else
{
/* first assume it's a UUID */
{
/* must be a filename, check if it's in the collection */
/* not registered, do that on the fly */
if (!dvdImage)
{
{
/* time to register the image */
}
}
}
if (!dvdImage)
{
break;
}
}
}
if (dvdpassthrough)
{
}
if (floppy)
{
/* disable? */
{
/* disable the controller */
}
else
{
/* enable the controller */
/* unmount? */
{
}
/* host drive? */
{
if (!hostFloppyDrive)
{
errorArgument("Invalid host floppy drive name");
break;
}
}
else
{
/* first assume it's a UUID */
{
/* must be a filename */
{
/** @todo first iterate through the collection and try to find the image */
/* time to register the image */
}
}
if (!floppyImage)
{
break;
}
}
}
}
if (audio)
{
/* disable? */
{
}
{
}
#ifdef __WIN__
{
}
{
}
#endif /* __WIN__ */
#ifdef __LINUX__
{
}
# ifdef VBOX_WITH_ALSA
{
}
# endif
#endif /* !__LINUX__ */
#ifdef __DARWIN__
{
}
#endif /* !__DARWIN__ */
else
{
break;
}
}
/* Shared clipboard state */
if (clipboard)
{
/* ComPtr<IClipboardMode> clipboardMode;
machine->COMGETTER(ClipboardMode)(clipboardMode.asOutParam());
ASSERT(clipboardMode);
*/
{
}
{
}
{
}
{
}
else
{
break;
}
}
/* iterate through all possible NICs */
for (ULONG n = 0; n < NetworkAdapterCount; n ++)
{
/* something about the NIC? */
if (nics[n])
{
{
}
{
}
{
}
{
}
{
}
else
{
break;
}
}
/* something about the NIC type? */
if (nictype[n])
{
{
}
{
}
else
{
break;
}
}
/* something about the MAC address? */
if (macs[n])
{
/* generate one? */
{
}
else
{
}
}
/* the link status flag? */
if (cableconnected[n])
{
{
}
{
}
else
{
break;
}
}
/* the trace flag? */
if (nictrace[n])
{
{
}
{
}
else
{
break;
}
}
/* the tracefile flag? */
if (nictracefile[n])
{
}
/* the host interface device? */
if (hostifdev[n])
{
/* remove it? */
{
}
else
{
}
}
/* the internal network name? */
if (intnet[n])
{
/* remove it? */
{
}
else
{
}
}
#ifdef __LINUX__
/* the TAP setup application? */
if (tapsetup[n])
{
/* remove it? */
{
}
else
{
}
}
/* the TAP terminate application? */
if (tapterm[n])
{
/* remove it? */
{
}
else
{
}
}
#endif /* __LINUX__ */
}
break;
#ifdef VBOX_VRDP
{
if (vrdpServer)
{
if (vrdp)
{
{
}
{
}
else
{
break;
}
}
if (vrdpport != UINT16_MAX)
{
}
if (vrdpaddress)
{
}
if (vrdpauthtype)
{
{
}
{
}
{
}
else
{
break;
}
}
if (vrdpmulticon)
{
{
}
{
}
else
{
break;
}
}
}
}
#endif /* VBOX_VRDP */
/*
*/
if (fUsbEnabled != -1)
{
{
}
}
if (snapshotFolder)
{
{
}
else
{
}
}
/* commit changes */
} while (0);
/* it's important to always close sessions */
}
{
if (argc < 1)
{
}
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
/* default to GUI session type */
/* has a session type been specified? */
{
{
sessionType = "gui";
}
{
sessionType = "vrdp";
}
{
sessionType = "capture";
}
else
{
}
}
CHECK_ERROR_RET(virtualBox, OpenRemoteSession(session, uuid, sessionType, progress.asOutParam()), rc);
RTPrintf("Waiting for the remote session to open...\n");
if (FAILED(resultCode))
{
}
else
{
RTPrintf("Remote session has been successfully opened.\n");
}
}
/* it's important to always close sessions */
}
{
if (argc < 2)
{
}
/* try to find the given machine */
{
}
else
{
}
return 1;
/* open a session for the VM */
do
{
/* get the associated console */
/* ... and session machine */
/* which command? */
{
}
{
}
{
}
{
}
{
{
if (info.isBasicAvailable())
{
}
else
{
RTPrintf("Error: failed to save machine state. No error message available!\n");
}
}
}
{
}
{
/* Get the number of network adapters */
ULONG NetworkAdapterCount = 0;
if (!n)
{
break;
}
{
break;
}
/* get the corresponding network adapter */
if (adapter)
{
{
}
{
}
else
{
break;
}
}
}
{
if (argc < 3)
{
break;
}
{
// assume address
if (attach)
{
}
else
{
}
}
if (attach)
else
{
}
}
{
if (argc != 5)
{
break;
}
}
{
bool fAllowLocalLogon = true;
if (argc == 7)
{
{
break;
}
fAllowLocalLogon = false;
}
else if (argc != 5)
{
break;
}
CHECK_ERROR_BREAK(guest, SetCredentials(Bstr(argv[2]), Bstr(argv[3]), Bstr(argv[4]), fAllowLocalLogon));
}
{
if (argc != 3)
{
break;
}
/* unmount? */
{
}
/* host drive? */
{
if (!hostDVDDrive)
{
errorArgument("Invalid host DVD drive name");
break;
}
}
else
{
/* first assume it's a UUID */
{
/* must be a filename, check if it's in the collection */
/* not registered, do that on the fly */
if (!dvdImage)
{
{
/* time to register the image */
}
}
}
if (!dvdImage)
{
break;
}
}
}
{
if (argc != 3)
{
break;
}
/* unmount? */
{
}
/* host drive? */
{
if (!hostFloppyDrive)
{
errorArgument("Invalid host floppy drive name");
break;
}
}
else
{
/* first assume it's a UUID */
{
/* must be a filename */
{
/** @todo first iterate through the collection and try to find the image */
/* time to register the image */
}
}
if (!floppyImage)
{
break;
}
}
}
else
{
}
}
while (0);
}
{
if (argc != 1)
{
}
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
do
{
/* we have to open a session for this task */
} while (0);
}
}
{
/* we need at least a VM and a command */
if (argc < 2)
{
}
/* the first argument must be the VM */
/* assume it's a UUID */
{
/* must be a name */
}
if (!machine)
return 1;
do
{
/* we have to open a session for this task. First try an existing session */
/* switch based on the command */
{
/* there must be a name */
if (argc < 3)
{
break;
}
{
break;
}
if (argc == 5)
{
if (info.isBasicAvailable())
{
}
else
{
RTPrintf("Error: failed to take snapshot. No error message available!\n");
}
}
}
{
/* exactly one parameter: snapshot name */
if (argc != 3)
{
break;
}
/* assume it's a UUID */
{
}
else
{
/* then it must be a name */
}
{
if (info.isBasicAvailable())
{
}
else
{
RTPrintf("Error: failed to discard snapshot. No error message available!\n");
}
}
}
{
if ( (argc != 3)
{
break;
}
bool fAll = false;
fAll = true;
if (fAll)
{
}
else
{
}
{
if (info.isBasicAvailable())
{
}
else
{
RTPrintf("Error: failed to discard. No error message available!\n");
}
}
}
{
if (argc < 3)
{
break;
}
{
}
else
{
/* assume it's a UUID */
{
}
else
{
/* then it must be a name */
}
}
/* parse options */
for (int i = 3; i < argc; i++)
{
{
if (argc <= i + 1)
{
break;
}
i++;
}
{
if (argc <= i + 1)
{
break;
}
i++;
}
else
{
break;
}
}
}
{
/* exactly one parameter: snapshot name */
if (argc != 3)
{
break;
}
/* assume it's a UUID */
{
}
else
{
/* then it must be a name */
}
/* get the machine of the given snapshot */
}
else
{
}
} while (0);
}
{
if (argc != 1)
{
}
bool registered = true;
/* first guess is that it's a UUID */
/* no? then it must be a filename */
{
/* no? well, then it's an unregistered image */
{
registered = false;
}
}
{
/* query a VDI object (will remain null if it's not VDI) */
/* check for accessibility */
if (accessible)
{
if (description)
{
}
}
else
{
}
const char *typeStr = "unknown";
switch (type)
{
typeStr = "standard";
break;
typeStr = "immutable";
break;
typeStr = "writethrough";
break;
}
const char *storageTypeStr = "unknown";
switch (storageType)
{
storageTypeStr = "Virtual Disk Image (VDI)";
break;
storageTypeStr = "VMDK Image";
break;
storageTypeStr = "iSCSI target";
break;
}
if (registered)
{
}
if (vdi)
{
/* VDI specific information */
}
else
{
/* Generic location information */
}
}
}
{
if (argc < 2)
{
}
{
/* there can be a type parameter */
{
}
if (argc == 4)
{
{
}
{
}
}
{
/* change the type if requested */
if (type)
{
}
}
}
{
{
}
}
{
{
}
}
else
{
}
}
{
if (argc != 2)
{
}
/* first guess is that it's a UUID */
{
/* not a UUID or not registered? Then it must be a filename */
if (!hardDisk)
{
}
{
}
}
else
{
/* not a UUID or not registered? Then it must be a filename */
if (!dvdImage)
{
}
{
}
}
else
{
/* not a UUID or not registered? Then it must be a filename */
if (!floppyImage)
{
}
{
}
}
else
{
}
}
#ifdef __WIN__
{
if (argc != 1)
{
}
do
{
hostif.asOutParam(),
progress.asOutParam()));
{
}
}
while (0);
}
{
if (argc != 1)
{
}
do
{
/* first guess is that it's a UUID */
{
/* not a valid UUID, search for it */
}
hostif.asOutParam(),
progress.asOutParam()));
{
}
}
while (0);
}
#endif /* __WIN__ */
{
if (argc != 2)
{
}
/* global data? */
{
/* enumeration? */
{
do
{
{
}
} while (extraDataKey);
}
else
{
if (value)
else
RTPrintf("No value set!\n");
}
}
else
{
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
/* enumeration? */
{
do
{
{
}
} while (extraDataKey);
}
else
{
if (value)
else
RTPrintf("No value set!\n");
}
}
}
}
{
if (argc < 2)
{
}
/* global data? */
{
if (argc < 3)
else if (argc == 3)
else
}
else
{
/* assume it's a UUID */
{
/* must be a name */
}
if (machine)
{
if (argc < 3)
else if (argc == 3)
else
}
}
}
{
/* there must be two arguments: property name and value */
if (argc != 2)
{
}
{
/* reset to default? */
{
}
else
{
}
}
{
/* reset to default? */
{
}
else
{
}
}
{
/* reset to default? */
{
}
else
{
}
}
{
else
}
else
{
}
}
{
/* at least: 0: command, 1: index, 2: -target, 3: <target value> */
if (argc < 4)
{
}
/* which command? */
{
}
/* which index? */
{
}
{
case USBFilterCmd::Add:
case USBFilterCmd::Modify:
{
/* at least: 0: command, 1: index, 2: -target, 3: <target value>, 4: -name, 5: <name value> */
if (argc < 6)
{
{
}
else
{
}
}
// set Active to true by default
// (assuming that the user sets up all necessary attributes
// at once and wants the filter to be active immediately)
for (int i = 2; i < argc; i++)
{
{
{
}
i++;
else
{
/* assume it's a UUID of a machine */
{
/* must be a name */
}
}
}
{
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
else
{
}
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
}
{
if (argc <= i + 1)
{
}
i++;
else
{
}
}
}
{
||
)
)
{
}
}
break;
}
case USBFilterCmd::Remove:
{
/* at least: 0: command, 1: index, 2: -target, 3: <target value> */
if (argc < 4)
{
}
for (int i = 2; i < argc; i++)
{
{
{
}
i++;
else
{
/* assume it's a UUID of a machine */
{
/* must be a name */
}
}
}
}
// mandatory options
{
}
break;
}
default: break;
}
else
{
/* open a session for the VM */
/* get the mutable session machine */
/* and get the USB controller */
}
{
case USBFilterCmd::Add:
{
{
if (!f.mProductId.isNull())
if (!f.mManufacturer.isNull())
if (!f.mSerialNumber.isNull())
}
else
{
if (!f.mProductId.isNull())
if (!f.mManufacturer.isNull())
if (!f.mSerialNumber.isNull())
}
break;
}
case USBFilterCmd::Modify:
{
{
if (!f.mProductId.isNull())
if (!f.mManufacturer.isNull())
if (!f.mSerialNumber.isNull())
}
else
{
if (!f.mProductId.isNull())
if (!f.mManufacturer.isNull())
if (!f.mSerialNumber.isNull())
}
break;
}
case USBFilterCmd::Remove:
{
{
}
else
{
}
break;
}
default:
break;
}
{
/* commit and close the session */
}
}
{
/* we need at least a command and target */
if (argc < 2)
{
}
/* assume it's a UUID */
{
/* must be a name */
}
if (!machine)
return 1;
{
/* we need at least four more parameters */
if (argc < 5)
{
}
bool fTransient = false;
for (int i = 2; i < argc; i++)
{
{
{
}
i++;
}
{
{
}
i++;
}
{
fTransient = true;
}
else
{
}
}
/* required arguments */
{
}
if (fTransient)
{
/* open an existing session for the VM */
/* get the session machine */
/* get the session console */
if (console)
}
else
{
/* open a session for the VM */
/* get the mutable session machine */
}
}
{
/* we need at least two more parameters */
if (argc < 3)
{
}
bool fTransient = false;
for (int i = 2; i < 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)
}
else
{
/* open a session for the VM */
/* get the mutable session machine */
/* commit and close the session */
}
}
else
{
}
return 0;
}
{
&errMsg);
if (VBOX_SUCCESS (vrc))
{
/// @todo (dmik) use cfgLdrEntityResolver later
if (VBOX_SUCCESS (vrc))
{
if (mode != HUSPD_DryRun)
{
if (mode != HUSPD_ApplyNoBackup)
{
if (VBOX_FAILURE (vrc))
{
RTPrintf ("Error copying '%s' to '%s' (%Vrc)\n",
}
}
if (VBOX_SUCCESS (vrc))
{
if (VBOX_FAILURE (vrc))
{
RTPrintf ("Error saving the settings file '%s' (%Vrc)%s%s\n",
}
}
}
}
else
{
RTPrintf ("Could not convert the settings file '%s' (%Vrc)%s%s\n",
}
CFGLDRFree (config);
}
else
{
RTPrintf ("Error loading the settings file '%s' (%Vrc)%s%s\n",
}
if (errMsg)
return vrc;
}
bool skipInvalid)
{
if (VBOX_FAILURE (vrc))
{
return vrc;
}
while (VBOX_SUCCESS (vrc))
{
if (VBOX_FAILURE (vrc))
{
if (vrc == VERR_NO_MORE_FILES)
vrc = VINF_SUCCESS;
else
break;
}
{
continue;
mode, skipInvalid);
if (VBOX_FAILURE (vrc))
break;
continue;
}
{
continue;
}
else
continue;
if (skipInvalid)
vrc = VINF_SUCCESS;
}
RTDirClose (dir);
return vrc;
}
{
const char *dirOrFilePath = NULL;
bool apply = false;
bool nobackup = false;
bool skipinvalid = false;
for (int i = 0; i < argc; i++)
{
if (i == 0 && argv[i][0] != '-')
{
dirOrFilePath = argv[i];
}
else if (argv[i][0] == '-')
{
apply = true;
nobackup = true;
skipinvalid = true;
else
{
}
}
else
{
}
}
if (apply)
int vrc = CFGLDRInitialize();
if (VBOX_FAILURE (vrc))
{
return 1;
}
if (dirOrFilePath)
{
if (RTDirExists (dirOrFilePath))
{
char fullPath [RTPATH_MAX];
if (VBOX_FAILURE (vrc))
{
return 1;
}
RTPrintf ("Updating settings files in the following directory:\n"
"\n %s\n\n", fullPath);
}
else
{
}
}
else
{
RTPrintf ("Updating settings files in the following VirtualBox Home Directory:\n"
}
if (mode == HUSPD_DryRun)
{
RTPrintf ("NOTE: No actual changes to the setting files were made.\n"
" Repeat the command with the -apply option supplied.\n");
}
}
// main
///////////////////////////////////////////////////////////////////////////////
{
/*
* Before we do anything, init the runtime without loading
* the support driver.
*/
RTR3Init(false);
RTPrintf("VirtualBox Command Line Management Interface Version %s\n"
"(C) 2005-2007 innotek GmbH\n"
"All rights reserved.\n"
"\n",
/* shortcut for no parameters or help */
if ( (argc < 2)
{
return 0;
}
/* Special option to dump really all commands, even the ones not
* understood on this platform. */
{
return 0;
}
/*
* The input is in the host OS'es codepage (NT guarantees ACP).
* For VBox we use UTF-8 and convert to UCS-2 when calling (XP)COM APIs.
* For simplicity, just convert the argv[] array here.
*/
for (int i = 2; i < argc; i++)
{
char *converted;
}
do
{
// scopes all the stuff till shutdown
////////////////////////////////////////////////////////////////////////////
/* update settings command (no VirtualBox instantiation!) */
{
break;
}
/* convertdd: does not need a VirtualBox instantiation) */
{
break;
}
{
RTPrintf ("[!] Failed to create the VirtualBox object!\n");
RTPrintf ("[!] Most likely, the VirtualBox COM server is not running "
"or failed to start.\n");
else
break;
}
/* create the event queue
* after the session is closed) */
/*
* All registered command handlers
*/
struct
{
const char *command;
} commandHandlers[] =
{
{ "internalcommands", handleInternalCommands },
{ "list", handleList },
{ "showvminfo", handleShowVMInfo },
{ "registervm", handleRegisterVM },
{ "unregistervm", handleUnregisterVM },
{ "createvdi", handleCreateVDI },
{ "modifyvdi", handleModifyVDI },
{ "addiscsidisk", handleAddiSCSIDisk },
{ "createvm", handleCreateVM },
{ "modifyvm", handleModifyVM },
{ "clonevdi", handleCloneVDI },
{ "startvm", handleStartVM },
{ "controlvm", handleControlVM },
{ "discardstate", handleDiscardState },
{ "snapshot", handleSnapshot },
{ "registerimage", handleRegisterImage },
{ "unregisterimage", handleUnregisterImage },
{ "showvdiinfo", handleShowVDIInfo },
#ifdef __WIN__
{ "createhostif", handleCreateHostIF },
{ "removehostif", handleRemoveHostIF },
#endif
{ "getextradata", handleGetExtraData },
{ "setextradata", handleSetExtraData },
{ "setproperty", handleSetProperty },
{ "usbfilter", handleUSBFilter },
{ "sharedfolder", handleSharedFolder },
};
int commandIndex;
{
{
break;
}
}
{
}
// end "all-stuff" scope
////////////////////////////////////////////////////////////////////////////
}
while (0);
/*
* Free converted argument vector
*/
for (int i = 2; i < argc; i++)
{
}
return rc;
}