Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
virtualbox: savestate and resume guest, renew IP address
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
jezaustin
Tux's lil' helper
Tux's lil' helper


Joined: 22 Sep 2006
Posts: 84
Location: england

PostPosted: Fri Oct 25, 2013 11:43 am    Post subject: virtualbox: savestate and resume guest, renew IP address Reply with quote

Hi

just wanted to share a technique I developed to solve a minor problem on my virtualbox guests: DHCP leases would expire while the guest was hibernated, causing IP address clashes. I want to renew the IP address automatically after resumption.

The solution is to savestate from a script run on the guest. This interrupts the script before it is finished, so when the guest is resumed, the script continues with its next instructions, which are to renew the IP address.

My guest is windows, so the script is a batch file:
Code:
plink.exe <puttySession> VBoxManage controlvm """<vboxGuest>""" savestate
ipconfig /release
ipconfig /renew


plink (from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) opens an SSH session and runs the VBoxManage command remotely on the host.

I can launch this from the guest (I have a shortcut on the desktop), but I tend to hibernate my guests from the host. From my fluxbox menu
Code:
[submenu] (VMs)
    [exec]  (start <vboxGuest>) {VBoxManage startvm "<vboxGuest>"}
    [exec]  (hibernate <vboxGuest>) {VBoxManage guestcontrol "<vboxGuest>" exec --image "C:\\path\\to\\savestate.bat" --username <guestUserName> --password <guestUserPasswd> --wait-stderr}


This might be of use to someone, and/or you might be amused by the control passing back and forth between host and guest!
NB: I find "guestcontrol exec" to be a bit flakey -- my first idea was to run a script on the host to "startvm" the guest, then "guestcontrol exec" the ip renewal, but it wasn't reliable. The hibernate command above is not completely reliable, but I prefer failure to hibernate (obvious and harmless) to failure to renew the IP address (silent and perhaps dangerous).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum