summaryrefslogtreecommitdiff
path: root/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2016-03-16 19:17:22 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2016-03-16 19:17:22 +0000
commit7297168b42e116e39686219718c4630e7f5d0789 (patch)
tree6ee5249f7301dd2aa36393f1bdf8256086b2d2b9 /src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
parentb04e8b7219d5795d4537eec00157206a3d5cb678 (diff)
downloadVirtualBox-svn-7297168b42e116e39686219718c4630e7f5d0789.tar.gz
Main: Add API to IHost for adding and removing USB device sources in addition to the default host one (only USB/IP backend supported so far which will be used in the future for automatic USB testing). Add support for it in VBoxManage
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@60067 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp')
-rw-r--r--src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp b/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
index 3fb44e956d6..82c1e136d6a 100644
--- a/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
+++ b/src/VBox/Frontends/VBoxManage/VBoxManageUSB.cpp
@@ -546,4 +546,54 @@ RTEXITCODE handleUSBFilter(HandlerArg *a)
return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
}
+
+RTEXITCODE handleUSBDevSource(HandlerArg *a)
+{
+ HRESULT rc = S_OK;
+
+ /* at least: 0: command, 1: source id */
+ if (a->argc < 2)
+ return errorSyntax(USAGE_USBDEVSOURCE, "Not enough parameters");
+
+ ComPtr<IHost> host;
+ if (!strcmp(a->argv[0], "add"))
+ {
+ Bstr strBackend;
+ Bstr strAddress;
+ if (a->argc != 6)
+ return errorSyntax(USAGE_USBDEVSOURCE, "Invalid number of parameters");
+
+ for (int i = 2; i < a->argc; i++)
+ {
+ if (!strcmp(a->argv[i], "--backend"))
+ {
+ i++;
+ strBackend = a->argv[i];
+ }
+ else if (!strcmp(a->argv[i], "--address"))
+ {
+ i++;
+ strAddress = a->argv[i];
+ }
+ else
+ return errorSyntax(USAGE_USBDEVSOURCE, "Parameter \"%s\" is invalid", a->argv[i]);
+ }
+
+ SafeArray<BSTR> usbSourcePropNames;
+ SafeArray<BSTR> usbSourcePropValues;
+
+ CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(host.asOutParam()), RTEXITCODE_FAILURE);
+ CHECK_ERROR_RET(host, AddUSBDeviceSource(strBackend.raw(), Bstr(a->argv[1]).raw(), strAddress.raw(),
+ ComSafeArrayAsInParam(usbSourcePropNames), ComSafeArrayAsInParam(usbSourcePropValues)),
+ RTEXITCODE_FAILURE);
+ }
+ else if (!strcmp(a->argv[0], "remove"))
+ {
+ CHECK_ERROR_RET(a->virtualBox, COMGETTER(Host)(host.asOutParam()), RTEXITCODE_FAILURE);
+ CHECK_ERROR_RET(host, RemoveUSBDeviceSource(Bstr(a->argv[1]).raw()), RTEXITCODE_FAILURE);
+ }
+
+ return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
+}
+
/* vi: set tabstop=4 shiftwidth=4 expandtab: */