Page 1 of 1
Is It Possible To Query The Host's Name From Within A Guest?
Posted: 26. Apr 2014, 08:28
by saberman
Host: Windows 8.1 Pro x64
Guest: Windows 7 Ultimate x64
I have a development/testing environment where a VM may be moved from one host to another. Each of the hosts have the same set of folders. I want to be able to dynamically map a couple of the host's folders when a user signs into a VM. For example, consider the following folder structure on the host:
V:\VirtualBox (Shared as VirtualBox)
V:\VirtualBox\Data1
V:\VirtualBox\Data2
Host: Host1
When a user logs into the VM I want to map
G ==> \\<hostname>\VirtualBox\Data1
H ==> \\<hostname>\VirtualBox\Data2
I can used shared folders for this as they do provide full Windows support.
If I can grab the host's name I can write a little utility that will be called from a login script to do the mapping.
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 26. Apr 2014, 17:58
by noteirak
You can't query the host name from virtualbox itself, no.
What is possible on the other hand would be to set a custom guestproperty from the host and then get this back from the guest.
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 26. Apr 2014, 23:06
by saberman
>set a custom guestproperty from the host and then get this back from the guest.
Is there a simple way to do that?
If not I think I will setup a shared folder for the purpase of having a cmd file in a folder called Startup that will do the mapping. The login script in the guest would run the cmd file. Each host would have the same file folder and cmd file but with the host's name in the cmd file. It will waste a drive letter as the folder will have to be statically mapped in the guest.
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 27. Apr 2014, 01:56
by ChipMcK
saberman wrote:>set a custom guestproperty from the host and then get this back from the guest.
Is there a simple way to do that?
check out
HOWTO: Use Guest Properties
google search
guestproperty site:forums.virtualbox.org
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 27. Apr 2014, 04:09
by rpmurray
I'm assuming this only works if you have Guest Additions installed in the guest?
Edit: Yes, that's the case. From the manual:
4.6 Guest properties. Starting with version 2.1, VirtualBox allows for requesting certain properties from a running guest, provided that the VirtualBox Guest Additions are installed and the VM is running.
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 27. Apr 2014, 06:08
by saberman
ChipMcK wrote:saberman wrote:>set a custom guestproperty from the host and then get this back from the guest.
Is there a simple way to do that?
check out
HOWTO: Use Guest Properties
google search
guestproperty site:forums.virtualbox.org
The link has:
On the Host the properties are accessed through VBoxManage command with the following qualifiers:guestproperty get <vmname>|<uuid> <property> [-verbose]
guestproperty set <vmname>|<uuid> <property> [<value> [-flags <flags>]]
guestproperty enumerate <vmname>|<uuid> [-patterns <patterns>]
and on the Guest with the corresponding VBoxControl commands
guestproperty get <property> [-verbose]
guestproperty set <property> [<value> [-flags <flags>]]
guestproperty enumerate [-patterns <patterns>]
I am sure that is very meaningful to someone working with the VitrualBox SDK but it is meaningless to me. I need to be able to set a property that is passed to all VMs on the host. I also do not see how I can retieve the property in the guest programatically -- they appear to be command line commands.
I will try the shared folder with a script approach. At least I understand that.
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 27. Apr 2014, 13:11
by ChipMcK
saberman wrote:
I am sure that is very meaningful to someone working with the VitrualBox SDK but it is meaningless to me. I need to be able to set a property that is passed to all VMs on the host. I also do not see how I can retieve the property in the guest programatically -- they appear to be command line commands.
I do not have the SDK installed and the commands work without errors. Yes, you will need to develop script files using the commands, just as you will for the 'shqred folders' approach.
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 27. Apr 2014, 18:50
by saberman
>Yes, you will need to develop script files using the commands
Any example of having the script on the host side run everytime a VM is started?
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 27. Apr 2014, 21:16
by ChipMcK
you are joking, yes?
You might try reading the * manual.
8.30. VBoxManage guestproperty
and
4.6. Guest properties
Life is easier if you RTFM
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 27. Apr 2014, 22:07
by saberman
>You might try reading the * manual.
I did before I posted. Now please point me to the part that explains how to trigger the VBoxManage guestproperty command automatically after VirtualBox starts a guest VM sending the host's name as the value of the property.
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 27. Apr 2014, 22:20
by ChipMcK
I did not realize that English is not your native language
set <vm> <property> [<value> [--flags <flags>]]: This allows you to set a guest property by specifying the key and value. If <value> is omitted, the property is deleted. With --flags you can optionally specify additional behavior (you can combine several by separating them with commas):
TRANSIENT: the value will not be stored with the VM data when the VM exits;
TRANSRESET: the value will be deleted as soon as the VM restarts and/or exits;
TRANSIENT: the value will not be stored with the VM data when the VM exits; means that the
VBoxManage guestproperty set command needs be issued only once. BTW, VBox does not need to be active for my V4.3.10
Comprehend?
edited: substitute "only" in place of "but"
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 28. Apr 2014, 07:25
by saberman
>Comprehend?
No. Here is the scenario:
1. Copy the environment -- everything associated with VirtualBox -- to another host.
2. Click on a shortcut to start a VM.
3. User logs into the VM.
As I understand it, a request from the host to set a property has to be made when a VM is running. Exactly where do I put a script to set a property with the host's name that will execute automatically immediately after the VM starts but before the first user logins into the VM?
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 28. Apr 2014, 12:46
by ChipMcK
saberman wrote:>Comprehend?
No. Here is the scenario:
1. Copy the environment -- everything associated with VirtualBox -- to another host.
2. Click on a shortcut to start a VM.
3. User logs into the VM.
As I understand it, a request from the host to set a property has to be made when a VM is running. Exactly where do I put a script to set a property with the host's name that will execute automatically immediately after the VM starts but before the first user logins into the VM?
The
VBoxManage guestproperty set command is issued during the previous week, when you decide what key and its value for your VMs.
And the target VMs need not be active at the moment that
VBoxManage guestproperty set command is issued
.
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 28. Apr 2014, 17:40
by saberman
>during the previous week
This is a development environment. I shift hosts at least once a day and sometimes multiple times a day. The porocess has to be fully automated including inserting the name of the host in the guestproperty command.
>target VMs need not be active at the moment that VBoxManage guestproperty set command is issued
From the manual:
The “guestproperty” commands allow you to get or set properties of a running virtual machine.
I think the shared folder approach is easier and safer.
Re: Is It Possible To Query The Host's Name From Within A Gu
Posted: 28. Apr 2014, 18:19
by ChipMcK
saberman wrote:>target VMs need not be active at the moment that VBoxManage guestproperty set command is issued
From the manual:
The “guestproperty” commands allow you to get or set properties of a running virtual machine.
Not on my v4.3.10. That VM need not be active. It setting becomes part of the VM definition, unless
set <vm> <property> [<value> [--flags <flags>]]: This allows you to set a guest property by specifying the key and value. If <value> is omitted, the property is deleted. With --flags you can optionally specify additional behavior (you can combine several by separating them with commas):
TRANSIENT: the value will not be stored with the VM data when the VM exits;
TRANSRESET: the value will be deleted as soon as the VM restarts and/or exits;