VBoxManage.cpp revision fd1c6920c47aa3e43853f6152b9502d68a0a4f66
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/** @file
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync *
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * VBox frontends: VBoxManage (command-line interface)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync *
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * VBoxManage is VirtualBox's command-line interface. This is its rather
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * long source.
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync/*
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * Copyright (C) 2006-2007 innotek GmbH
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync *
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * available from http://www.virtualbox.org. This file is free software;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * General Public License as published by the Free Software Foundation,
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync/*******************************************************************************
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync* Header Files *
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync*******************************************************************************/
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <VBox/com/com.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <VBox/com/string.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <VBox/com/Guid.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <VBox/com/ErrorInfo.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <VBox/com/EventQueue.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <VBox/com/VirtualBox.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#define CFGLDR_HAVE_COM
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync#include <VBox/cfgldr.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <stdlib.h>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <stdarg.h>
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <vector>
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync#include <iprt/runtime.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <iprt/stream.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <iprt/string.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <iprt/asm.h>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include <iprt/uuid.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/thread.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/path.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/param.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/dir.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/file.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <iprt/env.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <VBox/err.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <VBox/version.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync#include <VBox/VBoxHDD.h>
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#include "VBoxManage.h"
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsyncusing namespace com;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync/* missing XPCOM <-> COM wrappers */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#ifndef STDMETHOD_
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync# define STDMETHOD_(ret, meth) NS_IMETHOD_(ret) meth
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#endif
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#ifndef NS_GET_IID
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync# define NS_GET_IID(I) IID_##I
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#endif
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#ifndef RT_OS_WINDOWS
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#define IUnknown nsISupports
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/** command handler type */
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsynctypedef DECLCALLBACK(int) FNHANDLER(int argc, char *argv[], ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsynctypedef FNHANDLER *PFNHANDLER;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/**
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync * Quick IUSBDevice implementation for detaching / attaching
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync * devices to the USB Controller.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncclass MyUSBDevice : public IUSBDevice
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync{
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncpublic:
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync // public initializer/uninitializer for internal purposes only
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync MyUSBDevice(uint16_t a_u16VendorId, uint16_t a_u16ProductId, uint16_t a_bcdRevision, uint64_t a_u64SerialHash, const char *a_pszComment)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync : m_usVendorId(a_u16VendorId), m_usProductId(a_u16ProductId),
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync m_bcdRevision(a_bcdRevision), m_u64SerialHash(a_u64SerialHash),
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync m_bstrComment(a_pszComment),
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync m_cRefs(0)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync STDMETHOD_(ULONG, AddRef)(void)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync return ASMAtomicIncU32(&m_cRefs);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync STDMETHOD_(ULONG, Release)(void)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ULONG cRefs = ASMAtomicDecU32(&m_cRefs);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (!cRefs)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync delete this;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return cRefs;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync STDMETHOD(QueryInterface)(const IID &iid, void **ppvObject)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync Guid guid(iid);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (guid == Guid(NS_GET_IID(IUnknown)))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync *ppvObject = (IUnknown *)this;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync else if (guid == Guid(NS_GET_IID(IUSBDevice)))
0c94a8282c9042b02f022302a3d987746140eab9vboxsync *ppvObject = (IUSBDevice *)this;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync else
0c94a8282c9042b02f022302a3d987746140eab9vboxsync return E_NOINTERFACE;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync AddRef();
0c94a8282c9042b02f022302a3d987746140eab9vboxsync return S_OK;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync STDMETHOD(COMGETTER(Id))(GUIDPARAMOUT a_pId) { return E_NOTIMPL; }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync STDMETHOD(COMGETTER(VendorId))(USHORT *a_pusVendorId) { *a_pusVendorId = m_usVendorId; return S_OK; }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync STDMETHOD(COMGETTER(ProductId))(USHORT *a_pusProductId) { *a_pusProductId = m_usProductId; return S_OK; }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync STDMETHOD(COMGETTER(Revision))(USHORT *a_pusRevision) { *a_pusRevision = m_bcdRevision; return S_OK; }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync STDMETHOD(COMGETTER(SerialHash))(ULONG64 *a_pullSerialHash) { *a_pullSerialHash = m_u64SerialHash; return S_OK; }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync STDMETHOD(COMGETTER(Manufacturer))(BSTR *a_pManufacturer) { return E_NOTIMPL; }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync STDMETHOD(COMGETTER(Product))(BSTR *a_pProduct) { return E_NOTIMPL; }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync STDMETHOD(COMGETTER(SerialNumber))(BSTR *a_pSerialNumber) { return E_NOTIMPL; }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync STDMETHOD(COMGETTER(Address))(BSTR *a_pAddress) { return E_NOTIMPL; }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsyncprivate:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** The vendor id of this USB device. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync USHORT m_usVendorId;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /** The product id of this USB device. */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync USHORT m_usProductId;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /** The product revision number of this USB device.
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync * (high byte = integer; low byte = decimal) */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync USHORT m_bcdRevision;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** The USB serial hash of the device. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uint64_t m_u64SerialHash;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** The user comment string. */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr m_bstrComment;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** Reference counter. */
56970d3a1944c7c073d66266cd52449835221badvboxsync uint32_t volatile m_cRefs;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync};
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync// types
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync///////////////////////////////////////////////////////////////////////////////
56970d3a1944c7c073d66266cd52449835221badvboxsync
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsynctemplate <typename T>
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncclass Nullable
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync{
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncpublic:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Nullable() : mIsNull (true) {}
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Nullable (const T &aValue, bool aIsNull = false)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync : mIsNull (aIsNull), mValue (aValue) {}
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync bool isNull() const { return mIsNull; };
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync void setNull (bool aIsNull = true) { mIsNull = aIsNull; }
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync operator const T&() const { return mValue; }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Nullable &operator= (const T &aValue)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync mValue = aValue;
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync mIsNull = false;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return *this;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncprivate:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync bool mIsNull;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync T mValue;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync};
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync/** helper structure to encapsulate USB filter manipulation commands */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncstruct USBFilterCmd
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync{
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync struct USBFilter
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync {
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync USBFilter ()
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync : mAction (USBDeviceFilterAction_InvalidUSBDeviceFilterAction)
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync {}
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync Bstr mName;
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync Nullable <bool> mActive;
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync Bstr mVendorId;
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync Bstr mProductId;
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync Bstr mRevision;
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync Bstr mManufacturer;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr mProduct;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync Bstr mRemote;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync Bstr mSerialNumber;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync USBDeviceFilterAction_T mAction;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync };
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync enum Action { Invalid, Add, Modify, Remove };
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync USBFilterCmd() : mAction (Invalid), mIndex (0), mGlobal (false) {}
1969e98a26e5b56b67fbe3b6bfa007f8f09e86ebvboxsync
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync Action mAction;
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync ULONG mIndex;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** flag whether the command target is a global filter */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync bool mGlobal;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /** machine this command is targeted at (null for global filters) */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ComPtr<IMachine> mMachine;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync USBFilter mFilter;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync};
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync// funcs
0c94a8282c9042b02f022302a3d987746140eab9vboxsync///////////////////////////////////////////////////////////////////////////////
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsyncstatic void showLogo(void)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync{
0c94a8282c9042b02f022302a3d987746140eab9vboxsync static bool fShown; /* show only once */
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (!fShown)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("VirtualBox Command Line Management Interface Version "
0c94a8282c9042b02f022302a3d987746140eab9vboxsync VBOX_VERSION_STRING "\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync "(C) 2005-2007 innotek GmbH\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync "All rights reserved.\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync "\n");
0c94a8282c9042b02f022302a3d987746140eab9vboxsync fShown = true;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync}
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsyncstatic void printUsage(USAGECATEGORY u64Cmd)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync{
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#ifdef RT_OS_LINUX
0c94a8282c9042b02f022302a3d987746140eab9vboxsync bool fLinux = true;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#else
0c94a8282c9042b02f022302a3d987746140eab9vboxsync bool fLinux = false;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#endif
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#ifdef RT_OS_WINDOWS
0c94a8282c9042b02f022302a3d987746140eab9vboxsync bool fWin = true;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#else
0c94a8282c9042b02f022302a3d987746140eab9vboxsync bool fWin = false;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync#endif
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#ifdef RT_OS_DARWIN
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync bool fDarwin = true;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#else
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync bool fDarwin = false;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#endif
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#ifdef VBOX_VRDP
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync bool fVRDP = true;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#else
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync bool fVRDP = false;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync#endif
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (u64Cmd == USAGE_DUMPOPTS)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync fLinux = true;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync fWin = true;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync fVRDP = true;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync u64Cmd = USAGE_ALL;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("Usage:\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync "\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (u64Cmd == USAGE_ALL)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage [-v|-version] print version number and exit\n");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage -nologo ... suppress the logo\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync "\n");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (u64Cmd & USAGE_LIST)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage list vms|ostypes|hostdvds|hostfloppies|");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (fWin)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf( "hostifs|");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf( "\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " hdds|dvds|floppies|usbhost|usbfilters|\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " systemproperties\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync "\n");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (u64Cmd & USAGE_SHOWVMINFO)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage showvminfo <uuid>|<name>\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-details]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-statistics]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-machinereadable]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync "\n");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (u64Cmd & USAGE_REGISTERVM)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage registervm <filename>\n"
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync "\n");
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (u64Cmd & USAGE_UNREGISTERVM)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage unregistervm <uuid>|<name>\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-delete]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync "\n");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
56970d3a1944c7c073d66266cd52449835221badvboxsync if (u64Cmd & USAGE_CREATEVM)
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync {
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync RTPrintf("VBoxManage createvm -name <name>\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " [-register]\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " [-basefolder <path> | -settingsfile <path>]\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " \n"
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync "\n");
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync }
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync if (u64Cmd & USAGE_MODIFYVM)
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage modifyvm <uuid|name>\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-name <name>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-ostype <ostype>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-memory <memorysize>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-vram <vramsize>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-acpi on|off]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-ioapic on|off]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-hwvirtex on|off|default]\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " [-monitorcount <number>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-bioslogofadein on|off]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-bioslogofadeout on|off]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-bioslogodisplaytime <msec>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-bioslogoimagepath <imagepath>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-biosbootmenu disabled|menuonly|messageandmenu]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-biossystemtimeoffset <msec>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-biospxedebug on|off]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-boot<1-4> none|floppy|dvd|disk|net>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-hd<a|b|d> none|<uuid>|<filename>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-dvd none|<uuid>|<filename>|host:<drive>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-dvdpassthrough on|off]\n"
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync " [-floppy disabled|empty|<uuid>|\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " <filename>|host:<drive>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-nic<1-N> none|null|nat|hostif|intnet]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-nictype<1-N> Am79C970A|Am79C973]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-cableconnected<1-N> on|off]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-nictrace<1-N> on|off]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-nictracefile<1-N> <filename>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-nicspeed<1-N> <kbps>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-hostifdev<1-N> none|<devicename>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-intnet<1-N> <network>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-macaddress<1-N> auto|<mac>]\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync " [-uart<1-N> off|<I/O base> <IRQ>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-uartmode<1-N> disconnected|\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync " server <pipe>|\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync " client <pipe>|\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " <devicename>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-guestmemoryballoon <balloonsize>]\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " [-gueststatisticsinterval <seconds>]\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync );
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (fLinux)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf(" [-tapsetup<1-N> none|<application>]\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync " [-tapterminate<1-N> none|<application>]\n");
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf(" [-audio none|null");
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (fWin)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync#ifdef VBOX_WITH_WINMM
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf( "|winmm|dsound");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf( "|dsound");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (fLinux)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf( "|oss"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#ifdef VBOX_WITH_ALSA
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync "|alsa"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync#endif
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync );
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (fDarwin)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf( "|coreaudio");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf( "]\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf(" [-clipboard disabled|hosttoguest|guesttohost|\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " bidirectional]\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (fVRDP)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf(" [-vrdp on|off]\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " [-vrdpport default|<port>]\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " [-vrdpaddress <host>]\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " [-vrdpauthtype null|external|guest]\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " [-vrdpmulticon on|off]\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf(" [-usb on|off]\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " [-snapshotfolder default|<path>]\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync "\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (u64Cmd & USAGE_STARTVM)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("VBoxManage startvm <uuid>|<name>\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " [-type gui|vrdp]\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync "\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (u64Cmd & USAGE_CONTROLVM)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("VBoxManage controlvm <uuid>|<name>\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " pause|resume|reset|poweroff|savestate|\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " acpipowerbutton |\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " setlinkstate<1-4> on|off |\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " usbattach <uuid>|<address> |\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " usbdetach <uuid>|<address> |\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " dvdattach none|<uuid>|<filename>|host:<drive> |\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " floppyattach none|<uuid>|<filename>|host:<drive> |\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " setvideomodehint <xres> <yres> <bpp> [display]|\n"
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync " setcredentials <username> <password> <domain>\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " [-allowlocallogon <yes|no>]\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync "\n");
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (u64Cmd & USAGE_DISCARDSTATE)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("VBoxManage discardstate <uuid>|<name>\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync "\n");
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (u64Cmd & USAGE_SNAPSHOT)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("VBoxManage snapshot <uuid>|<name>\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync " take <name> [-desc <desc>] |\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync " discard <uuid>|<name> |\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync " discardcurrent -state|-all |\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " edit <uuid>|<name>|-current\n"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync " [-newname <name>]\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync " [-newdesc <desc>] |\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync " showvminfo <uuid>|<name>\n"
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync "\n");
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (u64Cmd & USAGE_REGISTERIMAGE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("VBoxManage registerimage disk|dvd|floppy <filename>\n"
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync " [-type normal|immutable|writethrough] (disk only)\n"
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync "\n");
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (u64Cmd & USAGE_UNREGISTERIMAGE)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTPrintf("VBoxManage unregisterimage disk|dvd|floppy <uuid>|<filename>\n"
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync "\n");
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (u64Cmd & USAGE_SHOWVDIINFO)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage showvdiinfo <uuid>|<filename>\n"
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync "\n");
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync }
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync if (u64Cmd & USAGE_CREATEVDI)
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage createvdi -filename <filename>\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " -size <megabytes>\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " [-static]\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " [-comment <comment>]\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " [-register]\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " [-type normal|writethrough] (default: normal)\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync "\n");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (u64Cmd & USAGE_MODIFYVDI)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync RTPrintf("VBoxManage modifyvdi <uuid>|<filename>\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync#if 0 /* doesn't currently work */
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " settype normal|writethrough|immutable |\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync#endif
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " compact\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync "\n");
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync }
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync if (u64Cmd & USAGE_CLONEVDI)
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync {
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync RTPrintf("VBoxManage clonevdi <uuid>|<filename> <outputfile>\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync "\n");
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync }
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync if (u64Cmd & USAGE_CONVERTDD)
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync {
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync RTPrintf("VBoxManage convertdd <filename> <outputfile>\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync "VBoxManage convertdd stdin <outputfile> <bytes>\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync "\n");
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync }
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync if (u64Cmd & USAGE_ADDISCSIDISK)
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync {
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync RTPrintf("VBoxManage addiscsidisk -server <name>|<ip>\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " -target <target>\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " [-port <port>]\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " [-lun <lun>]\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " [-encodedlun <lun>]\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " [-username <username>]\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " [-password <password>]\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " [-comment <comment>]\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync "\n");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync if (u64Cmd & USAGE_CREATEHOSTIF && fWin)
1379dfd407ada5fab15655776896f13b61a951fdvboxsync {
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync RTPrintf("VBoxManage createhostif <name>\n"
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync "\n");
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync }
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync
1379dfd407ada5fab15655776896f13b61a951fdvboxsync if (u64Cmd & USAGE_REMOVEHOSTIF && fWin)
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync {
f9cdd92d151d9c28eb0f1aed25863fc04f85691dvboxsync RTPrintf("VBoxManage removehostif <uuid>|<name>\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync "\n");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (u64Cmd & USAGE_GETEXTRADATA)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf("VBoxManage getextradata global|<uuid>|<name>\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " <key>|enumerate\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync "\n");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
1379dfd407ada5fab15655776896f13b61a951fdvboxsync
1379dfd407ada5fab15655776896f13b61a951fdvboxsync if (u64Cmd & USAGE_SETEXTRADATA)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf("VBoxManage setextradata global|<uuid>|<name>\n"
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync " <key>\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " [<value>] (no value deletes key)\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync "\n");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (u64Cmd & USAGE_SETPROPERTY)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync RTPrintf("VBoxManage setproperty vdifolder default|<folder> |\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " machinefolder default|<folder> |\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " vrdpauthlibrary default|<library> |\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " hwvirtexenabled yes|no\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " loghistorycount <value>\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync "\n");
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (u64Cmd & USAGE_USBFILTER_ADD)
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf("VBoxManage usbfilter add <index,0-N>\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " -target <uuid>|<name>|global\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " -name <string>\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " -action ignore|hold (global filters only)\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-active yes|no] (yes)\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-vendorid <XXXX>] (null)\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-productid <XXXX>] (null)\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " [-revision <IIFF>] (null)\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " [-manufacturer <string>] (null)\n"
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync " [-product <string>] (null)\n"
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync " [-remote yes|no] (null, VM filters only)\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-serialnumber <string>] (null)\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync "\n");
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync }
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync if (u64Cmd & USAGE_USBFILTER_MODIFY)
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf("VBoxManage usbfilter modify <index,0-N>\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " -target <uuid>|<name>|global\n"
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync " [-name <string>]\n"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync " [-action ignore|hold] (global filters only)\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-active yes|no]\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-vendorid <XXXX>|\"\"]\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-productid <XXXX>|\"\"]\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-revision <IIFF>|\"\"]\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-manufacturer <string>|\"\"]\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-product <string>|\"\"]\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync " [-remote yes|no] (null, VM filters only)\n"
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync " [-serialnumber <string>|\"\"]\n"
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync "\n");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (u64Cmd & USAGE_USBFILTER_REMOVE)
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf("VBoxManage usbfilter remove <index,0-N>\n"
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync " -target <uuid>|<name>|global\n"
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync "\n");
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync }
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync if (u64Cmd & USAGE_SHAREDFOLDER_ADD)
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync {
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync RTPrintf("VBoxManage sharedfolder add <vmname>|<uuid>\n"
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync " -name <name> -hostpath <hostpath>\n"
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync " [-transient]\n"
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync "\n");
a66ec044d2a64d926996cd24da5faadccb070be3vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (u64Cmd & USAGE_SHAREDFOLDER_REMOVE)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage sharedfolder remove <vmname>|<uuid>\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " -name <name> [-transient]\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync "\n");
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (u64Cmd & USAGE_UPDATESETTINGS)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync RTPrintf("VBoxManage updatesettings [<dir>|<file>] [-apply]\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync " [-nobackup] [-skipinvalid]\n"
0c94a8282c9042b02f022302a3d987746140eab9vboxsync "\n");
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (u64Cmd & USAGE_VM_STATISTICS)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("VBoxManage vmstatistics <vmname>|<uuid>\n"
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync " [-pattern <pattern>] [-descriptions]\n"
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync "\n");
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync/**
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync * Print a usage synopsis and the syntax error message.
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncint errorSyntax(USAGECATEGORY u64Cmd, const char *pszFormat, ...)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync va_list args;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync showLogo(); // show logo even if suppressed
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (g_fInternalMode)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync printUsageInternal(u64Cmd);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync else
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync printUsage(u64Cmd);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync va_start(args, pszFormat);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("\n"
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync "Syntax error: %N\n", pszFormat, &args);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync va_end(args);
20f21077abf35d7b7b618acb159267933907407fvboxsync return 1;
20f21077abf35d7b7b618acb159267933907407fvboxsync}
20f21077abf35d7b7b618acb159267933907407fvboxsync
0d8c2135d15345cc68111eea91052cdf5518d7e3vboxsync/**
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * Print an error message without the syntax stuff.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncint errorArgument(const char *pszFormat, ...)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync{
20f21077abf35d7b7b618acb159267933907407fvboxsync va_list args;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync va_start(args, pszFormat);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("error: %N\n", pszFormat, &args);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync va_end(args);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync return 1;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync}
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync/**
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * Print out progress on the console
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncstatic void showProgress(ComPtr<IProgress> progress)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync BOOL fCompleted;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync LONG currentPercent, lastPercent = 0;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("0%%...");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTStrmFlush(g_pStdOut);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted))))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync progress->COMGETTER(Percent(&currentPercent));
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /* did we cross a 10% mark? */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (((currentPercent / 10) > (lastPercent / 10)))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /* make sure to also print out missed steps */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync for (LONG curVal = (lastPercent / 10) * 10 + 10; curVal <= (currentPercent / 10) * 10; curVal += 10)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (curVal < 100)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("%ld%%...", curVal);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTStrmFlush(g_pStdOut);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync lastPercent = currentPercent;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (fCompleted)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTPrintf("100%%\n");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTStrmFlush(g_pStdOut);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync break;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /* make sure the loop is not too tight */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTThreadSleep(100);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync}
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsyncstatic void showSnapshots(ComPtr<ISnapshot> rootSnapshot, VMINFO_DETAILS details, const Bstr &prefix = "", int level = 0)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync{
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /* start with the root */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync Bstr name;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync Guid uuid;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync rootSnapshot->COMGETTER(Name)(name.asOutParam());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync rootSnapshot->COMGETTER(Id)(uuid.asOutParam());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (details == VMINFO_MACHINEREADABLE)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /* print with hierarchical numbering */
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTPrintf("SnapshotName%lS=\"%lS\"\n", prefix.raw(), name.raw());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("SnapshotUUID%lS=\"%s\"\n", prefix.raw(), uuid.toString().raw());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /* print with indentation */
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf(" %lSName: %lS (UUID: %s)\n", prefix.raw(), name.raw(), uuid.toString().raw());
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync /* get the children */
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync ComPtr<ISnapshotCollection> coll;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync rootSnapshot->COMGETTER(Children)(coll.asOutParam());
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (coll)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ComPtr<ISnapshotEnumerator> enumerator;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync coll->Enumerate(enumerator.asOutParam());
20f21077abf35d7b7b618acb159267933907407fvboxsync ULONG index = 0;
20f21077abf35d7b7b618acb159267933907407fvboxsync BOOL hasMore = FALSE;
20f21077abf35d7b7b618acb159267933907407fvboxsync while (enumerator->HasMore(&hasMore), hasMore)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ComPtr<ISnapshot> snapshot;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync enumerator->GetNext(snapshot.asOutParam());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (snapshot)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync Bstr newPrefix;
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (details == VMINFO_MACHINEREADABLE)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync newPrefix = Utf8StrFmt("%lS-%d", prefix.raw(), index + 1);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync else
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync newPrefix = Utf8StrFmt("%lS ", prefix.raw());
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync /* recursive call */
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync showSnapshots(snapshot, details, newPrefix, level + 1);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync index++;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync}
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsyncstatic void makeTimeStr (char *s, int cb, int64_t millies)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTTIME t;
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTTIMESPEC ts;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTTimeSpecSetMilli(&ts, millies);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTTimeExplode (&t, &ts);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTStrPrintf(s, cb, "%04d/%02d/%02d %02d:%02d:%02d UTC",
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync t.i32Year, t.u8Month, t.u8MonthDay,
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync t.u8Hour, t.u8Minute, t.u8Second);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync}
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsyncstatic HRESULT showVMInfo (ComPtr <IVirtualBox> virtualBox, ComPtr<IMachine> machine,
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync ComPtr <IConsole> console = ComPtr <IConsole> (),
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync VMINFO_DETAILS details = VMINFO_NONE)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync{
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync HRESULT rc;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync /*
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * The rules for output in -argdump format:
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * 1) the key part (the [0-9a-zA-Z_]+ string before the '=' delimiter)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync * is all lowercase for "VBoxManage modifyvm" parameters. Any
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * other values printed are in CamelCase.
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * 2) strings (anything non-decimal) are printed surrounded by
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync * double quotes '"'. If the strings themselves contain double
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync * quotes, these characters are escaped by '\'. Any '\' character
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync * in the original string is also escaped by '\'.
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync * 3) numbers (containing just [0-9\-]) are written out unchanged.
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync */
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync /** @todo the quoting is not yet implemented! */
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync BOOL accessible = FALSE;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync CHECK_ERROR (machine, COMGETTER(Accessible) (&accessible));
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync CheckComRCReturnRC (rc);
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (!accessible)
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (details == VMINFO_MACHINEREADABLE)
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf("name=\"<inaccessible>\"\n");
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync else
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf ("Name: <inaccessible!>\n");
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync Guid uuid;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync rc = machine->COMGETTER(Id) (uuid.asOutParam());
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (details == VMINFO_MACHINEREADABLE)
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf ("UUID=\"%s\"\n", uuid.toString().raw());
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync else
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf ("UUID: %s\n", uuid.toString().raw());
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync if (details != VMINFO_MACHINEREADABLE)
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync Bstr settingsFilePath;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync rc = machine->COMGETTER(SettingsFilePath) (settingsFilePath.asOutParam());
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf ("Config file: %lS\n", settingsFilePath.raw());
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync ComPtr<IVirtualBoxErrorInfo> accessError;
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync rc = machine->COMGETTER(AccessError) (accessError.asOutParam());
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync RTPrintf ("Access error details:\n");
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync ErrorInfo ei (accessError);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync ei.print ("[-] ");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf ("\n");
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
9b1d52365befbce1af8f32d53c2e563ee9169501vboxsync return S_OK;
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync Bstr machineName;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync rc = machine->COMGETTER(Name)(machineName.asOutParam());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (details == VMINFO_MACHINEREADABLE)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("name=\"%lS\"\n", machineName.raw());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync RTPrintf("Name: %lS\n", machineName.raw());
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync
9b1d52365befbce1af8f32d53c2e563ee9169501vboxsync Bstr osTypeId;
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync rc = machine->COMGETTER(OSTypeId)(osTypeId.asOutParam());
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync ComPtr<IGuestOSType> osType;
9b1d52365befbce1af8f32d53c2e563ee9169501vboxsync rc = virtualBox->GetGuestOSType (osTypeId, osType.asOutParam());
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync Bstr osName;
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync rc = osType->COMGETTER(Description)(osName.asOutParam());
9b1d52365befbce1af8f32d53c2e563ee9169501vboxsync if (details == VMINFO_MACHINEREADABLE)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("ostype=\"%lS\"\n", osTypeId.raw());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("Guest OS: %lS\n", osName.raw());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync Guid uuid;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync rc = machine->COMGETTER(Id)(uuid.asOutParam());
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (details == VMINFO_MACHINEREADABLE)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync RTPrintf("UUID=\"%s\"\n", uuid.toString().raw());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("UUID: %s\n", uuid.toString().raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync Bstr settingsFilePath;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync rc = machine->COMGETTER(SettingsFilePath)(settingsFilePath.asOutParam());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (details == VMINFO_MACHINEREADABLE)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("CfgFile=\"%lS\"\n", settingsFilePath.raw());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("Config file: %lS\n", settingsFilePath.raw());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync ULONG memorySize;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync rc = machine->COMGETTER(MemorySize)(&memorySize);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (details == VMINFO_MACHINEREADABLE)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("memory=%u\n", memorySize);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("Memory size: %uMB\n", memorySize);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync ULONG vramSize;
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync rc = machine->COMGETTER(VRAMSize)(&vramSize);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (details == VMINFO_MACHINEREADABLE)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("vram=%u\n", vramSize);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("VRAM size: %uMB\n", vramSize);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync ComPtr <IBIOSSettings> biosSettings;
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync BIOSBootMenuMode_T bootMenuMode;
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync biosSettings->COMGETTER(BootMenuMode)(&bootMenuMode);
2346cab03e0c9fba1765c8e21ef98f03c8564cd8vboxsync const char *pszBootMenu = NULL;
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync switch (bootMenuMode)
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync {
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync case BIOSBootMenuMode_Disabled:
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync pszBootMenu = "disabled";
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync break;
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync case BIOSBootMenuMode_MenuOnly:
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync if (details == VMINFO_MACHINEREADABLE)
76f3a3817b6b96f5beb30b76efebdf2d87090cf0vboxsync pszBootMenu = "menuonly";
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync else
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync pszBootMenu = "menu only";
a655881be920ead6948994168c5ee09e5798aa05vboxsync break;
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync default:
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync if (details == VMINFO_MACHINEREADABLE)
8865793e4f3435f5e2c728d9e6739cd24d08c0devboxsync pszBootMenu = "messageandmenu";
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync pszBootMenu = "message and menu";
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync if (details == VMINFO_MACHINEREADABLE)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("bootmenu=\"%s\"\n", pszBootMenu);
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync else
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("Boot menu mode: %s\n", pszBootMenu);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL acpiEnabled;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync biosSettings->COMGETTER(ACPIEnabled)(&acpiEnabled);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("acpi=\"%s\"\n", acpiEnabled ? "on" : "off");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("ACPI: %s\n", acpiEnabled ? "on" : "off");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL ioapicEnabled;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync biosSettings->COMGETTER(IOAPICEnabled)(&ioapicEnabled);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("ioapic=\"%s\"\n", ioapicEnabled ? "on" : "off");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("IOAPIC: %s\n", ioapicEnabled ? "on" : "off");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync LONG64 timeOffset;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync biosSettings->COMGETTER(TimeOffset)(&timeOffset);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("biossystemtimeoffset=%lld\n", timeOffset);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Time offset: %lld ms\n", timeOffset);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync TriStateBool_T hwVirtExEnabled;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync machine->COMGETTER(HWVirtExEnabled)(&hwVirtExEnabled);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (hwVirtExEnabled == TriStateBool_Default)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync BOOL fHWVirtExEnabled;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync ComPtr<ISystemProperties> systemProperties;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync systemProperties->COMGETTER(HWVirtExEnabled)(&fHWVirtExEnabled);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (details == VMINFO_MACHINEREADABLE)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTPrintf("hwvirtex=\"default\"\n");
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTPrintf("Hardw. virt.ext: Default (%s)\n", fHWVirtExEnabled ? "on" : "off");
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (details == VMINFO_MACHINEREADABLE)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTPrintf("hwvirtex=\"%s\"\n", hwVirtExEnabled == TriStateBool_True ? "on" : "off");
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTPrintf("Hardw. virt.ext: %s\n", hwVirtExEnabled == TriStateBool_True ? "on" : "off");
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync MachineState_T machineState;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync const char *pszState = NULL;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync rc = machine->COMGETTER(State)(&machineState);
56970d3a1944c7c073d66266cd52449835221badvboxsync switch (machineState)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync case MachineState_PoweredOff:
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details == VMINFO_MACHINEREADABLE)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync pszState = "poweroff";
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync pszState = "powered off";
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case MachineState_Saved:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszState = "saved";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case MachineState_Aborted:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszState = "aborted";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case MachineState_Running:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszState = "running";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case MachineState_Paused:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszState = "paused";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case MachineState_Starting:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszState = "starting";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case MachineState_Stopping:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszState = "stopping";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case MachineState_Saving:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszState = "saving";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case MachineState_Restoring:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszState = "restoring";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync default:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszState = "unknown";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync LONG64 stateSince;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync machine->COMGETTER(LastStateChange)(&stateSince);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTTIMESPEC timeSpec;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTTimeSpecSetMilli(&timeSpec, stateSince);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync char pszTime[30] = {0};
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTTimeSpecToString(&timeSpec, pszTime, 30);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (details == VMINFO_MACHINEREADABLE)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("VMState=\"%s\"\n", pszState);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("VMStateChangeTime=\"%s\"\n", pszTime);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync RTPrintf("State: %s (since %s)\n", pszState, pszTime);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync ULONG numMonitors;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync machine->COMGETTER(MonitorCount)(&numMonitors);
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync if (details == VMINFO_MACHINEREADABLE)
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync RTPrintf("monitorcount=%d\n", numMonitors);
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync else
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync RTPrintf("Monitor count: %d\n", numMonitors);
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync ComPtr<IFloppyDrive> floppyDrive;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync rc = machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (SUCCEEDED(rc) && floppyDrive)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync BOOL fFloppyEnabled;
56970d3a1944c7c073d66266cd52449835221badvboxsync floppyDrive->COMGETTER(Enabled)(&fFloppyEnabled);
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync Utf8Str pszFloppy = "invalid";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (fFloppyEnabled)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync DriveState_T floppyState;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync floppyDrive->COMGETTER(State)(&floppyState);
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync switch (floppyState)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case DriveState_ImageMounted:
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync ComPtr<IFloppyImage> floppyImage;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync rc = floppyDrive->GetImage(floppyImage.asOutParam());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (SUCCEEDED(rc) && floppyImage)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync Bstr imagePath;
2d66abeefb9716ed570bb5714884d3fe08629452vboxsync floppyImage->COMGETTER(FilePath)(imagePath.asOutParam());
2d66abeefb9716ed570bb5714884d3fe08629452vboxsync Guid imageGuid;
2d66abeefb9716ed570bb5714884d3fe08629452vboxsync floppyImage->COMGETTER(Id)(imageGuid.asOutParam());
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (details == VMINFO_MACHINEREADABLE)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync RTPrintf("FloppyImageUUID=\"%s\"\n", imageGuid.toString().raw());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszFloppy = Utf8StrFmt("%lS", imagePath.raw());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszFloppy = Utf8StrFmt("%lS (UUID: %s)", imagePath.raw(), imageGuid.toString().raw());
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync case DriveState_HostDriveCaptured:
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync ComPtr<IHostFloppyDrive> hostFloppyDrive;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync rc = floppyDrive->GetHostDrive(hostFloppyDrive.asOutParam());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (SUCCEEDED(rc) && floppyDrive)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync Bstr driveName;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync hostFloppyDrive->COMGETTER(Name)(driveName.asOutParam());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (details == VMINFO_MACHINEREADABLE)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszFloppy = Utf8StrFmt("host:%lS", driveName.raw());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync pszFloppy = Utf8StrFmt("Host drive %lS", driveName.raw());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync break;
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync case DriveState_NotMounted:
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
23d8f7aff045c2bade1b168fee79a3e4749e2345vboxsync pszFloppy = "empty";
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync break;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync pszFloppy = "disabled";
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync if (details == VMINFO_MACHINEREADABLE)
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("floppy=\"%s\"\n", pszFloppy.raw());
e70bda5438c3582164d26f171a8bc8d3d7da1e12vboxsync else
e70bda5438c3582164d26f171a8bc8d3d7da1e12vboxsync RTPrintf("Floppy: %s\n", pszFloppy.raw());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync ComPtr<IHardDisk> hardDisk;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync Bstr filePath;
20f21077abf35d7b7b618acb159267933907407fvboxsync rc = machine->GetHardDisk(DiskControllerType_IDE0Controller, 0, hardDisk.asOutParam());
20f21077abf35d7b7b618acb159267933907407fvboxsync if (SUCCEEDED(rc) && hardDisk)
20f21077abf35d7b7b618acb159267933907407fvboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /// @todo (dmik) we temporarily use the location property to
20f21077abf35d7b7b618acb159267933907407fvboxsync // determine the image file name. This is subject to change
20f21077abf35d7b7b618acb159267933907407fvboxsync // when iSCSI disks are here (we should either query a
20f21077abf35d7b7b618acb159267933907407fvboxsync // storage-specific interface from IHardDisk, or "standardize"
20f21077abf35d7b7b618acb159267933907407fvboxsync // the location property)
20f21077abf35d7b7b618acb159267933907407fvboxsync hardDisk->COMGETTER(Location)(filePath.asOutParam());
20f21077abf35d7b7b618acb159267933907407fvboxsync hardDisk->COMGETTER(Id)(uuid.asOutParam());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details == VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("hda=\"%lS\"\n", filePath.raw());
c66c4413faa5a72ce047742f9acfa85e94dec8afvboxsync RTPrintf("HdaImageUUID=\"%s\"\n", uuid.toString().raw());
e70bda5438c3582164d26f171a8bc8d3d7da1e12vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync RTPrintf("Primary master: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync else
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (details == VMINFO_MACHINEREADABLE)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync RTPrintf("hda=\"none\"\n");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync rc = machine->GetHardDisk(DiskControllerType_IDE0Controller, 1, hardDisk.asOutParam());
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (SUCCEEDED(rc) && hardDisk)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync /// @todo (dmik) we temporarily use the location property to
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync // determine the image file name. This is subject to change
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync // when iSCSI disks are here (we should either query a
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync // storage-specific interface from IHardDisk, or "standardize"
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync // the location property)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync hardDisk->COMGETTER(Location)(filePath.asOutParam());
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync hardDisk->COMGETTER(Id)(uuid.asOutParam());
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (details == VMINFO_MACHINEREADABLE)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync RTPrintf("hdb=\"%lS\"\n", filePath.raw());
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync RTPrintf("HdbImageUUID=\"%s\"\n", uuid.toString().raw());
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync else
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync RTPrintf("Primary slave: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync else
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync {
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (details == VMINFO_MACHINEREADABLE)
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync RTPrintf("hdb=\"none\"\n");
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync }
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync rc = machine->GetHardDisk(DiskControllerType_IDE1Controller, 1, hardDisk.asOutParam());
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync if (SUCCEEDED(rc) && hardDisk)
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync {
66b58af085e22ee26be57f98127fb49ee2e91790vboxsync /// @todo (dmik) we temporarily use the location property to
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync // determine the image file name. This is subject to change
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync // when iSCSI disks are here (we should either query a
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync // storage-specific interface from IHardDisk, or "standardize"
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync // the location property)
56970d3a1944c7c073d66266cd52449835221badvboxsync hardDisk->COMGETTER(Location)(filePath.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync hardDisk->COMGETTER(Id)(uuid.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("hdd=\"%lS\"\n", filePath.raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("HddImageUUID=\"%s\"\n", uuid.toString().raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("Secondary slave: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("hdd=\"none\"\n");
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync ComPtr<IDVDDrive> dvdDrive;
56970d3a1944c7c073d66266cd52449835221badvboxsync rc = machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (SUCCEEDED(rc) && dvdDrive)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync ComPtr<IDVDImage> dvdImage;
56970d3a1944c7c073d66266cd52449835221badvboxsync rc = dvdDrive->GetImage(dvdImage.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (SUCCEEDED(rc) && dvdImage)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync rc = dvdImage->COMGETTER(FilePath)(filePath.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (SUCCEEDED(rc) && filePath)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync rc = dvdImage->COMGETTER(Id)(uuid.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("dvd=\"%lS\"\n", filePath.raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("DvdImageUUID=\"%s\"\n", uuid.toString().raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("DVD: %lS (UUID: %s)\n", filePath.raw(), uuid.toString().raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync ComPtr<IHostDVDDrive> hostDVDDrive;
56970d3a1944c7c073d66266cd52449835221badvboxsync rc = dvdDrive->GetHostDrive(hostDVDDrive.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (SUCCEEDED(rc) && hostDVDDrive)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync Bstr name;
56970d3a1944c7c073d66266cd52449835221badvboxsync hostDVDDrive->COMGETTER(Name)(name.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("dvd=\"host:%lS\"\n", name.raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("DVD: Host drive %lS", name.raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("dvd=\"none\"\n");
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("DVD: empty");
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync BOOL fPassthrough;
56970d3a1944c7c073d66266cd52449835221badvboxsync dvdDrive->COMGETTER(Passthrough)(&fPassthrough);
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("dvdpassthrough=\"%s\"\n", fPassthrough ? "on" : "off");
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync if (fPassthrough)
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf(" (passthrough enabled)");
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("\n");
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync
56970d3a1944c7c073d66266cd52449835221badvboxsync /* get the maximum amount of NICS */
56970d3a1944c7c073d66266cd52449835221badvboxsync ComPtr<ISystemProperties> sysProps;
56970d3a1944c7c073d66266cd52449835221badvboxsync virtualBox->COMGETTER(SystemProperties)(sysProps.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync ULONG maxNICs = 0;
56970d3a1944c7c073d66266cd52449835221badvboxsync sysProps->COMGETTER(NetworkAdapterCount)(&maxNICs);
56970d3a1944c7c073d66266cd52449835221badvboxsync for (ULONG currentNIC = 0; currentNIC < maxNICs; currentNIC++)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync ComPtr<INetworkAdapter> nic;
56970d3a1944c7c073d66266cd52449835221badvboxsync rc = machine->GetNetworkAdapter(currentNIC, nic.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (SUCCEEDED(rc) && nic)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync BOOL fEnabled;
56970d3a1944c7c073d66266cd52449835221badvboxsync nic->COMGETTER(Enabled)(&fEnabled);
56970d3a1944c7c073d66266cd52449835221badvboxsync if (!fEnabled)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("nic%d=\"none\"\n", currentNIC + 1);
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("NIC %d: disabled\n", currentNIC + 1);
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync Bstr strMACAddress;
56970d3a1944c7c073d66266cd52449835221badvboxsync nic->COMGETTER(MACAddress)(strMACAddress.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync Utf8Str strAttachment;
56970d3a1944c7c073d66266cd52449835221badvboxsync NetworkAttachmentType_T attachment;
56970d3a1944c7c073d66266cd52449835221badvboxsync nic->COMGETTER(AttachmentType)(&attachment);
56970d3a1944c7c073d66266cd52449835221badvboxsync switch (attachment)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync case NetworkAttachmentType_NoNetworkAttachment:
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync strAttachment = "null";
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync strAttachment = "none";
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync case NetworkAttachmentType_NATNetworkAttachment:
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync strAttachment = "nat";
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync strAttachment = "NAT";
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync case NetworkAttachmentType_HostInterfaceNetworkAttachment:
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync Bstr strHostIfDev;
56970d3a1944c7c073d66266cd52449835221badvboxsync nic->COMGETTER(HostInterface)(strHostIfDev.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("hostifdev%d=\"%lS\"\n", currentNIC + 1, strHostIfDev.raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync strAttachment = "hostif";
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync strAttachment = Utf8StrFmt("Host Interface '%lS'", strHostIfDev.raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync case NetworkAttachmentType_InternalNetworkAttachment:
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync Bstr strNetwork;
56970d3a1944c7c073d66266cd52449835221badvboxsync nic->COMGETTER(InternalNetwork)(strNetwork.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("intnet%d=\"%lS\"\n", currentNIC + 1, strNetwork.raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync strAttachment = "intnet";
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync strAttachment = Utf8StrFmt("Internal Network '%s'", Utf8Str(strNetwork).raw());
56970d3a1944c7c073d66266cd52449835221badvboxsync break;
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync default:
56970d3a1944c7c073d66266cd52449835221badvboxsync strAttachment = "unknown";
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* cable connected */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fConnected;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync nic->COMGETTER(CableConnected)(&fConnected);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* trace stuff */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fTraceEnabled;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync nic->COMGETTER(TraceEnabled)(&fTraceEnabled);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr traceFile;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync nic->COMGETTER(TraceFile)(traceFile.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* NIC type */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Utf8Str strNICType;
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync NetworkAdapterType_T NICType;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync nic->COMGETTER(AdapterType)(&NICType);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync switch (NICType) {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case NetworkAdapterType_NetworkAdapterAm79C970A:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync strNICType = "Am79C970A";
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case NetworkAdapterType_NetworkAdapterAm79C973:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync strNICType = "Am79C973";
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync default:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync strNICType = "unknown";
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* reported line speed */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG ulLineSpeed;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync nic->COMGETTER(LineSpeed)(&ulLineSpeed);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (details == VMINFO_MACHINEREADABLE)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync RTPrintf("macaddress%d=\"%lS\"\n", currentNIC + 1, strMACAddress.raw());
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync RTPrintf("cableconnected%d=\"%s\"\n", currentNIC + 1, fConnected ? "on" : "off");
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync RTPrintf("nic%d=\"%s\"\n", currentNIC + 1, strAttachment.raw());
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync RTPrintf("NIC %d: MAC: %lS, Attachment: %s, Cable connected: %s, Trace: %s (file: %lS), Type: %s, Reported speed: %d Mbps\n",
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync currentNIC + 1, strMACAddress.raw(), strAttachment.raw(),
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync fConnected ? "on" : "off",
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync fTraceEnabled ? "on" : "off", traceFile.raw(),
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync strNICType.raw(),
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync ulLineSpeed / 1000);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* get the maximum amount of UARTs */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG maxUARTs = 0;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync sysProps->COMGETTER(SerialPortCount)(&maxUARTs);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync for (ULONG currentUART = 0; currentUART < maxUARTs; currentUART++)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<ISerialPort> uart;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = machine->GetSerialPort(currentUART, uart.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc) && uart)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fEnabled;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uart->COMGETTER(Enabled)(&fEnabled);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!fEnabled)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("uart%d=\"off\"\n", currentUART + 1);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("UART %d: disabled\n", currentUART + 1);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG ulIRQ, ulIOBase;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PortMode_T HostMode;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr path;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL fServer;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uart->COMGETTER(IRQ)(&ulIRQ);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uart->COMGETTER(IOBase)(&ulIOBase);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uart->COMGETTER(Path)(path.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uart->COMGETTER(Server)(&fServer);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync uart->COMGETTER(HostMode)(&HostMode);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("uart%d=\"%#06x,%d\"\n", currentUART + 1,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ulIOBase, ulIRQ);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("UART %d: I/O base: 0x%04x, IRQ: %d",
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync currentUART + 1, ulIOBase, ulIRQ);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync switch (HostMode)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync default:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case PortMode_DisconnectedPort:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("uartmode%d=\"disconnected\"\n", currentUART + 1);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf(", disconnected\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case PortMode_HostPipePort:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("uartmode%d=\"%s,%lS\"\n", currentUART + 1,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync fServer ? "server" : "client", path.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf(", attached to pipe (%s) '%lS'\n",
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync fServer ? "server" : "client", path.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync case PortMode_HostDevicePort:
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("uartmode%d=\"%lS\"\n", currentUART + 1,
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync path.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf(", attached to device '%lS'\n", path.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<IAudioAdapter> AudioAdapter;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = machine->COMGETTER(AudioAdapter)(AudioAdapter.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync const char *psz = "Unknown";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync BOOL fEnabled;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync rc = AudioAdapter->COMGETTER(Enabled)(&fEnabled);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (SUCCEEDED(rc) && fEnabled)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync AudioDriverType_T enmType;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync rc = AudioAdapter->COMGETTER(AudioDriver)(&enmType);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync switch (enmType)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync case AudioDriverType_NullAudioDriver:
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (details == VMINFO_MACHINEREADABLE)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync psz = "null";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync psz = "Null";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync break;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync case AudioDriverType_WINMMAudioDriver:
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (details == VMINFO_MACHINEREADABLE)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync psz = "winmm";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync psz = "WINMM";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync break;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync case AudioDriverType_DSOUNDAudioDriver:
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (details == VMINFO_MACHINEREADABLE)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync psz = "dsound";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync psz = "DSOUND";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync break;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync case AudioDriverType_OSSAudioDriver:
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (details == VMINFO_MACHINEREADABLE)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync psz = "oss";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync psz = "OSS";
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync break;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync case AudioDriverType_ALSAAudioDriver:
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync psz = "alsa";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync psz = "ALSA";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case AudioDriverType_CoreAudioDriver:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync psz = "coreaudio";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync psz = "CoreAudio";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync default:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync psz = "unknown";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync fEnabled = FALSE;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (fEnabled)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("audio=\"%s\"\n", psz);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("audio=\"none\"\n");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Audio: %s (Driver: %s)\n", fEnabled ? "enabled" : "disabled", psz);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Shared clipboard */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync const char *psz = "Unknown";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ClipboardMode_T enmMode;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = machine->COMGETTER(ClipboardMode)(&enmMode);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync switch (enmMode)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case ClipboardMode_ClipDisabled:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync psz = "disabled";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync psz = "disabled";
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync break;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync case ClipboardMode_ClipHostToGuest:
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (details == VMINFO_MACHINEREADABLE)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync psz = "hosttoguest";
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync psz = "HostToGuest";
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync break;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync case ClipboardMode_ClipGuestToHost:
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (details == VMINFO_MACHINEREADABLE)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync psz = "guesttohost";
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync psz = "GuestToHost";
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync break;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync case ClipboardMode_ClipBidirectional:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync psz = "bidirectional";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync psz = "Bidirectional";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync default:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync psz = "unknown";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("clipboard=\"%s\"\n", psz);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Clipboard Mode: %s\n", psz);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (console)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ComPtr<IDisplay> display;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(console, COMGETTER(Display)(display.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ULONG xRes, yRes, bpp;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(display, COMGETTER(Width)(&xRes), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(display, COMGETTER(Height)(&yRes), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(display, COMGETTER(BitsPerPixel)(&bpp), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("VideoMode=\"%d,%d,%d\"\n", xRes, yRes, bpp);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Video mode: %dx%dx%d\n", xRes, yRes, bpp);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * VRDP
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ComPtr<IVRDPServer> vrdpServer;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (SUCCEEDED(rc) && vrdpServer)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync BOOL fEnabled = false;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync vrdpServer->COMGETTER(Enabled)(&fEnabled);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (fEnabled)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ULONG port;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync vrdpServer->COMGETTER(Port)(&port);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Bstr address;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync vrdpServer->COMGETTER(NetAddress)(address.asOutParam());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync BOOL fMultiCon;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync vrdpServer->COMGETTER(AllowMultiConnection)(&fMultiCon);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync VRDPAuthType_T vrdpAuthType;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync const char *strAuthType;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync vrdpServer->COMGETTER(AuthType)(&vrdpAuthType);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync switch (vrdpAuthType)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case VRDPAuthType_VRDPAuthNull:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync strAuthType = "null";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case VRDPAuthType_VRDPAuthExternal:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync strAuthType = "external";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync case VRDPAuthType_VRDPAuthGuest:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync strAuthType = "guest";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync default:
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync strAuthType = "unknown";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync break;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("vrdp=\"on\"\n");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("vrdpport=%d\n", port);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("vrdpaddress=\"%lS\"\n", address.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("vrdpauthtype=\"%s\"\n", strAuthType);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("vrdpmulticon=\"%s\"\n", fMultiCon ? "on" : "off");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (address.isEmpty())
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync address = "0.0.0.0";
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("VRDP: enabled (Address %lS, Port %d, MultiConn: %s, Authentication type: %s)\n", address.raw(), port, fMultiCon ? "on" : "off", strAuthType);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("vrdp=\"off\"\n");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("VRDP: disabled\n");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /*
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync * USB.
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ComPtr<IUSBController> USBCtl;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = machine->COMGETTER(USBController)(USBCtl.asOutParam());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (SUCCEEDED(rc))
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync BOOL fEnabled;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = USBCtl->COMGETTER(Enabled)(&fEnabled);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (FAILED(rc))
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync fEnabled = false;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("usb=\"%s\"\n", fEnabled ? "on" : "off");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USB: %s\n", fEnabled ? "enabled" : "disabled");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details != VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("\nUSB Device Filters:\n\n");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ComPtr<IUSBDeviceFilterCollection> Coll;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (USBCtl, COMGETTER(DeviceFilters)(Coll.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ComPtr<IUSBDeviceFilterEnumerator> Enum;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (Coll, Enumerate(Enum.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ULONG index = 0;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync BOOL fMore = FALSE;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = Enum->HasMore (&fMore);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ASSERT_RET (SUCCEEDED (rc), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (!fMore)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details != VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("<none>\n\n");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync while (fMore)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ComPtr<IUSBDeviceFilter> DevPtr;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = Enum->GetNext(DevPtr.asOutParam());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ASSERT_RET (SUCCEEDED (rc), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* Query info. */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Index: %lu\n", index);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync BOOL bActive = FALSE;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (DevPtr, COMGETTER (Active) (&bActive), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USBFilterActive%d=\"%s\"\n", index + 1, bActive ? "on" : "off");
661bfa5aae55ac2f94fa1cb131ea2323e5f6e633vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Active: %s\n", bActive ? "yes" : "no");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync Bstr bstr;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (DevPtr, COMGETTER (Name) (bstr.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USBFilterName%d=\"%lS\"\n", index + 1, bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Name: %lS\n", bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (DevPtr, COMGETTER (VendorId) (bstr.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USBFilterVendorId%d=\"%lS\"\n", index + 1, bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("VendorId: %lS\n", bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (DevPtr, COMGETTER (ProductId) (bstr.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USBFilterProductId%d=\"%lS\"\n", index + 1, bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("ProductId: %lS\n", bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (DevPtr, COMGETTER (Revision) (bstr.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USBFilterRevision%d=\"%lS\"\n", index + 1, bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Revision: %lS\n", bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (DevPtr, COMGETTER (Manufacturer) (bstr.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USBFilterManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Manufacturer: %lS\n", bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (DevPtr, COMGETTER (Product) (bstr.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USBFilterProduct%d=\"%lS\"\n", index + 1, bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Product: %lS\n", bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (DevPtr, COMGETTER (Remote) (bstr.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USBFilterRemote%d=\"%lS\"\n", index + 1, bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Remote: %lS\n\n", bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (DevPtr, COMGETTER (SerialNumber) (bstr.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("USBFilterSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Serial Number: %lS\n\n", bstr.raw());
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = Enum->HasMore (&fMore);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ASSERT_RET (SUCCEEDED (rc), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync index ++;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (console)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync index = 0;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync /* scope */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details != VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Available remote USB devices:\n\n");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ComPtr<IHostUSBDeviceCollection> coll;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET (console, COMGETTER(RemoteUSBDevices) (coll.asOutParam()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ComPtr <IHostUSBDeviceEnumerator> en;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (coll, Enumerate (en.asOutParam()), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync BOOL more = FALSE;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = en->HasMore (&more);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ASSERT_RET (SUCCEEDED (rc), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (!more)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (details != VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("<none>\n\n");
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync while (more)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ComPtr <IHostUSBDevice> dev;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = en->GetNext (dev.asOutParam());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ASSERT_RET (SUCCEEDED (rc), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Query info. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync Guid id;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync USHORT usVendorId;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync USHORT usProductId;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync USHORT bcdRevision;
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync if (details == VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("USBRemoteUUID%d=\"%S\"\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "USBRemoteVendorId%d=\"%#06x\"\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "USBRemoteProductId%d=\"%#06x\"\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "USBRemoteRevision%d=\"%#04x%02x\"\n",
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index + 1, id.toString().raw(),
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index + 1, usVendorId,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index + 1, usProductId,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index + 1, bcdRevision >> 8, bcdRevision & 0xff);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("UUID: %S\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "VendorId: 0x%04x (%04X)\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "ProductId: 0x%04x (%04X)\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "Revision: %u.%u (%02u%02u)\n",
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync id.toString().raw(),
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync usVendorId, usVendorId, usProductId, usProductId,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync bcdRevision >> 8, bcdRevision & 0xff,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync bcdRevision >> 8, bcdRevision & 0xff);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
f40cc8247b1da75ce42e73e6c557ec29b8f830a5vboxsync /* optional stuff. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync Bstr bstr;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (!bstr.isEmpty())
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (details == VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("USBRemoteManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("Manufacturer: %lS\n", bstr.raw());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (!bstr.isEmpty())
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (details == VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("USBRemoteProduct%d=\"%lS\"\n", index + 1, bstr.raw());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("Product: %lS\n", bstr.raw());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (!bstr.isEmpty())
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (details == VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("USBRemoteSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("SerialNumber: %lS\n", bstr.raw());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (!bstr.isEmpty())
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (details == VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("USBRemoteAddress%d=\"%lS\"\n", index + 1, bstr.raw());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("Address: %lS\n", bstr.raw());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (details != VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("\n");
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync rc = en->HasMore (&more);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ASSERT_RET (SUCCEEDED (rc), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index ++;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index = 0;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* scope */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (details != VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf ("Currently Attached USB Devices:\n\n");
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ComPtr <IUSBDeviceCollection> coll;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (console, COMGETTER(USBDevices) (coll.asOutParam()), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ComPtr <IUSBDeviceEnumerator> en;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (coll, Enumerate (en.asOutParam()), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync BOOL more = FALSE;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = en->HasMore (&more);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ASSERT_RET (SUCCEEDED (rc), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (!more)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (details != VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("<none>\n\n");
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync }
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync while (more)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync {
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ComPtr <IUSBDevice> dev;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync rc = en->GetNext (dev.asOutParam());
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync ASSERT_RET (SUCCEEDED (rc), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync /* Query info. */
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync Guid id;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync USHORT usVendorId;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync USHORT usProductId;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync USHORT bcdRevision;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync if (details == VMINFO_MACHINEREADABLE)
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("USBAttachedUUID%d=\"%S\"\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "USBAttachedVendorId%d=\"%#06x\"\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "USBAttachedProductId%d=\"%#06x\"\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "USBAttachedRevision%d=\"%#04x%02x\"\n",
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index + 1, id.toString().raw(),
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index + 1, usVendorId,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index + 1, usProductId,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync index + 1, bcdRevision >> 8, bcdRevision & 0xff);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync else
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync RTPrintf("UUID: %S\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "VendorId: 0x%04x (%04X)\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "ProductId: 0x%04x (%04X)\n"
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync "Revision: %u.%u (%02u%02u)\n",
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync id.toString().raw(),
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync usVendorId, usVendorId, usProductId, usProductId,
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync bcdRevision >> 8, bcdRevision & 0xff,
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync bcdRevision >> 8, bcdRevision & 0xff);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* optional stuff. */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync Bstr bstr;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (!bstr.isEmpty())
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details == VMINFO_MACHINEREADABLE)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("USBAttachedManufacturer%d=\"%lS\"\n", index + 1, bstr.raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("Manufacturer: %lS\n", bstr.raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (!bstr.isEmpty())
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details == VMINFO_MACHINEREADABLE)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("USBAttachedProduct%d=\"%lS\"\n", index + 1, bstr.raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("Product: %lS\n", bstr.raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (!bstr.isEmpty())
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details == VMINFO_MACHINEREADABLE)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("USBAttachedSerialNumber%d=\"%lS\"\n", index + 1, bstr.raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("SerialNumber: %lS\n", bstr.raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (!bstr.isEmpty())
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details == VMINFO_MACHINEREADABLE)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("USBAttachedAddress%d=\"%lS\"\n", index + 1, bstr.raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("Address: %lS\n", bstr.raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details != VMINFO_MACHINEREADABLE)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("\n");
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync rc = en->HasMore (&more);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ASSERT_RET (SUCCEEDED (rc), rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync index ++;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync } /* USB */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /*
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync * Shared folders
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details != VMINFO_MACHINEREADABLE)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("Shared folders: ");
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync uint32_t numSharedFolders = 0;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync#if 0 // not yet implemented
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /* globally shared folders first */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ComPtr<ISharedFolderCollection> sfColl;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ComPtr<ISharedFolderEnumerator> sfEnum;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync CHECK_ERROR_RET(virtualBox, COMGETTER(SharedFolders)(sfColl.asOutParam()), rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync CHECK_ERROR_RET(sfColl, Enumerate(sfEnum.asOutParam()), rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync BOOL fMore;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync sfEnum->HasMore(&fMore);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync while (fMore)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ComPtr<ISharedFolder> sf;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync CHECK_ERROR_RET(sfEnum, GetNext(sf.asOutParam()), rc);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync Bstr name, hostPath;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync sf->COMGETTER(Name)(name.asOutParam());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync sf->COMGETTER(HostPath)(hostPath.asOutParam());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("Name: '%lS', Host path: '%lS' (global mapping)\n", name.raw(), hostPath.raw());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ++numSharedFolders;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync CHECK_ERROR_RET(sfEnum, HasMore(&fMore), rc);
8f7ee9e453c60b3b699799538a45950b35266665vboxsync }
8f7ee9e453c60b3b699799538a45950b35266665vboxsync }
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync#endif
8f7ee9e453c60b3b699799538a45950b35266665vboxsync /* now VM mappings */
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync ComPtr<ISharedFolderCollection> sfColl;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync ComPtr<ISharedFolderEnumerator> sfEnum;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync CHECK_ERROR_RET(machine, COMGETTER(SharedFolders)(sfColl.asOutParam()), rc);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync CHECK_ERROR_RET(sfColl, Enumerate(sfEnum.asOutParam()), rc);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync ULONG index = 0;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync BOOL fMore;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync sfEnum->HasMore(&fMore);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync while (fMore)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync ComPtr<ISharedFolder> sf;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync CHECK_ERROR_RET(sfEnum, GetNext(sf.asOutParam()), rc);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync Bstr name, hostPath;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync sf->COMGETTER(Name)(name.asOutParam());
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync sf->COMGETTER(HostPath)(hostPath.asOutParam());
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync RTPrintf("\n\n");
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync if (details == VMINFO_MACHINEREADABLE)
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync {
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync RTPrintf("SharedFolderNameMachineMapping%d=\"%lS\"\n", index + 1,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync name.raw());
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync RTPrintf("SharedFolderPathMachineMapping%d=\"%lS\"\n", index + 1,
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync hostPath.raw());
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync else
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync RTPrintf("Name: '%lS', Host path: '%lS' (machine mapping)\n", name.raw(), hostPath.raw());
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ++numSharedFolders;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync CHECK_ERROR_RET(sfEnum, HasMore(&fMore), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /* transient mappings */
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (console)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ComPtr<ISharedFolderCollection> sfColl;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ComPtr<ISharedFolderEnumerator> sfEnum;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync CHECK_ERROR_RET(console, COMGETTER(SharedFolders)(sfColl.asOutParam()), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync CHECK_ERROR_RET(sfColl, Enumerate(sfEnum.asOutParam()), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ULONG index = 0;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync BOOL fMore;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync sfEnum->HasMore(&fMore);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync while (fMore)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ComPtr<ISharedFolder> sf;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync CHECK_ERROR_RET(sfEnum, GetNext(sf.asOutParam()), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync Bstr name, hostPath;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync sf->COMGETTER(Name)(name.asOutParam());
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync sf->COMGETTER(HostPath)(hostPath.asOutParam());
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("\n\n");
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (details == VMINFO_MACHINEREADABLE)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("SharedFolderNameTransientMapping%d=\"%lS\"\n", index + 1,
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync name.raw());
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("SharedFolderPathTransientMapping%d=\"%lS\"\n", index + 1,
0d8c2135d15345cc68111eea91052cdf5518d7e3vboxsync hostPath.raw());
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("Name: '%lS', Host path: '%lS' (transient mapping)\n", name.raw(), hostPath.raw());
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync ++numSharedFolders;
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync CHECK_ERROR_RET(sfEnum, HasMore(&fMore), rc);
fdb40b7d2efa84fc6f03b7a695cb4b2e035c30c7vboxsync }
8f7ee9e453c60b3b699799538a45950b35266665vboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (!numSharedFolders && details != VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("<none>\n");
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (details != VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("\n");
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (console)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync /*
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync * Live VRDP info.
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync */
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ComPtr<IRemoteDisplayInfo> remoteDisplayInfo;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync CHECK_ERROR_RET(console, COMGETTER(RemoteDisplayInfo)(remoteDisplayInfo.asOutParam()), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync BOOL Active;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ULONG NumberOfClients;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync LONG64 BeginTime;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync LONG64 EndTime;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ULONG64 BytesSent;
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync ULONG64 BytesSentTotal;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ULONG64 BytesReceived;
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync ULONG64 BytesReceivedTotal;
9c9db71d639cf066ed41d49629d46d48bff4be2fvboxsync Bstr User;
9c9db71d639cf066ed41d49629d46d48bff4be2fvboxsync Bstr Domain;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync Bstr ClientName;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync Bstr ClientIP;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ULONG ClientVersion;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ULONG EncryptionStyle;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Active) (&Active), rc);
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(NumberOfClients) (&NumberOfClients), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BeginTime) (&BeginTime), rc);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EndTime) (&EndTime), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSent) (&BytesSent), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesSentTotal) (&BytesSentTotal), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceived) (&BytesReceived), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(BytesReceivedTotal) (&BytesReceivedTotal), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(User) (User.asOutParam ()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(Domain) (Domain.asOutParam ()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientName) (ClientName.asOutParam ()), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientIP) (ClientIP.asOutParam ()), rc);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(ClientVersion) (&ClientVersion), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync CHECK_ERROR_RET(remoteDisplayInfo, COMGETTER(EncryptionStyle) (&EncryptionStyle), rc);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (details == VMINFO_MACHINEREADABLE)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("VRDPActiveConnection=\"%s\"\n", Active ? "on": "off");
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("VRDP Connection: %s\n", Active? "active": "not active");
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("VRDPClients=%d\n", NumberOfClients);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Clients so far: %d\n", NumberOfClients);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (NumberOfClients > 0)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync char timestr[128];
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (Active)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync makeTimeStr (timestr, sizeof (timestr), BeginTime);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (details == VMINFO_MACHINEREADABLE)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("VRDPStartTime=\"%s\"\n", timestr);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Start time: %s\n", timestr);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync makeTimeStr (timestr, sizeof (timestr), BeginTime);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (details == VMINFO_MACHINEREADABLE)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("VRDPLastStartTime=\"%s\"\n", timestr);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync else
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("Last started: %s\n", timestr);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync makeTimeStr (timestr, sizeof (timestr), EndTime);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("VRDPLastEndTime=\"%s\"\n", timestr);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("Last ended: %s\n", timestr);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("VRDPBytesSent=%llu\n", BytesSent);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("VRDPThroughputSend=%llu\n", (BytesSent * 1000) / (EndTime - BeginTime) );
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("VRDPBytesSentTotal=%llu\n", BytesSentTotal);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("VRDPBytesReceived=%llu\n", BytesReceived);
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("VRDPThroughputReceive=%llu\n", (BytesReceived * 1000) / (EndTime - BeginTime) );
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("VRDPBytesReceivedTotal=%llu\n", BytesReceivedTotal);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("Sent: %llu Bytes\n", BytesSent);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Average speed: %llu B/s\n", (BytesSent * 1000) / (EndTime - BeginTime) );
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("Sent total: %llu Bytes\n", BytesSentTotal);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("Received: %llu Bytes\n", BytesReceived);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("Speed: %llu B/s\n", (BytesReceived * 1000) / (EndTime - BeginTime) );
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("Received total: %llu Bytes\n", BytesReceivedTotal);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (Active)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (details == VMINFO_MACHINEREADABLE)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("VRDPUserName=\"%lS\"\n", User.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("VRDPDomain=\"%lS\"\n", Domain.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("VRDPClientName=\"%lS\"\n", ClientName.raw());
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("VRDPClientIP=\"%lS\"\n", ClientIP.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("VRDPClientVersion=%d\n", ClientVersion);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("VRDPEncryption=\"%s\"\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("User name: %lS\n", User.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Domain: %lS\n", Domain.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Client name: %lS\n", ClientName.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Client IP: %lS\n", ClientIP.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Client version: %d\n", ClientVersion);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Encryption: %s\n", EncryptionStyle == 0? "RDP4": "RDP5 (X.509)");
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details != VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if ( details == VMINFO_STANDARD
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync || details == VMINFO_FULL
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync || details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c94a8282c9042b02f022302a3d987746140eab9vboxsync Bstr description;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync machine->COMGETTER(Description)(description.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!description.isEmpty())
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (details == VMINFO_MACHINEREADABLE)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync RTPrintf("description=\"%lS\"\n", description.raw());
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync else
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync RTPrintf("Description:\n%lS\n", description.raw());
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync ULONG guestVal;
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (details != VMINFO_MACHINEREADABLE)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync RTPrintf("Guest:\n\n");
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync rc = machine->COMGETTER(MemoryBalloonSize)(&guestVal);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (SUCCEEDED(rc))
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (details == VMINFO_MACHINEREADABLE)
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync RTPrintf("GuestMemoryBalloon=%d\n", guestVal);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync RTPrintf("Configured memory balloon size: %d MB\n", guestVal);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync rc = machine->COMGETTER(StatisticsUpdateInterval)(&guestVal);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (SUCCEEDED(rc))
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("GuestStatisticsUpdateInterval=%d\n", guestVal);
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync {
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (guestVal == 0)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Statistics update: disabled\n");
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync else
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("Statistics update interval: %d seconds\n", guestVal);
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync }
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync }
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync if (details != VMINFO_MACHINEREADABLE)
88e56f700a3b8dfdf1646f96320f335e22339caavboxsync RTPrintf("\n");
49a6b09abb20015b0af3e618a1f92b7e26785e90vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if ( console
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync && ( details == VMINFO_STATISTICS
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync || details == VMINFO_FULL
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync || details == VMINFO_MACHINEREADABLE))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr <IGuest> guest;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = console->COMGETTER(Guest)(guest.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ULONG statVal;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_SampleNumber, &statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("StatGuestSample=%d\n", statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Guest statistics for sample %d:\n\n", statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_Idle, &statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("StatGuestLoadIdleCPU%d=%d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("CPU%d: CPU Load Idle %-3d%%\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_Kernel, &statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("StatGuestLoadKernelCPU%d=%d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("CPU%d: CPU Load Kernel %-3d%%\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_CPULoad_User, &statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync if (details == VMINFO_MACHINEREADABLE)
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("StatGuestLoadUserCPU%d=%d\n", 0, statVal);
38745c55f37c31ba8b78cc728d2f08ea6eec38d6vboxsync else
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync RTPrintf("CPU%d: CPU Load User %-3d%%\n", 0, statVal);
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync }
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync rc = guest->GetStatistic(0, GuestStatisticType_Threads, &statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
5c4d7e2aae42bbf39793dfa686925f076a56b4d5vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("StatGuestThreadsCPU%d=%d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("CPU%d: Threads %d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_Processes, &statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("StatGuestProcessesCPU%d=%d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("CPU%d: Processes %d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_Handles, &statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("StatGuestHandlesCPU%d=%d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("CPU%d: Handles %d\n", 0, statVal);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync rc = guest->GetStatistic(0, GuestStatisticType_MemoryLoad, &statVal);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (SUCCEEDED(rc))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync if (details == VMINFO_MACHINEREADABLE)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("StatGuestMemoryLoadCPU%d=%d\n", 0, statVal);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync else
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("CPU%d: Memory Load %d%%\n", 0, statVal);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_PhysMemTotal, &statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("StatGuestMemoryTotalPhysCPU%d=%d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("CPU%d: Total physical memory %-4d MB\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_PhysMemAvailable, &statVal);
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync if (SUCCEEDED(rc))
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync {
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync if (details == VMINFO_MACHINEREADABLE)
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync RTPrintf("StatGuestMemoryFreePhysCPU%d=%d\n", 0, statVal);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync RTPrintf("CPU%d: Free physical memory %-4d MB\n", 0, statVal);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync rc = guest->GetStatistic(0, GuestStatisticType_PhysMemBalloon, &statVal);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("StatGuestMemoryBalloonCPU%d=%d\n", 0, statVal);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync else
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync RTPrintf("CPU%d: Memory balloon size %-4d MB\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_MemCommitTotal, &statVal);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (SUCCEEDED(rc))
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (details == VMINFO_MACHINEREADABLE)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync RTPrintf("StatGuestMemoryCommittedCPU%d=%d\n", 0, statVal);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("CPU%d: Committed memory %-4d MB\n", 0, statVal);
d7cf060b16385dd6e5af7c74cd49c9ef8ffb3b22vboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync rc = guest->GetStatistic(0, GuestStatisticType_MemKernelTotal, &statVal);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (SUCCEEDED(rc))
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (details == VMINFO_MACHINEREADABLE)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync RTPrintf("StatGuestMemoryTotalKernelCPU%d=%d\n", 0, statVal);
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync else
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync RTPrintf("CPU%d: Total kernel memory %-4d MB\n", 0, statVal);
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync }
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync rc = guest->GetStatistic(0, GuestStatisticType_MemKernelPaged, &statVal);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (SUCCEEDED(rc))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details == VMINFO_MACHINEREADABLE)
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync RTPrintf("StatGuestMemoryPagedKernelCPU%d=%d\n", 0, statVal);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
82e3a4017d20f44c30ff909e6b825ff78139cbbbvboxsync RTPrintf("CPU%d: Paged kernel memory %-4d MB\n", 0, statVal);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync rc = guest->GetStatistic(0, GuestStatisticType_MemKernelNonpaged, &statVal);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (SUCCEEDED(rc))
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync RTPrintf("StatGuestMemoryNonpagedKernelCPU%d=%d\n", 0, statVal);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync else
d7cf060b16385dd6e5af7c74cd49c9ef8ffb3b22vboxsync RTPrintf("CPU%d: Nonpaged kernel memory %-4d MB\n", 0, statVal);
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync rc = guest->GetStatistic(0, GuestStatisticType_MemSystemCache, &statVal);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (SUCCEEDED(rc))
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details == VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("StatGuestSystemCacheSizeCPU%d=%d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("CPU%d: System cache size %-4d MB\n", 0, statVal);
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = guest->GetStatistic(0, GuestStatisticType_PageFileSize, &statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (details == VMINFO_MACHINEREADABLE)
19320d55d1417c39b3b5673a53aaa5ef177242c8vboxsync RTPrintf("StatGuestPageFileSizeCPU%d=%d\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("CPU%d: Page file size %-4d MB\n", 0, statVal);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details != VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync RTPrintf("[!] FAILED calling console->getGuest at line %d!\n", __LINE__);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync PRINT_RC_MESSAGE(rc);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /*
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync * snapshots
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync */
56970d3a1944c7c073d66266cd52449835221badvboxsync ComPtr<ISnapshot> snapshot;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = machine->GetSnapshot(Guid(), snapshot.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc) && snapshot)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details != VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Snapshots:\n\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync showSnapshots(snapshot, details);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (details != VMINFO_MACHINEREADABLE)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("\n");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return S_OK;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync}
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsyncstatic int handleShowVMInfo(int argc, char *argv[],
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync{
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync HRESULT rc;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* at least one option: the UUID or name of the VM */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (argc < 1)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync return errorSyntax(USAGE_SHOWVMINFO, "Incorrect number of parameters");
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* try to find the given machine */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr <IMachine> machine;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Guid uuid (argv[0]);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!uuid.isEmpty())
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CHECK_ERROR (virtualBox, GetMachine (uuid, machine.asOutParam()));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CHECK_ERROR (virtualBox, FindMachine (Bstr(argv[0]), machine.asOutParam()));
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (SUCCEEDED (rc))
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync machine->COMGETTER(Id) (uuid.asOutParam());
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (FAILED (rc))
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync return 1;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync /* 2nd option can be -details, -statistics or -argdump */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync VMINFO_DETAILS details = VMINFO_NONE;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync bool fDetails = false;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync bool fStatistics = false;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync bool fMachinereadable = false;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync for (int i=1;i<argc;i++)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!strcmp(argv[i], "-details"))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync fDetails = true;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!strcmp(argv[i], "-statistics"))
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync fStatistics = true;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (!strcmp(argv[1], "-machinereadable"))
56970d3a1944c7c073d66266cd52449835221badvboxsync fMachinereadable = true;
56970d3a1944c7c073d66266cd52449835221badvboxsync }
56970d3a1944c7c073d66266cd52449835221badvboxsync if (fMachinereadable)
56970d3a1944c7c073d66266cd52449835221badvboxsync details = VMINFO_MACHINEREADABLE;
56970d3a1944c7c073d66266cd52449835221badvboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync if (fDetails && fStatistics)
56970d3a1944c7c073d66266cd52449835221badvboxsync details = VMINFO_FULL;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (fDetails)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync details = VMINFO_STANDARD;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (fStatistics)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync details = VMINFO_STATISTICS;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr <IConsole> console;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* open an existing session for the VM */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = virtualBox->OpenExistingSession (session, uuid);
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* get the session machine */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = session->COMGETTER(Machine)(machine.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc))
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* get the session console */
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = session->COMGETTER(Console)(console.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync rc = showVMInfo (virtualBox, machine, console, details);
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (console)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync session->Close();
9c9db71d639cf066ed41d49629d46d48bff4be2fvboxsync
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync return SUCCEEDED (rc) ? 0 : 1;
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync}
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsyncstatic int handleList(int argc, char *argv[],
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync{
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync HRESULT rc = S_OK;
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync /* exactly one option: the object */
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync if (argc != 1)
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync {
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync return errorSyntax(USAGE_LIST, "Incorrect number of parameters");
81614fc60e096e714022d10d38b70a36b9b21d48vboxsync }
44372afb953dc9f1f1ec71943f5f561a607c0307vboxsync
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync /* which object? */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (strcmp(argv[0], "vms") == 0)
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /*
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync * Get the list of all registered VMs
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ComPtr<IMachineCollection> collection;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync rc = virtualBox->COMGETTER(Machines)(collection.asOutParam());
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ComPtr<IMachineEnumerator> enumerator;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync if (SUCCEEDED(rc))
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync rc = collection->Enumerate(enumerator.asOutParam());
56970d3a1944c7c073d66266cd52449835221badvboxsync if (SUCCEEDED(rc))
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync /*
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync * Iterate through the collection
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync */
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync BOOL hasMore = FALSE;
56970d3a1944c7c073d66266cd52449835221badvboxsync while (enumerator->HasMore(&hasMore), hasMore)
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync {
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync ComPtr<IMachine> machine;
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync rc = enumerator->GetNext(machine.asOutParam());
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync if ((SUCCEEDED(rc)) && machine)
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync {
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync rc = showVMInfo(virtualBox, machine);
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync }
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync else
56970d3a1944c7c073d66266cd52449835221badvboxsync if (strcmp(argv[0], "ostypes") == 0)
4f4cb69bca6bfda8f4d911759d1f3c6f528a173dvboxsync {
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ComPtr<IGuestOSTypeCollection> coll;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync ComPtr<IGuestOSTypeEnumerator> enumerator;
9540ab73f6cd0c76f44f6bbfe73f89ac145390b8vboxsync CHECK_ERROR(virtualBox, COMGETTER(GuestOSTypes)(coll.asOutParam()));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc) && coll)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync BOOL hasMore;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync ComPtr<IGuestOSType> guestOS;
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync CHECK_RC_BREAK(enumerator->GetNext(guestOS.asOutParam()));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr guestId;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync guestOS->COMGETTER(Id)(guestId.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("ID: %lS\n", guestId.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr guestDescription;
56970d3a1944c7c073d66266cd52449835221badvboxsync guestOS->COMGETTER(Description)(guestDescription.asOutParam());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync RTPrintf("Description: %lS\n\n", guestDescription.raw());
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync else
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (strcmp(argv[0], "hostdvds") == 0)
29099c2d04b11e614f1fa399fab9e9162f2788b9vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<IHost> host;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<IHostDVDDriveCollection> coll;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<IHostDVDDriveEnumerator> enumerator;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CHECK_ERROR(host, COMGETTER(DVDDrives)(coll.asOutParam()));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc) && coll)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync BOOL hasMore;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<IHostDVDDrive> dvdDrive;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CHECK_RC_BREAK(enumerator->GetNext(dvdDrive.asOutParam()));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync Bstr name;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync dvdDrive->COMGETTER(Name)(name.asOutParam());
0c94a8282c9042b02f022302a3d987746140eab9vboxsync RTPrintf("Name: %lS\n\n", name.raw());
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync }
0c94a8282c9042b02f022302a3d987746140eab9vboxsync else
0c94a8282c9042b02f022302a3d987746140eab9vboxsync if (strcmp(argv[0], "hostfloppies") == 0)
0c94a8282c9042b02f022302a3d987746140eab9vboxsync {
56970d3a1944c7c073d66266cd52449835221badvboxsync ComPtr<IHost> host;
56970d3a1944c7c073d66266cd52449835221badvboxsync CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
56970d3a1944c7c073d66266cd52449835221badvboxsync ComPtr<IHostFloppyDriveCollection> coll;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync ComPtr<IHostFloppyDriveEnumerator> enumerator;
0c94a8282c9042b02f022302a3d987746140eab9vboxsync CHECK_ERROR(host, COMGETTER(FloppyDrives)(coll.asOutParam()));
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync if (SUCCEEDED(rc) && coll)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync BOOL hasMore;
e250515922582e0410c9bcb6d24b0f17bef083a0vboxsync while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync {
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync ComPtr<IHostFloppyDrive> floppyDrive;
0c69348b58bb8eabb1bea8867ee932b667bd0d34vboxsync CHECK_RC_BREAK(enumerator->GetNext(floppyDrive.asOutParam()));
Bstr name;
floppyDrive->COMGETTER(Name)(name.asOutParam());
RTPrintf("Name: %lS\n\n", name.raw());
}
}
}
#ifdef RT_OS_WINDOWS
else
if (strcmp(argv[0], "hostifs") == 0)
{
ComPtr<IHost> host;
CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
ComPtr<IHostNetworkInterfaceCollection> coll;
ComPtr<IHostNetworkInterfaceEnumerator> enumerator;
CHECK_ERROR(host, COMGETTER(NetworkInterfaces)(coll.asOutParam()));
if (SUCCEEDED(rc) && coll)
{
CHECK_ERROR(coll, Enumerate(enumerator.asOutParam()));
BOOL hasMore;
while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
{
ComPtr<IHostNetworkInterface> networkInterface;
CHECK_RC_BREAK(enumerator->GetNext(networkInterface.asOutParam()));
Bstr interfaceName;
networkInterface->COMGETTER(Name)(interfaceName.asOutParam());
RTPrintf("Name: %lS\n", interfaceName.raw());
Guid interfaceGuid;
networkInterface->COMGETTER(Id)(interfaceGuid.asOutParam());
RTPrintf("GUID: %lS\n\n", Bstr(interfaceGuid.toString()));
}
}
}
#endif /* RT_OS_WINDOWS */
else
if (strcmp(argv[0], "hdds") == 0)
{
ComPtr<IHardDiskCollection> hddColl;
CHECK_ERROR(virtualBox, COMGETTER(HardDisks)(hddColl.asOutParam()));
ComPtr<IHardDiskEnumerator> enumerator;
CHECK_ERROR(hddColl, Enumerate(enumerator.asOutParam()));
BOOL hasMore;
while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
{
ComPtr<IHardDisk> hdd;
CHECK_RC_BREAK(enumerator->GetNext(hdd.asOutParam()));
Guid uuid;
hdd->COMGETTER(Id)(uuid.asOutParam());
RTPrintf("UUID: %s\n", uuid.toString().raw());
HardDiskStorageType_T storageType;
hdd->COMGETTER(StorageType)(&storageType);
const char *storageTypeString = "unknown";
switch (storageType)
{
case HardDiskStorageType_VirtualDiskImage:
storageTypeString = "Virtual Disk Image";
break;
case HardDiskStorageType_ISCSIHardDisk:
storageTypeString = "iSCSI hard disk";
break;
}
RTPrintf("Storage type: %s\n", storageTypeString);
Bstr filepath;
/// @todo (dmik) we temporarily use the location property to
// determine the image file name. This is subject to change
// when iSCSI disks are here (we should either query a
// storage-specific interface from IHardDisk, or "standardize"
// the location property)
hdd->COMGETTER(Location)(filepath.asOutParam());
RTPrintf("Path: %lS\n", filepath.raw());
BOOL fAccessible;
hdd->COMGETTER(AllAccessible)(&fAccessible);
RTPrintf("Accessible: %s\n", fAccessible ? "yes" : "no");
Guid machineUUID;
hdd->COMGETTER(MachineId)(machineUUID.asOutParam());
if (!machineUUID.isEmpty())
{
ComPtr<IMachine> machine;
CHECK_ERROR(virtualBox, GetMachine(machineUUID, machine.asOutParam()));
ASSERT(machine);
Bstr name;
machine->COMGETTER(Name)(name.asOutParam());
machine->COMGETTER(Id)(uuid.asOutParam());
RTPrintf("Usage: %lS (UUID: %s)\n", name.raw(), uuid.toString().raw());
}
RTPrintf("\n");
}
}
else
if (strcmp(argv[0], "dvds") == 0)
{
ComPtr<IDVDImageCollection> dvdColl;
CHECK_ERROR(virtualBox, COMGETTER(DVDImages)(dvdColl.asOutParam()));
ComPtr<IDVDImageEnumerator> enumerator;
CHECK_ERROR(dvdColl, Enumerate(enumerator.asOutParam()));
BOOL hasMore;
while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
{
ComPtr<IDVDImage> dvdImage;
CHECK_RC_BREAK(enumerator->GetNext(dvdImage.asOutParam()));
Guid uuid;
dvdImage->COMGETTER(Id)(uuid.asOutParam());
RTPrintf("UUID: %s\n", uuid.toString().raw());
Bstr filePath;
dvdImage->COMGETTER(FilePath)(filePath.asOutParam());
RTPrintf("Path: %lS\n", filePath.raw());
BOOL fAccessible;
dvdImage->COMGETTER(Accessible)(&fAccessible);
RTPrintf("Accessible: %s\n", fAccessible ? "yes" : "no");
Bstr machineUUIDs;
CHECK_ERROR(virtualBox, GetDVDImageUsage(uuid, ResourceUsage_AllUsage, machineUUIDs.asOutParam()));
/** @todo usage */
RTPrintf("\n");
}
}
else
if (strcmp(argv[0], "floppies") == 0)
{
ComPtr<IFloppyImageCollection> floppyColl;
CHECK_ERROR(virtualBox, COMGETTER(FloppyImages)(floppyColl.asOutParam()));
ComPtr<IFloppyImageEnumerator> enumerator;
CHECK_ERROR(floppyColl, Enumerate(enumerator.asOutParam()));
BOOL hasMore;
while (SUCCEEDED(enumerator->HasMore(&hasMore)) && hasMore)
{
ComPtr<IFloppyImage> floppyImage;
CHECK_RC_BREAK(enumerator->GetNext(floppyImage.asOutParam()));
Guid uuid;
floppyImage->COMGETTER(Id)(uuid.asOutParam());
RTPrintf("UUID: %s\n", uuid.toString().raw());
Bstr filePath;
floppyImage->COMGETTER(FilePath)(filePath.asOutParam());
RTPrintf("Path: %lS\n", filePath.raw());
BOOL fAccessible;
floppyImage->COMGETTER(Accessible)(&fAccessible);
RTPrintf("Accessible: %s\n", fAccessible ? "yes" : "no");
Bstr machineUUIDs;
CHECK_ERROR(virtualBox, GetFloppyImageUsage(uuid, ResourceUsage_AllUsage, machineUUIDs.asOutParam()));
/** @todo usage */
RTPrintf("\n");
}
}
else
if (strcmp(argv[0], "usbhost") == 0)
{
ComPtr<IHost> Host;
CHECK_ERROR_RET (virtualBox, COMGETTER(Host)(Host.asOutParam()), 1);
ComPtr<IHostUSBDeviceCollection> CollPtr;
CHECK_ERROR_RET (Host, COMGETTER(USBDevices)(CollPtr.asOutParam()), 1);
ComPtr<IHostUSBDeviceEnumerator> EnumPtr;
CHECK_ERROR_RET (CollPtr, Enumerate(EnumPtr.asOutParam()), 1);
RTPrintf("Host USB Devices:\n\n");
BOOL fMore = FALSE;
rc = EnumPtr->HasMore (&fMore);
ASSERT_RET (SUCCEEDED (rc), 1);
if (!fMore)
{
RTPrintf("<none>\n\n");
}
else
while (fMore)
{
ComPtr <IHostUSBDevice> dev;
rc = EnumPtr->GetNext (dev.asOutParam());
ASSERT_RET (SUCCEEDED (rc), 1);
/* Query info. */
Guid id;
CHECK_ERROR_RET (dev, COMGETTER(Id)(id.asOutParam()), 1);
USHORT usVendorId;
CHECK_ERROR_RET (dev, COMGETTER(VendorId)(&usVendorId), 1);
USHORT usProductId;
CHECK_ERROR_RET (dev, COMGETTER(ProductId)(&usProductId), 1);
USHORT bcdRevision;
CHECK_ERROR_RET (dev, COMGETTER(Revision)(&bcdRevision), 1);
RTPrintf("UUID: %S\n"
"VendorId: 0x%04x (%04X)\n"
"ProductId: 0x%04x (%04X)\n"
"Revision: %u.%u (%02u%02u)\n",
id.toString().raw(),
usVendorId, usVendorId, usProductId, usProductId,
bcdRevision >> 8, bcdRevision & 0xff,
bcdRevision >> 8, bcdRevision & 0xff);
/* optional stuff. */
Bstr bstr;
CHECK_ERROR_RET (dev, COMGETTER(Manufacturer)(bstr.asOutParam()), 1);
if (!bstr.isEmpty())
RTPrintf("Manufacturer: %lS\n", bstr.raw());
CHECK_ERROR_RET (dev, COMGETTER(Product)(bstr.asOutParam()), 1);
if (!bstr.isEmpty())
RTPrintf("Product: %lS\n", bstr.raw());
CHECK_ERROR_RET (dev, COMGETTER(SerialNumber)(bstr.asOutParam()), 1);
if (!bstr.isEmpty())
RTPrintf("SerialNumber: %lS\n", bstr.raw());
CHECK_ERROR_RET (dev, COMGETTER(Address)(bstr.asOutParam()), 1);
if (!bstr.isEmpty())
RTPrintf("Address: %lS\n", bstr.raw());
/* current state */
USBDeviceState_T state;
CHECK_ERROR_RET (dev, COMGETTER(State)(&state), 1);
const char *pszState = "?";
switch (state)
{
case USBDeviceState_USBDeviceNotSupported:
pszState = "Not supported"; break;
case USBDeviceState_USBDeviceUnavailable:
pszState = "Unavailable"; break;
case USBDeviceState_USBDeviceBusy:
pszState = "Busy"; break;
case USBDeviceState_USBDeviceAvailable:
pszState = "Available"; break;
case USBDeviceState_USBDeviceHeld:
pszState = "Held"; break;
case USBDeviceState_USBDeviceCaptured:
pszState = "Captured"; break;
default:
ASSERT (false);
break;
}
RTPrintf("Current State: %s\n\n", pszState);
rc = EnumPtr->HasMore (&fMore);
ASSERT_RET (SUCCEEDED (rc), rc);
}
}
else
if (strcmp(argv[0], "usbfilters") == 0)
{
RTPrintf("Global USB Device Filters:\n\n");
ComPtr <IHost> host;
CHECK_ERROR_RET (virtualBox, COMGETTER(Host) (host.asOutParam()), 1);
ComPtr<IHostUSBDeviceFilterCollection> coll;
CHECK_ERROR_RET (host, COMGETTER (USBDeviceFilters)(coll.asOutParam()), 1);
ComPtr<IHostUSBDeviceFilterEnumerator> en;
CHECK_ERROR_RET (coll, Enumerate(en.asOutParam()), 1);
ULONG index = 0;
BOOL more = FALSE;
rc = en->HasMore (&more);
ASSERT_RET (SUCCEEDED (rc), 1);
if (!more)
{
RTPrintf("<none>\n\n");
}
else
while (more)
{
ComPtr<IHostUSBDeviceFilter> flt;
rc = en->GetNext (flt.asOutParam());
ASSERT_RET (SUCCEEDED (rc), 1);
/* Query info. */
RTPrintf("Index: %lu\n", index);
BOOL active = FALSE;
CHECK_ERROR_RET (flt, COMGETTER (Active) (&active), 1);
RTPrintf("Active: %s\n", active ? "yes" : "no");
USBDeviceFilterAction_T action;
CHECK_ERROR_RET (flt, COMGETTER (Action) (&action), 1);
const char *pszAction = "<invalid>";
switch (action)
{
case USBDeviceFilterAction_USBDeviceFilterIgnore:
pszAction = "Ignore";
break;
case USBDeviceFilterAction_USBDeviceFilterHold:
pszAction = "Hold";
break;
default:
break;
}
RTPrintf("Action: %s\n", pszAction);
Bstr bstr;
CHECK_ERROR_RET (flt, COMGETTER (Name) (bstr.asOutParam()), 1);
RTPrintf("Name: %lS\n", bstr.raw());
CHECK_ERROR_RET (flt, COMGETTER (VendorId) (bstr.asOutParam()), 1);
RTPrintf("VendorId: %lS\n", bstr.raw());
CHECK_ERROR_RET (flt, COMGETTER (ProductId) (bstr.asOutParam()), 1);
RTPrintf("ProductId: %lS\n", bstr.raw());
CHECK_ERROR_RET (flt, COMGETTER (Revision) (bstr.asOutParam()), 1);
RTPrintf("Revision: %lS\n", bstr.raw());
CHECK_ERROR_RET (flt, COMGETTER (Manufacturer) (bstr.asOutParam()), 1);
RTPrintf("Manufacturer: %lS\n", bstr.raw());
CHECK_ERROR_RET (flt, COMGETTER (Product) (bstr.asOutParam()), 1);
RTPrintf("Product: %lS\n", bstr.raw());
CHECK_ERROR_RET (flt, COMGETTER (SerialNumber) (bstr.asOutParam()), 1);
RTPrintf("Serial Number: %lS\n\n", bstr.raw());
rc = en->HasMore (&more);
ASSERT_RET (SUCCEEDED (rc), 1);
index ++;
}
}
else if (strcmp(argv[0], "systemproperties") == 0)
{
ComPtr<ISystemProperties> systemProperties;
virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
Bstr str;
ULONG ulValue;
ULONG64 ul64Value;
BOOL flag;
systemProperties->COMGETTER(MinGuestRAM)(&ulValue);
RTPrintf("Minimum guest RAM size: %u Megabytes\n", ulValue);
systemProperties->COMGETTER(MaxGuestRAM)(&ulValue);
RTPrintf("Maximum guest RAM size: %u Megabytes\n", ulValue);
systemProperties->COMGETTER(MaxGuestVRAM)(&ulValue);
RTPrintf("Maximum video RAM size: %u Megabytes\n", ulValue);
systemProperties->COMGETTER(MaxVDISize)(&ul64Value);
RTPrintf("Maximum VDI size: %lu Megabytes\n", ul64Value);
systemProperties->COMGETTER(DefaultVDIFolder)(str.asOutParam());
RTPrintf("Default VDI filder: %lS\n", str.raw());
systemProperties->COMGETTER(DefaultMachineFolder)(str.asOutParam());
RTPrintf("Default machine folder: %lS\n", str.raw());
systemProperties->COMGETTER(RemoteDisplayAuthLibrary)(str.asOutParam());
RTPrintf("VRDP authentication library: %lS\n", str.raw());
systemProperties->COMGETTER(HWVirtExEnabled)(&flag);
RTPrintf("Hardware virt. extensions: %s\n", flag ? "yes" : "no");
systemProperties->COMGETTER(LogHistoryCount)(&ulValue);
RTPrintf("Log history count: %u\n", ulValue);
}
else
{
return errorSyntax(USAGE_LIST, "Invalid parameter '%s'", Utf8Str(argv[0]).raw());
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleRegisterVM(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
if (argc != 1)
{
return errorSyntax(USAGE_REGISTERVM, "Incorrect number of parameters");
}
ComPtr<IMachine> machine;
CHECK_ERROR(virtualBox, OpenMachine(Bstr(argv[0]), machine.asOutParam()));
if (SUCCEEDED(rc))
{
ASSERT(machine);
CHECK_ERROR(virtualBox, RegisterMachine(machine));
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleUnregisterVM(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
if ((argc != 1) && (argc != 2))
{
return errorSyntax(USAGE_UNREGISTERVM, "Incorrect number of parameters");
}
ComPtr<IMachine> machine;
/* assume it's a UUID */
rc = virtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
if (FAILED(rc) || !machine)
{
/* must be a name */
CHECK_ERROR(virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
}
if (machine)
{
Guid uuid;
machine->COMGETTER(Id)(uuid.asOutParam());
machine = NULL;
CHECK_ERROR(virtualBox, UnregisterMachine(uuid, machine.asOutParam()));
if (SUCCEEDED(rc) && machine)
{
/* are we supposed to delete the config file? */
if ((argc == 2) && (strcmp(argv[1], "-delete") == 0))
{
CHECK_ERROR(machine, DeleteSettings());
}
}
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleCreateVDI(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
Bstr filename;
uint64_t sizeMB = 0;
bool fStatic = false;
Bstr comment;
bool fRegister = false;
const char *type = "normal";
/* let's have a closer look at the arguments */
for (int i = 0; i < argc; i++)
{
if (strcmp(argv[i], "-filename") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
filename = argv[i];
}
else if (strcmp(argv[i], "-size") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
sizeMB = RTStrToUInt64(argv[i]);
}
else if (strcmp(argv[i], "-static") == 0)
{
fStatic = true;
}
else if (strcmp(argv[i], "-comment") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
comment = argv[i];
}
else if (strcmp(argv[i], "-register") == 0)
{
fRegister = true;
}
else if (strcmp(argv[i], "-type") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
type = argv[i];
}
else
{
return errorSyntax(USAGE_CREATEVDI, "Invalid parameter '%s'", Utf8Str(argv[i]).raw());
}
}
/* check the outcome */
if (!filename || (sizeMB == 0))
{
return errorSyntax(USAGE_CREATEVDI, "Parameters -filename and -size are required");
}
if (strcmp(type, "normal") && strcmp(type, "writethrough"))
{
return errorArgument("Invalid VDI type '%s' specified", Utf8Str(type).raw());
}
ComPtr<IHardDisk> hardDisk;
CHECK_ERROR(virtualBox, CreateHardDisk(HardDiskStorageType_VirtualDiskImage, hardDisk.asOutParam()));
if (SUCCEEDED(rc) && hardDisk)
{
CHECK_ERROR(hardDisk,COMSETTER(Description)(comment));
ComPtr<IVirtualDiskImage> vdi = hardDisk;
CHECK_ERROR(vdi, COMSETTER(FilePath)(filename));
ComPtr<IProgress> progress;
if (fStatic)
{
CHECK_ERROR(vdi, CreateFixedImage(sizeMB, progress.asOutParam()));
}
else
{
CHECK_ERROR(vdi, CreateDynamicImage(sizeMB, progress.asOutParam()));
}
if (SUCCEEDED(rc) && progress)
{
CHECK_ERROR(progress, WaitForCompletion(-1));
if (SUCCEEDED(rc))
{
progress->COMGETTER(ResultCode)(&rc);
if (FAILED(rc))
{
com::ProgressErrorInfo info(progress);
if (info.isBasicAvailable())
{
RTPrintf("Error: failed to create disk image. Error message: %lS\n", info.getText().raw());
}
else
{
RTPrintf("Error: failed to create disk image. No error message available!\n");
}
}
else
{
Guid uuid;
CHECK_ERROR(hardDisk, COMGETTER(Id)(uuid.asOutParam()));
if (strcmp(type, "normal") == 0)
{
/* nothing required, default */
}
else if (strcmp(type, "writethrough") == 0)
{
CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_WritethroughHardDisk));
}
RTPrintf("Disk image created. UUID: %s\n", uuid.toString().raw());
}
}
}
if (SUCCEEDED(rc) && fRegister)
{
CHECK_ERROR(virtualBox, RegisterHardDisk(hardDisk));
}
}
return SUCCEEDED(rc) ? 0 : 1;
}
static DECLCALLBACK(int) vdiProgressCallback(PVM pVM, unsigned uPercent, void *pvUser)
{
unsigned *pPercent = (unsigned *)pvUser;
if (*pPercent != uPercent)
{
*pPercent = uPercent;
RTPrintf(".");
if ((uPercent % 10) == 0 && uPercent)
RTPrintf("%d%%", uPercent);
RTStrmFlush(g_pStdOut);
}
return VINF_SUCCESS;
}
static int handleModifyVDI(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
/* The uuid/filename and a command */
if (argc < 2)
{
return errorSyntax(USAGE_MODIFYVDI, "Incorrect number of parameters");
}
ComPtr<IHardDisk> hardDisk;
ComPtr<IVirtualDiskImage> vdi;
Bstr filepath;
/* first guess is that it's a UUID */
Guid uuid(argv[0]);
rc = virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
/* no? then it must be a filename */
if (!hardDisk)
{
filepath = argv[0];
CHECK_ERROR(virtualBox, FindVirtualDiskImage(filepath, vdi.asOutParam()));
hardDisk = vdi;
}
else
{
vdi = hardDisk;
}
/* let's find out which command */
// doesn't currently work if (strcmp(argv[1], "settype") == 0)
if (0)
{
/* hard disk must be registered */
if (SUCCEEDED(rc) && hardDisk && vdi)
{
char *type = NULL;
if (argc <= 2)
{
return errorArgument("Missing argument to for settype");
}
type = argv[2];
HardDiskType_T hddType;
CHECK_ERROR(hardDisk, COMGETTER(Type)(&hddType));
if (strcmp(type, "normal") == 0)
{
if (hddType != HardDiskType_NormalHardDisk)
CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_NormalHardDisk));
}
else if (strcmp(type, "writethrough") == 0)
{
if (hddType != HardDiskType_WritethroughHardDisk)
CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_WritethroughHardDisk));
}
else if (strcmp(type, "immutable") == 0)
{
if (hddType != HardDiskType_ImmutableHardDisk)
CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_ImmutableHardDisk));
}
else
{
return errorArgument("Invalid VDI type '%s' specified", Utf8Str(type).raw());
}
}
else
{
return errorArgument("Hard disk image not registered");
}
}
else if (strcmp(argv[1], "compact") == 0)
{
ComPtr<IVirtualDiskImage> vdi;
/* the hard disk image might not be registered */
if (!hardDisk)
{
virtualBox->OpenVirtualDiskImage(Bstr(argv[0]), vdi.asOutParam());
if (!vdi)
{
return errorArgument("Hard disk image not found");
}
}
else
vdi = hardDisk;
if (!vdi)
return errorArgument("Invalid hard disk type. The command only works on VDI files\n");
Bstr fileName;
vdi->COMGETTER(FilePath)(fileName.asOutParam());
/* close the file */
hardDisk = NULL;
vdi = NULL;
unsigned uProcent;
RTPrintf("Shrinking '%lS': 0%%", fileName.raw());
int vrc = VDIShrinkImage(Utf8Str(fileName).raw(), vdiProgressCallback, &uProcent);
if (VBOX_FAILURE(vrc))
{
RTPrintf("Error while shrinking hard disk image: %Vrc\n", vrc);
rc = E_FAIL;
}
}
else
{
return errorSyntax(USAGE_MODIFYVDI, "Invalid parameter '%s'", Utf8Str(argv[1]).raw());
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleCloneVDI(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
/* source VDI and target path */
if (argc != 2)
{
return errorSyntax(USAGE_CLONEVDI, "Incorrect number of parameters");
}
/* first guess is that it's a UUID */
Guid uuid(argv[0]);
ComPtr<IHardDisk> hardDisk;
rc = virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
if (!hardDisk)
{
/* not successful? Then it must be a filename */
ComPtr<IVirtualDiskImage> vdi;
CHECK_ERROR(virtualBox, OpenVirtualDiskImage(Bstr(argv[0]), vdi.asOutParam()));
hardDisk = vdi;
}
if (hardDisk)
{
ComPtr<IVirtualDiskImage> vdiOut;
ComPtr<IProgress> progress;
CHECK_ERROR(hardDisk, CloneToImage(Bstr(argv[1]), vdiOut.asOutParam(), progress.asOutParam()));
if (SUCCEEDED(rc))
{
showProgress(progress);
progress->COMGETTER(ResultCode)(&rc);
if (FAILED(rc))
{
com::ProgressErrorInfo info(progress);
if (info.isBasicAvailable())
{
RTPrintf("Error: failed to clone disk image. Error message: %lS\n", info.getText().raw());
}
else
{
RTPrintf("Error: failed to clone disk image. No error message available!\n");
}
}
}
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleConvertDDImage(int argc, char *argv[])
{
#ifdef RT_OS_LINUX
const bool fReadFromStdIn = (argc >= 1) && !strcmp(argv[0], "stdin");
#else
const bool fReadFromStdIn = false;
#endif
if ((!fReadFromStdIn && argc != 2) || (fReadFromStdIn && argc != 3))
return errorSyntax(USAGE_CONVERTDD, "Incorrect number of parameters");
RTPrintf("Converting VDI: from DD image file=\"%s\" to file=\"%s\"...\n",
argv[0], argv[1]);
/* open raw image file. */
RTFILE File;
int rc = VINF_SUCCESS;
if (fReadFromStdIn)
File = 0;
else
rc = RTFileOpen(&File, argv[0], RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
if (VBOX_FAILURE(rc))
{
RTPrintf("File=\"%s\" open error: %Rrf\n", argv[0], rc);
return rc;
}
uint64_t cbFile;
/* get image size. */
if (fReadFromStdIn)
cbFile = RTStrToUInt64(argv[2]);
else
rc = RTFileGetSize(File, &cbFile);
if (VBOX_SUCCESS(rc))
{
RTPrintf("Creating fixed image with size %RU64Bytes (%RU64MB)...\n", cbFile, (cbFile + _1M - 1) / _1M);
char pszComment[256];
RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", argv[0]);
rc = VDICreateBaseImage(argv[1],
VDI_IMAGE_TYPE_FIXED,
cbFile,
pszComment, NULL, NULL);
if (VBOX_SUCCESS(rc))
{
PVDIDISK pVdi = VDIDiskCreate();
rc = VDIDiskOpenImage(pVdi, argv[1], VDI_OPEN_FLAGS_NORMAL);
if (VBOX_SUCCESS(rc))
{
/* alloc work buffer. */
void *pvBuf = RTMemAlloc(VDIDiskGetBufferSize(pVdi));
if (pvBuf)
{
uint64_t off = 0;
while (off < cbFile)
{
size_t cbRead = 0;
rc = RTFileRead(File, pvBuf, VDIDiskGetBufferSize(pVdi), &cbRead);
if (VBOX_FAILURE(rc) || !cbRead)
break;
rc = VDIDiskWrite(pVdi, off, pvBuf, cbRead);
if (VBOX_FAILURE(rc))
break;
off += cbRead;
}
RTMemFree(pvBuf);
}
else
rc = VERR_NO_MEMORY;
VDIDiskCloseImage(pVdi);
}
if (VBOX_FAILURE(rc))
{
/* delete image on error */
RTPrintf("Failed (%Vrc)!\n", rc);
VDIDeleteImage(argv[1]);
}
}
else
RTPrintf("Failed to create output file (%Vrc)!\n", rc);
}
RTFileClose(File);
return rc;
}
static int handleAddiSCSIDisk(int argc, char *argv[],
ComPtr <IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
HRESULT rc;
Bstr server;
Bstr target;
uint16_t port = UINT16_MAX;
uint64_t lun = UINT64_MAX;
Bstr username;
Bstr password;
Bstr comment;
/* at least server and target */
if (argc < 4)
{
return errorSyntax(USAGE_ADDISCSIDISK, "Not enough parameters");
}
/* let's have a closer look at the arguments */
for (int i = 0; i < argc; i++)
{
if (strcmp(argv[i], "-server") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
server = argv[i];
}
else if (strcmp(argv[i], "-target") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
target = argv[i];
}
else if (strcmp(argv[i], "-port") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
port = atoi(argv[i]);
}
else if (strcmp(argv[i], "-lun") == 0)
{
/** @todo move the LUN encoding algorithm into IISCSIHardDisk, add decoding */
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
char *pszNext;
int rc = RTStrToUInt64Ex(argv[i], &pszNext, 0, &lun);
if (VBOX_FAILURE(rc) || *pszNext != '\0' || lun >= 16384)
return errorArgument("Invalid LUN number '%s'", argv[i]);
if (lun <= 255)
{
/* Assume bus identifier = 0. */
lun = (lun << 48); /* uses peripheral device addressing method */
}
else
{
/* Check above already limited the LUN to 14 bits. */
lun = (lun << 48) | RT_BIT_64(62); /* uses flat space addressing method */
}
}
else if (strcmp(argv[i], "-encodedlun") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
char *pszNext;
int rc = RTStrToUInt64Ex(argv[i], &pszNext, 0, &lun);
if (VBOX_FAILURE(rc) || *pszNext != '\0')
return errorArgument("Invalid encoded LUN number '%s'", argv[i]);
}
else if (strcmp(argv[i], "-username") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
username = argv[i];
}
else if (strcmp(argv[i], "-password") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
password = argv[i];
}
else if (strcmp(argv[i], "-comment") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
comment = argv[i];
}
else
{
return errorSyntax(USAGE_ADDISCSIDISK, "Invalid parameter '%s'", Utf8Str(argv[i]).raw());
}
}
/* check for required options */
if (!server || !target)
{
return errorSyntax(USAGE_ADDISCSIDISK, "Parameters -server and -target are required");
}
ComPtr<IHardDisk> hardDisk;
CHECK_ERROR(aVirtualBox, CreateHardDisk(HardDiskStorageType_ISCSIHardDisk, hardDisk.asOutParam()));
if (SUCCEEDED(rc) && hardDisk)
{
CHECK_ERROR(hardDisk, COMSETTER(Description)(comment));
ComPtr<IISCSIHardDisk> iSCSIDisk = hardDisk;
CHECK_ERROR(iSCSIDisk, COMSETTER(Server)(server));
if (port != UINT16_MAX)
CHECK_ERROR(iSCSIDisk, COMSETTER(Port)(port));
CHECK_ERROR(iSCSIDisk, COMSETTER(Target)(target));
if (lun != UINT64_MAX)
CHECK_ERROR(iSCSIDisk, COMSETTER(Lun)(lun));
CHECK_ERROR(iSCSIDisk, COMSETTER(UserName)(username));
CHECK_ERROR(iSCSIDisk, COMSETTER(Password)(password));
if (SUCCEEDED(rc))
{
CHECK_ERROR(aVirtualBox, RegisterHardDisk(hardDisk));
}
if (SUCCEEDED(rc))
{
Guid guid;
CHECK_ERROR(hardDisk, COMGETTER(Id)(guid.asOutParam()));
RTPrintf("iSCSI disk created. UUID: %s\n", guid.toString().raw());
}
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleCreateVM(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
Bstr baseFolder;
Bstr settingsFile;
Bstr name;
bool fRegister = false;
for (int i = 0; i < argc; i++)
{
if (strcmp(argv[i], "-basefolder") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
baseFolder = argv[i];
}
else if (strcmp(argv[i], "-settingsfile") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
settingsFile = argv[i];
}
else if (strcmp(argv[i], "-name") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
name = argv[i];
}
else if (strcmp(argv[i], "-register") == 0)
{
fRegister = true;
}
else
{
return errorSyntax(USAGE_CREATEVM, "Invalid parameter '%s'", Utf8Str(argv[i]).raw());
}
}
if (!name)
{
return errorSyntax(USAGE_CREATEVM, "Parameter -name is required");
}
if (!!baseFolder && !!settingsFile)
{
return errorSyntax(USAGE_CREATEVM, "Either -basefolder or -settingsfile must be specified");
}
do
{
ComPtr<IMachine> machine;
if (!settingsFile)
CHECK_ERROR_BREAK(virtualBox,
CreateMachine(baseFolder, name, machine.asOutParam()));
else
CHECK_ERROR_BREAK(virtualBox,
CreateLegacyMachine(settingsFile, name, machine.asOutParam()));
CHECK_ERROR_BREAK(machine, SaveSettings());
if (fRegister)
{
CHECK_ERROR_BREAK(virtualBox, RegisterMachine(machine));
}
Guid uuid;
CHECK_ERROR_BREAK(machine, COMGETTER(Id)(uuid.asOutParam()));
CHECK_ERROR_BREAK(machine, COMGETTER(SettingsFilePath)(settingsFile.asOutParam()));
RTPrintf("Virtual machine '%ls' is created%s.\n"
"UUID: %s\n"
"Settings file: '%ls'\n",
name.raw(), fRegister ? " and registered" : "",
uuid.toString().raw(), settingsFile.raw());
}
while (0);
return SUCCEEDED(rc) ? 0 : 1;
}
/**
* Parses a number.
*
* @returns Valid number on success.
* @returns 0 if invalid number. All necesary bitching has been done.
* @param psz Pointer to the nic number.
*/
static unsigned parseNum(const char *psz, unsigned cMaxNum, const char *name)
{
uint32_t u32;
char *pszNext;
int rc = RTStrToUInt32Ex(psz, &pszNext, 10, &u32);
if ( VBOX_SUCCESS(rc)
&& *pszNext == '\0'
&& u32 >= 1
&& u32 <= cMaxNum)
return (unsigned)u32;
errorArgument("Invalid %s number '%s'", name, psz);
return 0;
}
static int handleModifyVM(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
Bstr name;
Bstr ostype;
ULONG memorySize = 0;
ULONG vramSize = 0;
char *acpi = NULL;
char *hwvirtex = NULL;
char *ioapic = NULL;
int monitorcount = -1;
char *bioslogofadein = NULL;
char *bioslogofadeout = NULL;
uint32_t bioslogodisplaytime = ~0;
char *bioslogoimagepath = NULL;
char *biosbootmenumode = NULL;
char *biossystemtimeoffset = NULL;
char *biospxedebug = NULL;
DeviceType_T bootDevice[4];
int bootDeviceChanged[4] = { false };
char *hdds[4] = {0};
char *dvd = NULL;
char *dvdpassthrough = NULL;
char *floppy = NULL;
char *audio = NULL;
char *clipboard = NULL;
#ifdef VBOX_VRDP
char *vrdp = NULL;
uint16_t vrdpport = UINT16_MAX;
char *vrdpaddress = NULL;
char *vrdpauthtype = NULL;
char *vrdpmulticon = NULL;
#endif
int fUsbEnabled = -1;
char *snapshotFolder = NULL;
ULONG guestMemBalloonSize = (ULONG)-1;
ULONG guestStatInterval = (ULONG)-1;
/* VM ID + at least one parameter + value */
if (argc < 3)
{
return errorSyntax(USAGE_MODIFYVM, "Not enough parameters");
}
/* Get the number of network adapters */
ULONG NetworkAdapterCount = 0;
{
ComPtr <ISystemProperties> info;
CHECK_ERROR_RET (virtualBox, COMGETTER(SystemProperties) (info.asOutParam()), 1);
CHECK_ERROR_RET (info, COMGETTER(NetworkAdapterCount) (&NetworkAdapterCount), 1);
}
ULONG SerialPortCount = 0;
{
ComPtr <ISystemProperties> info;
CHECK_ERROR_RET (virtualBox, COMGETTER(SystemProperties) (info.asOutParam()), 1);
CHECK_ERROR_RET (info, COMGETTER(SerialPortCount) (&SerialPortCount), 1);
}
std::vector <char *> nics (NetworkAdapterCount, 0);
std::vector <char *> nictype (NetworkAdapterCount, 0);
std::vector <char *> cableconnected (NetworkAdapterCount, 0);
std::vector <char *> nictrace (NetworkAdapterCount, 0);
std::vector <char *> nictracefile (NetworkAdapterCount, 0);
std::vector <char *> nicspeed (NetworkAdapterCount, 0);
std::vector <char *> hostifdev (NetworkAdapterCount, 0);
std::vector <const char *> intnet (NetworkAdapterCount, 0);
#ifdef RT_OS_LINUX
std::vector <char *> tapsetup (NetworkAdapterCount, 0);
std::vector <char *> tapterm (NetworkAdapterCount, 0);
#endif
std::vector <char *> macs (NetworkAdapterCount, 0);
std::vector <char *> uarts_mode (SerialPortCount, 0);
std::vector <ULONG> uarts_base (SerialPortCount, 0);
std::vector <ULONG> uarts_irq (SerialPortCount, 0);
std::vector <char *> uarts_path (SerialPortCount, 0);
for (int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "-name") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
name = argv[i];
}
else if (strcmp(argv[i], "-ostype") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
ostype = argv[i];
}
else if (strcmp(argv[i], "-memory") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
memorySize = atoi(argv[i]);
}
else if (strcmp(argv[i], "-vram") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
vramSize = atoi(argv[i]);
}
else if (strcmp(argv[i], "-acpi") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
acpi = argv[i];
}
else if (strcmp(argv[i], "-ioapic") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
ioapic = argv[i];
}
else if (strcmp(argv[i], "-hwvirtex") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
hwvirtex = argv[i];
}
else if (strcmp(argv[i], "-monitorcount") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
monitorcount = atoi(argv[i]);
}
else if (strcmp(argv[i], "-bioslogofadein") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
bioslogofadein = argv[i];
}
else if (strcmp(argv[i], "-bioslogofadeout") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
bioslogofadeout = argv[i];
}
else if (strcmp(argv[i], "-bioslogodisplaytime") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
bioslogodisplaytime = atoi(argv[i]);
}
else if (strcmp(argv[i], "-bioslogoimagepath") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
bioslogoimagepath = argv[i];
}
else if (strcmp(argv[i], "-biosbootmenu") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
biosbootmenumode = argv[i];
}
else if (strcmp(argv[i], "-biossystemtimeoffset") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
biossystemtimeoffset = argv[i];
}
else if (strcmp(argv[i], "-biospxedebug") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
biospxedebug = argv[i];
}
else if (strncmp(argv[i], "-boot", 5) == 0)
{
ULONG n = 0;
if (!argv[i][5])
{
return errorSyntax(USAGE_MODIFYVM, "Missing boot slot number in '%s'", argv[i]);
}
if ((n = strtoul(&argv[i][5], NULL, 10)) < 1)
{
return errorSyntax(USAGE_MODIFYVM, "Invalid boot slot number in '%s'", argv[i]);
}
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
if (strcmp(argv[i], "none") == 0)
{
bootDevice[n - 1] = DeviceType_NoDevice;
}
else if (strcmp(argv[i], "floppy") == 0)
{
bootDevice[n - 1] = DeviceType_FloppyDevice;
}
else if (strcmp(argv[i], "dvd") == 0)
{
bootDevice[n - 1] = DeviceType_DVDDevice;
}
else if (strcmp(argv[i], "disk") == 0)
{
bootDevice[n - 1] = DeviceType_HardDiskDevice;
}
else if (strcmp(argv[i], "net") == 0)
{
bootDevice[n - 1] = DeviceType_NetworkDevice;
}
else
{
return errorArgument("Invalid boot device '%s'", argv[i]);
}
bootDeviceChanged[n - 1] = true;
}
else if (strcmp(argv[i], "-hda") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
hdds[0] = argv[i];
}
else if (strcmp(argv[i], "-hdb") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
hdds[1] = argv[i];
}
else if (strcmp(argv[i], "-hdd") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
hdds[2] = argv[i];
}
else if (strcmp(argv[i], "-dvd") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
dvd = argv[i];
}
else if (strcmp(argv[i], "-dvdpassthrough") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
dvdpassthrough = argv[i];
}
else if (strcmp(argv[i], "-floppy") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
floppy = argv[i];
}
else if (strcmp(argv[i], "-audio") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
audio = argv[i];
}
else if (strcmp(argv[i], "-clipboard") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
clipboard = argv[i];
}
else if (strncmp(argv[i], "-cableconnected", 15) == 0)
{
unsigned n = parseNum(&argv[i][15], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
cableconnected[n - 1] = argv[i + 1];
i++;
}
/* watch for the right order of these -nic* comparisons! */
else if (strncmp(argv[i], "-nictracefile", 13) == 0)
{
unsigned n = parseNum(&argv[i][13], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
nictracefile[n - 1] = argv[i + 1];
i++;
}
else if (strncmp(argv[i], "-nictrace", 9) == 0)
{
unsigned n = parseNum(&argv[i][9], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
nictrace[n - 1] = argv[i + 1];
i++;
}
else if (strncmp(argv[i], "-nictype", 8) == 0)
{
unsigned n = parseNum(&argv[i][8], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
nictype[n - 1] = argv[i + 1];
i++;
}
else if (strncmp(argv[i], "-nicspeed", 9) == 0)
{
unsigned n = parseNum(&argv[i][9], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
nicspeed[n - 1] = argv[i + 1];
i++;
}
else if (strncmp(argv[i], "-nic", 4) == 0)
{
unsigned n = parseNum(&argv[i][4], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
nics[n - 1] = argv[i + 1];
i++;
}
else if (strncmp(argv[i], "-hostifdev", 10) == 0)
{
unsigned n = parseNum(&argv[i][10], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
hostifdev[n - 1] = argv[i + 1];
i++;
}
else if (strncmp(argv[i], "-intnet", 7) == 0)
{
unsigned n = parseNum(&argv[i][7], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
intnet[n - 1] = argv[i + 1];
i++;
}
#ifdef RT_OS_LINUX
else if (strncmp(argv[i], "-tapsetup", 9) == 0)
{
unsigned n = parseNum(&argv[i][9], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
tapsetup[n - 1] = argv[i + 1];
i++;
}
else if (strncmp(argv[i], "-tapterminate", 13) == 0)
{
unsigned n = parseNum(&argv[i][13], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
tapterm[n - 1] = argv[i + 1];
i++;
}
#endif /* RT_OS_LINUX */
else if (strncmp(argv[i], "-macaddress", 11) == 0)
{
unsigned n = parseNum(&argv[i][11], NetworkAdapterCount, "NIC");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
macs[n - 1] = argv[i + 1];
i++;
}
#ifdef VBOX_VRDP
else if (strcmp(argv[i], "-vrdp") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
vrdp = argv[i];
}
else if (strcmp(argv[i], "-vrdpport") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
if (strcmp(argv[i], "default") == 0)
vrdpport = 0;
else
vrdpport = atoi(argv[i]);
}
else if (strcmp(argv[i], "-vrdpaddress") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
vrdpaddress = argv[i];
}
else if (strcmp(argv[i], "-vrdpauthtype") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
vrdpauthtype = argv[i];
}
else if (strcmp(argv[i], "-vrdpmulticon") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
vrdpmulticon = argv[i];
}
#endif /* VBOX_VRDP */
else if (strcmp(argv[i], "-usb") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
if (strcmp(argv[i], "on") == 0 || strcmp(argv[i], "enable") == 0)
fUsbEnabled = 1;
else if (strcmp(argv[i], "off") == 0 || strcmp(argv[i], "disable") == 0)
fUsbEnabled = 0;
else
return errorArgument("Invalid -usb argument '%s'", argv[i]);
}
else if (strcmp(argv[i], "-snapshotfolder") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
snapshotFolder = argv[i];
}
else if (strncmp(argv[i], "-uartmode", 9) == 0)
{
unsigned n = parseNum(&argv[i][9], SerialPortCount, "UART");
if (!n)
return 1;
i++;
if (strcmp(argv[i], "disconnected") == 0)
{
uarts_mode[n - 1] = argv[i];
}
else
{
if (strcmp(argv[i], "server") == 0 || strcmp(argv[i], "client") == 0)
{
uarts_mode[n - 1] = argv[i];
i++;
#ifdef RT_OS_WINDOWS
if (strncmp(argv[i], "\\\\.\\pipe\\", 9))
return errorArgument("Uart pipe must start with \\\\.\\pipe\\");
#endif
}
else
{
uarts_mode[n - 1] = (char*)"device";
}
if (argc <= i)
{
return errorArgument("Missing argument to -uartmode");
}
uarts_path[n - 1] = argv[i];
}
}
else if (strncmp(argv[i], "-uart", 5) == 0)
{
unsigned n = parseNum(&argv[i][5], SerialPortCount, "UART");
if (!n)
return 1;
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
if (strcmp(argv[i], "off") == 0 || strcmp(argv[i], "disable") == 0)
{
uarts_base[n - 1] = (ULONG)-1;
}
else
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i-1]);
}
uint32_t uVal;
int vrc;
vrc = RTStrToUInt32Ex(argv[i], NULL, 0, &uVal);
if (vrc != VINF_SUCCESS || uVal == 0)
return errorArgument("Error parsing UART I/O base '%s'", argv[i]);
uarts_base[n - 1] = uVal;
i++;
vrc = RTStrToUInt32Ex(argv[i], NULL, 0, &uVal);
if (vrc != VINF_SUCCESS)
return errorArgument("Error parsing UART IRQ '%s'", argv[i]);
uarts_irq[n - 1] = uVal;
}
}
else if (strncmp(argv[i], "-guestmemoryballoon", 19) == 0)
{
if (argc <= i + 1)
return errorArgument("Missing argument to '%s'", argv[i-1]);
i++;
uint32_t uVal;
int vrc;
vrc = RTStrToUInt32Ex(argv[i], NULL, 0, &uVal);
if (vrc != VINF_SUCCESS)
return errorArgument("Error parsing guest memory balloon size '%s'", argv[i]);
guestMemBalloonSize = uVal;
}
else if (strncmp(argv[i], "-gueststatisticsinterval", 24) == 0)
{
if (argc <= i + 1)
return errorArgument("Missing argument to '%s'", argv[i-1]);
i++;
uint32_t uVal;
int vrc;
vrc = RTStrToUInt32Ex(argv[i], NULL, 0, &uVal);
if (vrc != VINF_SUCCESS)
return errorArgument("Error parsing guest statistics interval '%s'", argv[i]);
guestStatInterval = uVal;
}
else
{
return errorSyntax(USAGE_MODIFYVM, "Invalid parameter '%s'", Utf8Str(argv[i]).raw());
}
}
/* try to find the given machine */
ComPtr <IMachine> machine;
Guid uuid (argv[0]);
if (!uuid.isEmpty())
{
CHECK_ERROR (virtualBox, GetMachine (uuid, machine.asOutParam()));
}
else
{
CHECK_ERROR (virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
if (SUCCEEDED (rc))
machine->COMGETTER(Id)(uuid.asOutParam());
}
if (FAILED (rc))
return 1;
/* open a session for the VM */
CHECK_ERROR_RET (virtualBox, OpenSession(session, uuid), 1);
do
{
/* get the mutable session machine */
session->COMGETTER(Machine)(machine.asOutParam());
ComPtr <IBIOSSettings> biosSettings;
machine->COMGETTER(BIOSSettings)(biosSettings.asOutParam());
if (name)
CHECK_ERROR(machine, COMSETTER(Name)(name));
if (ostype)
{
ComPtr<IGuestOSType> guestOSType;
CHECK_ERROR(virtualBox, GetGuestOSType(ostype, guestOSType.asOutParam()));
if (SUCCEEDED(rc) && guestOSType)
{
CHECK_ERROR(machine, COMSETTER(OSTypeId)(ostype));
}
else
{
errorArgument("Invalid guest OS type '%s'", Utf8Str(ostype).raw());
rc = E_FAIL;
break;
}
}
if (memorySize > 0)
CHECK_ERROR(machine, COMSETTER(MemorySize)(memorySize));
if (vramSize > 0)
CHECK_ERROR(machine, COMSETTER(VRAMSize)(vramSize));
if (acpi)
{
if (strcmp(acpi, "on") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(true));
}
else if (strcmp(acpi, "off") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(ACPIEnabled)(false));
}
else
{
errorArgument("Invalid -acpi argument '%s'", acpi);
rc = E_FAIL;
break;
}
}
if (ioapic)
{
if (strcmp(ioapic, "on") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(true));
}
else if (strcmp(ioapic, "off") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(IOAPICEnabled)(false));
}
else
{
errorArgument("Invalid -ioapic argument '%s'", ioapic);
rc = E_FAIL;
break;
}
}
if (hwvirtex)
{
if (strcmp(hwvirtex, "on") == 0)
{
CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TriStateBool_True));
}
else if (strcmp(hwvirtex, "off") == 0)
{
CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TriStateBool_False));
}
else if (strcmp(hwvirtex, "default") == 0)
{
CHECK_ERROR(machine, COMSETTER(HWVirtExEnabled)(TriStateBool_Default));
}
else
{
errorArgument("Invalid -hwvirtex argument '%s'", hwvirtex);
rc = E_FAIL;
break;
}
}
if (monitorcount != -1)
{
CHECK_ERROR(machine, COMSETTER(MonitorCount)(monitorcount));
}
if (bioslogofadein)
{
if (strcmp(bioslogofadein, "on") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(true));
}
else if (strcmp(bioslogofadein, "off") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(LogoFadeIn)(false));
}
else
{
errorArgument("Invalid -bioslogofadein argument '%s'", bioslogofadein);
rc = E_FAIL;
break;
}
}
if (bioslogofadeout)
{
if (strcmp(bioslogofadeout, "on") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(true));
}
else if (strcmp(bioslogofadeout, "off") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(LogoFadeOut)(false));
}
else
{
errorArgument("Invalid -bioslogofadeout argument '%s'", bioslogofadeout);
rc = E_FAIL;
break;
}
}
if (bioslogodisplaytime != ~0U)
{
CHECK_ERROR(biosSettings, COMSETTER(LogoDisplayTime)(bioslogodisplaytime));
}
if (bioslogoimagepath)
{
CHECK_ERROR(biosSettings, COMSETTER(LogoImagePath)(Bstr(bioslogoimagepath)));
}
if (biosbootmenumode)
{
if (strcmp(biosbootmenumode, "disabled") == 0)
CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_Disabled));
else if (strcmp(biosbootmenumode, "menuonly") == 0)
CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MenuOnly));
else if (strcmp(biosbootmenumode, "messageandmenu") == 0)
CHECK_ERROR(biosSettings, COMSETTER(BootMenuMode)(BIOSBootMenuMode_MessageAndMenu));
else
{
errorArgument("Invalid -biosbootmenu argument '%s'", biosbootmenumode);
rc = E_FAIL;
break;
}
}
if (biossystemtimeoffset)
{
LONG64 timeOffset = RTStrToInt64(biossystemtimeoffset);
CHECK_ERROR(biosSettings, COMSETTER(TimeOffset)(timeOffset));
}
if (biospxedebug)
{
if (strcmp(biospxedebug, "on") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(true));
}
else if (strcmp(biospxedebug, "off") == 0)
{
CHECK_ERROR(biosSettings, COMSETTER(PXEDebugEnabled)(false));
}
else
{
errorArgument("Invalid -biospxedebug argument '%s'", biospxedebug);
rc = E_FAIL;
break;
}
}
for (int curBootDev = 0; curBootDev < 4; curBootDev++)
{
if (bootDeviceChanged[curBootDev])
CHECK_ERROR(machine, SetBootOrder (curBootDev + 1, bootDevice[curBootDev]));
}
if (hdds[0])
{
if (strcmp(hdds[0], "none") == 0)
{
machine->DetachHardDisk(DiskControllerType_IDE0Controller, 0);
}
else
{
/* first guess is that it's a UUID */
Guid uuid(hdds[0]);
ComPtr<IHardDisk> hardDisk;
rc = virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
/* not successful? Then it must be a filename */
if (!hardDisk)
{
CHECK_ERROR(virtualBox, OpenHardDisk(Bstr(hdds[0]), hardDisk.asOutParam()));
if (SUCCEEDED(rc) && hardDisk)
{
/* first check if it's already registered */
Guid hddUUID;
hardDisk->COMGETTER(Id)(hddUUID.asOutParam());
ComPtr<IHardDisk> registeredHDD;
rc = virtualBox->GetHardDisk(hddUUID, registeredHDD.asOutParam());
if (SUCCEEDED(rc) && registeredHDD)
hardDisk = registeredHDD;
else
{
/* it has to be registered */
CHECK_ERROR(virtualBox, RegisterHardDisk(hardDisk));
if (FAILED(rc))
break;
}
}
}
if (hardDisk)
{
hardDisk->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(machine, AttachHardDisk(uuid, DiskControllerType_IDE0Controller, 0));
}
else
rc = E_FAIL;
if (FAILED(rc))
break;
}
}
if (hdds[1])
{
if (strcmp(hdds[1], "none") == 0)
{
machine->DetachHardDisk(DiskControllerType_IDE0Controller, 1);
}
else
{
/* first guess is that it's a UUID */
Guid uuid(hdds[1]);
ComPtr<IHardDisk> hardDisk;
rc = virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
/* not successful? Then it must be a filename */
if (!hardDisk)
{
CHECK_ERROR(virtualBox, OpenHardDisk(Bstr(hdds[1]), hardDisk.asOutParam()));
if (SUCCEEDED(rc) && hardDisk)
{
/* first check if it's already registered */
Guid hddUUID;
hardDisk->COMGETTER(Id)(hddUUID.asOutParam());
ComPtr<IHardDisk> registeredHDD;
rc = virtualBox->GetHardDisk(hddUUID, registeredHDD.asOutParam());
if (SUCCEEDED(rc) && registeredHDD)
hardDisk = registeredHDD;
else
{
/* it has to be registered */
CHECK_ERROR(virtualBox, RegisterHardDisk(hardDisk));
if (FAILED(rc))
break;
}
}
}
if (hardDisk)
{
hardDisk->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(machine, AttachHardDisk(uuid, DiskControllerType_IDE0Controller, 1));
}
else
rc = E_FAIL;
if (FAILED(rc))
break;
}
}
if (hdds[2])
{
if (strcmp(hdds[2], "none") == 0)
{
machine->DetachHardDisk(DiskControllerType_IDE1Controller, 1);
}
else
{
/* first guess is that it's a UUID */
Guid uuid(hdds[2]);
ComPtr<IHardDisk> hardDisk;
rc = virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
/* not successful? Then it must be a filename */
if (!hardDisk)
{
CHECK_ERROR(virtualBox, OpenHardDisk(Bstr(hdds[2]), hardDisk.asOutParam()));
if (SUCCEEDED(rc) && hardDisk)
{
/* first check if it's already registered */
Guid hddUUID;
hardDisk->COMGETTER(Id)(hddUUID.asOutParam());
ComPtr<IHardDisk> registeredHDD;
rc = virtualBox->GetHardDisk(hddUUID, registeredHDD.asOutParam());
if (SUCCEEDED(rc) && registeredHDD)
hardDisk = registeredHDD;
else
{
/* it has to be registered */
CHECK_ERROR(virtualBox, RegisterHardDisk(hardDisk));
if (FAILED(rc))
break;
}
}
}
if (hardDisk)
{
hardDisk->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(machine, AttachHardDisk(uuid, DiskControllerType_IDE1Controller, 1));
}
else
rc = E_FAIL;
if (FAILED(rc))
break;
}
}
if (dvd)
{
ComPtr<IDVDDrive> dvdDrive;
machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
ASSERT(dvdDrive);
/* unmount? */
if (strcmp(dvd, "none") == 0)
{
CHECK_ERROR(dvdDrive, Unmount());
}
/* host drive? */
else if (strncmp(dvd, "host:", 5) == 0)
{
ComPtr<IHost> host;
CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
ComPtr<IHostDVDDriveCollection> hostDVDs;
CHECK_ERROR(host, COMGETTER(DVDDrives)(hostDVDs.asOutParam()));
ComPtr<IHostDVDDrive> hostDVDDrive;
rc = hostDVDs->FindByName(Bstr(dvd + 5), hostDVDDrive.asOutParam());
if (!hostDVDDrive)
{
/* 2nd try: try with the real name, important on Linux+libhal */
char szPathReal[RTPATH_MAX];
if (VBOX_FAILURE(RTPathReal(dvd + 5, szPathReal, sizeof(szPathReal))))
{
errorArgument("Invalid host DVD drive name");
rc = E_FAIL;
break;
}
rc = hostDVDs->FindByName(Bstr(szPathReal), hostDVDDrive.asOutParam());
if (!hostDVDDrive)
{
errorArgument("Invalid host DVD drive name");
rc = E_FAIL;
break;
}
}
CHECK_ERROR(dvdDrive, CaptureHostDrive(hostDVDDrive));
}
else
{
/* first assume it's a UUID */
Guid uuid(dvd);
ComPtr<IDVDImage> dvdImage;
rc = virtualBox->GetDVDImage(uuid, dvdImage.asOutParam());
if (FAILED(rc) || !dvdImage)
{
/* must be a filename, check if it's in the collection */
ComPtr<IDVDImageCollection> dvdImages;
virtualBox->COMGETTER(DVDImages)(dvdImages.asOutParam());
rc = dvdImages->FindByPath(Bstr(dvd), dvdImage.asOutParam());
/* not registered, do that on the fly */
if (!dvdImage)
{
Guid emptyUUID;
CHECK_ERROR(virtualBox, OpenDVDImage(Bstr(dvd), emptyUUID, dvdImage.asOutParam()));
if (SUCCEEDED(rc) && dvdImage)
{
/* time to register the image */
CHECK_ERROR(virtualBox, RegisterDVDImage(dvdImage));
}
}
}
if (!dvdImage)
{
rc = E_FAIL;
break;
}
dvdImage->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(dvdDrive, MountImage(uuid));
}
}
if (dvdpassthrough)
{
ComPtr<IDVDDrive> dvdDrive;
machine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
ASSERT(dvdDrive);
CHECK_ERROR(dvdDrive, COMSETTER(Passthrough)(strcmp(dvdpassthrough, "on") == 0));
}
if (floppy)
{
ComPtr<IFloppyDrive> floppyDrive;
machine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
ASSERT(floppyDrive);
/* disable? */
if (strcmp(floppy, "disabled") == 0)
{
/* disable the controller */
CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(false));
}
else
{
/* enable the controller */
CHECK_ERROR(floppyDrive, COMSETTER(Enabled)(true));
/* unmount? */
if (strcmp(floppy, "empty") == 0)
{
CHECK_ERROR(floppyDrive, Unmount());
}
/* host drive? */
else if (strncmp(floppy, "host:", 5) == 0)
{
ComPtr<IHost> host;
CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
ComPtr<IHostFloppyDriveCollection> hostFloppies;
CHECK_ERROR(host, COMGETTER(FloppyDrives)(hostFloppies.asOutParam()));
ComPtr<IHostFloppyDrive> hostFloppyDrive;
rc = hostFloppies->FindByName(Bstr(floppy + 5), hostFloppyDrive.asOutParam());
if (!hostFloppyDrive)
{
errorArgument("Invalid host floppy drive name");
rc = E_FAIL;
break;
}
CHECK_ERROR(floppyDrive, CaptureHostDrive(hostFloppyDrive));
}
else
{
/* first assume it's a UUID */
Guid uuid(floppy);
ComPtr<IFloppyImage> floppyImage;
rc = virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam());
if (FAILED(rc) || !floppyImage)
{
/* must be a filename */
Guid emptyUUID;
CHECK_ERROR(virtualBox, OpenFloppyImage(Bstr(floppy), emptyUUID, floppyImage.asOutParam()));
if (SUCCEEDED(rc) && floppyImage)
{
/** @todo first iterate through the collection and try to find the image */
/* time to register the image */
CHECK_ERROR(virtualBox, RegisterFloppyImage(floppyImage));
}
}
if (!floppyImage)
{
rc = E_FAIL;
break;
}
floppyImage->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(floppyDrive, MountImage(uuid));
}
}
}
if (audio)
{
ComPtr<IAudioAdapter> audioAdapter;
machine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam());
ASSERT(audioAdapter);
/* disable? */
if (strcmp(audio, "none") == 0)
{
CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(false));
}
else if (strcmp(audio, "null") == 0)
{
CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_NullAudioDriver));
CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
}
#ifdef RT_OS_WINDOWS
#ifdef VBOX_WITH_WINMM
else if (strcmp(audio, "winmm") == 0)
{
CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_WINMMAudioDriver));
CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
}
#endif
else if (strcmp(audio, "dsound") == 0)
{
CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_DSOUNDAudioDriver));
CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
}
#endif /* RT_OS_WINDOWS */
#ifdef RT_OS_LINUX
else if (strcmp(audio, "oss") == 0)
{
CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_OSSAudioDriver));
CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
}
# ifdef VBOX_WITH_ALSA
else if (strcmp(audio, "alsa") == 0)
{
CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_ALSAAudioDriver));
CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
}
# endif
#endif /* !RT_OS_LINUX */
#ifdef RT_OS_DARWIN
else if (strcmp(audio, "coreaudio") == 0)
{
CHECK_ERROR(audioAdapter, COMSETTER(AudioDriver)(AudioDriverType_CoreAudioDriver));
CHECK_ERROR(audioAdapter, COMSETTER(Enabled)(true));
}
#endif /* !RT_OS_DARWIN */
else
{
errorArgument("Invalid -audio argument '%s'", audio);
rc = E_FAIL;
break;
}
}
/* Shared clipboard state */
if (clipboard)
{
/* ComPtr<IClipboardMode> clipboardMode;
machine->COMGETTER(ClipboardMode)(clipboardMode.asOutParam());
ASSERT(clipboardMode);
*/
if (strcmp(clipboard, "disabled") == 0)
{
CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_ClipDisabled));
}
else if (strcmp(clipboard, "hosttoguest") == 0)
{
CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_ClipHostToGuest));
}
else if (strcmp(clipboard, "guesttohost") == 0)
{
CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_ClipGuestToHost));
}
else if (strcmp(clipboard, "bidirectional") == 0)
{
CHECK_ERROR(machine, COMSETTER(ClipboardMode)(ClipboardMode_ClipBidirectional));
}
else
{
errorArgument("Invalid -clipboard argument '%s'", clipboard);
rc = E_FAIL;
break;
}
}
/* iterate through all possible NICs */
for (ULONG n = 0; n < NetworkAdapterCount; n ++)
{
ComPtr<INetworkAdapter> nic;
CHECK_ERROR_RET (machine, GetNetworkAdapter (n, nic.asOutParam()), 1);
ASSERT(nic);
/* something about the NIC? */
if (nics[n])
{
if (strcmp(nics[n], "none") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(Enabled) (FALSE), 1);
}
else if (strcmp(nics[n], "null") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
CHECK_ERROR_RET(nic, Detach(), 1);
}
else if (strcmp(nics[n], "nat") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
CHECK_ERROR_RET(nic, AttachToNAT(), 1);
}
else if (strcmp(nics[n], "hostif") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
CHECK_ERROR_RET(nic, AttachToHostInterface(), 1);
}
else if (strcmp(nics[n], "intnet") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(Enabled) (TRUE), 1);
CHECK_ERROR_RET(nic, AttachToInternalNetwork(), 1);
}
else
{
errorArgument("Invalid type '%s' specfied for NIC %lu", nics[n], n + 1);
rc = E_FAIL;
break;
}
}
/* something about the NIC type? */
if (nictype[n])
{
if (strcmp(nictype[n], "Am79C970A") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_NetworkAdapterAm79C970A), 1);
}
else if (strcmp(nictype[n], "Am79C973") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(AdapterType)(NetworkAdapterType_NetworkAdapterAm79C973), 1);
}
else
{
errorArgument("Invalid NIC type '%s' specified for NIC %lu", nictype[n], n + 1);
rc = E_FAIL;
break;
}
}
/* something about the MAC address? */
if (macs[n])
{
/* generate one? */
if (strcmp(macs[n], "auto") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(NULL), 1);
}
else
{
CHECK_ERROR_RET(nic, COMSETTER(MACAddress)(Bstr(macs[n])), 1);
}
}
/* something about the reported link speed? */
if (nicspeed[n])
{
uint32_t u32LineSpeed;
u32LineSpeed = atoi(nicspeed[n]);
if (u32LineSpeed < 1000 || u32LineSpeed > 4000000)
{
errorArgument("Invalid -nicspeed%lu argument '%s'", n + 1, nicspeed[n]);
rc = E_FAIL;
break;
}
CHECK_ERROR_RET(nic, COMSETTER(LineSpeed)(u32LineSpeed), 1);
}
/* the link status flag? */
if (cableconnected[n])
{
if (strcmp(cableconnected[n], "on") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(TRUE), 1);
}
else if (strcmp(cableconnected[n], "off") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(CableConnected)(FALSE), 1);
}
else
{
errorArgument("Invalid -cableconnected%lu argument '%s'", n + 1, cableconnected[n]);
rc = E_FAIL;
break;
}
}
/* the trace flag? */
if (nictrace[n])
{
if (strcmp(nictrace[n], "on") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(TRUE), 1);
}
else if (strcmp(nictrace[n], "off") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(TraceEnabled)(FALSE), 1);
}
else
{
errorArgument("Invalid -nictrace%lu argument '%s'", n + 1, nictrace[n]);
rc = E_FAIL;
break;
}
}
/* the tracefile flag? */
if (nictracefile[n])
{
CHECK_ERROR_RET(nic, COMSETTER(TraceFile)(Bstr(nictracefile[n])), 1);
}
/* the host interface device? */
if (hostifdev[n])
{
/* remove it? */
if (strcmp(hostifdev[n], "none") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(NULL), 1);
}
else
{
CHECK_ERROR_RET(nic, COMSETTER(HostInterface)(Bstr(hostifdev[n])), 1);
}
}
/* the internal network name? */
if (intnet[n])
{
/* remove it? */
if (strcmp(intnet[n], "none") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(NULL), 1);
}
else
{
CHECK_ERROR_RET(nic, COMSETTER(InternalNetwork)(Bstr(intnet[n])), 1);
}
}
#ifdef RT_OS_LINUX
/* the TAP setup application? */
if (tapsetup[n])
{
/* remove it? */
if (strcmp(tapsetup[n], "none") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(TAPSetupApplication)(NULL), 1);
}
else
{
CHECK_ERROR_RET(nic, COMSETTER(TAPSetupApplication)(Bstr(tapsetup[n])), 1);
}
}
/* the TAP terminate application? */
if (tapterm[n])
{
/* remove it? */
if (strcmp(tapterm[n], "none") == 0)
{
CHECK_ERROR_RET(nic, COMSETTER(TAPTerminateApplication)(NULL), 1);
}
else
{
CHECK_ERROR_RET(nic, COMSETTER(TAPTerminateApplication)(Bstr(tapterm[n])), 1);
}
}
#endif /* RT_OS_LINUX */
}
if (FAILED(rc))
break;
/* iterate through all possible serial ports */
for (ULONG n = 0; n < SerialPortCount; n ++)
{
ComPtr<ISerialPort> uart;
CHECK_ERROR_RET (machine, GetSerialPort (n, uart.asOutParam()), 1);
ASSERT(uart);
if (uarts_base[n])
{
if (uarts_base[n] == (ULONG)-1)
{
CHECK_ERROR_RET(uart, COMSETTER(Enabled) (FALSE), 1);
}
else
{
CHECK_ERROR_RET(uart, COMSETTER(IOBase) (uarts_base[n]), 1);
CHECK_ERROR_RET(uart, COMSETTER(IRQ) (uarts_irq[n]), 1);
CHECK_ERROR_RET(uart, COMSETTER(Enabled) (TRUE), 1);
}
}
if (uarts_mode[n])
{
if (strcmp(uarts_mode[n], "disconnected") == 0)
{
CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_DisconnectedPort), 1);
}
else
{
if (strcmp(uarts_mode[n], "server") == 0)
{
CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipePort), 1);
CHECK_ERROR_RET(uart, COMSETTER(Server) (TRUE), 1);
}
else if (strcmp(uarts_mode[n], "client") == 0)
{
CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostPipePort), 1);
CHECK_ERROR_RET(uart, COMSETTER(Server) (FALSE), 1);
}
else
{
CHECK_ERROR_RET(uart, COMSETTER(HostMode) (PortMode_HostDevicePort), 1);
}
CHECK_ERROR_RET(uart, COMSETTER(Path) (Bstr(uarts_path[n])), 1);
}
}
}
if (FAILED(rc))
break;
#ifdef VBOX_VRDP
if (vrdp || (vrdpport != UINT16_MAX) || vrdpaddress || vrdpauthtype || vrdpmulticon)
{
ComPtr<IVRDPServer> vrdpServer;
machine->COMGETTER(VRDPServer)(vrdpServer.asOutParam());
ASSERT(vrdpServer);
if (vrdpServer)
{
if (vrdp)
{
if (strcmp(vrdp, "on") == 0)
{
CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(true));
}
else if (strcmp(vrdp, "off") == 0)
{
CHECK_ERROR(vrdpServer, COMSETTER(Enabled)(false));
}
else
{
errorArgument("Invalid -vrdp argument '%s'", vrdp);
rc = E_FAIL;
break;
}
}
if (vrdpport != UINT16_MAX)
{
CHECK_ERROR(vrdpServer, COMSETTER(Port)(vrdpport));
}
if (vrdpaddress)
{
CHECK_ERROR(vrdpServer, COMSETTER(NetAddress)(Bstr(vrdpaddress)));
}
if (vrdpauthtype)
{
if (strcmp(vrdpauthtype, "null") == 0)
{
CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_VRDPAuthNull));
}
else if (strcmp(vrdpauthtype, "external") == 0)
{
CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_VRDPAuthExternal));
}
else if (strcmp(vrdpauthtype, "guest") == 0)
{
CHECK_ERROR(vrdpServer, COMSETTER(AuthType)(VRDPAuthType_VRDPAuthGuest));
}
else
{
errorArgument("Invalid -vrdpauthtype argument '%s'", vrdpauthtype);
rc = E_FAIL;
break;
}
}
if (vrdpmulticon)
{
if (strcmp(vrdpmulticon, "on") == 0)
{
CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(true));
}
else if (strcmp(vrdpmulticon, "off") == 0)
{
CHECK_ERROR(vrdpServer, COMSETTER(AllowMultiConnection)(false));
}
else
{
errorArgument("Invalid -vrdpmulticon argument '%s'", vrdpmulticon);
rc = E_FAIL;
break;
}
}
}
}
#endif /* VBOX_VRDP */
/*
* USB enable/disable
*/
if (fUsbEnabled != -1)
{
ComPtr<IUSBController> UsbCtl;
CHECK_ERROR(machine, COMGETTER(USBController)(UsbCtl.asOutParam()));
if (SUCCEEDED(rc))
{
CHECK_ERROR(UsbCtl, COMSETTER(Enabled)(!!fUsbEnabled));
}
}
if (snapshotFolder)
{
if (strcmp(snapshotFolder, "default") == 0)
{
CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(NULL));
}
else
{
CHECK_ERROR(machine, COMSETTER(SnapshotFolder)(Bstr(snapshotFolder)));
}
}
if (guestMemBalloonSize != (ULONG)-1)
CHECK_ERROR(machine, COMSETTER(MemoryBalloonSize)(guestMemBalloonSize));
if (guestStatInterval != (ULONG)-1)
CHECK_ERROR(machine, COMSETTER(StatisticsUpdateInterval)(guestStatInterval));
/* commit changes */
CHECK_ERROR(machine, SaveSettings());
} while (0);
/* it's important to always close sessions */
session->Close();
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleStartVM(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
if (argc < 1)
{
return errorSyntax(USAGE_STARTVM, "Not enough parameters");
}
ComPtr<IMachine> machine;
/* assume it's a UUID */
rc = virtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
if (FAILED(rc) || !machine)
{
/* must be a name */
CHECK_ERROR(virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
}
if (machine)
{
Guid uuid;
machine->COMGETTER(Id)(uuid.asOutParam());
/* default to GUI session type */
Bstr sessionType = "gui";
/* has a session type been specified? */
if ((argc > 2) && (strcmp(argv[1], "-type") == 0))
{
if (strcmp(argv[2], "gui") == 0)
{
sessionType = "gui";
}
else if (strcmp(argv[2], "vrdp") == 0)
{
sessionType = "vrdp";
}
else if (strcmp(argv[2], "capture") == 0)
{
sessionType = "capture";
}
else
{
return errorArgument("Invalid session type argument '%s'", argv[2]);
}
}
Bstr env;
#ifdef RT_OS_LINUX
/* make sure the VM process will start on the same display as VBoxManage */
{
const char *display = RTEnvGet ("DISPLAY");
if (display)
env = Utf8StrFmt ("DISPLAY=%s", display);
}
#endif
ComPtr<IProgress> progress;
CHECK_ERROR_RET(virtualBox, OpenRemoteSession(session, uuid, sessionType,
env, progress.asOutParam()), rc);
RTPrintf("Waiting for the remote session to open...\n");
CHECK_ERROR_RET(progress, WaitForCompletion (-1), 1);
BOOL completed;
CHECK_ERROR_RET(progress, COMGETTER(Completed)(&completed), rc);
ASSERT(completed);
HRESULT resultCode;
CHECK_ERROR_RET(progress, COMGETTER(ResultCode)(&resultCode), rc);
if (FAILED(resultCode))
{
ComPtr <IVirtualBoxErrorInfo> errorInfo;
CHECK_ERROR_RET(progress, COMGETTER(ErrorInfo)(errorInfo.asOutParam()), 1);
ErrorInfo info (errorInfo);
PRINT_ERROR_INFO(info);
}
else
{
RTPrintf("Remote session has been successfully opened.\n");
}
}
/* it's important to always close sessions */
session->Close();
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleControlVM(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
if (argc < 2)
{
return errorSyntax(USAGE_CONTROLVM, "Not enough parameters");
}
/* try to find the given machine */
ComPtr <IMachine> machine;
Guid uuid (argv[0]);
if (!uuid.isEmpty())
{
CHECK_ERROR (virtualBox, GetMachine (uuid, machine.asOutParam()));
}
else
{
CHECK_ERROR (virtualBox, FindMachine (Bstr(argv[0]), machine.asOutParam()));
if (SUCCEEDED (rc))
machine->COMGETTER(Id) (uuid.asOutParam());
}
if (FAILED (rc))
return 1;
/* open a session for the VM */
CHECK_ERROR_RET (virtualBox, OpenExistingSession (session, uuid), 1);
do
{
/* get the associated console */
ComPtr<IConsole> console;
CHECK_ERROR_BREAK (session, COMGETTER(Console)(console.asOutParam()));
/* ... and session machine */
ComPtr<IMachine> sessionMachine;
CHECK_ERROR_BREAK (session, COMGETTER(Machine)(sessionMachine.asOutParam()));
/* which command? */
if (strcmp(argv[1], "pause") == 0)
{
CHECK_ERROR_BREAK (console, Pause());
}
else if (strcmp(argv[1], "resume") == 0)
{
CHECK_ERROR_BREAK (console, Resume());
}
else if (strcmp(argv[1], "reset") == 0)
{
CHECK_ERROR_BREAK (console, Reset());
}
else if (strcmp(argv[1], "poweroff") == 0)
{
CHECK_ERROR_BREAK (console, PowerDown());
}
else if (strcmp(argv[1], "savestate") == 0)
{
ComPtr<IProgress> progress;
CHECK_ERROR_BREAK (console, SaveState(progress.asOutParam()));
showProgress(progress);
progress->COMGETTER(ResultCode)(&rc);
if (FAILED(rc))
{
com::ProgressErrorInfo info(progress);
if (info.isBasicAvailable())
{
RTPrintf("Error: failed to save machine state. Error message: %lS\n", info.getText().raw());
}
else
{
RTPrintf("Error: failed to save machine state. No error message available!\n");
}
}
}
else if (strcmp(argv[1], "acpipowerbutton") == 0)
{
CHECK_ERROR_BREAK (console, PowerButton());
}
else if (strncmp(argv[1], "setlinkstate", 12) == 0)
{
/* Get the number of network adapters */
ULONG NetworkAdapterCount = 0;
ComPtr <ISystemProperties> info;
CHECK_ERROR_BREAK (virtualBox, COMGETTER(SystemProperties) (info.asOutParam()));
CHECK_ERROR_BREAK (info, COMGETTER(NetworkAdapterCount) (&NetworkAdapterCount));
unsigned n = parseNum(&argv[1][12], NetworkAdapterCount, "NIC");
if (!n)
{
rc = E_FAIL;
break;
}
if (argc <= 1 + 1)
{
errorArgument("Missing argument to '%s'", argv[1]);
rc = E_FAIL;
break;
}
/* get the corresponding network adapter */
ComPtr<INetworkAdapter> adapter;
CHECK_ERROR_BREAK (sessionMachine, GetNetworkAdapter(n - 1, adapter.asOutParam()));
if (adapter)
{
if (strcmp(argv[2], "on") == 0)
{
CHECK_ERROR_BREAK (adapter, COMSETTER(CableConnected)(TRUE));
}
else if (strcmp(argv[2], "off") == 0)
{
CHECK_ERROR_BREAK (adapter, COMSETTER(CableConnected)(FALSE));
}
else
{
errorArgument("Invalid link state '%s'", Utf8Str(argv[2]).raw());
rc = E_FAIL;
break;
}
}
}
else if (strcmp (argv[1], "usbattach") == 0 ||
strcmp (argv[1], "usbdetach") == 0)
{
if (argc < 3)
{
errorSyntax(USAGE_CONTROLVM, "Not enough parameters");
rc = E_FAIL;
break;
}
bool attach = strcmp (argv[1], "usbattach") == 0;
Guid usbId = argv [2];
if (usbId.isEmpty())
{
// assume address
if (attach)
{
ComPtr <IHost> host;
CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host) (host.asOutParam()));
ComPtr <IHostUSBDeviceCollection> coll;
CHECK_ERROR_BREAK (host, COMGETTER(USBDevices) (coll.asOutParam()));
ComPtr <IHostUSBDevice> dev;
CHECK_ERROR_BREAK (coll, FindByAddress (Bstr (argv [2]), dev.asOutParam()));
CHECK_ERROR_BREAK (dev, COMGETTER(Id) (usbId.asOutParam()));
}
else
{
ComPtr <IUSBDeviceCollection> coll;
CHECK_ERROR_BREAK (console, COMGETTER(USBDevices)(coll.asOutParam()));
ComPtr <IUSBDevice> dev;
CHECK_ERROR_BREAK (coll, FindByAddress (Bstr (argv [2]), dev.asOutParam()));
CHECK_ERROR_BREAK (dev, COMGETTER(Id) (usbId.asOutParam()));
}
}
if (attach)
CHECK_ERROR_BREAK (console, AttachUSBDevice (usbId));
else
{
ComPtr <IUSBDevice> dev;
CHECK_ERROR_BREAK (console, DetachUSBDevice (usbId, dev.asOutParam()));
}
}
else if (strcmp(argv[1], "setvideomodehint") == 0)
{
if (argc != 5 && argc != 6)
{
errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
rc = E_FAIL;
break;
}
uint32_t xres = atoi(argv[2]);
uint32_t yres = atoi(argv[3]);
uint32_t bpp = atoi(argv[4]);
uint32_t displayIdx = 0;
if (argc == 6)
displayIdx = atoi(argv[5]);
ComPtr<IDisplay> display;
CHECK_ERROR_BREAK(console, COMGETTER(Display)(display.asOutParam()));
CHECK_ERROR_BREAK(display, SetVideoModeHint(xres, yres, bpp, displayIdx));
}
else if (strcmp(argv[1], "setcredentials") == 0)
{
bool fAllowLocalLogon = true;
if (argc == 7)
{
if (strcmp(argv[5], "-allowlocallogon") != 0)
{
errorArgument("Invalid parameter '%s'", argv[5]);
rc = E_FAIL;
break;
}
if (strcmp(argv[6], "no") == 0)
fAllowLocalLogon = false;
}
else if (argc != 5)
{
errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
rc = E_FAIL;
break;
}
ComPtr<IGuest> guest;
CHECK_ERROR_BREAK(console, COMGETTER(Guest)(guest.asOutParam()));
CHECK_ERROR_BREAK(guest, SetCredentials(Bstr(argv[2]), Bstr(argv[3]), Bstr(argv[4]), fAllowLocalLogon));
}
else if (strcmp(argv[1], "dvdattach") == 0)
{
if (argc != 3)
{
errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
rc = E_FAIL;
break;
}
ComPtr<IDVDDrive> dvdDrive;
sessionMachine->COMGETTER(DVDDrive)(dvdDrive.asOutParam());
ASSERT(dvdDrive);
/* unmount? */
if (strcmp(argv[2], "none") == 0)
{
CHECK_ERROR(dvdDrive, Unmount());
}
/* host drive? */
else if (strncmp(argv[2], "host:", 5) == 0)
{
ComPtr<IHost> host;
CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
ComPtr<IHostDVDDriveCollection> hostDVDs;
CHECK_ERROR(host, COMGETTER(DVDDrives)(hostDVDs.asOutParam()));
ComPtr<IHostDVDDrive> hostDVDDrive;
rc = hostDVDs->FindByName(Bstr(argv[2] + 5), hostDVDDrive.asOutParam());
if (!hostDVDDrive)
{
errorArgument("Invalid host DVD drive name");
rc = E_FAIL;
break;
}
CHECK_ERROR(dvdDrive, CaptureHostDrive(hostDVDDrive));
}
else
{
/* first assume it's a UUID */
Guid uuid(argv[2]);
ComPtr<IDVDImage> dvdImage;
rc = virtualBox->GetDVDImage(uuid, dvdImage.asOutParam());
if (FAILED(rc) || !dvdImage)
{
/* must be a filename, check if it's in the collection */
ComPtr<IDVDImageCollection> dvdImages;
virtualBox->COMGETTER(DVDImages)(dvdImages.asOutParam());
rc = dvdImages->FindByPath(Bstr(argv[2]), dvdImage.asOutParam());
/* not registered, do that on the fly */
if (!dvdImage)
{
Guid emptyUUID;
CHECK_ERROR(virtualBox, OpenDVDImage(Bstr(argv[2]), emptyUUID, dvdImage.asOutParam()));
if (SUCCEEDED(rc) && dvdImage)
{
/* time to register the image */
CHECK_ERROR(virtualBox, RegisterDVDImage(dvdImage));
}
}
}
if (!dvdImage)
{
rc = E_FAIL;
break;
}
dvdImage->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(dvdDrive, MountImage(uuid));
}
}
else if (strcmp(argv[1], "floppyattach") == 0)
{
if (argc != 3)
{
errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
rc = E_FAIL;
break;
}
ComPtr<IFloppyDrive> floppyDrive;
sessionMachine->COMGETTER(FloppyDrive)(floppyDrive.asOutParam());
ASSERT(floppyDrive);
/* unmount? */
if (strcmp(argv[2], "none") == 0)
{
CHECK_ERROR(floppyDrive, Unmount());
}
/* host drive? */
else if (strncmp(argv[2], "host:", 5) == 0)
{
ComPtr<IHost> host;
CHECK_ERROR(virtualBox, COMGETTER(Host)(host.asOutParam()));
ComPtr<IHostFloppyDriveCollection> hostFloppies;
CHECK_ERROR(host, COMGETTER(FloppyDrives)(hostFloppies.asOutParam()));
ComPtr<IHostFloppyDrive> hostFloppyDrive;
rc = hostFloppies->FindByName(Bstr(argv[2] + 5), hostFloppyDrive.asOutParam());
if (!hostFloppyDrive)
{
errorArgument("Invalid host floppy drive name");
rc = E_FAIL;
break;
}
CHECK_ERROR(floppyDrive, CaptureHostDrive(hostFloppyDrive));
}
else
{
/* first assume it's a UUID */
Guid uuid(argv[2]);
ComPtr<IFloppyImage> floppyImage;
rc = virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam());
if (FAILED(rc) || !floppyImage)
{
/* must be a filename, check if it's in the collection */
ComPtr<IFloppyImageCollection> floppyImages;
virtualBox->COMGETTER(FloppyImages)(floppyImages.asOutParam());
rc = floppyImages->FindByPath(Bstr(argv[2]), floppyImage.asOutParam());
/* not registered, do that on the fly */
if (!floppyImage)
{
Guid emptyUUID;
CHECK_ERROR(virtualBox, OpenFloppyImage(Bstr(argv[2]), emptyUUID, floppyImage.asOutParam()));
if (SUCCEEDED(rc) && floppyImage)
{
/* time to register the image */
CHECK_ERROR(virtualBox, RegisterFloppyImage(floppyImage));
}
}
}
if (!floppyImage)
{
rc = E_FAIL;
break;
}
floppyImage->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(floppyDrive, MountImage(uuid));
}
}
else if (strncmp(argv[1], "-guestmemoryballoon", 19) == 0)
{
if (argc != 3)
{
errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
rc = E_FAIL;
break;
}
uint32_t uVal;
int vrc;
vrc = RTStrToUInt32Ex(argv[2], NULL, 0, &uVal);
if (vrc != VINF_SUCCESS)
{
errorArgument("Error parsing guest memory balloon size '%s'", argv[2]);
rc = E_FAIL;
break;
}
/* guest is running; update IGuest */
ComPtr <IGuest> guest;
rc = console->COMGETTER(Guest)(guest.asOutParam());
if (SUCCEEDED(rc))
CHECK_ERROR(guest, COMSETTER(MemoryBalloonSize)(uVal));
}
else if (strncmp(argv[1], "-gueststatisticsinterval", 24) == 0)
{
if (argc != 3)
{
errorSyntax(USAGE_CONTROLVM, "Incorrect number of parameters");
rc = E_FAIL;
break;
}
uint32_t uVal;
int vrc;
vrc = RTStrToUInt32Ex(argv[2], NULL, 0, &uVal);
if (vrc != VINF_SUCCESS)
{
errorArgument("Error parsing guest memory balloon size '%s'", argv[2]);
rc = E_FAIL;
break;
}
/* guest is running; update IGuest */
ComPtr <IGuest> guest;
rc = console->COMGETTER(Guest)(guest.asOutParam());
if (SUCCEEDED(rc))
CHECK_ERROR(guest, COMSETTER(StatisticsUpdateInterval)(uVal));
}
else
{
errorSyntax(USAGE_CONTROLVM, "Invalid parameter '%s'", Utf8Str(argv[1]).raw());
rc = E_FAIL;
}
}
while (0);
session->Close();
return SUCCEEDED (rc) ? 0 : 1;
}
static int handleDiscardState(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
if (argc != 1)
{
return errorSyntax(USAGE_DISCARDSTATE, "Incorrect number of parameters");
}
ComPtr<IMachine> machine;
/* assume it's a UUID */
rc = virtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
if (FAILED(rc) || !machine)
{
/* must be a name */
CHECK_ERROR(virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
}
if (machine)
{
do
{
/* we have to open a session for this task */
Guid guid;
machine->COMGETTER(Id)(guid.asOutParam());
CHECK_ERROR_BREAK(virtualBox, OpenSession(session, guid));
ComPtr<IConsole> console;
CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam()));
CHECK_ERROR_BREAK(console, DiscardSavedState());
CHECK_ERROR_BREAK(session, Close());
} while (0);
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleSnapshot(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
/* we need at least a VM and a command */
if (argc < 2)
{
return errorSyntax(USAGE_SNAPSHOT, "Not enough parameters");
}
/* the first argument must be the VM */
ComPtr<IMachine> machine;
/* assume it's a UUID */
rc = virtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
if (FAILED(rc) || !machine)
{
/* must be a name */
CHECK_ERROR(virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
}
if (!machine)
return 1;
Guid guid;
machine->COMGETTER(Id)(guid.asOutParam());
do
{
/* we have to open a session for this task. First try an existing session */
rc = virtualBox->OpenExistingSession(session, guid);
if (FAILED(rc))
CHECK_ERROR_BREAK(virtualBox, OpenSession(session, guid));
ComPtr<IConsole> console;
CHECK_ERROR_BREAK(session, COMGETTER(Console)(console.asOutParam()));
/* switch based on the command */
if (strcmp(argv[1], "take") == 0)
{
/* there must be a name */
if (argc < 3)
{
errorSyntax(USAGE_SNAPSHOT, "Missing snapshot name");
rc = E_FAIL;
break;
}
Bstr name(argv[2]);
if ((argc > 3) && ((argc != 5) || (strcmp(argv[3], "-desc") != 0)))
{
errorSyntax(USAGE_SNAPSHOT, "Incorrect description format");
rc = E_FAIL;
break;
}
Bstr desc;
if (argc == 5)
desc = argv[4];
ComPtr<IProgress> progress;
CHECK_ERROR_BREAK(console, TakeSnapshot(name, desc, progress.asOutParam()));
showProgress(progress);
progress->COMGETTER(ResultCode)(&rc);
if (FAILED(rc))
{
com::ProgressErrorInfo info(progress);
if (info.isBasicAvailable())
{
RTPrintf("Error: failed to take snapshot. Error message: %lS\n", info.getText().raw());
}
else
{
RTPrintf("Error: failed to take snapshot. No error message available!\n");
}
}
}
else if (strcmp(argv[1], "discard") == 0)
{
/* exactly one parameter: snapshot name */
if (argc != 3)
{
errorSyntax(USAGE_SNAPSHOT, "Expecting snapshot name only");
rc = E_FAIL;
break;
}
ComPtr<ISnapshot> snapshot;
/* assume it's a UUID */
Guid guid(argv[2]);
if (!guid.isEmpty())
{
CHECK_ERROR_BREAK(machine, GetSnapshot(guid, snapshot.asOutParam()));
}
else
{
/* then it must be a name */
CHECK_ERROR_BREAK(machine, FindSnapshot(Bstr(argv[2]), snapshot.asOutParam()));
}
snapshot->COMGETTER(Id)(guid.asOutParam());
ComPtr<IProgress> progress;
CHECK_ERROR_BREAK(console, DiscardSnapshot(guid, progress.asOutParam()));
showProgress(progress);
progress->COMGETTER(ResultCode)(&rc);
if (FAILED(rc))
{
com::ProgressErrorInfo info(progress);
if (info.isBasicAvailable())
{
RTPrintf("Error: failed to discard snapshot. Error message: %lS\n", info.getText().raw());
}
else
{
RTPrintf("Error: failed to discard snapshot. No error message available!\n");
}
}
}
else if (strcmp(argv[1], "discardcurrent") == 0)
{
if ( (argc != 3)
|| ( (strcmp(argv[2], "-state") != 0)
&& (strcmp(argv[2], "-all") != 0)))
{
errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(argv[2]).raw());
rc = E_FAIL;
break;
}
bool fAll = false;
if (strcmp(argv[2], "-all") == 0)
fAll = true;
ComPtr<IProgress> progress;
if (fAll)
{
CHECK_ERROR_BREAK(console, DiscardCurrentSnapshotAndState(progress.asOutParam()));
}
else
{
CHECK_ERROR_BREAK(console, DiscardCurrentState(progress.asOutParam()));
}
showProgress(progress);
progress->COMGETTER(ResultCode)(&rc);
if (FAILED(rc))
{
com::ProgressErrorInfo info(progress);
if (info.isBasicAvailable())
{
RTPrintf("Error: failed to discard. Error message: %lS\n", info.getText().raw());
}
else
{
RTPrintf("Error: failed to discard. No error message available!\n");
}
}
}
else if (strcmp(argv[1], "edit") == 0)
{
if (argc < 3)
{
errorSyntax(USAGE_SNAPSHOT, "Missing snapshot name");
rc = E_FAIL;
break;
}
ComPtr<ISnapshot> snapshot;
if (strcmp(argv[2], "-current") == 0)
{
CHECK_ERROR_BREAK(machine, COMGETTER(CurrentSnapshot)(snapshot.asOutParam()));
}
else
{
/* assume it's a UUID */
Guid guid(argv[2]);
if (!guid.isEmpty())
{
CHECK_ERROR_BREAK(machine, GetSnapshot(guid, snapshot.asOutParam()));
}
else
{
/* then it must be a name */
CHECK_ERROR_BREAK(machine, FindSnapshot(Bstr(argv[2]), snapshot.asOutParam()));
}
}
/* parse options */
for (int i = 3; i < argc; i++)
{
if (strcmp(argv[i], "-newname") == 0)
{
if (argc <= i + 1)
{
errorArgument("Missing argument to '%s'", argv[i]);
rc = E_FAIL;
break;
}
i++;
snapshot->COMSETTER(Name)(Bstr(argv[i]));
}
else if (strcmp(argv[i], "-newdesc") == 0)
{
if (argc <= i + 1)
{
errorArgument("Missing argument to '%s'", argv[i]);
rc = E_FAIL;
break;
}
i++;
snapshot->COMSETTER(Description)(Bstr(argv[i]));
}
else
{
errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(argv[i]).raw());
rc = E_FAIL;
break;
}
}
}
else if (strcmp(argv[1], "showvminfo") == 0)
{
/* exactly one parameter: snapshot name */
if (argc != 3)
{
errorSyntax(USAGE_SNAPSHOT, "Expecting snapshot name only");
rc = E_FAIL;
break;
}
ComPtr<ISnapshot> snapshot;
/* assume it's a UUID */
Guid guid(argv[2]);
if (!guid.isEmpty())
{
CHECK_ERROR_BREAK(machine, GetSnapshot(guid, snapshot.asOutParam()));
}
else
{
/* then it must be a name */
CHECK_ERROR_BREAK(machine, FindSnapshot(Bstr(argv[2]), snapshot.asOutParam()));
}
/* get the machine of the given snapshot */
ComPtr<IMachine> machine;
snapshot->COMGETTER(Machine)(machine.asOutParam());
showVMInfo(virtualBox, machine, console);
}
else
{
errorSyntax(USAGE_SNAPSHOT, "Invalid parameter '%s'", Utf8Str(argv[1]).raw());
rc = E_FAIL;
}
} while (0);
session->Close();
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleShowVDIInfo(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
if (argc != 1)
{
return errorSyntax(USAGE_SHOWVDIINFO, "Incorrect number of parameters");
}
ComPtr<IHardDisk> hardDisk;
Bstr filepath;
bool registered = true;
/* first guess is that it's a UUID */
Guid uuid(argv[0]);
rc = virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
/* no? then it must be a filename */
if (FAILED (rc))
{
filepath = argv[0];
rc = virtualBox->FindHardDisk(filepath, hardDisk.asOutParam());
/* no? well, then it's an unregistered image */
if (FAILED (rc))
{
registered = false;
CHECK_ERROR(virtualBox, OpenHardDisk(filepath, hardDisk.asOutParam()));
}
}
if (SUCCEEDED(rc) && hardDisk)
{
/* query a VDI object (will remain null if it's not VDI) */
ComPtr<IVirtualDiskImage> vdi = hardDisk;
hardDisk->COMGETTER(Id)(uuid.asOutParam());
RTPrintf("UUID: %s\n", uuid.toString().raw());
RTPrintf("Registered: %s\n", registered ? "yes" : "no");
/* check for accessibility */
BOOL accessible = FALSE;
CHECK_ERROR_RET (hardDisk, COMGETTER(Accessible)(&accessible), 1);
RTPrintf("Accessible: %s\n", accessible ? "yes" : "no");
if (!accessible)
{
Bstr err;
CHECK_ERROR_RET (hardDisk, COMGETTER(LastAccessError)(err.asOutParam()), 1);
RTPrintf("Access Error: %lS\n", err.raw());
}
Bstr description;
hardDisk->COMGETTER(Description)(description.asOutParam());
if (description)
{
RTPrintf("Description: %lS\n", description.raw());
}
ULONG64 size;
hardDisk->COMGETTER(Size)(&size);
RTPrintf("Size: %llu MBytes\n", size);
ULONG64 actualSize;
hardDisk->COMGETTER(ActualSize)(&actualSize);
RTPrintf("Current size on disk: %llu MBytes\n", actualSize >> 20);
HardDiskType_T type;
hardDisk->COMGETTER(Type)(&type);
const char *typeStr = "unknown";
switch (type)
{
case HardDiskType_NormalHardDisk:
typeStr = "standard";
break;
case HardDiskType_ImmutableHardDisk:
typeStr = "immutable";
break;
case HardDiskType_WritethroughHardDisk:
typeStr = "writethrough";
break;
}
RTPrintf("Type: %s\n", typeStr);
HardDiskStorageType_T storageType;
const char *storageTypeStr = "unknown";
hardDisk->COMGETTER(StorageType)(&storageType);
switch (storageType)
{
case HardDiskStorageType_VirtualDiskImage:
storageTypeStr = "Virtual Disk Image (VDI)";
break;
case HardDiskStorageType_VMDKImage:
storageTypeStr = "VMDK Image";
break;
case HardDiskStorageType_ISCSIHardDisk:
storageTypeStr = "iSCSI target";
break;
}
RTPrintf("Storage type: %s\n", storageTypeStr);
if (registered)
{
hardDisk->COMGETTER(MachineId)(uuid.asOutParam());
RTPrintf("In use by VM: %s\n", uuid ? uuid.toString().raw() : "<none>");
}
if (vdi)
{
/* VDI specific information */
vdi->COMGETTER(FilePath)(filepath.asOutParam());
RTPrintf("Path: %lS\n", filepath.raw());
}
else
{
/* Generic location information */
Bstr loc;
hardDisk->COMGETTER(Location)(loc.asOutParam());
RTPrintf("Location: %lS\n", loc.raw());
}
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleRegisterImage(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
if (argc < 2)
{
return errorSyntax(USAGE_REGISTERIMAGE, "Not enough parameters");
}
Bstr filepath(argv[1]);
if (strcmp(argv[0], "disk") == 0)
{
const char *type = NULL;
/* there can be a type parameter */
if ((argc > 2) && (argc != 4))
{
return errorSyntax(USAGE_REGISTERIMAGE, "Incorrect number of parameters");
}
if (argc == 4)
{
if (strcmp(argv[2], "-type") != 0)
{
return errorSyntax(USAGE_REGISTERIMAGE, "Invalid parameter '%s'", Utf8Str(argv[2]).raw());
}
if ( (strcmp(argv[3], "normal") != 0)
&& (strcmp(argv[3], "immutable") != 0)
&& (strcmp(argv[3], "writethrough") != 0))
{
return errorArgument("Invalid VDI type '%s' specified", Utf8Str(argv[3]).raw());
}
type = argv[3];
}
ComPtr<IHardDisk> hardDisk;
CHECK_ERROR(virtualBox, OpenHardDisk(filepath, hardDisk.asOutParam()));
if (SUCCEEDED(rc) && hardDisk)
{
/* change the type if requested */
if (type)
{
if (strcmp(type, "normal") == 0)
CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_NormalHardDisk));
else if (strcmp(type, "immutable") == 0)
CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_ImmutableHardDisk));
else if (strcmp(type, "writethrough") == 0)
CHECK_ERROR(hardDisk, COMSETTER(Type)(HardDiskType_WritethroughHardDisk));
}
if (SUCCEEDED(rc))
CHECK_ERROR(virtualBox, RegisterHardDisk(hardDisk));
}
}
else if (strcmp(argv[0], "dvd") == 0)
{
ComPtr<IDVDImage> dvdImage;
CHECK_ERROR(virtualBox, OpenDVDImage(filepath, Guid(), dvdImage.asOutParam()));
if (SUCCEEDED(rc) && dvdImage)
{
CHECK_ERROR(virtualBox, RegisterDVDImage(dvdImage));
}
}
else if (strcmp(argv[0], "floppy") == 0)
{
ComPtr<IFloppyImage> floppyImage;
CHECK_ERROR(virtualBox, OpenFloppyImage(filepath, Guid(), floppyImage.asOutParam()));
if (SUCCEEDED(rc) && floppyImage)
{
CHECK_ERROR(virtualBox, RegisterFloppyImage(floppyImage));
}
}
else
{
return errorSyntax(USAGE_REGISTERIMAGE, "Invalid parameter '%s'", Utf8Str(argv[1]).raw());
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleUnregisterImage(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
if (argc != 2)
{
return errorSyntax(USAGE_UNREGISTERIMAGE, "Incorrect number of parameters");
}
/* first guess is that it's a UUID */
Guid uuid(argv[1]);
if (strcmp(argv[0], "disk") == 0)
{
ComPtr<IHardDisk> hardDisk;
rc = virtualBox->GetHardDisk(uuid, hardDisk.asOutParam());
/* not a UUID or not registered? Then it must be a filename */
if (!hardDisk)
{
ComPtr<IVirtualDiskImage> vdi;
CHECK_ERROR(virtualBox, FindVirtualDiskImage(Bstr(argv[1]), vdi.asOutParam()));
hardDisk = vdi;
}
if (SUCCEEDED(rc) && hardDisk)
{
hardDisk->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(virtualBox, UnregisterHardDisk(uuid, hardDisk.asOutParam()));
}
}
else
if (strcmp(argv[0], "dvd") == 0)
{
ComPtr<IDVDImage> dvdImage;
rc = virtualBox->GetDVDImage(uuid, dvdImage.asOutParam());
/* not a UUID or not registered? Then it must be a filename */
if (!dvdImage)
{
ComPtr<IDVDImageCollection> dvdColl;
virtualBox->COMGETTER(DVDImages)(dvdColl.asOutParam());
CHECK_ERROR(dvdColl, FindByPath(Bstr(argv[1]), dvdImage.asOutParam()));
}
if (SUCCEEDED(rc) && dvdImage)
{
dvdImage->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(virtualBox, UnregisterDVDImage(uuid, dvdImage.asOutParam()));
}
}
else
if (strcmp(argv[0], "floppy") == 0)
{
ComPtr<IFloppyImage> floppyImage;
rc = virtualBox->GetFloppyImage(uuid, floppyImage.asOutParam());
/* not a UUID or not registered? Then it must be a filename */
if (!floppyImage)
{
ComPtr<IFloppyImageCollection> floppyColl;
virtualBox->COMGETTER(FloppyImages)(floppyColl.asOutParam());
CHECK_ERROR(floppyColl, FindByPath(Bstr(argv[1]), floppyImage.asOutParam()));
}
if (SUCCEEDED(rc) && floppyImage)
{
floppyImage->COMGETTER(Id)(uuid.asOutParam());
CHECK_ERROR(virtualBox, UnregisterFloppyImage(uuid, floppyImage.asOutParam()));
}
}
else
{
return errorSyntax(USAGE_UNREGISTERIMAGE, "Invalid parameter '%s'", Utf8Str(argv[1]).raw());
}
return SUCCEEDED(rc) ? 0 : 1;
}
#ifdef RT_OS_WINDOWS
static int handleCreateHostIF(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
if (argc != 1)
{
return errorSyntax(USAGE_CREATEHOSTIF, "Incorrect number of parameters");
}
HRESULT rc = S_OK;
do
{
ComPtr<IHost> host;
CHECK_ERROR_BREAK(virtualBox, COMGETTER(Host)(host.asOutParam()));
ComPtr<IHostNetworkInterface> hostif;
ComPtr<IProgress> progress;
CHECK_ERROR_BREAK(host,
CreateHostNetworkInterface(Bstr(argv[0]),
hostif.asOutParam(),
progress.asOutParam()));
showProgress(progress);
HRESULT result;
CHECK_ERROR_BREAK(progress, COMGETTER(ResultCode)(&result));
if (FAILED(result))
{
com::ProgressErrorInfo info(progress);
PRINT_ERROR_INFO(info);
rc = result;
}
}
while (0);
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleRemoveHostIF(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
if (argc != 1)
{
return errorSyntax(USAGE_REMOVEHOSTIF, "Incorrect number of parameters");
}
HRESULT rc = S_OK;
do
{
ComPtr<IHost> host;
CHECK_ERROR_BREAK(virtualBox, COMGETTER(Host)(host.asOutParam()));
ComPtr<IHostNetworkInterface> hostif;
/* first guess is that it's a UUID */
Guid uuid(argv[0]);
if (uuid.isEmpty())
{
/* not a valid UUID, search for it */
ComPtr<IHostNetworkInterfaceCollection> coll;
CHECK_ERROR_BREAK(host, COMGETTER(NetworkInterfaces)(coll.asOutParam()));
CHECK_ERROR_BREAK(coll, FindByName(Bstr(argv[0]), hostif.asOutParam()));
CHECK_ERROR_BREAK(hostif, COMGETTER(Id)(uuid.asOutParam()));
}
ComPtr<IProgress> progress;
CHECK_ERROR_BREAK(host,
RemoveHostNetworkInterface(uuid,
hostif.asOutParam(),
progress.asOutParam()));
showProgress(progress);
HRESULT result;
CHECK_ERROR_BREAK(progress, COMGETTER(ResultCode)(&result));
if (FAILED(result))
{
com::ProgressErrorInfo info(progress);
PRINT_ERROR_INFO(info);
rc = result;
}
}
while (0);
return SUCCEEDED(rc) ? 0 : 1;
}
#endif /* RT_OS_WINDOWS */
static int handleGetExtraData(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc = S_OK;
if (argc != 2)
{
return errorSyntax(USAGE_GETEXTRADATA, "Incorrect number of parameters");
}
/* global data? */
if (strcmp(argv[0], "global") == 0)
{
/* enumeration? */
if (strcmp(argv[1], "enumerate") == 0)
{
Bstr extraDataKey;
do
{
Bstr nextExtraDataKey;
Bstr nextExtraDataValue;
HRESULT rcEnum = virtualBox->GetNextExtraDataKey(extraDataKey, nextExtraDataKey.asOutParam(),
nextExtraDataValue.asOutParam());
extraDataKey = nextExtraDataKey;
if (SUCCEEDED(rcEnum) && extraDataKey)
{
RTPrintf("Key: %lS, Value: %lS\n", nextExtraDataKey.raw(), nextExtraDataValue.raw());
}
} while (extraDataKey);
}
else
{
Bstr value;
CHECK_ERROR(virtualBox, GetExtraData(Bstr(argv[1]), value.asOutParam()));
if (value)
RTPrintf("Value: %lS\n", value.raw());
else
RTPrintf("No value set!\n");
}
}
else
{
ComPtr<IMachine> machine;
/* assume it's a UUID */
rc = virtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
if (FAILED(rc) || !machine)
{
/* must be a name */
CHECK_ERROR(virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
}
if (machine)
{
/* enumeration? */
if (strcmp(argv[1], "enumerate") == 0)
{
Bstr extraDataKey;
do
{
Bstr nextExtraDataKey;
Bstr nextExtraDataValue;
HRESULT rcEnum = machine->GetNextExtraDataKey(extraDataKey, nextExtraDataKey.asOutParam(),
nextExtraDataValue.asOutParam());
extraDataKey = nextExtraDataKey;
if (SUCCEEDED(rcEnum) && extraDataKey)
{
RTPrintf("Key: %lS, Value: %lS\n", nextExtraDataKey.raw(), nextExtraDataValue.raw());
}
} while (extraDataKey);
}
else
{
Bstr value;
CHECK_ERROR(machine, GetExtraData(Bstr(argv[1]), value.asOutParam()));
if (value)
RTPrintf("Value: %lS\n", value.raw());
else
RTPrintf("No value set!\n");
}
}
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleSetExtraData(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc = S_OK;
if (argc < 2)
{
return errorSyntax(USAGE_SETEXTRADATA, "Not enough parameters");
}
/* global data? */
if (strcmp(argv[0], "global") == 0)
{
if (argc < 3)
CHECK_ERROR(virtualBox, SetExtraData(Bstr(argv[1]), NULL));
else if (argc == 3)
CHECK_ERROR(virtualBox, SetExtraData(Bstr(argv[1]), Bstr(argv[2])));
else
return errorSyntax(USAGE_SETEXTRADATA, "Too many parameters");
}
else
{
ComPtr<IMachine> machine;
/* assume it's a UUID */
rc = virtualBox->GetMachine(Guid(argv[0]), machine.asOutParam());
if (FAILED(rc) || !machine)
{
/* must be a name */
CHECK_ERROR(virtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
}
if (machine)
{
if (argc < 3)
CHECK_ERROR(machine, SetExtraData(Bstr(argv[1]), NULL));
else if (argc == 3)
CHECK_ERROR(machine, SetExtraData(Bstr(argv[1]), Bstr(argv[2])));
else
return errorSyntax(USAGE_SETEXTRADATA, "Too many parameters");
}
}
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleSetProperty(int argc, char *argv[],
ComPtr<IVirtualBox> virtualBox, ComPtr<ISession> session)
{
HRESULT rc;
/* there must be two arguments: property name and value */
if (argc != 2)
{
return errorSyntax(USAGE_SETPROPERTY, "Incorrect number of parameters");
}
ComPtr<ISystemProperties> systemProperties;
virtualBox->COMGETTER(SystemProperties)(systemProperties.asOutParam());
if (strcmp(argv[0], "vdifolder") == 0)
{
/* reset to default? */
if (strcmp(argv[1], "default") == 0)
CHECK_ERROR(systemProperties, COMSETTER(DefaultVDIFolder)(NULL));
else
CHECK_ERROR(systemProperties, COMSETTER(DefaultVDIFolder)(Bstr(argv[1])));
}
else if (strcmp(argv[0], "machinefolder") == 0)
{
/* reset to default? */
if (strcmp(argv[1], "default") == 0)
CHECK_ERROR(systemProperties, COMSETTER(DefaultMachineFolder)(NULL));
else
CHECK_ERROR(systemProperties, COMSETTER(DefaultMachineFolder)(Bstr(argv[1])));
}
else if (strcmp(argv[0], "vrdpauthlibrary") == 0)
{
/* reset to default? */
if (strcmp(argv[1], "default") == 0)
CHECK_ERROR(systemProperties, COMSETTER(RemoteDisplayAuthLibrary)(NULL));
else
CHECK_ERROR(systemProperties, COMSETTER(RemoteDisplayAuthLibrary)(Bstr(argv[1])));
}
else if (strcmp(argv[0], "hwvirtexenabled") == 0)
{
if (strcmp(argv[1], "yes") == 0)
CHECK_ERROR(systemProperties, COMSETTER(HWVirtExEnabled)(TRUE));
else if (strcmp(argv[1], "no") == 0)
CHECK_ERROR(systemProperties, COMSETTER(HWVirtExEnabled)(FALSE));
else
return errorArgument("Invalid value '%s' for hardware virtualization extension flag", argv[1]);
}
else if (strcmp(argv[0], "loghistorycount") == 0)
{
uint32_t uVal;
int vrc;
vrc = RTStrToUInt32Ex(argv[1], NULL, 0, &uVal);
if (vrc != VINF_SUCCESS)
return errorArgument("Error parsing Log history count '%s'", argv[1]);
CHECK_ERROR(systemProperties, COMSETTER(LogHistoryCount)(uVal));
}
else
return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", Utf8Str(argv[0]).raw());
return SUCCEEDED(rc) ? 0 : 1;
}
static int handleUSBFilter (int argc, char *argv[],
ComPtr <IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
HRESULT rc = S_OK;
USBFilterCmd cmd;
/* at least: 0: command, 1: index, 2: -target, 3: <target value> */
if (argc < 4)
{
return errorSyntax(USAGE_USBFILTER, "Not enough parameters");
}
/* which command? */
cmd.mAction = USBFilterCmd::Invalid;
if (strcmp (argv [0], "add") == 0) cmd.mAction = USBFilterCmd::Add;
else if (strcmp (argv [0], "modify") == 0) cmd.mAction = USBFilterCmd::Modify;
else if (strcmp (argv [0], "remove") == 0) cmd.mAction = USBFilterCmd::Remove;
if (cmd.mAction == USBFilterCmd::Invalid)
{
return errorSyntax(USAGE_USBFILTER, "Invalid parameter '%s'", Utf8Str(argv[0]).raw());
}
/* which index? */
char *endptr = NULL;
cmd.mIndex = strtoul (argv[1], &endptr, 10);
if (!endptr || *endptr)
{
return errorSyntax(USAGE_USBFILTER, "Invalid index '%s'", argv[1]);
}
switch (cmd.mAction)
{
case USBFilterCmd::Add:
case USBFilterCmd::Modify:
{
/* at least: 0: command, 1: index, 2: -target, 3: <target value>, 4: -name, 5: <name value> */
if (argc < 6)
{
if (cmd.mAction == USBFilterCmd::Add)
{
return errorSyntax(USAGE_USBFILTER_ADD, "Not enough parameters");
}
else
{
return errorSyntax(USAGE_USBFILTER_MODIFY, "Not enough parameters");
}
}
// set Active to true by default
// (assuming that the user sets up all necessary attributes
// at once and wants the filter to be active immediately)
if (cmd.mAction == USBFilterCmd::Add)
cmd.mFilter.mActive = true;
for (int i = 2; i < argc; i++)
{
if (strcmp(argv [i], "-target") == 0)
{
if (argc <= i + 1 || !*argv[i+1])
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
if (strcmp (argv [i], "global") == 0)
cmd.mGlobal = true;
else
{
/* assume it's a UUID of a machine */
rc = aVirtualBox->GetMachine(Guid(argv[i]), cmd.mMachine.asOutParam());
if (FAILED(rc) || !cmd.mMachine)
{
/* must be a name */
CHECK_ERROR_RET(aVirtualBox, FindMachine(Bstr(argv[i]), cmd.mMachine.asOutParam()), 1);
}
}
}
else if (strcmp(argv [i], "-name") == 0)
{
if (argc <= i + 1 || !*argv[i+1])
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
cmd.mFilter.mName = argv [i];
}
else if (strcmp(argv [i], "-active") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
if (strcmp (argv [i], "yes") == 0)
cmd.mFilter.mActive = true;
else if (strcmp (argv [i], "no") == 0)
cmd.mFilter.mActive = false;
else
{
return errorArgument("Invalid -active argument '%s'", Utf8Str(argv[i]).raw());
}
}
else if (strcmp(argv [i], "-vendorid") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
cmd.mFilter.mVendorId = argv [i];
}
else if (strcmp(argv [i], "-productid") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
cmd.mFilter.mProductId = argv [i];
}
else if (strcmp(argv [i], "-revision") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
cmd.mFilter.mRevision = argv [i];
}
else if (strcmp(argv [i], "-manufacturer") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
cmd.mFilter.mManufacturer = argv [i];
}
else if (strcmp(argv [i], "-product") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
cmd.mFilter.mProduct = argv [i];
}
else if (strcmp(argv [i], "-remote") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
cmd.mFilter.mRemote = argv[i];
}
else if (strcmp(argv [i], "-serialnumber") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
cmd.mFilter.mSerialNumber = argv [i];
}
else if (strcmp(argv [i], "-action") == 0)
{
if (argc <= i + 1)
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
if (strcmp (argv [i], "ignore") == 0)
cmd.mFilter.mAction = USBDeviceFilterAction_USBDeviceFilterIgnore;
else if (strcmp (argv [i], "hold") == 0)
cmd.mFilter.mAction = USBDeviceFilterAction_USBDeviceFilterHold;
else
{
return errorArgument("Invalid USB filter action '%s'", Utf8Str(argv[i]).raw());
}
}
}
if (cmd.mAction == USBFilterCmd::Add)
{
// mandatory/forbidden options
if ( cmd.mFilter.mName.isEmpty()
||
( cmd.mGlobal
&& cmd.mFilter.mAction == USBDeviceFilterAction_InvalidUSBDeviceFilterAction
)
|| ( !cmd.mGlobal
&& !cmd.mMachine)
|| ( cmd.mGlobal
&& cmd.mFilter.mRemote)
)
{
return errorSyntax(USAGE_USBFILTER_ADD, "Mandatory options not supplied");
}
}
break;
}
case USBFilterCmd::Remove:
{
/* at least: 0: command, 1: index, 2: -target, 3: <target value> */
if (argc < 4)
{
return errorSyntax(USAGE_USBFILTER_REMOVE, "Not enough parameters");
}
for (int i = 2; i < argc; i++)
{
if (strcmp(argv [i], "-target") == 0)
{
if (argc <= i + 1 || !*argv[i+1])
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
if (strcmp (argv [i], "global") == 0)
cmd.mGlobal = true;
else
{
/* assume it's a UUID of a machine */
rc = aVirtualBox->GetMachine(Guid(argv[i]), cmd.mMachine.asOutParam());
if (FAILED(rc) || !cmd.mMachine)
{
/* must be a name */
CHECK_ERROR_RET(aVirtualBox, FindMachine(Bstr(argv[i]), cmd.mMachine.asOutParam()), 1);
}
}
}
}
// mandatory options
if (!cmd.mGlobal && !cmd.mMachine)
{
return errorSyntax(USAGE_USBFILTER_REMOVE, "Mandatory options not supplied");
}
break;
}
default: break;
}
USBFilterCmd::USBFilter &f = cmd.mFilter;
ComPtr <IHost> host;
ComPtr <IUSBController> ctl;
if (cmd.mGlobal)
CHECK_ERROR_RET (aVirtualBox, COMGETTER(Host) (host.asOutParam()), 1);
else
{
Guid uuid;
cmd.mMachine->COMGETTER(Id)(uuid.asOutParam());
/* open a session for the VM */
CHECK_ERROR_RET (aVirtualBox, OpenSession(aSession, uuid), 1);
/* get the mutable session machine */
aSession->COMGETTER(Machine)(cmd.mMachine.asOutParam());
/* and get the USB controller */
CHECK_ERROR_RET (cmd.mMachine, COMGETTER(USBController) (ctl.asOutParam()), 1);
}
switch (cmd.mAction)
{
case USBFilterCmd::Add:
{
if (cmd.mGlobal)
{
ComPtr <IHostUSBDeviceFilter> flt;
CHECK_ERROR_BREAK (host, CreateUSBDeviceFilter (f.mName, flt.asOutParam()));
if (!f.mActive.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
if (!f.mVendorId.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty()));
if (!f.mProductId.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty()));
if (!f.mRevision.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty()));
if (!f.mManufacturer.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty()));
if (!f.mSerialNumber.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty()));
if (f.mAction != USBDeviceFilterAction_InvalidUSBDeviceFilterAction)
CHECK_ERROR_BREAK (flt, COMSETTER(Action) (f.mAction));
CHECK_ERROR_BREAK (host, InsertUSBDeviceFilter (cmd.mIndex, flt));
}
else
{
ComPtr <IUSBDeviceFilter> flt;
CHECK_ERROR_BREAK (ctl, CreateDeviceFilter (f.mName, flt.asOutParam()));
if (!f.mActive.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
if (!f.mVendorId.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty()));
if (!f.mProductId.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty()));
if (!f.mRevision.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty()));
if (!f.mManufacturer.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty()));
if (!f.mRemote.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote.setNullIfEmpty()));
if (!f.mSerialNumber.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty()));
CHECK_ERROR_BREAK (ctl, InsertDeviceFilter (cmd.mIndex, flt));
}
break;
}
case USBFilterCmd::Modify:
{
if (cmd.mGlobal)
{
ComPtr <IHostUSBDeviceFilterCollection> coll;
CHECK_ERROR_BREAK (host, COMGETTER(USBDeviceFilters) (coll.asOutParam()));
ComPtr <IHostUSBDeviceFilter> flt;
CHECK_ERROR_BREAK (coll, GetItemAt (cmd.mIndex, flt.asOutParam()));
if (!f.mName.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName.setNullIfEmpty()));
if (!f.mActive.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
if (!f.mVendorId.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty()));
if (!f.mProductId.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty()));
if (!f.mRevision.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty()));
if (!f.mManufacturer.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty()));
if (!f.mSerialNumber.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty()));
if (f.mAction != USBDeviceFilterAction_InvalidUSBDeviceFilterAction)
CHECK_ERROR_BREAK (flt, COMSETTER(Action) (f.mAction));
}
else
{
ComPtr <IUSBDeviceFilterCollection> coll;
CHECK_ERROR_BREAK (ctl, COMGETTER(DeviceFilters) (coll.asOutParam()));
ComPtr <IUSBDeviceFilter> flt;
CHECK_ERROR_BREAK (coll, GetItemAt (cmd.mIndex, flt.asOutParam()));
if (!f.mName.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Name) (f.mName.setNullIfEmpty()));
if (!f.mActive.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Active) (f.mActive));
if (!f.mVendorId.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(VendorId) (f.mVendorId.setNullIfEmpty()));
if (!f.mProductId.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(ProductId) (f.mProductId.setNullIfEmpty()));
if (!f.mRevision.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Revision) (f.mRevision.setNullIfEmpty()));
if (!f.mManufacturer.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Manufacturer) (f.mManufacturer.setNullIfEmpty()));
if (!f.mRemote.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(Remote) (f.mRemote.setNullIfEmpty()));
if (!f.mSerialNumber.isNull())
CHECK_ERROR_BREAK (flt, COMSETTER(SerialNumber) (f.mSerialNumber.setNullIfEmpty()));
}
break;
}
case USBFilterCmd::Remove:
{
if (cmd.mGlobal)
{
ComPtr <IHostUSBDeviceFilter> flt;
CHECK_ERROR_BREAK (host, RemoveUSBDeviceFilter (cmd.mIndex, flt.asOutParam()));
}
else
{
ComPtr <IUSBDeviceFilter> flt;
CHECK_ERROR_BREAK (ctl, RemoveDeviceFilter (cmd.mIndex, flt.asOutParam()));
}
break;
}
default:
break;
}
if (cmd.mMachine)
{
/* commit and close the session */
CHECK_ERROR(cmd.mMachine, SaveSettings());
aSession->Close();
}
return SUCCEEDED (rc) ? 0 : 1;
}
static int handleSharedFolder (int argc, char *argv[],
ComPtr <IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
HRESULT rc;
/* we need at least a command and target */
if (argc < 2)
{
return errorSyntax(USAGE_SHAREDFOLDER, "Not enough parameters");
}
ComPtr<IMachine> machine;
/* assume it's a UUID */
rc = aVirtualBox->GetMachine(Guid(argv[1]), machine.asOutParam());
if (FAILED(rc) || !machine)
{
/* must be a name */
CHECK_ERROR(aVirtualBox, FindMachine(Bstr(argv[1]), machine.asOutParam()));
}
if (!machine)
return 1;
Guid uuid;
machine->COMGETTER(Id)(uuid.asOutParam());
if (strcmp(argv[0], "add") == 0)
{
/* we need at least four more parameters */
if (argc < 5)
{
return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Not enough parameters");
}
char *name = NULL;
char *hostpath = NULL;
bool fTransient = false;
for (int i = 2; i < argc; i++)
{
if (strcmp(argv[i], "-name") == 0)
{
if (argc <= i + 1 || !*argv[i+1])
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
name = argv[i];
}
else if (strcmp(argv[i], "-hostpath") == 0)
{
if (argc <= i + 1 || !*argv[i+1])
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
hostpath = argv[i];
}
else if (strcmp(argv[i], "-transient") == 0)
{
fTransient = true;
}
else
{
return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Invalid parameter '%s'", Utf8Str(argv[i]).raw());
}
}
/* required arguments */
if (!name || !hostpath)
{
return errorSyntax(USAGE_SHAREDFOLDER_ADD, "Parameters -name and -hostpath are required");
}
if (fTransient)
{
ComPtr <IConsole> console;
/* open an existing session for the VM */
CHECK_ERROR_RET(aVirtualBox, OpenExistingSession (aSession, uuid), 1);
/* get the session machine */
CHECK_ERROR_RET(aSession, COMGETTER(Machine)(machine.asOutParam()), 1);
/* get the session console */
CHECK_ERROR_RET(aSession, COMGETTER(Console)(console.asOutParam()), 1);
CHECK_ERROR(console, CreateSharedFolder(Bstr(name), Bstr(hostpath)));
if (console)
aSession->Close();
}
else
{
/* open a session for the VM */
CHECK_ERROR_RET (aVirtualBox, OpenSession(aSession, uuid), 1);
/* get the mutable session machine */
aSession->COMGETTER(Machine)(machine.asOutParam());
CHECK_ERROR(machine, CreateSharedFolder(Bstr(name), Bstr(hostpath)));
if (SUCCEEDED(rc))
CHECK_ERROR(machine, SaveSettings());
aSession->Close();
}
}
else if (strcmp(argv[0], "remove") == 0)
{
/* we need at least two more parameters */
if (argc < 3)
{
return errorSyntax(USAGE_SHAREDFOLDER_REMOVE, "Not enough parameters");
}
char *name = NULL;
bool fTransient = false;
for (int i = 2; i < argc; i++)
{
if (strcmp(argv[i], "-name") == 0)
{
if (argc <= i + 1 || !*argv[i+1])
{
return errorArgument("Missing argument to '%s'", argv[i]);
}
i++;
name = argv[i];
}
else if (strcmp(argv[i], "-transient") == 0)
{
fTransient = true;
}
else
{
return errorSyntax(USAGE_SHAREDFOLDER_REMOVE, "Invalid parameter '%s'", Utf8Str(argv[i]).raw());
}
}
/* required arguments */
if (!name)
{
return errorSyntax(USAGE_SHAREDFOLDER_REMOVE, "Parameter -name is required");
}
if (fTransient)
{
ComPtr <IConsole> console;
/* open an existing session for the VM */
CHECK_ERROR_RET(aVirtualBox, OpenExistingSession (aSession, uuid), 1);
/* get the session machine */
CHECK_ERROR_RET(aSession, COMGETTER(Machine)(machine.asOutParam()), 1);
/* get the session console */
CHECK_ERROR_RET(aSession, COMGETTER(Console)(console.asOutParam()), 1);
CHECK_ERROR(console, RemoveSharedFolder(Bstr(name)));
if (console)
aSession->Close();
}
else
{
/* open a session for the VM */
CHECK_ERROR_RET (aVirtualBox, OpenSession(aSession, uuid), 1);
/* get the mutable session machine */
aSession->COMGETTER(Machine)(machine.asOutParam());
CHECK_ERROR(machine, RemoveSharedFolder(Bstr(name)));
/* commit and close the session */
CHECK_ERROR(machine, SaveSettings());
aSession->Close();
}
}
else
{
return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", Utf8Str(argv[0]).raw());
}
return 0;
}
static int handleVMStatistics(int argc, char *argv[],
ComPtr<IVirtualBox> aVirtualBox, ComPtr<ISession> aSession)
{
HRESULT rc;
/* at least one option: the UUID or name of the VM */
if (argc < 1)
return errorSyntax(USAGE_VM_STATISTICS, "Incorrect number of parameters");
/* try to find the given machine */
ComPtr <IMachine> machine;
Guid uuid (argv[0]);
if (!uuid.isEmpty())
CHECK_ERROR(aVirtualBox, GetMachine(uuid, machine.asOutParam()));
else
{
CHECK_ERROR(aVirtualBox, FindMachine(Bstr(argv[0]), machine.asOutParam()));
if (SUCCEEDED (rc))
machine->COMGETTER(Id)(uuid.asOutParam());
}
if (FAILED(rc))
return 1;
/* */
bool fWithDescriptions = false;
const char *pszPattern = NULL; /* all */
for (int i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "-pattern"))
{
if (pszPattern)
return errorSyntax(USAGE_VM_STATISTICS, "Multiple -patterns options is not permitted");
if (i + 1 >= argc)
return errorArgument("Missing argument to '%s'", argv[i]);
pszPattern = argv[++i];
}
else if (!strcmp(argv[i], "-descriptions"))
fWithDescriptions = true;
/* add: -file <filename> and -formatted */
else
return errorSyntax(USAGE_VM_STATISTICS, "Unknown option '%s'", argv[i]);
}
/* open an existing session for the VM. */
CHECK_ERROR(aVirtualBox, OpenExistingSession(aSession, uuid));
if (SUCCEEDED(rc))
{
/* get the session console. */
ComPtr <IConsole> console;
CHECK_ERROR(aSession, COMGETTER(Console)(console.asOutParam()));
if (SUCCEEDED(rc))
{
/* get the machine debugger. */
ComPtr <IMachineDebugger> debugger;
CHECK_ERROR(console, COMGETTER(Debugger)(debugger.asOutParam()));
if (SUCCEEDED(rc))
{
if (1/*fDumpStats*/)
{
Bstr stats;
CHECK_ERROR(debugger, GetStats(Bstr(pszPattern).raw(), fWithDescriptions, stats.asOutParam()));
if (SUCCEEDED(rc))
{
RTPrintf("%ls\n", stats.raw());
}
}
}
aSession->Close();
}
}
return SUCCEEDED(rc) ? 0 : 1;
}
enum HUSPD { HUSPD_DryRun, HUSPD_Apply, HUSPD_ApplyNoBackup };
static int handleUpdateSettings_processFile (const char *filePath, HUSPD mode)
{
RTPrintf ("%s\n", filePath);
CFGHANDLE config = 0;
char *errMsg = NULL;
int vrc = CFGLDRLoad (&config, filePath, NIL_RTFILE,
NULL, false, NULL, //cfgLdrEntityResolver,
&errMsg);
if (VBOX_SUCCESS (vrc))
{
CFGNODE vbox = 0;
CFGLDRGetNode (config, "VirtualBox", 0, &vbox);
Bstr version;
CFGLDRQueryBSTR (vbox, "version", version.asOutParam());
CFGLDRReleaseNode (vbox);
RTPrintf (" current version : %ls\n", version.raw());
/// @todo (dmik) use cfgLdrEntityResolver later
vrc = CFGLDRTransform (config, "SettingsConverter.xsl", NULL, &errMsg);
if (VBOX_SUCCESS (vrc))
{
CFGLDRGetNode (config, "VirtualBox", 0, &vbox);
CFGLDRQueryBSTR (vbox, "version", version.asOutParam());
CFGLDRReleaseNode (vbox);
RTPrintf (" new version : %ls\n\n", version.raw());
if (mode != HUSPD_DryRun)
{
if (mode != HUSPD_ApplyNoBackup)
{
Utf8StrFmt filePathBak ("%s.bak", filePath);
vrc = RTFileCopy (filePath, filePathBak);
if (VBOX_FAILURE (vrc))
{
RTPrintf ("Error copying '%s' to '%s' (%Vrc)\n",
filePath, filePathBak.raw(), vrc);
}
}
if (VBOX_SUCCESS (vrc))
{
vrc = CFGLDRSave (config, &errMsg);
if (VBOX_FAILURE (vrc))
{
RTPrintf ("Error saving the settings file '%s' (%Vrc)%s%s\n",
filePath, vrc,
errMsg ? "\n" : "", errMsg ? errMsg : "");
}
}
}
}
else
{
RTPrintf ("Could not convert the settings file '%s' (%Vrc)%s%s\n",
filePath, vrc, errMsg ? "\n" : "", errMsg ? errMsg : "");
}
CFGLDRFree (config);
}
else
{
RTPrintf ("Error loading the settings file '%s' (%Vrc)%s%s\n",
filePath, vrc, errMsg ? "\n" : "", errMsg ? errMsg : "");
}
if (errMsg)
RTStrFree (errMsg);
return vrc;
}
static int handleUpdateSettings_processDir (const char *dirPath, HUSPD mode,
bool skipInvalid)
{
PRTDIR dir;
int vrc = RTDirOpen (&dir, dirPath);
if (VBOX_FAILURE (vrc))
{
return vrc;
}
RTDIRENTRYEX entry;
while (VBOX_SUCCESS (vrc))
{
vrc = RTDirReadEx (dir, &entry, NULL, RTFSOBJATTRADD_UNIX);
if (VBOX_FAILURE (vrc))
{
if (vrc == VERR_NO_MORE_FILES)
vrc = VINF_SUCCESS;
else
RTPrintf ("Error reading directory '%s' (%Vrc)\n", dirPath, vrc);
break;
}
if (RTFS_IS_DIRECTORY (entry.Info.Attr.fMode))
{
if (entry.szName[0] == '.' &&
(entry.szName[1] == 0 ||
(entry.szName[1] == '.' && entry.szName[2] == 0)))
continue;
vrc = handleUpdateSettings_processDir (
Utf8StrFmt ("%s%c%s", dirPath, RTPATH_DELIMITER, entry.szName),
mode, skipInvalid);
if (VBOX_FAILURE (vrc))
break;
continue;
}
else if (RTFS_IS_FILE (entry.Info.Attr.fMode))
{
const char *ext = RTPathExt (entry.szName);
if (!ext || strcmp (ext, ".xml") != 0)
continue;
}
else
continue;
Utf8Str filePath = Utf8StrFmt ("%s%c%s", dirPath, RTPATH_DELIMITER,
entry.szName);
vrc = handleUpdateSettings_processFile (filePath, mode);
if (skipInvalid)
vrc = VINF_SUCCESS;
}
RTDirClose (dir);
return vrc;
}
static int handleUpdateSettings (int argc, char *argv[])
{
const char *dirOrFilePath = NULL;
bool apply = false;
bool nobackup = false;
bool skipinvalid = false;
for (int i = 0; i < argc; i++)
{
if (i == 0 && argv[i][0] != '-')
{
dirOrFilePath = argv[i];
}
else if (argv[i][0] == '-')
{
if (strcmp (&argv[i][1], "apply") == 0)
apply = true;
else if (strcmp (&argv[i][1], "nobackup") == 0)
nobackup = true;
else if (strcmp (&argv[i][1], "skipinvalid") == 0)
skipinvalid = true;
else
{
return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", Utf8Str(argv[i]).raw());
}
}
else
{
return errorSyntax(USAGE_SETPROPERTY, "Invalid parameter '%s'", Utf8Str(argv[i]).raw());
}
}
HUSPD mode = HUSPD_DryRun;
if (apply)
mode = nobackup ? HUSPD_ApplyNoBackup : HUSPD_Apply;
int vrc = CFGLDRInitialize();
if (VBOX_FAILURE (vrc))
{
RTPrintf ("Could not initialize XML subsystem (%Vrc)\n", vrc);
return 1;
}
if (dirOrFilePath)
{
if (RTDirExists (dirOrFilePath))
{
char fullPath [RTPATH_MAX];
vrc = RTPathReal (dirOrFilePath, fullPath, RTPATH_MAX);
if (VBOX_FAILURE (vrc))
{
RTPrintf ("Invalid directory path '%s' (%Vrc)\n", dirOrFilePath, vrc);
return 1;
}
RTPrintf ("Updating settings files in the following directory:\n"
"\n %s\n\n", fullPath);
vrc = handleUpdateSettings_processDir (dirOrFilePath, mode, skipinvalid);
}
else
{
vrc = handleUpdateSettings_processFile (dirOrFilePath, mode);
}
}
else
{
char homeDir [RTPATH_MAX];
vrc = GetVBoxUserHomeDirectory (homeDir, sizeof (homeDir));
AssertRC (vrc);
if (VBOX_SUCCESS (vrc))
{
RTPrintf ("Updating settings files in the following VirtualBox Home Directory:\n"
"\n %s\n\n", homeDir);
vrc = handleUpdateSettings_processDir (homeDir, mode, skipinvalid);
}
}
if (mode == HUSPD_DryRun)
{
RTPrintf ("NOTE: No actual changes to the setting files were made.\n"
" Repeat the command with the -apply option supplied.\n");
}
CFGLDRShutdown();
return VBOX_SUCCESS (vrc) ? 0 : 1;
}
// main
///////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
/*
* Before we do anything, init the runtime without loading
* the support driver.
*/
RTR3Init(false);
bool fShowLogo = true;
int iCmd = 1;
int iCmdArg;
for (int i = 1; i < argc || argc <= iCmd; i++)
{
if ( argc <= iCmd
|| (strcmp(argv[i], "help") == 0)
|| (strcmp(argv[i], "-?") == 0)
|| (strcmp(argv[i], "-h") == 0)
|| (strcmp(argv[i], "-help") == 0)
|| (strcmp(argv[i], "--help") == 0))
{
showLogo();
printUsage(USAGE_ALL);
return 0;
}
else if ( strcmp(argv[i], "-v") == 0
|| strcmp(argv[i], "-version") == 0
|| strcmp(argv[i], "-Version") == 0
|| strcmp(argv[i], "--version") == 0)
{
/* Print version number, and do nothing else. */
RTPrintf("%sr%d\n", VBOX_VERSION_STRING, VBoxSVNRev ());
exit(0);
}
else if (strcmp(argv[i], "-nologo") == 0)
{
/* suppress the logo */
fShowLogo = false;
iCmd++;
}
else if (strcmp(argv[i], "-dumpopts") == 0)
{
/* Special option to dump really all commands,
* even the ones not understood on this platform. */
printUsage(USAGE_DUMPOPTS);
return 0;
}
else
{
break;
}
}
iCmdArg = iCmd + 1;
if (fShowLogo)
showLogo();
HRESULT rc;
CHECK_RC_RET (com::Initialize());
/*
* The input is in the host OS'es codepage (NT guarantees ACP).
* For VBox we use UTF-8 and convert to UCS-2 when calling (XP)COM APIs.
* For simplicity, just convert the argv[] array here.
*/
for (int i = iCmdArg; i < argc; i++)
{
char *converted;
RTStrCurrentCPToUtf8(&converted, argv[i]);
argv[i] = converted;
}
do
{
// scopes all the stuff till shutdown
////////////////////////////////////////////////////////////////////////////
/* update settings command (no VirtualBox instantiation!) */
if (argc >= iCmdArg && (strcmp(argv[iCmd], "updatesettings") == 0))
{
rc = handleUpdateSettings(argc - iCmdArg, argv + iCmdArg);
break;
}
/* convertdd: does not need a VirtualBox instantiation) */
if (argc >= iCmdArg && (strcmp(argv[iCmd], "convertdd") == 0))
{
rc = handleConvertDDImage(argc - iCmdArg, argv + iCmdArg);
break;
}
ComPtr <IVirtualBox> virtualBox;
ComPtr <ISession> session;
rc = virtualBox.createLocalObject (CLSID_VirtualBox);
if (FAILED(rc))
{
RTPrintf ("[!] Failed to create the VirtualBox object!\n");
PRINT_RC_MESSAGE (rc);
com::ErrorInfo info;
if (!info.isFullAvailable() && !info.isBasicAvailable())
RTPrintf ("[!] Most likely, the VirtualBox COM server is not running "
"or failed to start.\n");
else
PRINT_ERROR_INFO (info);
break;
}
CHECK_RC_BREAK (session.createInprocObject (CLSID_Session));
/* create the event queue
* (here it is necessary only to process remaining XPCOM/IPC events
* after the session is closed) */
EventQueue eventQ;
/*
* All registered command handlers
*/
struct
{
const char *command;
PFNHANDLER handler;
} commandHandlers[] =
{
{ "internalcommands", handleInternalCommands },
{ "list", handleList },
{ "showvminfo", handleShowVMInfo },
{ "registervm", handleRegisterVM },
{ "unregistervm", handleUnregisterVM },
{ "createvdi", handleCreateVDI },
{ "modifyvdi", handleModifyVDI },
{ "addiscsidisk", handleAddiSCSIDisk },
{ "createvm", handleCreateVM },
{ "modifyvm", handleModifyVM },
{ "clonevdi", handleCloneVDI },
{ "startvm", handleStartVM },
{ "controlvm", handleControlVM },
{ "discardstate", handleDiscardState },
{ "snapshot", handleSnapshot },
{ "registerimage", handleRegisterImage },
{ "unregisterimage", handleUnregisterImage },
{ "showvdiinfo", handleShowVDIInfo },
#ifdef RT_OS_WINDOWS
{ "createhostif", handleCreateHostIF },
{ "removehostif", handleRemoveHostIF },
#endif
{ "getextradata", handleGetExtraData },
{ "setextradata", handleSetExtraData },
{ "setproperty", handleSetProperty },
{ "usbfilter", handleUSBFilter },
{ "sharedfolder", handleSharedFolder },
{ "vmstatistics", handleVMStatistics },
{ NULL, NULL }
};
int commandIndex;
for (commandIndex = 0; commandHandlers[commandIndex].command != NULL; commandIndex++)
{
if (strcmp(commandHandlers[commandIndex].command, argv[iCmd]) == 0)
{
rc = commandHandlers[commandIndex].handler(argc - iCmdArg, &argv[iCmdArg], virtualBox, session);
break;
}
}
if (!commandHandlers[commandIndex].command)
{
rc = errorSyntax(USAGE_ALL, "Invalid command '%s'", Utf8Str(argv[iCmd]).raw());
}
// end "all-stuff" scope
////////////////////////////////////////////////////////////////////////////
}
while (0);
com::Shutdown();
/*
* Free converted argument vector
*/
for (int i = iCmdArg; i < argc; i++)
RTStrFree(argv[i]);
return rc;
}