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