From nobody Sun May 5 16:21:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150887936966487.19024307420636; Tue, 24 Oct 2017 14:09:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0139F37E8E; Tue, 24 Oct 2017 21:09:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C32835D9CB; Tue, 24 Oct 2017 21:09:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 61FA11804485; Tue, 24 Oct 2017 21:09:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9OL9NHD023713 for ; Tue, 24 Oct 2017 17:09:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id BFA265D75A; Tue, 24 Oct 2017 21:09:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9BF15D6A2 for ; Tue, 24 Oct 2017 21:09:21 +0000 (UTC) Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F6903D957 for ; Tue, 24 Oct 2017 21:09:20 +0000 (UTC) Received: by mail-qk0-f196.google.com with SMTP id f199so28084753qke.2 for ; Tue, 24 Oct 2017 14:09:20 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id e43sm901453qte.74.2017.10.24.14.09.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Oct 2017 14:09:18 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0139F37E8E Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0139F37E8E Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="scPiNb9d" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3F6903D957 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3F6903D957 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=IzI6kjdYwXIqbVxouIs6Iqk2CSbQ0BzEnzKdspo7u+o=; b=scPiNb9deXSBPb9ApiTEK0pbSMdsPkxFg4L09zONfy/MWNjmI16JBgQlcVePQybW1U bRyHw8UeAnHgRc4GoqLQQKvQPz2l0u0Pibt3f5TBQrP0rsQ+D1JD9FeEvu35GVC98trG ZxV9XhUHDl7BZ9dHx6ZQj0GeIQlTxlOy+xirW+mBe9n08wGdOHje0E9SQnwsnXuFjFeJ e7k1AVg+5cGIWSIzc979jHhZlrVqfOr/HazgBnu/8AYxDYet0Hqm9/knF27PwTIW5mT6 206A2Ckbz9oougbbqicinmSe7PHf1SAJgvxq4Mhs6tMqiWjxuahm+7CvVqhsXfVM3Peo nt4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=IzI6kjdYwXIqbVxouIs6Iqk2CSbQ0BzEnzKdspo7u+o=; b=A1Rj/eNBDFKWHxjBwjW/aZimvgDhejySodBMuZIu7k+x6pJvEaPvGe+CSbHq1kvuIk Nrsoa/tzgVj//2BWjXQgo9HFdUTtEtJMgYIw+IYeIGd9+/azcCSn+dcZU+TMPrv4MQ5R xZhjFnqCg0/9DwqyjXQOgYALpBesTTUngawwX0cO8YeTk1VJtptvQrdW0aVQOZ85to+S QgI1b6YoKHpkRIxiRa2+cR+3ZL+QLa4Wme44bO+8Mt8TI2Ap/LD+tCra21PMWlxWdgiB RVddn/vsXzTW5BSal0XR5S0qPj9cR32A2G2I24xDhasosgkrncCFdDWqtsVQcYCRVc5D iTLA== X-Gm-Message-State: AMCzsaXFNkvcDebiUREa7nS3BgwNcfmkaMDmO2k1NbtuqcLhreUWycVB iIMzb+4NbeKK5SCmlue5QCpE7in1U0M= X-Google-Smtp-Source: ABhQp+SQqveiwKjJzFQnIgsJPdY1tsIjgwdCHeqOQe+wBxK6etqFNp/Fjk7/MSkhF/jnCtqG62kLog== X-Received: by 10.55.198.209 with SMTP id s78mr23795033qkl.143.1508879359229; Tue, 24 Oct 2017 14:09:19 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Tue, 24 Oct 2017 17:09:15 -0400 Message-Id: <20171024210917.7728-2-dzamirski@datto.com> In-Reply-To: <20171024210917.7728-1-dzamirski@datto.com> References: <20171024210917.7728-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 24 Oct 2017 21:09:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 24 Oct 2017 21:09:20 +0000 (UTC) for IP:'209.85.220.196' DOMAIN:'mail-qk0-f196.google.com' HELO:'mail-qk0-f196.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.469 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.220.196 mail-qk0-f196.google.com 209.85.220.196 mail-qk0-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/3] vbox: Remove old unflexible macros X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 24 Oct 2017 21:09:28 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The VBOX_SESSION_OPEN/CLOSE macros are only called in _vboxDomainSnapshotRestore and they are unflexible because: * assume the caller will have variable named "data" * can only create Write lock type As per above, it's not that hard to simply use the VBOX API directly. Reviewed-by: John Ferlan --- src/vbox/vbox_tmpl.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index dffeabde0..ce2ee9037 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -144,12 +144,6 @@ if (strUtf16) {\ (unsigned)(iid)->m3[7]);\ }\ =20 -#define VBOX_SESSION_OPEN(/* unused */ iid_value, /* in */ machine) \ - machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write) - -#define VBOX_SESSION_CLOSE() \ - data->vboxSession->vtbl->UnlockMachine(data->vboxSession) - #define VBOX_IID_INITIALIZER { NULL, true } =20 static void @@ -323,7 +317,7 @@ _vboxDomainSnapshotRestore(virDomainPtr dom, goto cleanup; } =20 - rc =3D VBOX_SESSION_OPEN(domiid.value, machine); + rc =3D machine->vtbl->LockMachine(machine, data->vboxSession, LockType= _Write); #if VBOX_API_VERSION < 5000000 if (NS_SUCCEEDED(rc)) rc =3D data->vboxSession->vtbl->GetConsole(data->vboxSession, &con= sole); @@ -368,7 +362,7 @@ _vboxDomainSnapshotRestore(virDomainPtr dom, #if VBOX_API_VERSION < 5000000 VBOX_RELEASE(console); #endif /*VBOX_API_VERSION < 5000000*/ - VBOX_SESSION_CLOSE(); + data->vboxSession->vtbl->UnlockMachine(data->vboxSession); vboxIIDUnalloc(&domiid); return ret; } --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:21:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 150887936985364.4992129743448; Tue, 24 Oct 2017 14:09:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 276A2820FF; Tue, 24 Oct 2017 21:09:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C74A660176; Tue, 24 Oct 2017 21:09:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 039D46EF22; Tue, 24 Oct 2017 21:09:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9OL9Opf023729 for ; Tue, 24 Oct 2017 17:09:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1CCD45DA69; Tue, 24 Oct 2017 21:09:24 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 175325D9CB for ; Tue, 24 Oct 2017 21:09:21 +0000 (UTC) Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF40F7EA9E for ; Tue, 24 Oct 2017 21:09:20 +0000 (UTC) Received: by mail-qk0-f195.google.com with SMTP id b15so28062183qkg.9 for ; Tue, 24 Oct 2017 14:09:20 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id e43sm901453qte.74.2017.10.24.14.09.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Oct 2017 14:09:19 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 276A2820FF Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 276A2820FF Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="IjHq7ZXO" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AF40F7EA9E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AF40F7EA9E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=gBsLN01U/jEUPkPVyu7h3sE4MUrEbiQvUpodKz8EY7g=; b=IjHq7ZXObQsmfAxX4//CXjJ3grDfUipl9fcmjs5HGeTqoafv/X9zLQ0UCAvTZvdfXN xvNOOIuf1XwnuS3Z6XgJzr+UqC62ZrOXpLFFjIDTT7gh/clIZnrjr+hDfBj6002i9iuy DM13ICXX/YO5iXAH38UuDPp6eSbJWuAe3ka+4A7aP/D5u3P370E0FRDedtZL+/Yn8WsF 0bqFmkvlvAc/QEpCnZHTgUxCALTca/ePJcLq3ugMIX4Fa0f7yRATNVI8H1nFz9WKOnFS j4Vy8m9jR2ZinbRn4Ip7dd80uMzloQi7nfHrdBEjHRLYwhYC8ksM44YQ6TKSM7AAQyfX LRyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=gBsLN01U/jEUPkPVyu7h3sE4MUrEbiQvUpodKz8EY7g=; b=LrrKhQRA4X3JhOJhcgZ3fDmf8OFm33Q9x97AjkIEdkY2Ejbv94R09JbXCTv9ja5foo W0eNcIdenwzT3kEYgvIH7ZxZi+08D9sZkEHSK/s5xEJG+7G9EojUY9ziHbXfH60lyn2s VD7dTWO+zidMpJS+YUvIlDuNO/fLaJFvFvp4nVkPtMoGcY6c282vVFs7yAAzXR3SedIm sTec0QhxO4DNEnzPJ1hBhqARcf7wXr+zpI7I7xTDAfv2Cetxl0O98SHKBcH3UKAIViOY lO3IO7AStKEQGCX+B+TDsIx++6neMjGdtau2mapT9K+COU0pQV82Y4vK2wY+P+TOfO0x wL2A== X-Gm-Message-State: AMCzsaWKCO1WlPRk+Nolvw1YG4zsIGnTgp/dpvSsybOruRTIehByWXX5 CQ7Dp2maBi6xOJH7QP6MsnfN7JCIYK4= X-Google-Smtp-Source: ABhQp+RYTCRuTiXIC1YVgKOFSNlzWfdbbpzQqXpLKVrPrm5V31B0f1bElKws+ZLgorv48/XqpPCt1g== X-Received: by 10.55.26.219 with SMTP id l88mr26277952qkh.57.1508879359700; Tue, 24 Oct 2017 14:09:19 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Tue, 24 Oct 2017 17:09:16 -0400 Message-Id: <20171024210917.7728-3-dzamirski@datto.com> In-Reply-To: <20171024210917.7728-1-dzamirski@datto.com> References: <20171024210917.7728-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 24 Oct 2017 21:09:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 24 Oct 2017 21:09:20 +0000 (UTC) for IP:'209.85.220.195' DOMAIN:'mail-qk0-f195.google.com' HELO:'mail-qk0-f195.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.469 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.220.195 mail-qk0-f195.google.com 209.85.220.195 mail-qk0-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/3] vbox: Make autoport set RDP port range. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 24 Oct 2017 21:09:28 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Dawid Zamirski 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. Reviewed-by: John Ferlan --- 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) {\ =20 #define VBOX_IID_INITIALIZER { NULL, true } =20 +/* 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_UN= USED, } =20 static nsresult -_vrdeServerSetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, - IVRDEServer *VRDEServer, virDomainGraphicsDefPtr graph= ics) +_vrdeServerSetPorts(vboxDriverPtr data, IVRDEServer *VRDEServer, + virDomainGraphicsDefPtr graphics) { nsresult rc =3D 0; PRUnichar *VRDEPortsKey =3D NULL; PRUnichar *VRDEPortsValue =3D NULL; =20 VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey); - VRDEPortsValue =3D PRUnicharFromInt(data->pFuncs, graphics->data.rdp.p= ort); + + if (graphics->data.rdp.autoport) + VBOX_UTF8_TO_UTF16(VBOX_RDP_AUTOPORT_RANGE, &VRDEPortsValue); + else + VRDEPortsValue =3D PRUnicharFromInt(data->pFuncs, + graphics->data.rdp.port); + rc =3D VRDEServer->vtbl->SetVRDEProperty(VRDEServer, VRDEPortsKey, VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsKey); --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 16:21:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508879369828447.9261544407659; Tue, 24 Oct 2017 14:09:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 299A9C070147; Tue, 24 Oct 2017 21:09:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C47315D6A2; Tue, 24 Oct 2017 21:09:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5C4DA6EF21; Tue, 24 Oct 2017 21:09:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9OL9NU5023715 for ; Tue, 24 Oct 2017 17:09:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2C275D6A2; Tue, 24 Oct 2017 21:09:23 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA3FF5D6A8 for ; Tue, 24 Oct 2017 21:09:22 +0000 (UTC) Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3233833A167 for ; Tue, 24 Oct 2017 21:09:21 +0000 (UTC) Received: by mail-qk0-f193.google.com with SMTP id b15so28062201qkg.9 for ; Tue, 24 Oct 2017 14:09:21 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id e43sm901453qte.74.2017.10.24.14.09.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Oct 2017 14:09:19 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 299A9C070147 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 299A9C070147 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="WejZDTTA" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3233833A167 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3233833A167 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=I4/LSYQmwZNRQ8JoHoFR2FRD8G/BhWA0zRyd9pEJVn8=; b=WejZDTTArvobaPNZqJyOH6ViF1N0Wy/wgHWihIzyf/Wl+VL6eqkdt1sUDdiZtBW4yi Ey11yU10e96NYKkrC+Yv20E+f8vk5m/VE8zm+xCxwLuosY+N+DYJZnAvvRF0Lf+f/jAq 7+we4vKPQipbBYfWqlI/NzsUD6IFTAVDA0PmBoIEQCxI5HJw0VjqERgj18XkbZ8RODjX jFWL8Y9m125dEYFQTVp5l2EK3AKu/WOa9WGdeqTQMB6J2EqUHU99VpysvQLJB6lJN2ph 4oVQ9+FXvIu9BkJOP36yhnPXZL6ASt8vDPgQntBK8q96Nf8hzLdYnzPLRuhaNAB/NJ8o TquQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=I4/LSYQmwZNRQ8JoHoFR2FRD8G/BhWA0zRyd9pEJVn8=; b=K76iAwOXS9B4w/6yFnjO4JKk9LO0q315g3lU7nEMGtWhZZ2/XnxFEBZfD0Usp2qXXW 8qM4UVGlgeq/t/sDpd58yo6Dl+bxyxsrJLY01DIdalS/Wlf6mAeTH6jpbeLO/rxxnCqt K/31tK82thyp6ZWVvPzYV/XftqJhQ3i6HagfKNx8WtEYA9zBXhKCOA3P1iaAWw0B8Ppw 5f8l3nhh4ngwZ4fUefuwsQ19Ry1fvCaUYjdebka12UtsKjgeNtoVd0XhE6w66AQyy5vj yztM91m4jizMQ/U2FCXXoQQsMarXbSRcMXnsbbSvJpHtebkWusPkpHWgitWjeOwDals7 XS/w== X-Gm-Message-State: AMCzsaWDkIMXPeC+TGAAFEZXD9D78rtLdYGtBGUQz9KH02D4PUHN3pVe 15d9Izhc6dw/Z2RvHXPc4DlTwnXHtMY= X-Google-Smtp-Source: ABhQp+TrzmxEx8TvEnlcuiBhgKxydpkXqQ6sSHmxOmAPJOmpxIbGA4u9YGA4HoGHvYe7bm2wc+Q17w== X-Received: by 10.55.214.201 with SMTP id p70mr26077028qkl.21.1508879360174; Tue, 24 Oct 2017 14:09:20 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Tue, 24 Oct 2017 17:09:17 -0400 Message-Id: <20171024210917.7728-4-dzamirski@datto.com> In-Reply-To: <20171024210917.7728-1-dzamirski@datto.com> References: <20171024210917.7728-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 24 Oct 2017 21:09:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 24 Oct 2017 21:09:21 +0000 (UTC) for IP:'209.85.220.193' DOMAIN:'mail-qk0-f193.google.com' HELO:'mail-qk0-f193.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.469 (DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 209.85.220.193 mail-qk0-f193.google.com 209.85.220.193 mail-qk0-f193.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/3] vbox: Read runtime RDP port and handle autoport X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 24 Oct 2017 21:09:28 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" VirutalBox has a IVRDEServerInfo structure available that gives the effective runtime port that the VM is using when it's running. This is useful when the "TCP/Ports" VBox property was set to port range (e.g. via autoport =3D "yes" or via VBoxManage) in which case it would be impossible to get the "active" port otherwise. Reviewed-by: John Ferlan --- src/vbox/vbox_common.c | 3 +- src/vbox/vbox_tmpl.c | 134 +++++++++++++++++++++++++++++++-------= ---- src/vbox/vbox_uniformed_api.h | 2 +- 3 files changed, 104 insertions(+), 35 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 92ee37164..d542f2b76 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3326,7 +3326,8 @@ vboxDumpDisplay(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) if (VIR_ALLOC(graphics) < 0) goto cleanup; =20 - gVBoxAPI.UIVRDEServer.GetPorts(data, VRDEServer, graphics); + gVBoxAPI.UIVRDEServer.GetPorts(data, VRDEServer, machine, graphics= ); + gVBoxAPI.UISession.Close(data->vboxSession); =20 graphics->type =3D VIR_DOMAIN_GRAPHICS_TYPE_RDP; =20 diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 2b3f2e3eb..c7682f13c 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -221,29 +221,6 @@ _vboxIIDFromArrayItem(vboxDriverPtr data, vboxIID *iid, _vboxIIDFromArrayItem(data, iid, array, idx) #define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16) =20 -/** - * Converts Utf-16 string to int - */ -static int PRUnicharToInt(PCVBOXXPCOM pFuncs, PRUnichar *strUtf16) -{ - char *strUtf8 =3D NULL; - int ret =3D 0; - - if (!strUtf16) - return -1; - - pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8); - if (!strUtf8) - return -1; - - if (virStrToLong_i(strUtf8, NULL, 10, &ret) < 0) - ret =3D -1; - - pFuncs->pfnUtf8Free(strUtf8); - - return ret; -} - /** * Converts int to Utf-16 string */ @@ -280,6 +257,54 @@ static virDomainState _vboxConvertState(PRUint32 state) } } =20 + +static int +vboxGetActiveVRDEServerPort(ISession *session, IMachine *machine) +{ + nsresult rc; + PRInt32 port =3D -1; + IVRDEServerInfo *vrdeInfo =3D NULL; + IConsole *console =3D NULL; + + rc =3D machine->vtbl->LockMachine(machine, session, LockType_Shared); + if (NS_FAILED(rc)) { + VIR_WARN("Could not obtain shared lock on VBox VM, rc=3D%08x", rc); + return -1; + } + + rc =3D session->vtbl->GetConsole(session, &console); + if (NS_FAILED(rc)) { + VIR_WARN("Could not get VBox session console, rc=3D%08x", rc); + goto cleanup; + } + + /* it may be null if VM is not running */ + if (!console) + goto cleanup; + + rc =3D console->vtbl->GetVRDEServerInfo(console, &vrdeInfo); + + if (NS_FAILED(rc) || !vrdeInfo) { + VIR_WARN("Could not get VBox VM VRDEServerInfo, rc=3D%08x", rc); + goto cleanup; + } + + rc =3D vrdeInfo->vtbl->GetPort(vrdeInfo, &port); + + if (NS_FAILED(rc)) { + VIR_WARN("Could not read port from VRDEServerInfo, rc=3D%08x", rc); + goto cleanup; + } + + cleanup: + VBOX_RELEASE(console); + VBOX_RELEASE(vrdeInfo); + session->vtbl->UnlockMachine(session); + + return port; +} + + static int _vboxDomainSnapshotRestore(virDomainPtr dom, IMachine *machine, @@ -1576,24 +1601,67 @@ _vrdeServerSetEnabled(IVRDEServer *VRDEServer, PRBo= ol enabled) } =20 static nsresult -_vrdeServerGetPorts(vboxDriverPtr data ATTRIBUTE_UNUSED, - IVRDEServer *VRDEServer, virDomainGraphicsDefPtr graph= ics) +_vrdeServerGetPorts(vboxDriverPtr data, IVRDEServer *VRDEServer, + IMachine *machine, virDomainGraphicsDefPtr graphics) { nsresult rc; PRUnichar *VRDEPortsKey =3D NULL; PRUnichar *VRDEPortsValue =3D NULL; + PRInt32 port =3D -1; + ssize_t nmatches =3D 0; + char **matches =3D NULL; + char *portUtf8 =3D NULL; + + /* get active (effective) port - available only when VM is running and= has + * the VBOX extensions installed (without extenstions RDP server + * functionality is disabled) + */ + port =3D vboxGetActiveVRDEServerPort(data->vboxSession, machine); =20 + if (port > 0) + graphics->data.rdp.port =3D port; + + /* get the port (or port range) set in VM properties, this info will + * be used to determine whether to set autoport flag + */ VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey); - rc =3D VRDEServer->vtbl->GetVRDEProperty(VRDEServer, VRDEPortsKey, &VR= DEPortsValue); - VBOX_UTF16_FREE(VRDEPortsKey); - if (VRDEPortsValue) { - /* even if vbox supports mutilpe ports, single port for now here */ - graphics->data.rdp.port =3D PRUnicharToInt(data->pFuncs, VRDEPorts= Value); - VBOX_UTF16_FREE(VRDEPortsValue); - } else { - graphics->data.rdp.autoport =3D true; + rc =3D VRDEServer->vtbl->GetVRDEProperty(VRDEServer, VRDEPortsKey, + &VRDEPortsValue); + + if (NS_FAILED(rc)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to read RDP port value, rc=3D%08x"), + (unsigned) rc); + goto cleanup; } =20 + VBOX_UTF16_TO_UTF8(VRDEPortsValue, &portUtf8); + + if (portUtf8) { + /* does the string contain digits only */ + nmatches =3D virStringSearch(portUtf8, "(^[[:digit:]]+$)", 1, &mat= ches); + + /* the port property is not numeric, then it must be a port range = or + * port list or combination of the two, either way it's an autoport + */ + if (nmatches !=3D 1) + graphics->data.rdp.autoport =3D true; + + /* no active port available, e.g. VM is powered off, try to get it= from + * the property string + */ + if (port < 0) { + if (nmatches =3D=3D 1 && virStrToLong_i(portUtf8, NULL, 10, &p= ort) =3D=3D 0) + graphics->data.rdp.port =3D port; + } + } + + cleanup: + virStringListFree(matches); + VBOX_UTF8_FREE(portUtf8); + VBOX_UTF16_FREE(VRDEPortsValue); + VBOX_UTF16_FREE(VRDEPortsKey); + return rc; } =20 diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 2ccaf43e8..8cf27789b 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -341,7 +341,7 @@ typedef struct { nsresult (*GetEnabled)(IVRDEServer *VRDEServer, PRBool *enabled); nsresult (*SetEnabled)(IVRDEServer *VRDEServer, PRBool enabled); nsresult (*GetPorts)(vboxDriverPtr driver, IVRDEServer *VRDEServer, - virDomainGraphicsDefPtr graphics); + IMachine *machine, virDomainGraphicsDefPtr graphi= cs); nsresult (*SetPorts)(vboxDriverPtr driver, IVRDEServer *VRDEServer, virDomainGraphicsDefPtr graphics); nsresult (*GetReuseSingleConnection)(IVRDEServer *VRDEServer, PRBool *= enabled); --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list