[libvirt] [PATCH v2 2/3] vbox: Make autoport set RDP port range.

Dawid Zamirski posted 3 patches 7 years, 6 months ago
[libvirt] [PATCH v2 2/3] vbox: Make autoport set RDP port range.
Posted by Dawid Zamirski 7 years, 6 months ago
From: Dawid Zamirski <dzrudy@gmail.com>

Originally autoport in vbox driver was setting the port to default value
(3389) which caused multiple 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 arbitrary
port range (3389-3689) to avoid that issue.
---
 src/vbox/vbox_tmpl.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index ce2ee9037..2b3f2e3eb 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -146,6 +146,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)
 {
@@ -1595,15 +1598,21 @@ _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.autoport)
+        VBOX_UTF8_TO_UTF16(VBOX_RDP_AUTOPORT_RANGE, &VRDEPortsValue);
+    else
+        VRDEPortsValue = PRUnicharFromInt(data->pFuncs,
+                                          graphics->data.rdp.port);
+
     rc = VRDEServer->vtbl->SetVRDEProperty(VRDEServer, VRDEPortsKey,
                                            VRDEPortsValue);
     VBOX_UTF16_FREE(VRDEPortsKey);
-- 
2.14.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 2/3] vbox: Make autoport set RDP port range.
Posted by John Ferlan 7 years, 6 months ago

On 10/24/2017 05:09 PM, Dawid Zamirski wrote:
> From: Dawid Zamirski <dzrudy@gmail.com>
> 
> Originally autoport in vbox driver was setting the port to default value
> (3389) which caused multiple 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 arbitrary
> port range (3389-3689) to avoid that issue.
> ---
>  src/vbox/vbox_tmpl.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list