Recently I've been trying to learn how to use XenServer for another project of mine, whereby I need to be able to programmatically launch and destroy virtual machines from the command line.
As this is primarily a personal project, I haven't been able to purchase any real hardware and so I am currently running XenServer inside Oracle VirtualBox in bridged mode, without HVM, and so I am only able to launch 32-bit Linux VMs (I think).
At present, I run the following commands which execute successfully launching a virtual machine and putting it in the running state:
xe vm-install template=<the_ubuntu_precise_template_32bit> new-name-label=UbuntuVM
sr-uuid=<local_storage_uuid>
xe network-list bridge=xenbr0 --minimal
xe vif-create vm-uuid=<vm_uuid> network-uuid=<network_uuid (previous command output)> mac=random device=0
xe vm-param-set uuid=<vm_uuid>
other-config:install-repository=http://archive.ubuntu.com/ubuntu/dists/precise-updates/
xe vm-start uuid=<vm_uuid>
Once I run these commands there is a brief pause whilst I assume the net installer is downloaded and then the vm goes into running mode. (as is displayed when I run xe vm-list
)
Then if I run xe console uuid=<vm_uuid>
, I enter into the ubuntu installer, however every time the installer fails.
In the setup, everything seems to be working fine, IPv6 is correctly setup, and I double checked on my router, finding that the VM is correctly registered as a connected device. Then it asks for me to chose a mirror, but upon selection of a mirror, the installer starts 'downloading the release files' and a progress bar begins which shoots from 0% to 100% over the course of a few minutes, returning the error message: BAD MIRROR
. I have tried different mirrors, however I found that none worked, and threw the same error.
Finally, I launched into the Shell included in the installer, and ran the following commands to test whether my internet connection worked:
ping 127.0.0.1
= 127.0.0.1 is alive!
ping 192.168.0.31
(the XenServer host) = 192.168.0.31 is alive!
ping 192.168.0.1
(my router) returns nothing however.
ping 8.8.8.8
also returns nothing.
From this is seems that the VM doesn't have access to the internet, and so I believe that there might be some issue with the network I assigned to the VM?
On the XenServer host I ran ifconfig
and received the following information:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 08:00:27:6f:51:a0 txqueuelen 1000 (Ethernet)
RX packets 246 bytes 47076 (45.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 93 bytes 10473 (10.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 0 (Local Loopback)
RX packets 16 bytes 4602 (4.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 4602 (4.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
xenbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.31 netmask 255.255.255.0 broadcast 192.168.0.255
ether 08:00:27:6f:51:a0 txqueuelen 0 (Ethernet)
RX packets 274 bytes 48924 (47.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 121 bytes 13909 (13.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
For good measure I also ran netstat -rn
on the XenServer host and received the following output:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 xenbr0
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 xenbr0
Any help would be greatly appreciated,
Cheers, Oli
Best Answer
Ok, so it turns out that after a very large faff, you cannot run XenServer in VirtualBox using a Bridged Adapter, and at the same time provide access to VMs. Therefore as a quick fix for this, I resorted to using NAT and port forwarding SSH to my host (my MacBook) so that I was able to connect. I'm not entirely sure as the reason why I wasn't able to run XenServer in Bridged Mode but I guess it has something to do with
xenbr0
not being setup correctly and quite frankly for a test machine to see if I am able to launch a VM, I cannot be bothered to reconfigure it, and am unsure whether it is even possible to do so.So, as a quick fix to all you VirtualBoxers, run XenServer in NAT as it doesn't work in bridged adapter mode.
Hope this helps anyone with a headache,
Oli.