VBoxManageModifyVM.cpp revision 1147e980f6ab0b7ff1d08c13ad1c03eea30d102d
/* $Id$ */
/** @file
* VBoxManage - Implementation of modifyvm command.
*/
/*
* Copyright (C) 2006-2012 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
#endif /* !VBOX_ONLY_DOCS */
#include "VBoxManage.h"
#ifndef VBOX_ONLY_DOCS
using namespace com;
/** @todo refine this after HDD changes; MSC 8.0/64 has trouble with handleModifyVM. */
#if defined(_MSC_VER)
#endif
enum
{
MODIFYVM_NAME = 1000,
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
MODIFYVM_HDA, // deprecated
MODIFYVM_HDB, // deprecated
MODIFYVM_HDD, // deprecated
MODIFYVM_IDECONTROLLER, // deprecated
MODIFYVM_SATAIDEEMULATION, // deprecated
MODIFYVM_SATAPORTCOUNT, // deprecated
MODIFYVM_SATAPORT, // deprecated
MODIFYVM_SATA, // deprecated
MODIFYVM_SCSIPORT, // deprecated
MODIFYVM_SCSITYPE, // deprecated
MODIFYVM_SCSI, // deprecated
MODIFYVM_DVDPASSTHROUGH, // deprecated
MODIFYVM_DVD, // deprecated
MODIFYVM_FLOPPY, // deprecated
#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
#endif
MODIFYVM_VRDPPORT, /* VRDE: deprecated */
MODIFYVM_VRDPADDRESS, /* VRDE: deprecated */
MODIFYVM_VRDPAUTHTYPE, /* VRDE: deprecated */
MODIFYVM_VRDPMULTICON, /* VRDE: deprecated */
MODIFYVM_VRDPREUSECON, /* VRDE: deprecated */
MODIFYVM_VRDPVIDEOCHANNEL, /* VRDE: deprecated */
MODIFYVM_VRDPVIDEOCHANNELQUALITY, /* VRDE: deprecated */
MODIFYVM_VRDP, /* VRDE: deprecated */
#ifdef VBOX_WITH_PCI_PASSTHROUGH
#endif
#ifdef VBOX_WITH_USB_CARDREADER
#endif
};
static const RTGETOPTDEF g_aModifyVMOptions[] =
{
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
{ "--natdnshostresolver", MODIFYVM_NATDNSHOSTRESOLVER, RTGETOPT_REQ_BOOL_ONOFF | RTGETOPT_FLAG_INDEX },
#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
#endif
{ "--vrdpvideochannelquality", MODIFYVM_VRDPVIDEOCHANNELQUALITY, RTGETOPT_REQ_STRING }, /* deprecated */
#ifdef VBOX_WITH_PCI_PASSTHROUGH
#endif
#ifdef VBOX_WITH_USB_CARDREADER
#endif
};
static void vrdeWarningDeprecatedOption(const char *pszOption)
{
RTStrmPrintf(g_pStdErr, "Warning: '--vrdp%s' is deprecated. Use '--vrde%s'.\n", pszOption, pszOption);
}
/** Parse PCI address in format 01:02.03 and convert it to the numeric representation. */
{
int rc;
return -1;
return -1;
return -1;
}
{
while (pcszGroups)
{
if (pComma)
{
}
else
{
pcszGroups = NULL;
}
}
}
int handleModifyVM(HandlerArg *a)
{
int c;
/* VM ID + at least one parameter. Parameter arguments are checked
* individually. */
if (a->argc < 2)
/* try to find the given machine */
/* Get the number of network adapters */
/* open a session for the VM */
/* get the mutable session machine */
{
switch (c)
{
case MODIFYVM_NAME:
{
break;
}
case MODIFYVM_GROUPS:
{
break;
}
case MODIFYVM_OSTYPE:
{
guestOSType.asOutParam()));
{
}
else
{
}
break;
}
case MODIFYVM_MEMORY:
{
break;
}
case MODIFYVM_PAGEFUSION:
{
break;
}
case MODIFYVM_VRAM:
{
break;
}
case MODIFYVM_FIRMWARE:
{
{
}
{
}
{
}
{
}
{
}
else
{
}
break;
}
case MODIFYVM_ACPI:
{
break;
}
case MODIFYVM_IOAPIC:
{
break;
}
case MODIFYVM_PAE:
{
break;
}
case MODIFYVM_SYNTHCPU:
{
break;
}
case MODIFYVM_HWVIRTEX:
{
break;
}
{
break;
}
case MODIFYVM_SETCPUID:
{
for (unsigned i = 0 ; i < 4 ; i++)
{
if (RT_FAILURE(vrc))
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid argument to '%s'",
}
break;
}
case MODIFYVM_DELCPUID:
{
break;
}
case MODIFYVM_DELALLCPUID:
{
break;
}
case MODIFYVM_NESTEDPAGING:
{
break;
}
case MODIFYVM_LARGEPAGES:
{
break;
}
case MODIFYVM_VTXVPID:
{
break;
}
case MODIFYVM_CPUS:
{
break;
}
case MODIFYVM_RTCUSEUTC:
{
break;
}
case MODIFYVM_CPUHOTPLUG:
{
break;
}
case MODIFYVM_PLUGCPU:
{
break;
}
case MODIFYVM_UNPLUGCPU:
{
break;
}
{
break;
}
case MODIFYVM_MONITORCOUNT:
{
break;
}
case MODIFYVM_ACCELERATE3D:
{
break;
}
#ifdef VBOX_WITH_VIDEOHWACCEL
{
break;
}
#endif
case MODIFYVM_BIOSLOGOFADEIN:
{
break;
}
case MODIFYVM_BIOSLOGOFADEOUT:
{
break;
}
{
break;
}
{
break;
}
case MODIFYVM_BIOSBOOTMENU:
{
{
}
{
}
{
}
else
{
}
break;
}
{
break;
}
case MODIFYVM_BIOSPXEDEBUG:
{
break;
}
case MODIFYVM_BOOT:
{
{
}
{
}
{
}
{
}
{
}
else
break;
}
case MODIFYVM_HDA: // deprecated
case MODIFYVM_HDB: // deprecated
case MODIFYVM_HDD: // deprecated
case MODIFYVM_SATAPORT: // deprecated
{
switch (c)
{
case MODIFYVM_HDA: // deprecated
u1 = 0;
break;
case MODIFYVM_HDB: // deprecated
u1 = 0;
u2 = 1;
break;
case MODIFYVM_HDD: // deprecated
u1 = 1;
u2 = 1;
break;
case MODIFYVM_SATAPORT: // deprecated
bstrController = L"SATA";
break;
}
{
}
else
{
false /* fForceNewUuidOnOpen */, NULL);
break;
if (hardDisk)
{
hardDisk));
}
else
}
break;
}
case MODIFYVM_IDECONTROLLER: // deprecated
{
{
}
{
}
{
}
else
{
}
break;
}
case MODIFYVM_SATAIDEEMULATION: // deprecated
{
SataCtl.asOutParam()));
break;
}
case MODIFYVM_SATAPORTCOUNT: // deprecated
{
SataCtl.asOutParam()));
break;
}
case MODIFYVM_SATA: // deprecated
{
{
ctl.asOutParam()));
}
else
break;
}
case MODIFYVM_SCSIPORT: // deprecated
{
{
GetOptState.uIndex, 0);
GetOptState.uIndex, 0));
}
else
{
false /* fForceNewUuidOnOpen */, NULL);
break;
if (hardDisk)
{
GetOptState.uIndex, 0,
hardDisk);
GetOptState.uIndex, 0,
hardDisk));
}
else
}
break;
}
case MODIFYVM_SCSITYPE: // deprecated
{
{
ctl.asOutParam()));
}
{
ctl.asOutParam()));
}
else
break;
}
case MODIFYVM_SCSI: // deprecated
{
{
ctl.asOutParam()));
}
{
}
break;
}
case MODIFYVM_DVDPASSTHROUGH: // deprecated
{
1, 0,
break;
}
case MODIFYVM_DVD: // deprecated
{
/* unmount? */
{
/* nothing to do, NULL object will cause unmount */
}
/* host drive? */
{
dvdMedium.asOutParam());
if (!dvdMedium)
{
/* 2nd try: try with the real name, important on Linux+libhal */
char szPathReal[RTPATH_MAX];
{
break;
}
dvdMedium.asOutParam());
if (!dvdMedium)
{
break;
}
}
}
else
{
false /* fForceNewUuidOnOpen */, NULL);
break;
if (!dvdMedium)
{
break;
}
}
1, 0,
FALSE /* aForce */));
break;
}
case MODIFYVM_FLOPPY: // deprecated
{
0, 0, floppyAttachment.asOutParam());
/* disable? */
{
/* disable the controller */
if (floppyAttachment)
0, 0));
}
else
{
/* enable the controller */
if (!floppyAttachment)
0, 0,
/* unmount? */
{
/* nothing to do, NULL object will cause unmount */
}
/* host drive? */
{
if (!floppyMedium)
{
break;
}
}
else
{
false /* fForceNewUuidOnOpen */, NULL);
break;
if (!floppyMedium)
{
break;
}
}
0, 0,
FALSE /* aForce */));
}
break;
}
case MODIFYVM_NICTRACEFILE:
{
break;
}
case MODIFYVM_NICTRACE:
{
break;
}
case MODIFYVM_NICPROPERTY:
{
if (nic)
{
/* Parse 'name=value' */
if (pszProperty)
{
if (pDelimiter)
{
*pDelimiter = '\0';
}
else
{
}
}
else
{
RTStrmPrintf(g_pStdErr, "Error: Failed to allocate memory for --nicproperty%d '%s'\n", GetOptState.uIndex, ValueUnion.psz);
}
}
break;
}
case MODIFYVM_NICTYPE:
{
{
}
{
}
#ifdef VBOX_WITH_E1000
{
}
{
}
{
}
#endif
#ifdef VBOX_WITH_VIRTIO
{
}
#endif /* VBOX_WITH_VIRTIO */
else
{
}
break;
}
case MODIFYVM_NICSPEED:
{
break;
}
case MODIFYVM_NICBOOTPRIO:
{
/* Somewhat arbitrary limitation - we can pass a list of up to 4 PCI devices
* to the PXE ROM, hence only boot priorities 1-4 are allowed (in addition to
* 0 for the default lowest priority).
*/
{
errorArgument("Invalid boot priority '%u' specfied for NIC %u", ValueUnion.u32, GetOptState.uIndex);
}
else
{
}
break;
}
case MODIFYVM_NICPROMISC:
{
else
{
rc = E_INVALIDARG;
break;
}
break;
}
case MODIFYVM_NICBWGROUP:
{
{
/* Just remove the bandwidth group. */
}
else
{
{
{
}
}
}
break;
}
case MODIFYVM_NIC:
{
{
}
{
}
{
}
{
}
{
}
{
}
{
}
else
{
}
break;
}
case MODIFYVM_CABLECONNECTED:
{
break;
}
case MODIFYVM_BRIDGEADAPTER:
{
/* remove it? */
{
}
else
{
}
break;
}
case MODIFYVM_HOSTONLYADAPTER:
{
/* remove it? */
{
}
else
{
}
break;
}
case MODIFYVM_INTNET:
{
/* remove it? */
{
}
else
{
}
break;
}
case MODIFYVM_GENERICDRV:
{
break;
}
case MODIFYVM_NATNET:
{
psz = "";
break;
}
case MODIFYVM_NATBINDIP:
{
break;
}
#define ITERATE_TO_NEXT_TERM(ch) \
do { \
while (*ch != ',') \
{ \
if (*ch == 0) \
{ \
return errorSyntax(USAGE_MODIFYVM, \
"Missing or Invalid argument to '%s'", \
} \
ch++; \
} \
*ch = '\0'; \
ch++; \
} while(0)
case MODIFYVM_NATSETTINGS:
{
char *strMtu;
char *strSockSnd;
char *strSockRcv;
char *strTcpSnd;
char *strTcpRcv;
CHECK_ERROR(driver, SetNetworkSettings(RTStrToUInt32(strMtu), RTStrToUInt32(strSockSnd), RTStrToUInt32(strSockRcv),
break;
}
case MODIFYVM_NATPF:
{
/* format name:proto:hostip:hostport:guestip:guestport*/
{
char *strName;
char *strProto;
char *strHostIp;
char *strHostPort;
char *strGuestIp;
char *strGuestPort;
else
{
break;
}
}
else
{
/* delete NAT Rule operation */
int vrc;
if (RT_FAILURE(vrc))
}
break;
}
case MODIFYVM_NATALIASMODE:
{
{
aliasMode = 0;
}
else
{
while(token)
{
aliasMode |= 0x1;
aliasMode |= 0x2;
aliasMode |= 0x4;
break;
token++;
}
}
break;
}
case MODIFYVM_NATTFTPPREFIX:
{
break;
}
case MODIFYVM_NATTFTPFILE:
{
break;
}
case MODIFYVM_NATTFTPSERVER:
{
break;
}
{
break;
}
case MODIFYVM_NATDNSPROXY:
{
break;
}
{
break;
}
case MODIFYVM_MACADDRESS:
{
/* generate one? */
{
}
else
{
}
break;
}
case MODIFYVM_HIDPTR:
{
bool fEnableUsb = false;
{
}
{
fEnableUsb = true;
}
{
fEnableUsb = true;
}
else
{
}
if (fEnableUsb)
{
/* Make sure the OHCI controller is enabled. */
{
fEnabled = false;
if (!fEnabled)
}
}
break;
}
case MODIFYVM_HIDKBD:
{
bool fEnableUsb = false;
{
}
{
fEnableUsb = true;
}
else
{
}
if (fEnableUsb)
{
/* Make sure the OHCI controller is enabled. */
{
fEnabled = false;
if (!fEnabled)
}
}
break;
}
case MODIFYVM_UARTMODE:
{
{
}
{
if (RT_FAILURE(vrc))
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid argument to '%s'",
{
}
{
}
{
}
}
else
{
}
break;
}
case MODIFYVM_UART:
{
else
{
if (RT_FAILURE(vrc))
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid argument to '%s'",
}
break;
}
#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS)
case MODIFYVM_LPTMODE:
{
break;
}
case MODIFYVM_LPT:
{
else
{
if (RT_FAILURE(vrc))
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid argument to '%s'",
}
break;
}
#endif
{
break;
}
case MODIFYVM_AUDIOCONTROLLER:
{
else
{
}
break;
}
case MODIFYVM_AUDIO:
{
/* disable? */
{
}
{
}
#ifdef RT_OS_WINDOWS
#ifdef VBOX_WITH_WINMM
{
}
#endif
{
}
#endif /* RT_OS_WINDOWS */
#ifdef RT_OS_LINUX
# ifdef VBOX_WITH_ALSA
{
}
# endif
# ifdef VBOX_WITH_PULSE
{
}
# endif
#endif /* !RT_OS_LINUX */
#ifdef RT_OS_SOLARIS
{
}
#endif /* !RT_OS_SOLARIS */
#ifdef RT_OS_FREEBSD
{
}
# ifdef VBOX_WITH_PULSE
{
}
# endif
#endif /* !RT_OS_FREEBSD */
#ifdef RT_OS_DARWIN
{
}
#endif /* !RT_OS_DARWIN */
{
}
# endif
else
{
}
break;
}
case MODIFYVM_CLIPBOARD:
{
else
{
}
{
}
break;
}
case MODIFYVM_VRDE_EXTPACK:
{
if (vrdeServer)
{
{
}
else
}
break;
}
case MODIFYVM_VRDEPROPERTY:
{
if (vrdeServer)
{
/* Parse 'name=value' */
if (pszProperty)
{
if (pDelimiter)
{
*pDelimiter = '\0';
}
else
{
break;
}
}
else
{
RTStrmPrintf(g_pStdErr, "Error: Failed to allocate memory for VRDE property '%s'\n", ValueUnion.psz);
}
}
break;
}
case MODIFYVM_VRDPPORT:
vrdeWarningDeprecatedOption("port");
case MODIFYVM_VRDEPORT:
{
else
break;
}
case MODIFYVM_VRDPADDRESS:
vrdeWarningDeprecatedOption("address");
case MODIFYVM_VRDEADDRESS:
{
break;
}
case MODIFYVM_VRDPAUTHTYPE:
vrdeWarningDeprecatedOption("authtype");
case MODIFYVM_VRDEAUTHTYPE:
{
{
}
{
}
{
}
else
{
}
break;
}
case MODIFYVM_VRDEAUTHLIBRARY:
{
if (vrdeServer)
{
{
}
else
}
break;
}
case MODIFYVM_VRDPMULTICON:
vrdeWarningDeprecatedOption("multicon");
case MODIFYVM_VRDEMULTICON:
{
break;
}
case MODIFYVM_VRDPREUSECON:
vrdeWarningDeprecatedOption("reusecon");
case MODIFYVM_VRDEREUSECON:
{
break;
}
vrdeWarningDeprecatedOption("videochannel");
{
break;
}
vrdeWarningDeprecatedOption("videochannelquality");
{
break;
}
case MODIFYVM_VRDP:
case MODIFYVM_VRDE:
{
break;
}
case MODIFYVM_USBEHCI:
{
break;
}
case MODIFYVM_USB:
{
break;
}
case MODIFYVM_SNAPSHOTFOLDER:
{
else
break;
}
{
break;
}
case MODIFYVM_TELEPORTER_PORT:
{
break;
}
{
break;
}
{
break;
}
{
char szPasswd[512];
int vrc = VINF_SUCCESS;
if (!fStdIn)
else
if (RT_SUCCESS(vrc))
{
if (RT_SUCCESS(vrc))
{
errorArgument("Provided password too long");
else
{
unsigned i;
;
szPasswd[i] = '\0';
}
}
if (!fStdIn)
}
else
break;
}
case MODIFYVM_TRACING_ENABLED:
{
break;
}
case MODIFYVM_TRACING_CONFIG:
{
break;
}
{
break;
}
case MODIFYVM_FAULT_TOLERANCE:
{
{
}
else
{
}
else
{
}
break;
}
{
break;
}
{
break;
}
{
break;
}
{
break;
}
case MODIFYVM_HARDWARE_UUID:
{
break;
}
case MODIFYVM_HPET:
{
break;
}
case MODIFYVM_IOCACHE:
{
break;
}
case MODIFYVM_IOCACHESIZE:
{
break;
}
case MODIFYVM_CHIPSET:
{
{
}
{
if (!fIoApic)
{
}
}
else
{
}
break;
}
{
break;
}
case MODIFYVM_AUTOSTART_DELAY:
{
break;
}
case MODIFYVM_AUTOSTOP_TYPE:
{
else
{
errorArgument("Invalid --autostop-type argument '%s' (valid: disabled, savestate, poweroff, acpishutdown)", ValueUnion.psz);
}
break;
}
#ifdef VBOX_WITH_PCI_PASSTHROUGH
case MODIFYVM_ATTACH_PCI:
{
{
errorArgument("Invalid --pciattach argument '%s' (valid: 'HB:HD.HF@GB:GD.GF' or just 'HB:HD.HF')", ValueUnion.psz);
}
else
{
}
break;
}
case MODIFYVM_DETACH_PCI:
{
if (iHostAddr == -1)
{
}
else
{
}
break;
}
#endif
#ifdef VBOX_WITH_USB_CARDREADER
case MODIFYVM_USBCARDREADER:
{
break;
}
#endif /* VBOX_WITH_USB_CARDREADER */
default:
{
break;
}
}
}
/* commit changes */
/* it's important to always close sessions */
a->session->UnlockMachine();
}
#endif /* !VBOX_ONLY_DOCS */