VBoxManageModifyVM.cpp revision 4114dcbc0414579cc42b66f4f7bd464a37672af7
/* $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;
#ifdef VBOX_WITH_VIDEOHWACCEL
char *accelerate2dvideo = NULL;
#endif
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;
int fLiveMigrationTarget = -1;
const char *pszLiveMigrationPassword = NULL;
/* 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];
}
#ifdef VBOX_WITH_VIDEOHWACCEL
{
if (a->argc <= i + 1)
i++;
accelerate2dvideo = a->argv[i];
}
#endif
{
if (a->argc <= i + 1)
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
}
{
if (a->argc <= i + 1)
i++;
fLiveMigrationTarget = 1;
fLiveMigrationTarget = 0;
else
}
{
if (a->argc <= i + 1)
i++;
if (vrc != VINF_SUCCESS)
}
{
if (a->argc <= i + 1)
i++;
pszLiveMigrationPassword = a->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)
/** @todo r=bird: What's the story on not reporting error some places
* (CHECK_ERROR) and immediately returning in other cases
* (CHECK_ERROR_RET)? If there is a logic, a comment why would be
* nice... */
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;
}
}
#ifdef VBOX_WITH_VIDEOHWACCEL
if (accelerate2dvideo)
{
{
}
{
}
else
{
break;
}
}
#endif
if (firmware)
{
{
}
{
}
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, false, Bstr(""), false, Bstr(""), 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, false, Bstr(""), false, Bstr(""), 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, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam()));
}
}
if (hardDisk)
{
}
else
break;
}
}
if (dvd)
{
/* unmount? */
{
/* nothing to do, NULL object will cause unmount */
}
/* host drive? */
{
if (!dvdMedium)
{
/* 2nd try: try with the real name, important on Linux+libhal */
char szPathReal[RTPATH_MAX];
{
break;
}
if (!dvdMedium)
{
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 (!dvdMedium)
{
}
}
if (!dvdMedium)
{
break;
}
}
/** @todo generalize this, allow arbitrary number of DVD drives
* and as a consequence multiple attachments and different
* storage controllers. */
}
if (dvdpassthrough)
{
}
if (idecontroller)
{
CHECK_ERROR(machine, GetStorageControllerByName(Bstr("IDE Controller"), storageController.asOutParam()));
{
}
{
}
{
}
else
{
break;
}
}
if (floppy)
{
/* disable? */
{
/* disable the controller */
if (floppyAttachment)
}
else
{
/* enable the controller */
if (!floppyAttachment)
/* unmount? */
{
/* nothing to do, NULL object will cause unmount */
}
/* host drive? */
{
if (!floppyMedium)
{
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 (!floppyMedium)
{
}
}
if (!floppyMedium)
{
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
{
}
# ifdef VBOX_WITH_SOLARIS_OSS
{
}
# endif
#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
#ifdef VBOX_WITH_VIRTIO
{
}
#endif /* VBOX_WITH_VIRTIO */
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 (vrdpServer)
{
if (vrdp)
{
{
}
{
}
else
{
break;
}
}
if (vrdpport)
{
}
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, false, Bstr(""), false, Bstr(""), 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, false, Bstr(""), false, Bstr(""), hardDisk.asOutParam()));
}
}
if (hardDisk)
{
}
else
break;
}
}
}
/*
* Live Migration.
*/
if (uLiveMigrationPort != UINT32_MAX)
if (fLiveMigrationTarget != -1)
/* commit changes */
}
while (0);
/* it's important to always close sessions */
}
#endif /* !VBOX_ONLY_DOCS */