VBoxManageModifyVM.cpp revision a837292ce5d8a9aef8dca14539c5eba8597ad58b
/* $Id$ */
/** @file
* VBoxManage - Implementation of modifyvm command.
*/
/*
* Copyright (C) 2006-2009 Sun Microsystems, Inc.
*
* 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.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#ifndef VBOX_ONLY_DOCS
#include <vector>
#include <list>
#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
int handleModifyVM(HandlerArg *a)
{
uint32_t memorySize = 0;
char *nestedpaging = NULL;
uint32_t monitorcount = ~0;
char *accelerate3d = NULL;
char *bioslogofadein = NULL;
char *bioslogofadeout = NULL;
uint32_t bioslogodisplaytime = ~0;
char *bioslogoimagepath = NULL;
char *biosbootmenumode = NULL;
char *biossystemtimeoffset = NULL;
char *biospxedebug = NULL;
int bootDeviceChanged[4] = { false };
char *hdds[50] = {0};
char *dvdpassthrough = NULL;
char *idecontroller = NULL;
char *audiocontroller = NULL;
#ifdef VBOX_WITH_VRDP
char *vrdpaddress = NULL;
char *vrdpauthtype = NULL;
char *vrdpmulticon = NULL;
char *vrdpreusecon = NULL;
#endif
int fUsbEnabled = -1;
int fUsbEhciEnabled = -1;
char *snapshotFolder = NULL;
int fSataEnabled = -1;
int fScsiEnabled = -1;
int fScsiLsiLogic = -1;
int sataPortCount = -1;
/* VM ID + at least one parameter. Parameter arguments are checked
* individually. */
if (a->argc < 2)
/* Get the number of network adapters */
ULONG NetworkAdapterCount = 0;
{
}
ULONG SerialPortCount = 0;
{
}
for (int i = 1; i < a->argc; i++)
{
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
nestedpaging = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
if (numCpus == UINT32_MAX)
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
accelerate3d = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
bioslogofadein = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
bioslogofadeout = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
bioslogoimagepath = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
biosbootmenumode = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
biossystemtimeoffset = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
biospxedebug = a->argv[i];
}
{
uint32_t n = 0;
if (a->argc <= i + 1)
i++;
{
}
{
}
{
}
{
}
{
}
else
bootDeviceChanged[n - 1] = true;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
dvdpassthrough = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
idecontroller = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
audiocontroller = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
/* watch for the right order of these --nic* comparisons! */
{
if (!n)
return 1;
if (a->argc <= i + 1)
{
}
i++;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
#if defined(VBOX_WITH_NETFLT)
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
#endif
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
else
{
if (RT_FAILURE(rc))
return errorArgument("Invalid IPv4 network '%s' specified -- CIDR notation expected.\n", a->argv[i + 1]);
if (Netmask & 0x1f)
return errorArgument("Prefix length of the NAT network must be less than 28.\n");
}
i++;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
#ifdef VBOX_WITH_VRDP
{
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
vrdpport = 0;
else
}
{
if (a->argc <= i + 1)
i++;
vrdpaddress = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
vrdpauthtype = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
vrdpmulticon = a->argv[i];
}
{
if (a->argc <= i + 1)
i++;
vrdpreusecon = a->argv[i];
}
#endif /* VBOX_WITH_VRDP */
{
if (a->argc <= i + 1)
i++;
fUsbEnabled = 1;
fUsbEnabled = 0;
else
}
{
if (a->argc <= i + 1)
i++;
fUsbEhciEnabled = 1;
fUsbEhciEnabled = 0;
else
}
{
if (a->argc <= i + 1)
i++;
snapshotFolder = a->argv[i];
}
{
if (!n)
return 1;
i++;
{
}
else
{
{
i++;
#ifdef RT_OS_WINDOWS
return errorArgument("Uart pipe must start with \\\\.\\pipe\\");
#endif
}
{
i++;
}
else
{
}
if (a->argc <= i)
return errorArgument("Missing argument to --uartmode");
}
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
{
}
else
{
if (a->argc <= i + 1)
int vrc;
i++;
if (vrc != VINF_SUCCESS)
}
}
#ifdef VBOX_WITH_MEM_BALLOONING
{
if (a->argc <= i + 1)
i++;
int vrc;
if (vrc != VINF_SUCCESS)
}
#endif
{
if (a->argc <= i + 1)
i++;
int vrc;
if (vrc != VINF_SUCCESS)
}
{
if (a->argc <= i + 1)
i++;
fSataEnabled = 1;
fSataEnabled = 0;
else
}
{
unsigned n;
if (a->argc <= i + 1)
i++;
if (!n)
return 1;
sataPortCount = n;
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
{
unsigned bootDevicePos = 0;
unsigned n;
if (!bootDevicePos)
return 1;
if (a->argc <= i + 1)
i++;
if (!n)
return 1;
}
{
if (a->argc <= i + 1)
i++;
fScsiEnabled = 1;
fScsiEnabled = 0;
else
}
{
if (!n)
return 1;
if (a->argc <= i + 1)
i++;
}
{
if (a->argc <= i + 1)
i++;
fScsiLsiLogic = 1;
fScsiLsiLogic = 0;
else
}
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 (nestedpaging)
{
{
}
{
}
else
{
break;
}
}
if (vtxvpid)
{
{
}
{
}
else
{
break;
}
}
if (pae)
{
{
}
{
}
else
{
break;
}
}
if (numCpus != UINT32_MAX)
{
}
if (monitorcount != ~0U)
{
}
if (accelerate3d)
{
{
}
{
}
else
{
break;
}
}
if (bioslogofadein)
{
{
}
{
}
else
{
break;
}
}
if (bioslogofadeout)
{
{
}
{
}
else
{
break;
}
}
if (bioslogodisplaytime != ~0U)
{
}
if (bioslogoimagepath)
{
}
if (biosbootmenumode)
{
else
{
break;
}
}
if (biossystemtimeoffset)
{
}
if (biospxedebug)
{
{
}
{
}
else
{
break;
}
}
{
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)
{
{
/* open the new hard disk object */
CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[0]), AccessMode_ReadWrite, hardDisk.asOutParam()));
}
}
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)
{
{
/* open the new hard disk object */
CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[1]), AccessMode_ReadWrite, hardDisk.asOutParam()));
}
}
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)
{
{
/* open the new hard disk object */
CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[2]), AccessMode_ReadWrite, hardDisk.asOutParam()));
}
}
if (hardDisk)
{
}
else
break;
}
}
if (dvd)
{
/* unmount? */
{
}
/* host drive? */
{
if (!hostDVDDrive)
{
/* 2nd try: try with the real name, important on Linux+libhal */
char szPathReal[RTPATH_MAX];
{
errorArgument("Invalid host DVD drive name");
break;
}
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)
{
}
}
if (!dvdImage)
{
break;
}
}
}
if (dvdpassthrough)
{
}
if (idecontroller)
{
{
}
{
}
{
}
else
{
break;
}
}
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, check if it's in the collection */
/* not registered, do that on the fly */
if (!floppyImage)
{
}
}
if (!floppyImage)
{
break;
}
}
}
}
if (audio || audiocontroller)
{
if (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_DARWIN
{
}
#endif /* !RT_OS_DARWIN */
else
{
break;
}
}
if (audiocontroller)
{
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])
{
{
}
{
}
{
}
{
}
{
}
#if defined(VBOX_WITH_NETFLT)
{
}
#endif
else
{
break;
}
}
/* something about the NIC type? */
if (nictype[n])
{
{
}
{
}
#ifdef VBOX_WITH_E1000
{
}
{
}
{
}
#endif
else
{
break;
}
}
/* something about the MAC address? */
if (macs[n])
{
/* generate one? */
{
}
else
{
}
}
/* something about the reported link speed? */
if (nicspeed[n])
{
{
break;
}
}
/* 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
{
}
}
/* the network of the NAT */
if (natnet[n])
{
}
}
break;
/* iterate through all possible serial ports */
for (ULONG n = 0; n < SerialPortCount; n ++)
{
if (uarts_base[n])
{
{
}
else
{
}
}
if (uarts_mode[n])
{
{
}
else
{
{
}
{
}
{
}
else
{
}
}
}
}
break;
#ifdef VBOX_WITH_VRDP
if (vrdp || (vrdpport != UINT16_MAX) || vrdpaddress || vrdpauthtype || vrdpmulticon || vrdpreusecon)
{
if (vrdpServer)
{
if (vrdp)
{
{
}
{
}
else
{
break;
}
}
if (vrdpport != UINT16_MAX)
{
}
if (vrdpaddress)
{
}
if (vrdpauthtype)
{
{
}
{
}
{
}
else
{
break;
}
}
if (vrdpmulticon)
{
{
}
{
}
else
{
break;
}
}
if (vrdpreusecon)
{
{
}
{
}
else
{
break;
}
}
}
}
#endif /* VBOX_WITH_VRDP */
/*
*/
if (fUsbEnabled != -1)
{
{
}
}
/*
*/
if (fUsbEhciEnabled != -1)
{
{
}
}
if (snapshotFolder)
{
{
}
else
{
}
}
/*
*/
if (fSataEnabled != -1)
{
if (fSataEnabled)
{
}
else
}
{
if (hdds[i])
{
{
}
else
{
/* first guess is that it's a UUID */
/* not successful? Then it must be a filename */
if (!hardDisk)
{
{
/* open the new hard disk object */
CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, hardDisk.asOutParam()));
}
}
if (hardDisk)
{
}
else
break;
}
}
}
for (uint32_t i = 0; i < 4; i++)
{
if (sataBootDevices[i] != -1)
{
{
}
}
}
if (sataPortCount != -1)
{
{
}
}
/*
*/
if (fScsiEnabled != -1)
{
if (fScsiEnabled)
{
if (!fScsiLsiLogic)
{
}
else /* LsiLogic is default */
{
}
}
else
{
}
}
{
if (hdds[i])
{
{
}
else
{
/* first guess is that it's a UUID */
/* not successful? Then it must be a filename */
if (!hardDisk)
{
{
/* open the new hard disk object */
CHECK_ERROR(a->virtualBox, OpenHardDisk(Bstr(hdds[i]), AccessMode_ReadWrite, hardDisk.asOutParam()));
}
}
if (hardDisk)
{
}
else
break;
}
}
}
/* commit changes */
}
while (0);
/* it's important to always close sessions */
}
#endif /* !VBOX_ONLY_DOCS */