Run VirtualBox as another user

This code change allowed me to have VirtualBox VMs and a Cloud device with Internet in GNS3 network at the same time.
(Tested only on Ubuntu Linux)

I ran GNS3 as a root user (required to configure Cloud devices to use my real PC's network cards):
> sudo gns3server (in one terminal window)
> sudo gns3 (in another terminal window)
But with GNS3 running as root, I could not add my VirtualBox non-root VMs to GNS3, because they did not show up in GNS3 VMs list.

To solve this problem, I made the changes to GNS3 server and GNS3 GUI code adding the following new setting to GNS3:

Edit -> Preferences... -> VirtualBox -> General -> General settings -> "Run VirtualBox as another user (GNS3 running as Linux root)"

By default, this field is empty, and when it is empty GNS3 runs as usual, as if there were no code changes at all.
But if I input a non-empty user name and press Apply, all subsequent VirtualBox operations are performed in the name of this user, not the user who is currently running GNS3.

Now I can run GNS3 as Linux root, setup GNS3 to run VirtualBox as the user who owns the VMs, and add these VMs to GNS3 network.

Dmitry
shmygov@rambler.ru