VBoxManageModifyVM.cpp revision dfd1cc060e48ca92057e20f7966ef0a65ab27bb9
/* $Id$ */
/** @file
* VBoxManage - Implementation of modifyvm command.
*/
/*
* Copyright (C) 2006-2014 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_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
#ifdef VBOX_WITH_VPX
#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_VPX
#endif
#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;
}
}
}
{
while (pcszScreens && *pcszScreens)
{
char *pszNext;
if (RT_FAILURE(rc))
return 1;
return 1;
{
if (*pszNext != ',')
return 1;
pszNext++;
}
}
return 0;
}
{
if ( uIndex >= 1
return uIndex;
return 0;
}
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 sessionMachine */
/* Get the number of network adapters */
/* open a session for the VM */
/* get the mutable session sessionMachine */
{
switch (c)
{
case MODIFYVM_NAME:
{
break;
}
case MODIFYVM_GROUPS:
{
break;
}
case MODIFYVM_DESCRIPTION:
{
break;
}
case MODIFYVM_OSTYPE:
{
guestOSType.asOutParam()));
{
}
else
{
}
break;
}
case MODIFYVM_ICONFILE:
{
int vrc = RTFileOpen(&iconFile, ValueUnion.psz, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
if (RT_FAILURE(vrc))
{
break;
}
if (RT_FAILURE(vrc))
{
break;
}
{
break;
}
if (RT_FAILURE(vrc))
{
break;
}
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_LONGMODE:
{
break;
}
case MODIFYVM_SYNTHCPU:
{
break;
}
case MODIFYVM_TFRESET:
{
break;
}
{
else
{
}
break;
}
case MODIFYVM_HWVIRTEX:
{
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_VTXUX:
{
CHECK_ERROR(sessionMachine, SetHWVirtExProperty(HWVirtExPropertyType_UnrestrictedExecution, ValueUnion.f));
break;
}
case MODIFYVM_CPUS:
{
break;
}
case MODIFYVM_RTCUSEUTC:
{
break;
}
case MODIFYVM_CPUHOTPLUG:
{
break;
}
case MODIFYVM_PLUGCPU:
{
break;
}
case MODIFYVM_UNPLUGCPU:
{
break;
}
{
break;
}
{
#ifdef VBOX_WITH_VMSVGA
#endif
else
{
}
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 */,
false /* fSilent */);
break;
if (hardDisk)
{
hardDisk));
}
else
}
break;
}
case MODIFYVM_IDECONTROLLER: // deprecated
{
{
}
{
}
{
}
else
{
}
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 */,
false /* fSilent */);
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 */,
false /* fSilent */);
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 */,
false /* fSilent */);
break;
if (!floppyMedium)
{
break;
}
}
0, 0,
FALSE /* aForce */));
}
break;
}
case MODIFYVM_NICTRACEFILE:
{
break;
break;
}
case MODIFYVM_NICTRACE:
{
break;
break;
}
case MODIFYVM_NICPROPERTY:
{
break;
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:
{
break;
{
}
{
}
#ifdef VBOX_WITH_E1000
{
}
{
}
{
}
#endif
#ifdef VBOX_WITH_VIRTIO
{
}
#endif /* VBOX_WITH_VIRTIO */
else
{
}
break;
}
case MODIFYVM_NICSPEED:
{
break;
break;
}
case MODIFYVM_NICBOOTPRIO:
{
break;
/* 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;
break;
}
case MODIFYVM_NICBWGROUP:
{
break;
{
/* Just remove the bandwidth group. */
}
else
{
{
{
}
}
}
break;
}
case MODIFYVM_NIC:
{
break;
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
else
{
}
break;
}
case MODIFYVM_CABLECONNECTED:
{
break;
break;
}
case MODIFYVM_BRIDGEADAPTER:
{
break;
/* remove it? */
{
}
else
{
}
break;
}
case MODIFYVM_HOSTONLYADAPTER:
{
break;
/* remove it? */
{
}
else
{
}
break;
}
case MODIFYVM_INTNET:
{
break;
/* remove it? */
{
}
else
{
}
break;
}
case MODIFYVM_GENERICDRV:
{
break;
break;
}
case MODIFYVM_NATNETWORKNAME:
{
break;
break;
}
case MODIFYVM_NATNET:
{
break;
psz = "";
break;
}
case MODIFYVM_NATBINDIP:
{
break;
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;
break;
CHECK_ERROR(engine, SetNetworkSettings(RTStrToUInt32(strMtu), RTStrToUInt32(strSockSnd), RTStrToUInt32(strSockRcv),
break;
}
case MODIFYVM_NATPF:
{
break;
/* 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)
{
break;
token++;
}
}
break;
}
case MODIFYVM_NATTFTPPREFIX:
{
break;
break;
}
case MODIFYVM_NATTFTPFILE:
{
break;
break;
}
case MODIFYVM_NATTFTPSERVER:
{
break;
break;
}
{
break;
break;
}
case MODIFYVM_NATDNSPROXY:
{
break;
break;
}
{
break;
break;
}
case MODIFYVM_MACADDRESS:
{
break;
/* generate one? */
{
}
else
{
}
break;
}
case MODIFYVM_HIDPTR:
{
bool fEnableUsb = false;
{
}
{
fEnableUsb = true;
}
{
fEnableUsb = true;
}
{
fEnableUsb = true;
}
else
{
}
if (fEnableUsb)
{
/* Make sure the OHCI controller is enabled. */
ULONG cOhciCtrls = 0;
&& !cOhciCtrls)
{
UsbCtl.asOutParam()));
}
}
break;
}
case MODIFYVM_HIDKBD:
{
bool fEnableUsb = false;
{
}
{
fEnableUsb = true;
}
else
{
}
if (fEnableUsb)
{
/* Make sure the OHCI controller is enabled. */
ULONG cOhciCtrls = 0;
&& !cOhciCtrls)
{
UsbCtl.asOutParam()));
}
}
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_DRAGANDDROP:
{
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_USBXHCI:
{
ULONG cXhciCtrls = 0;
{
if (!cXhciCtrls && ValueUnion.f)
{
UsbCtl.asOutParam()));
}
else if (cXhciCtrls && !ValueUnion.f)
}
break;
}
case MODIFYVM_USBEHCI:
{
ULONG cEhciCtrls = 0;
{
if (!cEhciCtrls && ValueUnion.f)
{
UsbCtl.asOutParam()));
}
else if (cEhciCtrls && !ValueUnion.f)
}
break;
}
case MODIFYVM_USB:
{
ULONG cOhciCtrls = 0;
{
if (!cOhciCtrls && ValueUnion.f)
{
UsbCtl.asOutParam()));
}
else if (cOhciCtrls && !ValueUnion.f)
}
break;
}
case MODIFYVM_SNAPSHOTFOLDER:
{
else
break;
}
{
break;
}
case MODIFYVM_TELEPORTER_PORT:
{
break;
}
{
break;
}
{
break;
}
{
if (rcExit != RTEXITCODE_SUCCESS)
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;
}
#ifdef VBOX_WITH_VPX
case MODIFYVM_VCP:
{
break;
}
case MODIFYVM_VCP_SCREENS:
{
{
errorArgument("Invalid list of screens specified\n");
break;
}
break;
}
case MODIFYVM_VCP_FILENAME:
{
/* empty string will fall through, leaving bstr empty */
if (*ValueUnion.psz)
{
if (RT_FAILURE(vrc))
{
break;
}
bstr = szVCFileAbs;
}
break;
}
case MODIFYVM_VCP_WIDTH:
{
break;
}
case MODIFYVM_VCP_HEIGHT:
{
break;
}
case MODIFYVM_VCP_RATE:
{
break;
}
case MODIFYVM_VCP_FPS:
{
break;
}
case MODIFYVM_VCP_MAXTIME:
{
break;
}
case MODIFYVM_VCP_MAXSIZE:
{
break;
}
case MODIFYVM_VCP_OPTIONS:
{
break;
}
#endif
{
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 */
case MODIFYVM_DEFAULTFRONTEND:
{
if (bstr == "default")
break;
}
default:
{
break;
}
}
}
/* commit changes */
/* it's important to always close sessions */
a->session->UnlockMachine();
}
#endif /* !VBOX_ONLY_DOCS */