VBoxManageControlVM.cpp revision 7e837ad8d6aeb3f86520ea7adb61e4eb15f2087e
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync * VBoxManage - Implementation of the controlvm command.
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2010 Oracle Corporation
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync * available from http://www.virtualbox.org. This file is free software;
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync * you can redistribute it and/or modify it under the terms of the GNU
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync * General Public License (GPL) as published by the Free Software
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync/*******************************************************************************
c4bfe32373c55416bf49dc29ebf45dfa560b4692vboxsync* Header Files *
2cb8d6f5cd0c9bf435c2d3fadd9ad873590e384bvboxsync*******************************************************************************/
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync * Parses a number.
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync * @returns Valid number on success.
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync * @returns 0 if invalid number. All necessary bitching has been done.
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync * @param psz Pointer to the nic number.
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsyncstatic unsigned parseNum(const char *psz, unsigned cMaxNum, const char *name)
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync return (unsigned)u32;
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync errorArgument("Invalid %s number '%s'", name, psz);
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync using namespace com;
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync return errorSyntax(USAGE_CONTROLVM, "Not enough parameters");
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync /* try to find the given machine */
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync CHECK_ERROR(a->virtualBox, FindMachine(Bstr(a->argv[0]).raw(),
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync /* open a session for the VM */
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync CHECK_ERROR_RET(machine, LockMachine(a->session, LockType_Shared), 1);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync /* get the associated console */
abb9f29bd46d8a8bab57155229f583db28b18f8dvboxsync CHECK_ERROR_BREAK(a->session, COMGETTER(Console)(console.asOutParam()));
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync /* ... and session machine */
730f8be51b729e8a3c1e32c756cd0f4ec088dd4dvboxsync CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()));
77db08a24f69bca943d5abc40b1930ee97f593edvboxsync /* which command? */
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Missing argument to '%s'. Expected CPU number.", a->argv[1]);
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync CHECK_ERROR_BREAK(sessionMachine, HotUnplugCPU(n));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Missing argument to '%s'. Expected CPU number.", a->argv[1]);
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync errorArgument("Missing argument to '%s'. Expected execution cap number.", a->argv[1]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync unsigned n = parseNum(a->argv[2], 100, "ExecutionCap");
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(sessionMachine, COMSETTER(CPUExecutionCap)(n));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(console, PowerDown(progress.asOutParam()));
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync RTMsgError("Failed to power off machine. Error message: %lS", info.getText().raw());
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync RTMsgError("Failed to power off machine. No error message available!");
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync /* first pause so we don't trigger a live save which needs more time/resources */
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync /* check if we are already paused */
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync CHECK_ERROR_BREAK(console, COMGETTER(State)(&machineState));
cbc215af8423a8326b27143c59c5d8fc9ffb0279vboxsync CHECK_ERROR(console, SaveState(progress.asOutParam()));
ece707b8d97e63ed54d4b48d7a8d841187e0023cvboxsync RTMsgError("Failed to save machine state. Error message: %lS", info.getText().raw());
ece707b8d97e63ed54d4b48d7a8d841187e0023cvboxsync RTMsgError("Failed to save machine state. No error message available!");
ece707b8d97e63ed54d4b48d7a8d841187e0023cvboxsync else if (!strcmp(a->argv[1], "keyboardputscancode"))
ece707b8d97e63ed54d4b48d7a8d841187e0023cvboxsync CHECK_ERROR_BREAK(console, COMGETTER(Keyboard)(keyboard.asOutParam()));
ece707b8d97e63ed54d4b48d7a8d841187e0023cvboxsync errorArgument("Missing argument to '%s'. Expected IBM PC AT set 2 keyboard scancode(s) as hex byte(s).", a->argv[1]);
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync /* Process the command line. */
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync int irc = RTStrToUInt8Ex(a->argv[i], NULL, 16, &u8Scancode);
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync RTMsgError("Converting '%s' returned %Rrc!", a->argv[i], rc);
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync RTMsgError("Error: '%s' is not a hex byte!", a->argv[i]);
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync /* Send scancodes to the VM. */
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync CHECK_ERROR_BREAK(keyboard, PutScancodes(ComSafeArrayAsInParam(saScancodes),
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync RTMsgError("Only %d scancodes were stored", codesStored);
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync /* Get the number of network adapters */
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync CHECK_ERROR_BREAK(a->virtualBox, COMGETTER(SystemProperties)(info.asOutParam()));
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync CHECK_ERROR_BREAK(info, COMGETTER(NetworkAdapterCount)(&NetworkAdapterCount));
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync unsigned n = parseNum(&a->argv[1][12], NetworkAdapterCount, "NIC");
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync /* get the corresponding network adapter */
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(n - 1, adapter.asOutParam()));
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync CHECK_ERROR_BREAK(adapter, COMSETTER(CableConnected)(TRUE));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(adapter, COMSETTER(CableConnected)(FALSE));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Invalid link state '%s'", Utf8Str(a->argv[2]).c_str());
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync /* here the order in which strncmp is called is important
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync * cause nictracefile can be very well compared with
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync * nictrace and nic and thus everything will always fail
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync * if the order is changed
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync /* Get the number of network adapters */
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(a->virtualBox, COMGETTER(SystemProperties)(info.asOutParam()));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(info, COMGETTER(NetworkAdapterCount)(&NetworkAdapterCount));
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync unsigned n = parseNum(&a->argv[1][12], NetworkAdapterCount, "NIC");
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync /* get the corresponding network adapter */
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(n - 1, adapter.asOutParam()));
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync CHECK_ERROR_RET(adapter, COMSETTER(TraceFile)(Bstr(a->argv[2]).raw()), 1);
8cb6f31c3048428b42c7370dfbb20e4de7254f40vboxsync errorArgument("Invalid filename or filename not specified for NIC %lu", n);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync RTMsgError("The NIC %d is currently disabled and thus can't change its tracefile", n);
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync /* Get the number of network adapters */
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync CHECK_ERROR_BREAK(a->virtualBox, COMGETTER(SystemProperties)(info.asOutParam()));
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync CHECK_ERROR_BREAK(info, COMGETTER(NetworkAdapterCount)(&NetworkAdapterCount));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync unsigned n = parseNum(&a->argv[1][8], NetworkAdapterCount, "NIC");
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync /* get the corresponding network adapter */
7cfcbe810de5334cdc2e8b92e77db705da143adavboxsync CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(n - 1, adapter.asOutParam()));
6902a98267d5180fb081cb5273751d0a628bf04dvboxsync CHECK_ERROR_RET(adapter, COMSETTER(TraceEnabled)(TRUE), 1);
3c9ed6defa3feca7e21adef4b5d1ba3002fc94c9vboxsync CHECK_ERROR_RET(adapter, COMSETTER(TraceEnabled)(FALSE), 1);
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync errorArgument("Invalid nictrace%lu argument '%s'", n, Utf8Str(a->argv[2]).c_str());
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync RTMsgError("The NIC %d is currently disabled and thus can't change its trace flag", n);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync /* Get the number of network adapters */
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync CHECK_ERROR_BREAK(a->virtualBox, COMGETTER(SystemProperties)(info.asOutParam()));
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync CHECK_ERROR_BREAK(info, COMGETTER(NetworkAdapterCount)(&NetworkAdapterCount));
bcd589d9db90b68d3af5d6839c1d613bb64d4c04vboxsync unsigned n = parseNum(&a->argv[1][5], NetworkAdapterCount, "NIC");
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync /* get the corresponding network adapter */
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(n - 1, adapter.asOutParam()));
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync CHECK_ERROR(adapter, COMGETTER(NatDriver)(engine.asOutParam()));
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync CHECK_ERROR(engine, RemoveRedirect(Bstr(a->argv[3]).raw()));
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync if (*ch == 0) \
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync "Missing or invalid argument to '%s'", \
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync "Wrong rule proto '%s' specified -- only 'udp' and 'tcp' are allowed.",
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync CHECK_ERROR(engine, AddRedirect(Bstr(strName).raw(), proto, Bstr(strHostIp).raw(),
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync RTStrToUInt16(strHostPort), Bstr(strGuestIp).raw(), RTStrToUInt16(strGuestPort)));
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync /* commit changes */
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync /* Get the number of network adapters */
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync CHECK_ERROR_BREAK(a->virtualBox, COMGETTER(SystemProperties)(info.asOutParam()));
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync CHECK_ERROR_BREAK(info, COMGETTER(NetworkAdapterCount)(&NetworkAdapterCount));
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync unsigned n = parseNum(&a->argv[1][3], NetworkAdapterCount, "NIC");
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync /* get the corresponding network adapter */
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync CHECK_ERROR_BREAK(sessionMachine, GetNetworkAdapter(n - 1, adapter.asOutParam()));
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync CHECK_ERROR_RET(adapter, COMSETTER(Enabled)(TRUE), 1);
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync CHECK_ERROR_RET(adapter, COMSETTER(Enabled)(TRUE), 1);
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync CHECK_ERROR_RET(adapter, COMSETTER(NATNetwork)(Bstr(a->argv[3]).raw()), 1);
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync || !strcmp(a->argv[2], "hostif")) /* backward compatibility */
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync errorArgument("Missing argument to '%s'", a->argv[2]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_RET(adapter, COMSETTER(Enabled)(TRUE), 1);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_RET(adapter, COMSETTER(HostInterface)(Bstr(a->argv[3]).raw()), 1);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_RET(adapter, AttachToBridgedInterface(), 1);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Missing argument to '%s'", a->argv[2]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_RET(adapter, COMSETTER(Enabled)(TRUE), 1);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_RET(adapter, COMSETTER(InternalNetwork)(Bstr(a->argv[3]).raw()), 1);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_RET(adapter, AttachToInternalNetwork(), 1);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Missing argument to '%s'", a->argv[2]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_RET(adapter, COMSETTER(Enabled)(TRUE), 1);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_RET(adapter, COMSETTER(HostInterface)(Bstr(a->argv[3]).raw()), 1);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_RET(adapter, AttachToHostOnlyInterface(), 1);
c9a593aa048a154e59b52d1237d89e3cdaee9b3dvboxsync errorArgument("Invalid type '%s' specfied for NIC %lu", Utf8Str(a->argv[2]).c_str(), n);
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync RTMsgError("The NIC %d is currently disabled and thus can't change its attachment type", n);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync RTStrmPrintf(g_pStdErr, "Warning: 'vrdp' is deprecated. Use 'vrde'.\n");
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(vrdeServer, COMSETTER(Enabled)(TRUE));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(vrdeServer, COMSETTER(Enabled)(FALSE));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Invalid remote desktop server state '%s'", Utf8Str(a->argv[2]).c_str());
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync RTStrmPrintf(g_pStdErr, "Warning: 'vrdpport' is deprecated. Use 'vrdeport'.\n");
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(vrdeServer, SetVRDEProperty(Bstr("TCP/Ports").raw(), ports.raw()));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync else if ( !strcmp(a->argv[1], "vrdevideochannelquality")
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync if (!strcmp(a->argv[1], "vrdpvideochannelquality"))
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync RTStrmPrintf(g_pStdErr, "Warning: 'vrdpvideochannelquality' is deprecated. Use 'vrdevideochannelquality'.\n");
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR(vrdeServer, SetVRDEProperty(Bstr("VideoChannel/Quality").raw(), value.raw()));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Missing argument to '%s'", a->argv[1]);
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync sessionMachine->COMGETTER(VRDEServer)(vrdeServer.asOutParam());
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync /* Parse 'name=value' */
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync CHECK_ERROR(vrdeServer, SetVRDEProperty(bstrName.raw(), bstrValue.raw()));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Invalid --vrdeproperty argument '%s'", a->argv[2]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync RTStrmPrintf(g_pStdErr, "Error: Failed to allocate memory for VRDE property '%s'\n", a->argv[2]);
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync errorSyntax(USAGE_CONTROLVM, "Not enough parameters");
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync // assume address
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync CHECK_ERROR_BREAK(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
416817daa142e9bb7eaf14a1b10577978a5e691bvboxsync CHECK_ERROR_BREAK(host, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(coll)));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(host, FindUSBDeviceByAddress(Bstr(a->argv[2]).raw(),
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(dev, COMGETTER(Id)(usbId.asOutParam()));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(console, COMGETTER(USBDevices)(ComSafeArrayAsOutParam(coll)));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR_BREAK(console, FindUSBDeviceByAddress(Bstr(a->argv[2]).raw(),
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync CHECK_ERROR_BREAK(dev, COMGETTER(Id)(usbId.asOutParam()));
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync CHECK_ERROR_BREAK(console, AttachUSBDevice(usbId.raw()));
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync CHECK_ERROR_BREAK(console, DetachUSBDevice(usbId.raw(),
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync CHECK_ERROR_BREAK(console, COMGETTER(Display)(display.asOutParam()));
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync CHECK_ERROR_BREAK(display, SetVideoModeHint(xres, yres, bpp, displayIdx));
2f4c1bacd54af5063c3185cc8eab03e4e8ef9b90vboxsync errorArgument("Invalid parameter '%s'", a->argv[5]);
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync CHECK_ERROR_BREAK(console, COMGETTER(Guest)(guest.asOutParam()));
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync CHECK_ERROR_BREAK(guest, SetCredentials(Bstr(a->argv[2]).raw(),
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync#if 0 /* TODO: review & remove */
8cb6f31c3048428b42c7370dfbb20e4de7254f40vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
3c9ed6defa3feca7e21adef4b5d1ba3002fc94c9vboxsync /* unmount? */
3c9ed6defa3feca7e21adef4b5d1ba3002fc94c9vboxsync /* nothing to do, NULL object will cause unmount */
3c9ed6defa3feca7e21adef4b5d1ba3002fc94c9vboxsync /* host drive? */
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync rc = host->FindHostDVDDrive(Bstr(a->argv[2] + 5), dvdMedium.asOutParam());
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorArgument("Invalid host DVD drive name \"%s\"",
3c9ed6defa3feca7e21adef4b5d1ba3002fc94c9vboxsync /* first assume it's a UUID */
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync rc = a->virtualBox->GetDVDImage(uuid, dvdMedium.asOutParam());
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync /* must be a filename, check if it's in the collection */
01df41f7a4e5f7de195a059541d1c89676da9673vboxsync rc = a->virtualBox->FindDVDImage(Bstr(a->argv[2]), dvdMedium.asOutParam());
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync /* not registered, do that on the fly */
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR(a->virtualBox, OpenDVDImage(Bstr(a->argv[2]), emptyUUID, dvdMedium.asOutParam()));
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync /** @todo generalize this, allow arbitrary number of DVD drives
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync * and as a consequence multiple attachments and different
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync * storage controllers. */
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync CHECK_ERROR(machine, MountMedium(Bstr("IDE Controller"), 1, 0, uuid, FALSE /* aForce */));
2dd7b4388106de88d20f33a8aa6c85c8babf507bvboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync /* unmount? */
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync /* nothing to do, NULL object will cause unmount */
5a07658d13590eba51dd98ef335a73d2a11edaa7vboxsync /* host drive? */
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync CHECK_ERROR(a->virtualBox, COMGETTER(Host)(host.asOutParam()));
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync host->FindHostFloppyDrive(Bstr(a->argv[2] + 5), floppyMedium.asOutParam());
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync errorArgument("Invalid host floppy drive name \"%s\"",
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync /* first assume it's a UUID */
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync rc = a->virtualBox->GetFloppyImage(uuid, floppyMedium.asOutParam());
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync /* must be a filename, check if it's in the collection */
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync rc = a->virtualBox->FindFloppyImage(Bstr(a->argv[2]), floppyMedium.asOutParam());
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync /* not registered, do that on the fly */
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync CHECK_ERROR(a->virtualBox, OpenFloppyImage(Bstr(a->argv[2]), emptyUUID, floppyMedium.asOutParam()));
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync CHECK_ERROR(machine, MountMedium(Bstr("Floppy Controller"), 0, 0, uuid, FALSE /* aForce */));
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync#endif /* obsolete dvdattach/floppyattach */
3a45119099f0df5230e8304145168aa5e2a3f1a1vboxsync else if (!strcmp(a->argv[1], "guestmemoryballoon"))
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync errorArgument("Error parsing guest memory balloon size '%s'", a->argv[2]);
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync /* guest is running; update IGuest */
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync rc = console->COMGETTER(Guest)(guest.asOutParam());
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync CHECK_ERROR(guest, COMSETTER(MemoryBalloonSize)(uVal));
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync { "--host", 'h', RTGETOPT_REQ_STRING }, /** @todo RTGETOPT_FLAG_MANDATORY */
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync { "--hostname", 'h', RTGETOPT_REQ_STRING }, /** @todo remove this */
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync { "--port", 'p', RTGETOPT_REQ_UINT32 }, /** @todo RTGETOPT_FLAG_MANDATORY */
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync { "--detailed-progress", 'D', RTGETOPT_REQ_NOTHING }
a8d502445ce722c6b9700c5579b4a38b58827b7dvboxsync RTGetOptInit(&GetOptState, a->argc, a->argv, s_aTeleportOptions, RT_ELEMENTS(s_aTeleportOptions), 2, RTGETOPTINIT_FLAGS_NO_STD_OPTS);
cb445170c831c6c56d2d82261e9193b66ceb98a7vboxsync CHECK_ERROR_BREAK(console, Teleport(bstrHostname.raw(), uPort,
cb445170c831c6c56d2d82261e9193b66ceb98a7vboxsync if (FAILED(rc) && rc != VBOX_E_INVALID_OBJECT_STATE)
cb445170c831c6c56d2d82261e9193b66ceb98a7vboxsync CHECK_ERROR_BREAK(progress, COMSETTER(Timeout)(cMsTimeout)); /* lazyness */
610972deee47d5e5229ccdb6c86cbb332d2b4626vboxsync RTMsgError("Teleportation failed. Error message: %lS", info.getText().raw());
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync RTMsgError("Teleportation failed. No error message available!");
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync errorSyntax(USAGE_CONTROLVM, "Invalid parameter '%s'", a->argv[1]);
8d1da51eb6665874aa82bf03668e03d1a0d63223vboxsync } while (0);