how to changing VM setting while in running state

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
Ghetas
Posts: 19
Joined: 19. Dec 2015, 17:35

how to changing VM setting while in running state

Post by Ghetas »

Dear all
i tried to change the memory size of the running VM but i get the errors below

my virtualbox version: 5.0.10
Operating system: Centos 6.7
Language: java
connect type: web service
my code is

Code: Select all


    static void testStart(VirtualBoxManager mgr, IVirtualBox vbox)
    {

    	

        IMachine m = vbox.getMachines().get(0);
        String name = m.getName();
        System.out.println("\nAttempting to start VM '" + name + "'");
        
        ISession session = mgr.getSessionObject();
        IProgress p = m.launchVMProcess(session, "gui", "");
        progressBar(mgr, p, 10000);
        session.unlockMachine();
        
        System.out.println("VM state: "+m.getState().toString());
        System.out.println("Memory Amount: " + m.getMemorySize());
        
        m.lockMachine(session, LockType.Shared);
        session.getMachine().setMemorySize(1024l);
        session.getMachine().saveSettings();
        session.unlockMachine();
       }
i changed the

Code: Select all

 m.lockMachine  (session, LockType.Shared); 
to

Code: Select all

 m.lockMachine(session, LockType.write); 
but still have the same error

VirtualBox version: 5.0.10

Code: Select all

Attempting to start VM 'VM1'
VM state: Running
Memory Amount: 1024
VBox error: VirtualBox error: rc=0x80bb0002 The machine is not mutable (state is Running) (0x80bb0002)
Error cause message: org.virtualbox_5_0.jaxws.RuntimeFaultMsg: VirtualBox error: rc=0x80bb0002 The machine is not mutable (state is Running) (0x80bb0002)
Overall result code: 80bb0002
Detail information #1
Error mesage: The machine is not mutable (state is Running)
Result code:  80bb0002
Component:    SessionMachine
Interface ID: f30138d4-e5ea-4b3a-8858-a059de4c93fd
Java stack trace:
org.virtualbox_5_0.VBoxException: VirtualBox error: rc=0x80bb0002 The machine is not mutable (state is Running) (0x80bb0002)
	at org.virtualbox_5_0.IMachine.setMemorySize(IMachine.java:790)
	at Vmtest.TestVBox.testStart(TestVBox.java:180)
	at Vmtest.TestVBox.main(TestVBox.java:315)
Caused by: org.virtualbox_5_0.jaxws.RuntimeFaultMsg: VirtualBox error: rc=0x80bb0002 The machine is not mutable (state is Running) (0x80bb0002)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
	at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
	at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
	at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
	at com.sun.proxy.$Proxy24.iMachineSetMemorySize(Unknown Source)
	at org.virtualbox_5_0.IMachine.setMemorySize(IMachine.java:782)
	... 2 more
Last edited by noteirak on 27. Dec 2015, 14:55, edited 1 time in total.
Reason: Added code tag
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: how to changing VM setting while in running state

Post by mpack »

PCs generally don't like you to mess with their motherboard while they are running. OS's generally don't expect it either.
Ghetas
Posts: 19
Joined: 19. Dec 2015, 17:35

Re: how to changing VM setting while in running state

Post by Ghetas »

mpack wrote:PCs generally don't like you to mess with their motherboard while they are running. OS's generally don't expect it either.

Thanks mpack but can you look at this link, it changes the memory of VM while it is running. I attempt to run the same example and it does not work with me. Also the comment 2 uses a new session to change the memory size of running VM

https://www.virtualbox.org/ticket/12164
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: how to changing VM setting while in running state

Post by mpack »

Ghetas wrote:Thanks mpack but can you look at this link, it changes the memory of VM while it is running.
The ability to do which was described as a bug, which the ticket you link to describes as fixed (perhaps) 10 months ago.
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: how to changing VM setting while in running state

Post by noteirak »

So to clear all this up:
- You are not supposed to modify the VM memory (and the majority of the settings) while the VM is running.
- Only specific setting can be changed, but it is not correctly documented in the API. I started a discussion about better documentation with a contribution and now waiting for the devs to see how to incorporate it.
- In the meantime, the best way to know what can be changed is to check in the GUI or see what is editable under "vboxmanage control

About the bug:
- I reported it a while ago (2 years!) and has been fixed since then in all versions (4.2, 4.3 and never present in 5.x) so don't expect it to work anymore.
- The bug only edited the config of the VM on disk, the actually running process did not take into account that increase in memory. So the only use of that change would have been to edit the config for the next shutdown of the VM (restart of the OS or reset of the VM would have not done the trick). Hardly something useful.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Ghetas
Posts: 19
Joined: 19. Dec 2015, 17:35

Re: how to changing VM setting while in running state

Post by Ghetas »

Ok it is clear now thanks so much noteirak
silvermangb@gmail.com
Posts: 8
Joined: 15. Sep 2016, 03:47

Re: how to changing VM setting while in running state

Post by silvermangb@gmail.com »

In a related issue, I want to change a network adapter setting. The machine is not running or saved. The script successfully locks the machine, but, I still get a "not mutable" error:

vbox = virtualbox.VirtualBox()
vbmanager = virtualbox.Manager()

vf_vm = vbox.find_machine('my machine')
session = vbmanager.get_session()
vf_vm.lock_machine(session,vblib.LockType.write)
na = vf_vm.get_network_adapter(1)

na.host_only_interface = 'VirtualBox Host-Only Ethernet Adapter'

How do you make a machine mutable, or, is this a misleading error message?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: how to changing VM setting while in running state

Post by mpack »

If your machine is not running or saved, then your problem doesn't belong in this topic (note topic title). Please start your own topic and provide a proper description and diagnostics (VM log file).
Post Reply