SOLVED Setting Jails startup order in order to get reliable epair interface

Status
Not open for further replies.

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
Hi all,

I've been looking for some time now for a way to set my jails startup order at boot time.
My problem is the following:
I have 3 jails,
-one VirtualBox jail created with the default VirtualBox template
-two jails based on standard template

Inside my VirtualBox Jail, I have a virtual machine running a Debian install, with it's NIC set up on "Bridged" mode.

My problem is that if the jails start in a different order, the epair bridge number of the VirtualBox changes, and when the virtual machine tries to start, it fails because it's set on the wrong epair (say it's set on "epair2b", but this time VirtualBox jail has "epair0b")

The problem does not occur at each boot, so I think there's a probleme with the jail startup order. But so far, I've not been able to find how this order is chosen or if there's a way to set it manualy

Thanks for your help
 

millst

Contributor
Joined
Feb 2, 2015
Messages
141
I don't think there is a way from the GUI, but the jails area has a .meta folder with scripts that you could probably use. Modify the jail-pre-start to enforce an order. It might be easier to modify your VirtualBox startup to dynamically figure out the epair name, however.
 

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
It might be easier to modify your VirtualBox startup to dynamically figure out the epair name, however.
Well, that's something I had thought about. But I thought that it would be "better" to find the setting to solve the probleme by setting the jail startup order... But since it's not straihtforward, I think tuning the VM startup could be something to think about...
 

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
After some research, I think I found a workaround, and will tweak my VBox Vmachine on startup in order to pass it the good epair device.
I will alter the VM configuration XML file that sits there
Code:
/home/vbox/VirtualBox VMs/_Name_Of_The_VM/_Name_Of_The_VM.vbox

You can find interesting (MAC adress, interface to use, NAT settings ...) in the following <Network><Adapter> Nodes. In fact, you can tweak any single parameter you already set in the VM webGUI.

Once the VBox Jail's networking has started up, it will be easy to find the actual epair interface and pass it to the XML config file, just before the VM is started up (will use the auto VM startup trick read here : https://forums.freenas.org/index.php?threads/enabling-autostart-of-virtualbox-vms-on-freenas.26503/)

I will use a command line XML editing utility, which should make it super easy to edit the .vbox file at VirtualBox jail startup, in rc.d.
I found XmlStarlet http://xmlstar.sourceforge.net/doc/UG/xmlstarlet-ug.html, which exists as a FreeBSD port and seems quite suitable for what I want to do.
I will let you know how things goes.
 
Last edited:

Doc Chacha

Dabbler
Joined
Sep 18, 2016
Messages
28
A short update:
1-I found that editing the XML file for the VM was in fact useless. It looks like it's read into RAM when VirtualBox starts, and that the version taht stays in RAM is written back to the XML file when you stop the jail. So any attempt to change the interface name or any other setting right into the XML file is useless...
2-I found another interesting method. It involves creating new scripts to strat the VM using VBoxManage command. It allows to change settings from the command line, to strat and stop VMs, to list running VMs... It's a powerfull tool. BUT... I did not manage to interface it with the classic way to autostart VM for rc.conf. It is still quite easy to create a startup/shutdown script from scratch, that could query ifconfig and then set the interface before launching the VM. I might end up doing that.
3-When trying to sort out how VM were lauched, it finaly came clear that they were launched using alphabetical order !!! The answer was THAT SIMPLE !

So, this solves my problem. I have two solutions:
1-carefully name my jails when setting them up, in order to be able to predict the epair interface that will be used for my VirtualBox (ie: name the virtual box jail aaa-something). Then every new jail will be after it in alphabetical order and none will "steal" the epair0b
2-write a startup script, which would be much cleaner... That could be something I would do if I have some spare time... and if I need to set up multiple Virtual box jails.
 
Status
Not open for further replies.
Top