VBoxManage.cpp revision 54d012edb10277db6ae96a7ddaefde72dbb37745
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * VBoxManage - VirtualBox's command-line interface.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Copyright (C) 2006-2009 Sun Microsystems, Inc.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * available from http://www.virtualbox.org. This file is free software;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * you can redistribute it and/or modify it under the terms of the GNU
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * General Public License (GPL) as published by the Free Software
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * additional information or have any questions.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/*******************************************************************************
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync* Header Files *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync*******************************************************************************/
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif /* !VBOX_ONLY_DOCS */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncusing namespace com;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/** command handler type */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif /* !VBOX_ONLY_DOCS */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync////////////////////////////////////////////////////////////////////////////////
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync// global variables
6a795f9e75e30c7f1d75cd45e5de233c71662f58vboxsync////////////////////////////////////////////////////////////////////////////////
6a795f9e75e30c7f1d75cd45e5de233c71662f58vboxsync////////////////////////////////////////////////////////////////////////////////
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync// functions
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync////////////////////////////////////////////////////////////////////////////////
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Print out progress on the console
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted))))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync progress->COMGETTER(OperationPercent(&ulCurrentOperationPercent));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync progress->COMGETTER(OperationDescription(bstrOperationDescription.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync || (ulCurrentOperationPercent != ulLastOperationPercent)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("(%ld/%ld) %ls %ld%% => %ld%% (%d s remaining)\n", ulOperation + 1, cOperations, bstrOperationDescription.raw(), ulCurrentOperationPercent, ulCurrentPercent, lSecsRem);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ulLastOperationPercent = ulCurrentOperationPercent;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* did we cross a 10% mark? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (((ulCurrentPercent / 10) > (ulLastPercent / 10)))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* make sure to also print out missed steps */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (ULONG curVal = (ulLastPercent / 10) * 10 + 10; curVal <= (ulCurrentPercent / 10) * 10; curVal += 10)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* make sure the loop is not too tight */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* complete the line. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (SUCCEEDED(progress->COMGETTER(ResultCode)(&rc)))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif /* !VBOX_ONLY_DOCS */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("VirtualBox Command Line Management Interface Version "
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync "(C) 2005-2009 Sun Microsystems, Inc.\n"
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync "All rights reserved.\n"
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_REGISTERVM, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, OpenMachine(Bstr(a->argv[0]), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, RegisterMachine(machine));
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync return errorSyntax(USAGE_UNREGISTERVM, "Incorrect number of parameters");
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync /* assume it's a UUID */
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync rc = a->virtualBox->GetMachine(Guid(a->argv[0]), machine.asOutParam());
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync /* must be a name */
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, UnregisterMachine(uuid, machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* are we supposed to delete the config file? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if ((a->argc == 2) && (strcmp(a->argv[1], "-delete") == 0))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bool fRegister = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (int i = 0; i < a->argc; i++)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Missing argument to '%s'", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Missing argument to '%s'", a->argv[i]);
4946f90c5c7016131555f0c925091d4ede6bdde0vboxsync return errorArgument("Missing argument to '%s'", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Missing argument to '%s'", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Missing argument to '%s'", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Invalid UUID format %s\n", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_CREATEVM, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_CREATEVM, "Parameter -name is required");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_CREATEVM, "Either -basefolder or -settingsfile must be specified");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CreateMachine(name, osTypeId, baseFolder, Guid(id), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CreateLegacyMachine(name, osTypeId, settingsFile, Guid(id), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(a->virtualBox, RegisterMachine(machine));
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync CHECK_ERROR_BREAK(machine, COMGETTER(Id)(uuid.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(machine, COMGETTER(SettingsFilePath)(settingsFile.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync "UUID: %s\n"
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync "Settings file: '%ls'\n",
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Parses a number.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns Valid number on success.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns 0 if invalid number. All necesary bitching has been done.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param psz Pointer to the nic number.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncunsigned parseNum(const char *psz, unsigned cMaxNum, const char *name)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return (unsigned)u32;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorArgument("Invalid %s number '%s'", name, psz);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/** @todo refine this after HDD changes; MSC 8.0/64 has trouble with handleModifyVM. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_STARTVM, "Not enough parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* assume it's a UUID */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = a->virtualBox->GetMachine(Guid(a->argv[0]), machine.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* must be a name */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* default to GUI session type */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* has a session type been specified? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if ((a->argc > 2) && (strcmp(a->argv[1], "-type") == 0))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Invalid session type argument '%s'", a->argv[2]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* make sure the VM process will start on the same display as VBoxManage */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(a->virtualBox, OpenRemoteSession(a->session, uuid, sessionType,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Waiting for the remote session to open...\n");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(progress, WaitForCompletion (-1), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(progress, COMGETTER(Completed)(&completed), rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(progress, COMGETTER(ResultCode)(&resultCode), rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(progress, COMGETTER(ErrorInfo)(errorInfo.asOutParam()), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Remote session has been successfully opened.\n");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* it's important to always close sessions */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_CONTROLVM, "Not enough parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* try to find the given machine */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR (a->virtualBox, GetMachine (uuid, machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR (a->virtualBox, FindMachine (Bstr(a->argv[0]), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* open a session for the VM */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET (a->virtualBox, OpenExistingSession (a->session, uuid), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the associated console */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (a->session, COMGETTER(Console)(console.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* ... and session machine */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (a->session, COMGETTER(Machine)(sessionMachine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* which command? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (console, SaveState(progress.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Error: failed to save machine state. Error message: %lS\n", info.getText().raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Error: failed to save machine state. No error message available!\n");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(a->argv[1], "acpipowerbutton") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(a->argv[1], "acpisleepbutton") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the machine debugger. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(console, COMGETTER(Debugger)(debugger.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(a->argv[1], "keyboardputscancode") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(console, COMGETTER(Keyboard)(keyboard.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorArgument("Missing argument to '%s'. Expected IBM PC AT set 2 keyboard scancode(s) as hex byte(s).", a->argv[1]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Arbitrary restrict the length of a sequence of scancodes to 1024. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Process the command line. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (i = 1 + 1; i < a->argc && cScancodes < (int)RT_ELEMENTS(alScancodes); i++, cScancodes++)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc = RTStrToUInt8Ex(a->argv[i], NULL, 16, &u8Scancode);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Error: converting '%s' returned %Rrc!\n", a->argv[i], rc);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Error: '%s' is not a hex byte!\n", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Error: too many scancodes, maximum %d allowed!\n", RT_ELEMENTS(alScancodes));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Send scancodes to the VM.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Note: 'PutScancodes' did not work here. Only the first scancode was transmitted.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (i = 0; i < cScancodes; i++)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(keyboard, PutScancode(alScancodes[i]));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Scancode[%d]: 0x%02X\n", i, alScancodes[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strncmp(a->argv[1], "setlinkstate", 12) == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Get the number of network adapters */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (a->virtualBox, COMGETTER(SystemProperties) (info.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (info, COMGETTER(NetworkAdapterCount) (&NetworkAdapterCount));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync unsigned n = parseNum(&a->argv[1][12], NetworkAdapterCount, "NIC");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the corresponding network adapter */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (sessionMachine, GetNetworkAdapter(n - 1, adapter.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (adapter, COMSETTER(CableConnected)(TRUE));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (adapter, COMSETTER(CableConnected)(FALSE));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorArgument("Invalid link state '%s'", Utf8Str(a->argv[2]).raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the corresponding VRDP server */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync sessionMachine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (vrdpServer, COMSETTER(Enabled)(TRUE));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (vrdpServer, COMSETTER(Enabled)(FALSE));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorArgument("Invalid vrdp server state '%s'", Utf8Str(a->argv[2]).raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif /* VBOX_WITH_VRDP */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorSyntax(USAGE_CONTROLVM, "Not enough parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bool attach = strcmp (a->argv[1], "usbattach") == 0;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // assume address
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (a->virtualBox, COMGETTER(Host) (host.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (host, COMGETTER(USBDevices) (ComSafeArrayAsOutParam(coll)));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (host, FindUSBDeviceByAddress (Bstr (a->argv [2]), dev.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (dev, COMGETTER(Id) (usbId.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (console, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(coll)));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (console, FindUSBDeviceByAddress (Bstr (a->argv [2]),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (dev, COMGETTER(Id) (usbId.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (console, AttachUSBDevice (usbId));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (console, DetachUSBDevice (usbId, dev.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(a->argv[1], "setvideomodehint") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(console, COMGETTER(Display)(display.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(display, SetVideoModeHint(xres, yres, bpp, displayIdx));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(a->argv[1], "setcredentials") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorArgument("Invalid parameter '%s'", a->argv[5]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(console, COMGETTER(Guest)(guest.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(guest, SetCredentials(Bstr(a->argv[2]), Bstr(a->argv[3]), Bstr(a->argv[4]), fAllowLocalLogon));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync sessionMachine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* unmount? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* host drive? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = host->COMGETTER(DVDDrives)(ComSafeArrayAsOutParam(hostDVDs));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = host->FindHostDVDDrive(Bstr(a->argv[2] + 5), hostDVDDrive.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(dvdDrive, CaptureHostDrive(hostDVDDrive));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* first assume it's a UUID */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = a->virtualBox->GetDVDImage(uuid, dvdImage.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* must be a filename, check if it's in the collection */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = a->virtualBox->FindDVDImage(Bstr(a->argv[2]), dvdImage.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* not registered, do that on the fly */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(a->argv[2]), emptyUUID, dvdImage.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync sessionMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* unmount? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* host drive? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync com::SafeIfaceArray <IHostFloppyDrive> hostFloppies;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = host->COMGETTER(FloppyDrives)(ComSafeArrayAsOutParam(hostFloppies));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync host->FindHostFloppyDrive(Bstr(a->argv[2] + 5), hostFloppyDrive.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(floppyDrive, CaptureHostDrive(hostFloppyDrive));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* first assume it's a UUID */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = a->virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* must be a filename, check if it's in the collection */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = a->virtualBox->FindFloppyImage(Bstr(a->argv[2]), floppyImage.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* not registered, do that on the fly */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(a->argv[2]), emptyUUID, floppyImage.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strncmp(a->argv[1], "-guestmemoryballoon", 19) == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorArgument("Error parsing guest memory balloon size '%s'", a->argv[2]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* guest is running; update IGuest */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = console->COMGETTER(Guest)(guest.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(guest, COMSETTER(MemoryBalloonSize)(uVal));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strncmp(a->argv[1], "-gueststatisticsinterval", 24) == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorArgument("Error parsing guest statistics interval '%s'", a->argv[2]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* guest is running; update IGuest */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = console->COMGETTER(Guest)(guest.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(guest, COMSETTER(StatisticsUpdateInterval)(uVal));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync errorSyntax(USAGE_CONTROLVM, "Invalid parameter '%s'", Utf8Str(a->argv[1]).raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_DISCARDSTATE, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* assume it's a UUID */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = a->virtualBox->GetMachine(Guid(a->argv[0]), machine.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* must be a name */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* we have to open a session for this task */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guid));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_ADOPTSTATE, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* assume it's a UUID */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = a->virtualBox->GetMachine(Guid(a->argv[0]), machine.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* must be a name */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* we have to open a session for this task */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(a->virtualBox, OpenSession(a->session, guid));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(console, AdoptSavedState (Bstr (a->argv[1])));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_GETEXTRADATA, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* global data? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* enumeration? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync HRESULT rcEnum = a->virtualBox->GetNextExtraDataKey(extraDataKey, nextExtraDataKey.asOutParam(),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Key: %lS, Value: %lS\n", nextExtraDataKey.raw(), nextExtraDataValue.raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, GetExtraData(Bstr(a->argv[1]), value.asOutParam()));
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync /* assume it's a UUID */
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync rc = a->virtualBox->GetMachine(Guid(a->argv[0]), machine.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* must be a name */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync /* enumeration? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync HRESULT rcEnum = machine->GetNextExtraDataKey(extraDataKey, nextExtraDataKey.asOutParam(),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Key: %lS, Value: %lS\n", nextExtraDataKey.raw(), nextExtraDataValue.raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(machine, GetExtraData(Bstr(a->argv[1]), value.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SETEXTRADATA, "Not enough parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* global data? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, SetExtraData(Bstr(a->argv[1]), NULL));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, SetExtraData(Bstr(a->argv[1]), Bstr(a->argv[2])));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SETEXTRADATA, "Too many parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* assume it's a UUID */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = a->virtualBox->GetMachine(Guid(a->argv[0]), machine.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* must be a name */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(machine, SetExtraData(Bstr(a->argv[1]), NULL));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(machine, SetExtraData(Bstr(a->argv[1]), Bstr(a->argv[2])));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SETEXTRADATA, "Too many parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* there must be two arguments: property name and value */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SETPROPERTY, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync a->virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* reset to default? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(DefaultHardDiskFolder)(NULL));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(DefaultHardDiskFolder)(Bstr(a->argv[1])));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* reset to default? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(DefaultMachineFolder)(NULL));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(DefaultMachineFolder)(Bstr(a->argv[1])));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(a->argv[0], "vrdpauthlibrary") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* reset to default? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(RemoteDisplayAuthLibrary)(NULL));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(RemoteDisplayAuthLibrary)(Bstr(a->argv[1])));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(a->argv[0], "websrvauthlibrary") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* reset to default? */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(WebServiceAuthLibrary)(NULL));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(WebServiceAuthLibrary)(Bstr(a->argv[1])));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(a->argv[0], "hwvirtexenabled") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(HWVirtExEnabled)(TRUE));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(HWVirtExEnabled)(FALSE));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Invalid value '%s' for hardware virtualization extension flag", a->argv[1]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(a->argv[0], "loghistorycount") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Error parsing Log history count '%s'", a->argv[1]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(systemProperties, COMSETTER(LogHistoryCount)(uVal));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", a->argv[0]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* we need at least a command and target */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SHAREDFOLDER, "Not enough parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* assume it's a UUID */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = a->virtualBox->GetMachine(Guid(a->argv[1]), machine.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* must be a name */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[1]), machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* we need at least four more parameters */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Not enough parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bool fTransient = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Missing argument to '%s'", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Missing argument to '%s'", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SHAREDFOLDER_ADD, "No spaces allowed in parameter '-name'!");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* required arguments */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Parameters -name and -hostpath are required");
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync /* open an existing session for the VM */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(a->virtualBox, OpenExistingSession (a->session, uuid), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the session machine */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the session console */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(a->session, COMGETTER(Console)(console.asOutParam()), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(console, CreateSharedFolder(Bstr(name), Bstr(hostpath), fWritable));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* open a session for the VM */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET (a->virtualBox, OpenSession(a->session, uuid), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the mutable session machine */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync a->session->COMGETTER(Machine)(machine.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(machine, CreateSharedFolder(Bstr(name), Bstr(hostpath), fWritable));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* we need at least two more parameters */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SHAREDFOLDER_REMOVE, "Not enough parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bool fTransient = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Missing argument to '%s'", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SHAREDFOLDER_REMOVE, "Invalid parameter '%s'", Utf8Str(a->argv[i]).raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* required arguments */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SHAREDFOLDER_REMOVE, "Parameter -name is required");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* open an existing session for the VM */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(a->virtualBox, OpenExistingSession (a->session, uuid), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the session machine */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(a->session, COMGETTER(Machine)(machine.asOutParam()), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the session console */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET(a->session, COMGETTER(Console)(console.asOutParam()), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(console, RemoveSharedFolder(Bstr(name)));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* open a session for the VM */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_RET (a->virtualBox, OpenSession(a->session, uuid), 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the mutable session machine */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync a->session->COMGETTER(Machine)(machine.asOutParam());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(machine, RemoveSharedFolder(Bstr(name)));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* commit and close the session */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", Utf8Str(a->argv[0]).raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* at least one option: the UUID or name of the VM */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_VM_STATISTICS, "Incorrect number of parameters");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* try to find the given machine */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, GetMachine(uuid, machine.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]), machine.asOutParam()));
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync /* parse arguments. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync bool fReset = false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_VM_STATISTICS, "Multiple -patterns options is not permitted");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorArgument("Missing argument to '%s'", a->argv[i]);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* add: -file <filename> and -formatted */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return errorSyntax(USAGE_VM_STATISTICS, "Unknown option '%s'", a->argv[i]);
9b9a21c4dedad15ac8b2059a858a94c5a33db1bdvboxsync return errorSyntax(USAGE_VM_STATISTICS, "The -reset and -descriptions options does not mix");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* open an existing session for the VM. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->virtualBox, OpenExistingSession(a->session, uuid));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the session console. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(a->session, COMGETTER(Console)(console.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* get the machine debugger. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(console, COMGETTER(Debugger)(debugger.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(debugger, ResetStats(Bstr(pszPattern)));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR(debugger, GetStats(Bstr(pszPattern), fWithDescriptions, stats.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* if (fFormatted)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync { big mess }
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif /* !VBOX_ONLY_DOCS */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Checks if any of the settings files were auto-converted and informs the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * user if so.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @return @false if the program should terminate and @true otherwise.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncstatic bool checkForAutoConvertedSettings (ComPtr<IVirtualBox> virtualBox,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* return early if nothing to do */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return true;
9b9a21c4dedad15ac8b2059a858a94c5a33db1bdvboxsync CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFormatVersion) (formatVersion.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(virtualBox, COMGETTER(Machines)(ComSafeArrayAsOutParam (machines)));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(machines[i], COMGETTER(Accessible) (&accessible));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFileVersion) (version.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(machines[i], COMGETTER(SettingsFilePath) (filePath.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(),
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFileVersion) (version.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(virtualBox, COMGETTER(SettingsFilePath) (filePath.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync fileList.push_back (Utf8StrFmt ("%ls (%ls)", filePath.raw(),
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync"WARNING! The following VirtualBox settings files have been automatically\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync"converted to the new settings file format version '%ls':\n"
2d8894b1c178c9f1199cac84059ca66aa5dee6b3vboxsync for (std::list <Utf8Str>::const_iterator f = fileList.begin();
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync"The current command was aborted to prevent overwriting the above settings\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync"files with the results of the auto-conversion without your permission.\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync"Please put one of the following command line switches to the beginning of\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync"the VBoxManage command line and repeat the command:\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync" -convertSettings - to save all auto-converted files (it will not\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync" be possible to use these settings files with an\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync" older version of VirtualBox in the future);\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync" -convertSettingsBackup - to create backup copies of the settings files in\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync" the old format before saving them in the new format;\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync" -convertSettingsIgnore - to not save the auto-converted settings files.\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync"Note that if you use -convertSettingsIgnore, the auto-converted settings files\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync"will be implicitly saved in the new format anyway once you change a setting or\n"
23631945c9cb3df68ca51c69ed0b77e90164b402vboxsync"start a virtual machine, but NO backup copies will be created in this case.\n");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return false;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (std::list <ComPtr <IMachine> >::const_iterator m = cvtMachines.begin();
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK((*m), COMGETTER(Id) (id.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* open a session for the VM */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK (virtualBox, OpenSession (session, id));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR_BREAK(session, COMGETTER(Machine) (sm.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR (sm, SaveSettingsWithBackup (bakFileName.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync CHECK_ERROR (virtualBox, SaveSettingsWithBackup (bakFileName.asOutParam()));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif /* !VBOX_ONLY_DOCS */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync///////////////////////////////////////////////////////////////////////////////
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Before we do anything, init the runtime without loading
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * the support driver.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ConvertSettings fConvertSettings = ConvertSettings_No;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* global options */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Print version number, and do nothing else. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("%sr%d\n", VBOX_VERSION_STRING, VBoxSVNRev ());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Special option to dump really all commands,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * even the ones not understood on this platform. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* suppress the logo */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(argv[i], "-convertSettingsBackup") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync else if (strcmp(argv[i], "-convertSettingsIgnore") == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#else /* !VBOX_ONLY_DOCS */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * The input is in the host OS'es codepage (NT guarantees ACP).
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * For VBox we use UTF-8 and convert to UCS-2 when calling (XP)COM APIs.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * For simplicity, just convert the argv[] array here.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // scopes all the stuff till shutdown
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ////////////////////////////////////////////////////////////////////////////
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* convertfromraw: does not need a VirtualBox instantiation. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (argc >= iCmdArg && ( !strcmp(argv[iCmd], "convertfromraw")
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = handleConvertFromRaw(argc - iCmdArg, argv + iCmdArg);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = virtualBox.createLocalObject(CLSID_VirtualBox);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("ERROR: failed to create the VirtualBox object!\n");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("ERROR: failed to create a session object!\n");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (!info.isFullAvailable() && !info.isBasicAvailable())
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync RTPrintf("Most likely, the VirtualBox COM server is not running or failed to start.\n");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* create the event queue
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * (here it is necessary only to process remaining XPCOM/IPC events
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * after the session is closed) */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (!checkForAutoConvertedSettings (virtualBox, session, fConvertSettings))
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync HandlerArg handlerArg = { 0, NULL, eventQ, virtualBox, session };
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync HandlerArg handlerArg = { 0, NULL, virtualBox, session };
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * All registered command handlers
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync const char *command;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync { "createvdi", handleCreateHardDisk }, /* backward compatiblity */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync { "modifyvdi", handleModifyHardDisk }, /* backward compatiblity */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync { "clonevdi", handleCloneHardDisk }, /* backward compatiblity */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync { "registerimage", handleOpenMedium }, /* backward compatiblity */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync { "unregisterimage", handleCloseMedium }, /* backward compatiblity */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync { "showvdiinfo", handleShowHardDiskInfo }, /* backward compatiblity */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif /* VBOX_WITH_GUEST_PROPS defined */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync for (commandIndex = 0; commandHandlers[commandIndex].command != NULL; commandIndex++)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (strcmp(commandHandlers[commandIndex].command, argv[iCmd]) == 0)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = commandHandlers[commandIndex].handler(&handlerArg);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = errorSyntax(USAGE_ALL, "Invalid command '%s'", Utf8Str(argv[iCmd]).raw());
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync /* Although all handlers should always close the session if they open it,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * we do it here just in case if some of the handlers contains a bug --
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * leaving the direct session not closed will turn the machine state to
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Aborted which may have unwanted side effects like killing the saved
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * state file (if the machine was in the Saved state before). */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync // end "all-stuff" scope
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync ////////////////////////////////////////////////////////////////////////////
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#endif /* !VBOX_ONLY_DOCS */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Free converted argument vector
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync return rc != 0;