VBoxManage: change nictype, etc. while VM running

This is for discussing general topics about how to use VirtualBox.

VBoxManage: change nictype, etc. while VM running

Postby srondeau » 23. Jan 2013, 02:04

If the VM is powered off, one can use "VBoxManage modifyvm" to modify the NICs (e.g., nictype1, bridgeadapter1).

If the VM is powered on, modifyvm doesn't work via VBoxManage, and controlvm doesn't have the options to change those NIC characteristics. Surprisingly, the VirtualBox GUI allows changing those characteristics while the VM is running.

I would like to do that via VBoxManage -- can anyone tell me how, or would this be a new feature for VBoxManage?

Thanks!
srondeau
 
Posts: 9
Joined: 4. Mar 2010, 22:42
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: Windows

Re: VBoxManage: change nictype, etc. while VM running

Postby Martin » 23. Jan 2013, 11:47

Which parameters do you want to change? Most can be changed with "VBoxManage controlvm nic<1-N> ...."
The nic adapter type (Intel/AMD/...) can not be changed on a running VM, even the GUI.
Martin
Volunteer
 
Posts: 806
Joined: 30. May 2007, 18:05
Primary OS: Fedora 18
VBox Version: PUEL
Guest OSses: XP, Win7, Linux, OS/2

Re: VBoxManage: change nictype, etc. while VM running

Postby noteirak » 23. Jan 2013, 12:53

As pointed out by Martin, you have 2 types of NIC settings :

offline NIC settings, managed by vboxmanage modifyvm - this requires a poweroff VM
online NIC settings, managed by vboxmanage controlvm

The GUI doesn't not allow you to edit offline settings while the VM is powered on, but it does allow you to change online settings.
This is the same here.
HyperBox - Open-source Entreprise Virtualization Manager - http://hyperbox.altherian.org
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 3349
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Re: VBoxManage: change nictype, etc. while VM running

Postby srondeau » 24. Jan 2013, 02:04

Martin wrote:Which parameters do you want to change? Most can be changed with "VBoxManage controlvm nic<1-N> ...."
The nic adapter type (Intel/AMD/...) can not be changed on a running VM, even the GUI.


As indicated, I would like to change things (e.g., nictype1, bridgeadapter1) that are NOT in controlvm's parameter list.

I beg to differ, you can change the NIC type, bridge adapter, etc. at least under Fedora 17 as a host, while the VM is running and via the GUI. I do it often, and it works fine. I just can't find a way to do it via VBoxManage, and I would like to do this in a way that is scriptable.
srondeau
 
Posts: 9
Joined: 4. Mar 2010, 22:42
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: Windows

Re: VBoxManage: change nictype, etc. while VM running

Postby srondeau » 24. Jan 2013, 02:06

noteirak wrote:As pointed out by Martin, you have 2 types of NIC settings :

offline NIC settings, managed by vboxmanage modifyvm - this requires a poweroff VM
online NIC settings, managed by vboxmanage controlvm

The GUI doesn't not allow you to edit offline settings while the VM is powered on, but it does allow you to change online settings.
This is the same here.


Yes, I know, I noted that distinction in my original posting. But the GUI does allow changing of NIC settings such as nictype1 and bridgeadapter1 while the VM is running, whereas VBoxManage doesn't appear to.
srondeau
 
Posts: 9
Joined: 4. Mar 2010, 22:42
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: Windows

Re: VBoxManage: change nictype, etc. while VM running

Postby Perryg » 24. Jan 2013, 02:46

What version of VirtualBox are you using? Type VBoxManage controlvm and see if it has the same commands as mine does.

Code: Select all   Expand viewCollapse view
VBoxManage controlvm        <uuid>|<name>
                            pause|resume|reset|poweroff|savestate|
                            acpipowerbutton|acpisleepbutton|
                            keyboardputscancode <hex> [<hex> ...]|
                            setlinkstate<1-N> on|off |
                            nic<1-N> null|nat|bridged|intnet|hostonly|generic
                                     [<devicename>] |
                            nictrace<1-N> on|off
                            nictracefile<1-N> <filename>
                            nicproperty<1-N> name=[value]
                            natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
                                          <hostport>,[<guestip>],<guestport>
                            natpf<1-N> delete <rulename>
                            guestmemoryballoon <balloonsize in MB>]
                            gueststatisticsinterval <seconds>]
                            usbattach <uuid>|<address> |
                            usbdetach <uuid>|<address> |
                            clipboard disabled|hosttoguest|guesttohost|
                                         bidirectional]
                            draganddrop disabled|hosttoguest]
                            vrde on|off |
                            vrdeport <port> |
                            vrdeproperty <name=[value]> |
                            vrdevideochannelquality <percent>
                            setvideomodehint <xres> <yres> <bpp>
                                            [[<display>] [<enabled:yes|no>
                                              [<xorigin> <yorigin>]]] |
                            screenshotpng <file> [display] |
                            setcredentials <username>
                                           --passwordfile <file> | <password>
                                           <domain>
                                           [--allowlocallogon <yes|no>] |
                            teleport --host <name> --port <port>
                                     [--maxdowntime <msec>]
                                     [--passwordfile <file> |
                                      --password <password>]
                            plugcpu <id>
                            unplugcpu <id>
                            cpuexecutioncap <1-100>


Switches my guest to NAT and gets 10.0.2.15
Code: Select all   Expand viewCollapse view
VBoxManage controlvm Mint-14.1-64 nic1 nat


Switches back to Bridged and get 192.168.1.107
Code: Select all   Expand viewCollapse view
VBoxManage controlvm Mint-14.1-64 nic1 bridged eth0

Note: you probably will not see this change in the GUI until a complete shutdown, but it does work.
Perryg
Site Moderator
 
Posts: 25943
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX - Other

Re: VBoxManage: change nictype, etc. while VM running

Postby srondeau » 24. Jan 2013, 15:40

srondeau wrote:
Martin wrote:Which parameters do you want to change? Most can be changed with "VBoxManage controlvm nic<1-N> ...."
The nic adapter type (Intel/AMD/...) can not be changed on a running VM, even the GUI.


As indicated, I would like to change things (e.g., nictype1, bridgeadapter1) that are NOT in controlvm's parameter list.

I beg to differ, you can change the NIC type, bridge adapter, etc. at least under Fedora 17 as a host, while the VM is running and via the GUI. I do it often, and it works fine. I just can't find a way to do it via VBoxManage, and I would like to do this in a way that is scriptable.


Sorry, my mistake. I've used modifyvm to change "nictype1", and the GUI doesn't allow that to change... must have gotten it mixed up inmy mind. controlvm allows changes to "nic1". So the only thing that isn't documented that I need in controlvm is "bridgeadapter1", and by looking more closely at controlvm in the online documentation, I see that I can set that as follows:

VBoxManage controlvm myvm nic1 bridged em2.305
srondeau
 
Posts: 9
Joined: 4. Mar 2010, 22:42
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: Windows

Re: VBoxManage: change nictype, etc. while VM running

Postby srondeau » 24. Jan 2013, 15:41

Perryg wrote:What version of VirtualBox are you using? Type VBoxManage controlvm and see if it has the same commands as mine does.

Code: Select all   Expand viewCollapse view
VBoxManage controlvm        <uuid>|<name>
                            pause|resume|reset|poweroff|savestate|
                            acpipowerbutton|acpisleepbutton|
                            keyboardputscancode <hex> [<hex> ...]|
                            setlinkstate<1-N> on|off |
                            nic<1-N> null|nat|bridged|intnet|hostonly|generic
                                     [<devicename>] |
                            nictrace<1-N> on|off
                            nictracefile<1-N> <filename>
                            nicproperty<1-N> name=[value]
                            natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
                                          <hostport>,[<guestip>],<guestport>
                            natpf<1-N> delete <rulename>
                            guestmemoryballoon <balloonsize in MB>]
                            gueststatisticsinterval <seconds>]
                            usbattach <uuid>|<address> |
                            usbdetach <uuid>|<address> |
                            clipboard disabled|hosttoguest|guesttohost|
                                         bidirectional]
                            draganddrop disabled|hosttoguest]
                            vrde on|off |
                            vrdeport <port> |
                            vrdeproperty <name=[value]> |
                            vrdevideochannelquality <percent>
                            setvideomodehint <xres> <yres> <bpp>
                                            [[<display>] [<enabled:yes|no>
                                              [<xorigin> <yorigin>]]] |
                            screenshotpng <file> [display] |
                            setcredentials <username>
                                           --passwordfile <file> | <password>
                                           <domain>
                                           [--allowlocallogon <yes|no>] |
                            teleport --host <name> --port <port>
                                     [--maxdowntime <msec>]
                                     [--passwordfile <file> |
                                      --password <password>]
                            plugcpu <id>
                            unplugcpu <id>
                            cpuexecutioncap <1-100>


Switches my guest to NAT and gets 10.0.2.15
Code: Select all   Expand viewCollapse view
VBoxManage controlvm Mint-14.1-64 nic1 nat


Switches back to Bridged and get 192.168.1.107
Code: Select all   Expand viewCollapse view
VBoxManage controlvm Mint-14.1-64 nic1 bridged eth0

Note: you probably will not see this change in the GUI until a complete shutdown, but it does work.


Sorry, my mistake. I see that now. Thanks for the help.
srondeau
 
Posts: 9
Joined: 4. Mar 2010, 22:42
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: Windows

Re: VBoxManage: change nictype, etc. while VM running

Postby srondeau » 24. Jan 2013, 21:02

Perryg wrote:What version of VirtualBox are you using?


4.2.6

I have been successful in setting the bridged interface using controlvm as mentioned above.

I have submitted a ticket (11417) stating that the user manual is out of sync with the VBoxManage controlvm options; the user manual omits the critical "[<devicename>]" option that I needed to know about, plus many more.

Now I have run into not knowing how to set the Advanced/Promiscuous Mode setting for adapter "Intel Pro/1000 MT Desktop" from the command line while the VM is running. I have verified that the GUI allows changing the promiscuity from "Deny" to "Allow VMs", for example, and I believe it works inside the VM as desired.

Using:

VBoxManage controlvm

I can't see the equivalent of the modifyvm's "--nicpromisc1 allow-vms" in the controlvm options. I tried what made sense using nicproperty1 (e.g., promisc=allow-vms), but it did not change them.

Does anyone have any ideas how to do that with VBoxManage controlvm?
srondeau
 
Posts: 9
Joined: 4. Mar 2010, 22:42
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: Windows

Re: VBoxManage: change nictype, etc. while VM running

Postby Perryg » 24. Jan 2013, 22:05

nicproperty<1-N> name=[value]

If you look at the *.box file it shows you the proper name and syntax.

Code: Select all   Expand viewCollapse view
VBoxManage controlvm <name|uuid> nickproperty<n>
        promiscuousModePolicy="Deny"
        promiscuousModePolicy="AllowAll"
        promiscuousModePolicy="AllowNetwork"


Example:
Code: Select all   Expand viewCollapse view
VBoxManage controlvm <name|uuid> nickproperty1 promiscuousModePolicy="AllowAll"

Keep in mind that the GUI does not always see this right away either.
Perryg
Site Moderator
 
Posts: 25943
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX - Other

Re: VBoxManage: change nictype, etc. while VM running

Postby srondeau » 24. Jan 2013, 23:25

Perryg wrote:nicproperty<1-N> name=[value]

If you look at the *.box file it shows you the proper name and syntax.


What .box file is that? I see .vbox files for my VM, but with the default policy of Deny, there is no promiscuousModePolicy listed. I do see one in the .vbox-prev file, though, and it coincides with what you wrote. How did you get the list of acceptable values, through manually setting them in the GUI?

Perryg wrote:Example:
Code: Select all   Expand viewCollapse view
VBoxManage controlvm <name|uuid> nickproperty1 promiscuousModePolicy="AllowAll"

Keep in mind that the GUI does not always see this right away either.


Minor correction: should be "nicproperty1", not "nickproperty".

But even with the change in option name, a copy and paste of the promiscuousModePolicy string did not work for me using VBoxManage 4.2.6 on a running VM.

Code: Select all   Expand viewCollapse view
 VBoxManage controlvm backtrack nicproperty1 promiscuousModePolicy="AllowAll"
VBoxManage showvminfo backtrack | grep "NIC 1"


The "Promisc Policy" value is still "Deny". I exited VirtualBox GUI and then started it, so it could re-read any .vbox files, and it still listed the policy as "Deny".
srondeau
 
Posts: 9
Joined: 4. Mar 2010, 22:42
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: Windows

Re: VBoxManage: change nictype, etc. while VM running

Postby noteirak » 24. Jan 2013, 23:34

srondeau wrote:What .box file is that? I see .vbox files for my VM, but with the default policy of Deny, there is no promiscuousModePolicy listed. I do see one in the .vbox-prev file, though, and it coincides with what you wrote. How did you get the list of acceptable values, through manually setting them in the GUI?

Perry did indeed mean the .vbox file.
As for getting the list of accepable values, AFAIK vboxmanage doesn't have it, but it is in the source code - or in the vbox file.

srondeau wrote:But even with the change in option name, a copy and paste of the promiscuousModePolicy string did not work for me using VBoxManage 4.2.6 on a running VM.

Same on my side - it doesn't work, looks like a bug.

You can report this on the bugtracker, please report back here with the ticket number so other people can track down this issue and its status aswell.
HyperBox - Open-source Entreprise Virtualization Manager - http://hyperbox.altherian.org
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 3349
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Re: VBoxManage: change nictype, etc. while VM running

Postby Perryg » 24. Jan 2013, 23:38

Like I said it does not always update the GUI or even the file. You need to check to see if it actually works like it should. It did for me when I tested the commands to make sure.

Same with Nic type. The guest would change but the vbox file and the gui would not always update.

Sorry about the typo. I was under duress at the time. Too many people tugging on me at once.
Perryg
Site Moderator
 
Posts: 25943
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX - Other

Re: VBoxManage: change nictype, etc. while VM running

Postby srondeau » 25. Jan 2013, 18:50

Perryg wrote:Like I said it does not always update the GUI or even the file. You need to check to see if it actually works like it should. It did for me when I tested the commands to make sure..


Still doesn't work for me. Here is what I did to set up a testing environment, and the results.

1. Set up:

a. Three VMs: VM7 and VM8 on one host, VM9 on another host

VM7: 192.168.2.98
VM8: 192.168.2.88
VM9: 192.168.2.89

b. All VMs on the same subnet, 192.168.2.0/24, and same VLAN (318)

c. All VMs use Intel Pro/1000 MT Desktop adapter

d. No network services such as web/mail, to minimize traffic.

e. VM8 is pinging continuously to VM9:

Code: Select all   Expand viewCollapse view
ping 192.168.2.89


2. Results (done in the order presented here):

a. Initial state: all VMs have promiscuity "Deny", set by VirtualBox GUI:

VM7 is running wireshark capture
VM7 sees only DHCP discover and ARP traffic.

b. VM7's promiscuity is changed to "Allow VMs", set by VirtualBox GUI:

VM7's wireshark capture is stopped, then started.

VM7 sees ICMP requests from VM8 to VM9 and responses from VM9 to VM8
VM7 sees ARP requests for VM8's MAC address from VM9

c. VM7's promiscuity is changed to "Deny", set by VirtualBox GUI:

VM7's wireshark capture is stopped, then started.
VM7 sees only DHCP discover traffic.

d. VM7's state was set back to before any promiscuousModePolicy settings were made, either by the GUI or presumably by VBoxManage. Then VM7's promiscuity was changed to "AllowAll", via:

Code: Select all   Expand viewCollapse view
VBoxManage controlvm VM7 nicproperty1 promiscuousModePolicy="AllowAll"


VM7's wireshark capture is stopped, then started.
VM7 sees only DHCP discover traffic.

No promiscuousModePolicy string was found in current VM7.vbox file, even after a shutdown of VM7, and restarting the VirtualBox GUI.

e. VM7's promiscuity is changed to "Allow All", set by VirtualBox GUI:

VM7's wireshark capture is stopped, then started.

VM7 sees ICMP requests from VM8 to VM9 and responses from VM9 to VM8
VM7 sees ARP requests for VM8's MAC address from VM9

The promiscuousModePolicy string was found in the current VM7.vbox file, as follows:
<Adapter slot="0" enabled="true" MACAddress="08002734DF8D" cable="true"
speed="0" promiscuousModePolicy="AllowAll" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
<Forwarding name="guestssh" proto="1" hostport="54009" guestport="22"/>
</NAT>
<GenericInterface driver="">
<Property name="promiscuousModePolicy" value="AllowAll"/>
</GenericInterface>
</DisabledModes>
<BridgedInterface name="em2.318"/>
</Adapter>


Note that old property "promiscuousModePolicy", set by the previous "VBoxManage controlvm" command, appears in the 'DisabledModes/GenericInterface driver=""' portion.
srondeau
 
Posts: 9
Joined: 4. Mar 2010, 22:42
Primary OS: Fedora other
VBox Version: PUEL
Guest OSses: Windows

Re: VBoxManage: change nictype, etc. while VM running

Postby noteirak » 25. Jan 2013, 20:27

Code: Select all   Expand viewCollapse view
VBoxManage controlvm VM7 nicproperty1 promiscuousModePolicy="AllowAll"

Simply does not work, but I am not even sure it is supported. Regardless, right now, it is not possible to change that setting via vboxmanage.
If the setting is changed via the API, the .vbox is edited directly. If you try anything with vboxmanage, it is not, therefore something is not working or not implemented
So go ahead for the bugtracker.
HyperBox - Open-source Entreprise Virtualization Manager - http://hyperbox.altherian.org
Manage your VirtualBox infrastructure the free way!
noteirak
Site Moderator
 
Posts: 3349
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7

Next

Return to Using VirtualBox

Who is online

Users browsing this forum: No registered users and 12 guests