How to discover the hostname on which the VirtualBox GUI runs?

This is for discussing general topics about how to use VirtualBox.
rbarak
Posts: 52
Joined: 25. Sep 2018, 20:43

How to discover the hostname on which the VirtualBox GUI runs?

Post by rbarak »

I run VirtualBox on multiple CentOS hosts, and on occasion, I have several VirtualBox GUIs open on my workstation.[1]

I didn't find a way to discover - from a VirtualBox GUI, which is the hostname the VirtualBox GUI is running on.
Do you know where I can find the host hostname on which the VirtualBox runs?

---
[1] I ssh to the target VirtualBox machine with ssh -Y, and then
when I issue the command virtualbox, the VirtualBox GUI shows on my workstation.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: How to discover the hostname on which the VirtualBox GUI runs?

Post by fth0 »

Some ideas where to place the hostname in the VirtualBox GUI app window:
  • In the VirtualBox GUI app, you can see the names of the VMs, and their Description on the Details pane.
  • Depending on your workstation's window manager, you can set your X11 window's title.
rbarak
Posts: 52
Joined: 25. Sep 2018, 20:43

Re: How to discover the hostname on which the VirtualBox GUI runs?

Post by rbarak »

I'm expecting that from somewhere in the VirtualBox GUI, the VirtualBox host's hostname would be available.
The VirtualBox GUI as seen on my Workstation
The VirtualBox GUI as seen on my Workstation
Screenshot from 2019-07-30 15-34-56-min.png (57.5 KiB) Viewed 21063 times
I just cannot determine where this place in the GUI is.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: How to discover the hostname on which the VirtualBox GUI runs?

Post by fth0 »

rbarak wrote:I'm expecting that from somewhere in the VirtualBox GUI, the VirtualBox host's hostname would be available.
I just cannot determine where this place in the GUI is.
I'm not sure if I understand you correctly, so let me explain:
  • Like any program, the VirtualBox GUI app knows the hostname of the host it is running on (inherited from the shell environment), and like most programs, it does not display it anywhere in it's GUI (as far as I know).
  • If you use any kind of remote management system (you mentioned SSH with X11 forwarding), it would be the task of the remote management system to display the hostnames corresponding to the remote management windows displayed.
  • Since the hostname currently is not displayed, I made three suggestions (not ready made solutions) where you can get it displayed.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: How to discover the hostname on which the VirtualBox GUI runs?

Post by socratis »

rbarak wrote:I'm expecting that from somewhere in the VirtualBox GUI, the VirtualBox host's hostname would be available
Why would you expect that? Can you name a couple of apps that include the hostname in the title? Like Firefox, Chrome, Notepad++, gedit or Calculator?
rbarak wrote:I ssh to the target VirtualBox machine
Then you already know where you are! Just look at the last command issued in your host's Terminal, that should tell you where you are connected to.
fth0 wrote:In the VirtualBox GUI app, you can see the names of the VMs, and their Description on the Details pane.
That's a great idea that could get you easily out of the "trouble", add as your first line in the Description of the VMs the hostname.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to discover the hostname on which the VirtualBox GUI runs?

Post by scottgus1 »

@rbarak: I'm also not sure I understand what you're trying to do. First we need to clarify terminology as it is generally used on this forum:

The physical PC that is running Virtualbox and has all the virtual machines running on it is called the "host".

The virtual machines are called the "guests".

The "Virtualbox GUI" is often thought of by me as the main Virtualbox window, the screenshot you posted in your second post.

The windows that show the guest operating systems are the "guest windows".

In normal parlance the "hostname" is the network name of the PC, either physical or virtual. For example, my house server is called "snchomeserver" and when I want to get to that computer on my network from my other PCs, I enter \\snchomeserver as the root path name. When I open a command prompt on that PC and enter the command 'hostname' it returns "snchomeserver".

For example, this:
rbarak wrote:I run VirtualBox on multiple CentOS hosts
means you have lots of physical PCs with CentOS as the operating system installed on the PCs, and these PCs are running Virtualbox.
rbarak wrote:I have several VirtualBox GUIs open on my workstation....
I ssh to the target VirtualBox machine with ssh -Y, and then when I issue the command virtualbox, the VirtualBox GUI shows on my workstation.
Sounds like this 'virtualbox' command is going to the host PC. I enter 'virtualbox' at a command prompt and I get the main Virtualbox window popping open on my host desktop too. Entering the command again makes another main Virtualbox window, etc. Are you trying to get the 'virtualbox' command to go to your guest through ssh? It sounds like it isn't getting there.

Please clarify if you are ssh remoting into the CentOS host physical PCs, or are you ssh remoting into Virtualbox guests?

What exactly is the "hostname" you want to see?
rbarak
Posts: 52
Joined: 25. Sep 2018, 20:43

How to make X11 display the VirtualBox hostname in the Window's title?

Post by rbarak »

When I open VirtualBox GUIs from remote machines on my workstation,[1] the GUI title does not show the hostname on which the VirtualBox GUI runs.
Is there a way to make X11 display that hostname in the Window's title (e.g., to get a title like the below, with the (on <hostname>))?
Multiple VirtualBox GUIs
Multiple VirtualBox GUIs
multiple_virtualbox_GUIs.png (30.84 KiB) Viewed 21052 times
---
[1] I connect to the remote machine with
ssh -Y <hostname>
erdeslawe
Volunteer
Posts: 241
Joined: 8. Jul 2015, 10:23

Re: How to make X11 display the VirtualBox hostname in the Window's title?

Post by erdeslawe »

You've already asked a very similar question here: viewtopic.php?f=1&t=94122

I doubt that asking almost the same thing in another way in another forum is going to gain any different responses; and the duplication will not go down well with the Forum Admins.
rbarak
Posts: 52
Joined: 25. Sep 2018, 20:43

Re: How to make X11 display the VirtualBox hostname in the Window's title?

Post by rbarak »

Thanks for your concern, @erdeslawe.
The previous question you mentioned - was rather general.
Based on the replies I received to it (and elsewhere) I created this new question,
which is focused on the probable solution domain, and was asked of the Linux sub-group - which is probably where the specific solution knowledge lies.
rbarak
Posts: 52
Joined: 25. Sep 2018, 20:43

Re: How to discover the hostname on which the VirtualBox GUI runs?

Post by rbarak »

From <my workstation> I do
ssh -Y <remote hostname>
and then on <remote hostname> I do
virtualbox
which causes the VirtualBox GUI to be displayed by X11 on <my workstation>.

If I have several of these VirtualBox GUIs displayed on <my workstation>, then it's difficult to know who's whom, without being able to see, or enquire of, the <remote hostname> somewhere on the VirtualBox GUI.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to discover the hostname on which the VirtualBox GUI runs?

Post by scottgus1 »

Ok, so I'm a Windows guy, so let me understand: You ssh into another PC and if the command you run on the remote PC opens a window, it opens on your local PC? Interesting.

If I've understood right, then I can see how you'd have a group of main Virtualbox windows, one for each remote Virtualbox host you've ssh'ed into and run the 'virtualbox' command on. These windows are connected to the remote hosts. However, which window is connected to which host is not shown. Yep, that would be hard to handle.

Second However: Virtualbox does not have any programmed capability to display the name of the host PC it's running on in the main Virtualbox window. As Socratis and fth0 mention, displaying the hostname of the PC an application is running on within the application is possible. (In fact I have a vbscript I use on my home & backup servers that gets the server's hostname for the script's output, so it is possible.) But Virtualbox is not programmed to show the hostname at this time.

You will need to use a different remote software to show the hostname along with the window from the remote PC. Meanwhile you can suggest this hostname display idea in the Bugtracker as an enhancement (don't hold your breath waiting for the idea to be included though. You can also get the source-code and insert the code for your own hosts. Finally, you could as fth0 indicated, use the Description tab of the guests as a place to put info, such as put the hostname in the Description of each PC's first guest.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: How to make X11 display the VirtualBox hostname in the Window's title?

Post by fth0 »

Use xdotool on your workstation, e.g.:

Code: Select all

xdotool search --name "Oracle VM VirtualBox Manager" set_window --name "Oracle VM VirtualBox Manager (on ember)"
rbarak
Posts: 52
Joined: 25. Sep 2018, 20:43

Re: How to discover the hostname on which the VirtualBox GUI runs?

Post by rbarak »

scottgus1 wrote:Ok, so I'm a Windows guy, so let me understand: You ssh into another PC and if the command you run on the remote PC opens a window, it opens on your local PC? Interesting.
(The magic of X11)
scottgus1 wrote:If I've understood right, then I can see how you'd have a group of main Virtualbox windows, one for each remote Virtualbox host you've ssh'ed into and run the 'virtualbox' command on. These windows are connected to the remote hosts. However, which window is connected to which host is not shown. Yep, that would be hard to handle.

Second However: Virtualbox does not have any programmed capability to display the name of the host PC it's running on in the main Virtualbox window. As Socratis and fth0 mention, displaying the hostname of the PC an application is running on within the application is possible. (In fact I have a vbscript I use on my home & backup servers that gets the server's hostname for the script's output, so it is possible.) But Virtualbox is not programmed to show the hostname at this time.

You will need to use a different remote software to show the hostname along with the window from the remote PC. Meanwhile you can suggest this hostname display idea in the Bugtracker as an enhancement (don't hold your breath waiting for the idea to be included though. You can also get the source-code and insert the code for your own hosts. Finally, you could as fth0 indicated, use the Description tab of the guests as a place to put info, such as put the hostname in the Description of each PC's first guest.
Yes, I figured that I need to diagnose why X11 does not display the hostname on the Window title, e.g. - as you can see at the bottom window in the screenshot:
VirtualBox GUI with the hostname it's running on
VirtualBox GUI with the hostname it's running on
multiple_virtualbox_GUIs.png (30.84 KiB) Viewed 21085 times
Thus, I created a more focused question here.
rbarak
Posts: 52
Joined: 25. Sep 2018, 20:43

Re: How to make X11 display the VirtualBox hostname in the Window's title?

Post by rbarak »

fth0 wrote:Use xdotool on your workstation, e.g.:

Code: Select all

xdotool search --name "Oracle VM VirtualBox Manager" set_window --name "Oracle VM VirtualBox Manager (on ember)"
You're suggesting a sort of Catch 22 solution.
My problem is that I have a group of Windows, all of them named "Oracle VM VirtualBox Manager", which I don't know on which hostname each of them runs.
Thus, I cannot really use your xdtool suggestion, as I don't know what to give as the --name argument.
fth0
Volunteer
Posts: 5677
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: How to make X11 display the VirtualBox hostname in the Window's title?

Post by fth0 »

It depends on your (automated?) workflow that creates the Windows:

I could imagine a shell script that opens an SSH session to a host, starts the VirtualBox GUI, and calls xdotool in one go. Using this shell script for each host in turn ...
Post Reply