Originally autoport in vbox driver was setting the port to default
value (3389) which caused mutiple VM instances use the same port.
Since libvirt XML does not allow to set port ranges, this patch changes
the "autoport" behavior to set VBox's "TCP/Ports" property to an
arbitraty port range (3389-3689) to avoid that issue.
---
src/vbox/vbox_tmpl.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index dffeabde0..8e47d90d6 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -152,6 +152,9 @@ if (strUtf16) {\
#define VBOX_IID_INITIALIZER { NULL, true }
+/* default RDP port range to use for auto-port setting */
+#define VBOX_RDP_AUTOPORT_RANGE "3389-3689"
+
static void
_vboxIIDUnalloc(vboxDriverPtr data, vboxIID *iid)
{
@@ -1601,20 +1604,27 @@ _vrdeServerGetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED,
}
static nsresult
-_vrdeServerSetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED,
- IVRDEServer *VRDEServer, virDomainGraphicsDefPtr graphics)
+_vrdeServerSetPorts(vboxDriverPtr data, IVRDEServer *VRDEServer,
+ virDomainGraphicsDefPtr graphics)
{
nsresult rc = 0;
PRUnichar *VRDEPortsKey = NULL;
PRUnichar *VRDEPortsValue = NULL;
VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey);
- VRDEPortsValue = PRUnicharFromInt(data->pFuncs, graphics->data.rdp.port);
+
+ if (graphics->data.rdp.port)
+ VRDEPortsValue = PRUnicharFromInt(data->pFuncs,
+ graphics->data.rdp.port);
+ else if (graphics->data.rdp.autoport)
+ VBOX_UTF8_TO_UTF16(VBOX_RDP_AUTOPORT_RANGE, &VRDEPortsValue);
+
rc = VRDEServer->vtbl->SetVRDEProperty(VRDEServer, VRDEPortsKey,
VRDEPortsValue);
VBOX_UTF16_FREE(VRDEPortsKey);
VBOX_UTF16_FREE(VRDEPortsValue);
+
return rc;
}
--
2.14.2