VBoxManageDisk.cpp revision 64863d3a0ffadf1ac248b295b78be5d55db6ee13
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync * VBoxManage - The disk related commands.
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync * Copyright (C) 2006-2010 Oracle Corporation
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync * available from http://www.virtualbox.org. This file is free software;
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync * you can redistribute it and/or modify it under the terms of the GNU
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync * General Public License (GPL) as published by the Free Software
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync/*******************************************************************************
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync* Header Files *
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync*******************************************************************************/
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsyncusing namespace com;
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync///////////////////////////////////////////////////////////////////////////////
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsyncstatic DECLCALLBACK(void) handleVDError(void *pvUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync RTMsgError("Error code %Rrc at %s(%u) in function %s", rc, RT_SRC_POS_ARGS);
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsyncstatic int parseDiskVariant(const char *psz, MediumVariant_T *pDiskVariant)
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync // Parsing is intentionally inconsistent: "standard" resets the
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync // variant, whereas the other flags are cumulative.
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsyncstatic int parseDiskType(const char *psz, MediumType_T *pDiskType)
29bdc01040c07a3dd482a94a2cb8f0a90f8587a7vboxsync/** @todo move this into getopt, as getting bool values is generic */
*pb = false;
return rc;
int vrc;
bool fRemember = false;
RTGetOptInit(&GetState, a->argc, a->argv, g_aCreateHardDiskOptions, RT_ELEMENTS(g_aCreateHardDiskOptions),
fRemember = true;
case VINF_GETOPT_NOT_OPTION:
if (RT_C_IS_PRINT(c))
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
|| size == 0)
bool doClose = false;
if (doClose)
int vrc;
bool AutoReset = false;
bool fModifyResize = false;
RTGetOptInit(&GetState, a->argc, a->argv, g_aModifyHardDiskOptions, RT_ELEMENTS(g_aModifyHardDiskOptions),
fModifyDiskType = true;
fModifyAutoReset = true;
fModifyCompact = true;
fModifyResize = true;
case VINF_GETOPT_NOT_OPTION:
if (!FilenameOrUuid)
if (RT_C_IS_PRINT(c))
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
if (!FilenameOrUuid)
if (fModifyDiskType)
if (fModifyAutoReset)
if (fModifyCompact)
bool unknown = false;
if (!hardDisk)
unknown = true;
if (unknown)
if (fModifyResize)
bool unknown = false;
if (!hardDisk)
unknown = true;
if (unknown)
int vrc;
bool fExisting = false;
bool fRemember = false;
bool fSetDiskType = false;
RTGetOptInit(&GetState, a->argc, a->argv, g_aCloneHardDiskOptions, RT_ELEMENTS(g_aCloneHardDiskOptions),
fExisting = true;
fRemember = true;
fSetDiskType = true;
case VINF_GETOPT_NOT_OPTION:
if (RT_C_IS_GRAPH(c))
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
bool fSrcUnknown = false;
bool fDstUnknown = false;
fSrcUnknown = true;
if (fExisting)
fDstUnknown = true;
fRemember = true;
else if (fSetDiskType)
if (fSrcUnknown)
bool fReadFromStdIn = false;
RTGetOptInit(&GetState, argc, argv, g_aConvertFromRawHardDiskOptions, RT_ELEMENTS(g_aConvertFromRawHardDiskOptions),
case VINF_GETOPT_NOT_OPTION:
if (!srcfilename)
// If you change the OS list here don't forget to update VBoxManageHelp.cpp.
#ifndef RT_OS_WINDOWS
else if (!dstfilename)
if (fReadFromStdIn)
File = 0;
goto out;
if (fReadFromStdIn)
goto out;
goto out;
goto out;
if (!pvBuf)
goto out;
offFile = 0;
cbRead = 0;
goto out;
out:
if (pvBuf)
if (pDisk)
int vrc;
bool fIntNet = false;
RTGetOptInit(&GetState, a->argc, a->argv, g_aAddiSCSIDiskOptions, RT_ELEMENTS(g_aAddiSCSIDiskOptions),
fIntNet = true;
case VINF_GETOPT_NOT_OPTION:
if (RT_C_IS_PRINT(c))
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
// Bstr("iqn.2008-04.com.sun.virtualbox.initiator").detachTo(values.appendedRaw());
if (fIntNet)
RTGetOptInit(&GetState, a->argc, a->argv, g_aShowHardDiskInfoOptions, RT_ELEMENTS(g_aShowHardDiskInfoOptions),
case VINF_GETOPT_NOT_OPTION:
if (!FilenameOrUuid)
if (RT_C_IS_PRINT(c))
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
if (!FilenameOrUuid)
bool unknown = false;
unknown = true;
switch (type)
case MediumType_Normal:
case MediumType_Immutable:
case MediumType_Writethrough:
case MediumType_Shareable:
if (!unknown)
if (unknown)
bool fDelete = false;
RTGetOptInit(&GetState, a->argc, a->argv, g_aCloseMediumOptions, RT_ELEMENTS(g_aCloseMediumOptions),
fDelete = true;
case VINF_GETOPT_NOT_OPTION:
if (!FilenameOrUuid)
if (RT_C_IS_PRINT(c))
else if (c == VERR_GETOPT_UNKNOWN_OPTION)
if (!FilenameOrUuid)
if (fDelete)