VBoxManageModifyVM.cpp revision ab2292e9c32bd271ec91123ef38699a0284b72cb
/* $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
enum enOptionCodes
{
MODIFYVMNAME = 1000,
};
static const RTGETOPTDEF g_aModifyVMOptions[] =
{
};
int handleModifyVM(HandlerArg *a)
{
int c;
/* 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;
{
}
/* try to find the given machine */
{
}
else
{
}
return 1;
/* open a session for the VM */
/* get the mutable session machine */
{
switch (c)
{
case MODIFYVMNAME:
{
if (pValueUnion.psz)
break;
}
case MODIFYVMOSTYPE:
{
if (pValueUnion.psz)
{
{
}
else
{
}
}
break;
}
case MODIFYVMMEMORY:
{
if (pValueUnion.u32 > 0)
break;
}
case MODIFYVMVRAM:
{
if (pValueUnion.u32 > 0)
break;
}
case MODIFYVMFIRMWARE:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMACPI:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMIOAPIC:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMPAE:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMHWVIRTEX:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMNESTEDPAGING:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMVTXVPID:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMCPUS:
{
if (pValueUnion.u32 > 0)
break;
}
case MODIFYVMMONITORCOUNT:
{
if (pValueUnion.u32 > 0)
break;
}
case MODIFYVMACCELERATE3D:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
{
#ifdef VBOX_WITH_VIDEOHWACCEL
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
#endif
break;
}
case MODIFYVMBIOSLOGOFADEIN:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMBIOSLOGOFADEOUT:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
break;
}
}
break;
}
{
if (pValueUnion.u64 > 0)
break;
}
{
if (pValueUnion.psz)
break;
}
case MODIFYVMBIOSBOOTMENU:
{
if (pValueUnion.psz)
{
else
{
}
}
break;
}
{
if (pValueUnion.u64 > 0)
break;
}
case MODIFYVMBIOSPXEDEBUG:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMBOOT:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid boot slot number in '%s'",
{
}
{
}
{
}
{
}
{
}
else
break;
}
case MODIFYVMHDA:
{
{
}
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,
}
}
if (hardDisk)
{
}
else
}
break;
}
case MODIFYVMHDB:
{
{
}
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,
}
}
if (hardDisk)
{
}
else
}
break;
}
case MODIFYVMHDD:
{
{
}
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,
}
}
if (hardDisk)
{
}
else
}
break;
}
case MODIFYVMIDECONTROLLER:
{
{
}
{
}
{
}
else
{
}
break;
}
case MODIFYVMSATAIDEEMULATION:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid SATA boot slot number in '%s'",
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid SATA port number in '%s'",
break;
}
case MODIFYVMSATAPORTCOUNT:
{
break;
}
case MODIFYVMSATAPORT:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid SATA port number in '%s'",
{
}
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,
false, Bstr(""), false,
}
}
if (hardDisk)
{
0, DeviceType_HardDisk, uuid));
}
else
}
break;
}
case MODIFYVMSATA:
{
{
}
else
break;
}
case MODIFYVMSCSIPORT:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid SCSI port number in '%s'",
{
}
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,
}
}
if (hardDisk)
{
}
else
}
break;
}
case MODIFYVMSCSITYPE:
{
{
ctl.asOutParam()));
}
{
ctl.asOutParam()));
}
else
break;
}
case MODIFYVMSCSI:
{
{
}
{
}
break;
}
case MODIFYVMDVDPASSTHROUGH:
{
break;
}
case MODIFYVMDVD:
{
/* 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. */
break;
}
case MODIFYVMFLOPPY:
{
/* 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)
{
CHECK_ERROR (a->virtualBox,
floppyMedium.asOutParam()));
}
}
if (!floppyMedium)
{
break;
}
}
}
break;
}
case MODIFYVMNICTRACEFILE:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
break;
}
case MODIFYVMNICTRACE:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
{
}
{
}
else
{
}
break;
}
case MODIFYVMNICTYPE:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
{
}
{
}
#ifdef VBOX_WITH_E1000
{
}
{
}
{
}
#endif
#ifdef VBOX_WITH_VIRTIO
{
}
#endif /* VBOX_WITH_VIRTIO */
else
{
}
break;
}
case MODIFYVMNICSPEED:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
{
break;
}
break;
}
case MODIFYVMNIC:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
{
}
{
}
{
}
{
}
{
}
#if defined(VBOX_WITH_NETFLT)
{
}
#endif
else
{
}
break;
}
case MODIFYVMCABLECONNECTED:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
{
}
{
}
else
{
}
break;
}
case MODIFYVMBRIDGEADAPTER:
case MODIFYVMHOSTONLYADAPTER:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
/* remove it? */
{
}
else
{
}
break;
}
case MODIFYVMINTNET:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
/* remove it? */
{
}
else
{
}
break;
}
case MODIFYVMNATNET:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
break;
}
case MODIFYVMMACADDRESS:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid NIC slot number in '%s'",
/* generate one? */
{
}
else
{
}
break;
}
case MODIFYVMUARTMODE:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid Serial Port number in '%s'",
{
}
{
/**
* @todo: not the right way to get the second value for
* the argument, change this when RTGetOpt can return
* multiple values
*/
if (!pszIRQ)
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid argument to '%s'",
{
}
{
}
{
}
}
else
{
}
break;
}
case MODIFYVMUART:
{
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid Serial Port number in '%s'",
else
{
int vrc;
/**
* @todo: not the right way to get the second value for
* the argument, change this when RTGetOpt can return
* multiple values
*/
if (!pszIRQ)
return errorSyntax(USAGE_MODIFYVM,
"Missing or Invalid argument to '%s'",
}
break;
}
{
if (pValueUnion.u32 > 0)
break;
}
#ifdef VBOX_WITH_MEM_BALLOONING
{
if (pValueUnion.u32 > 0)
break;
}
#endif
case MODIFYVMAUDIOCONTROLLER:
{
if (pValueUnion.psz)
{
else
{
}
}
break;
}
case MODIFYVMAUDIO:
{
if (pValueUnion.psz)
{
/* 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;
}
case MODIFYVMCLIPBOARD:
{
if (pValueUnion.psz)
{
{
}
{
}
{
}
{
}
else
{
}
}
break;
}
#ifdef VBOX_WITH_VRDP
case MODIFYVMVRDPPORT:
{
if (pValueUnion.psz)
{
else
}
break;
}
case MODIFYVMVRDPADDRESS:
{
if (pValueUnion.psz)
{
}
break;
}
case MODIFYVMVRDPAUTHTYPE:
{
if (pValueUnion.psz)
{
{
}
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMVRDPMULTICON:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMVRDPREUSECON:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
case MODIFYVMVRDP:
{
if (pValueUnion.psz)
{
{
}
{
}
else
{
}
}
break;
}
#endif /* VBOX_WITH_VRDP */
case MODIFYVMUSBEHCI:
{
if (pValueUnion.psz)
{
{
else
}
}
break;
}
case MODIFYVMUSB:
{
if (pValueUnion.psz)
{
{
else
}
}
break;
}
case MODIFYVMSNAPSHOTFOLDER:
{
if (pValueUnion.psz)
{
else
}
break;
}
{
if (pValueUnion.psz)
{
else
}
break;
}
{
if (pValueUnion.u32 > 0)
break;
}
{
if (pValueUnion.psz)
break;
}
default:
{
break;
}
}
}
/* commit changes */
/* it's important to always close sessions */
}
#endif /* !VBOX_ONLY_DOCS */