VBoxManageStorageController.cpp revision a425b5e790c27d6a1a2cf738802e9034f0764a00
/* $Id$ */
/** @file
* VBoxManage - The storage controller related commands.
*/
/*
* 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.
*/
#ifndef VBOX_ONLY_DOCS
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VBoxManage.h"
using namespace com;
// funcs
///////////////////////////////////////////////////////////////////////////////
static const RTGETOPTDEF g_aStorageAttachOptions[] =
{
};
int handleStorageAttach(HandlerArg *a)
{
int c;
bool fRunTime = false;
const char *pszPassThrough = NULL;
if (a->argc < 9)
else if (a->argc > 13)
{
switch (c)
{
case 's': // storage controller name
{
if (ValueUnion.psz)
else
break;
}
case 'p': // port
{
break;
}
case 'd': // device
{
break;
}
case 'm': // medium <none|emptydrive|uuid|filename|host:<drive>>
{
if (ValueUnion.psz)
else
break;
}
case 't': // type <dvddrive|hdd|fdd>
{
if (ValueUnion.psz)
else
break;
}
case 'h': // passthrough <on|off>
{
if (ValueUnion.psz)
else
break;
}
default:
{
break;
}
}
}
|| !pszCtl
|| port == ~0U
|| device == ~0U)
{
return 1;
}
/* try to find the given machine */
{
}
else
{
}
/* open a session for the VM */
{
/* try to open an existing session for the VM */
fRunTime = true;
}
if (fRunTime)
{
errorArgument("DVD/HardDisk Drives can't be changed while the VM is still running\n");
if (pszPassThrough)
errorArgument("Drive passthrough state can't be changed while the VM is still running\n");
goto leave;
}
/* get the mutable session machine */
/* check if the storage controller is present */
{
goto leave;
}
{
}
{
if (fRunTime)
{
{
if ( (deviceType == DeviceType_DVD)
|| (deviceType == DeviceType_Floppy))
{
}
}
else
{
errorArgument("No DVD/Floppy Drive attached to the controller '%s'"
goto leave;
}
}
else
{
if (storageBus == StorageBus_Floppy)
else
}
}
else
{
if (!pszType)
{
goto leave;
}
{
if (!fRunTime)
{
/* check if there is a dvd drive at the given location, if not attach one */
{
if (deviceType != DeviceType_DVD)
{
}
}
else
{
}
}
do
{
/* 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;
}
}
} while (0);
if (dvdMedium)
{
}
}
&& !fRunTime)
{
/* if there is a dvd drive at the given location, remove it */
{
if (deviceType != DeviceType_HardDisk)
}
/* 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
{
}
}
{
if ( !fRunTime
&& !floppyAttachment)
/* host drive? */
{
if (!floppyMedium)
{
}
}
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)
{
}
}
if (floppyMedium)
{
}
}
else
{
}
}
if ( pszPassThrough
{
{
{
}
{
}
else
{
}
}
else
{
}
}
/* commit changes */
/* it's important to always close sessions */
}
static const RTGETOPTDEF g_aStorageControllerOptions[] =
{
};
int handleStorageController(HandlerArg *a)
{
int c;
const char *pszBusType = NULL;
const char *pszCtlType = NULL;
ULONG satabootdev = ~0U;
ULONG sataidedev = ~0U;
ULONG sataportcount = ~0U;
bool fRemoveCtl = false;
if (a->argc < 4)
{
switch (c)
{
case 'n': // controller name
{
if (ValueUnion.psz)
else
break;
}
{
if (ValueUnion.psz)
else
break;
}
{
if (ValueUnion.psz)
else
break;
}
case 'e': // sataideemulation
{
return errorSyntax(USAGE_STORAGECONTROLLER,
"Missing or Invalid SATA boot slot number in '%s'",
return errorSyntax(USAGE_STORAGECONTROLLER,
"Missing or Invalid SATA port number in '%s'",
break;
}
case 'p': // sataportcount
{
break;
}
case 'r': // remove controller
{
fRemoveCtl = true;
break;
}
default:
{
break;
}
}
}
return 1;
/* try to find the given machine */
{
}
else
{
}
/* open a session for the VM */
/* get the mutable session machine */
if (!pszCtl)
{
/* it's important to always close sessions */
return 1;
}
if (fRemoveCtl)
{
{
}
else
errorArgument("Can't detach the devices connected to '%s' Controller\n"
"and thus its removal failed.", pszCtl);
}
else
{
if (pszBusType)
{
{
}
{
}
{
}
{
}
else
{
}
}
if ( pszCtlType
{
{
{
}
{
}
{
}
{
}
{
}
{
}
{
}
else
{
}
}
else
{
}
}
if ( (sataportcount != ~0U)
{
{
}
else
{
}
}
if ( (sataidedev != ~0U)
&& (satabootdev != ~0U)
{
{
}
else
{
}
}
}
/* commit changes */
/* it's important to always close sessions */
}
#endif /* !VBOX_ONLY_DOCS */