version 1.37, 2014/12/24 16:06:38
|
version 1.47, 2014/12/26 18:35:45
|
Line 181 NetBSD, which is not yet a dom0, and the
|
Line 181 NetBSD, which is not yet a dom0, and the
|
NetBSD install to a dom0 install by just changing the kernel and boot |
NetBSD install to a dom0 install by just changing the kernel and boot |
configuration. |
configuration. |
|
|
|
For experimenting with Xen, a machine with as little as 1G of RAM and |
|
100G of disk can work. For running many domUs in productions, far |
|
more will be needed. |
|
|
Styles of dom0 operation |
Styles of dom0 operation |
------------------------ |
------------------------ |
|
|
Line 301 is using xm or xl. Note that xend is fo
|
Line 305 is using xm or xl. Note that xend is fo
|
only be used if you plan on using "xm". Do NOT enable xend if you |
only be used if you plan on using "xm". Do NOT enable xend if you |
plan on using "xl" as it will cause problems. |
plan on using "xl" as it will cause problems. |
|
|
|
The installation of NetBSD should already have created devices for xen |
|
(xencons, xenevt), but if they are not present, create them: |
|
|
|
cd /dev && sh MAKEDEV xen |
|
|
TODO: Give 3.1 advice (or remove it from pkgsrc). |
TODO: Give 3.1 advice (or remove it from pkgsrc). |
|
|
For 3.3 (and thus xm), add to rc.conf (but note that you should have |
For 3.3 (and thus xm), add to rc.conf (but note that you should have |
Line 329 For 4.2 with xl (preferred), add to rc.c
|
Line 338 For 4.2 with xl (preferred), add to rc.c
|
|
|
TODO: Recommend for/against xen-watchdog. |
TODO: Recommend for/against xen-watchdog. |
|
|
After you have configured the daemons and rebooted, run the following |
After you have configured the daemons and either started them or |
to inspect Xen's boot messages, available resources, and running |
rebooted, run the following (or use xl) to inspect Xen's boot |
domains: |
messages, available resources, and running domains: |
|
|
xm dmesg |
# xm dmesg |
xm info |
[xen's boot info] |
xm list |
# xm info |
|
[available memory, etc.] |
|
# xm list |
|
Name Id Mem(MB) CPU State Time(s) Console |
|
Domain-0 0 64 0 r---- 58.1 |
|
|
|
anita (for testing NetBSD) |
|
-------------------------- |
|
|
|
With the setup so far, one should be able to run anita (see |
|
pkgsrc/sysutils/py-anita) to test NetBSD releases, by doing (as root, |
|
because anita must create a domU): |
|
|
|
anita --vmm=xm test file:///usr/obj/i386/ |
|
|
|
Alternatively, one can use --vmm=xl to use xl-based domU creation instead. |
|
TODO: check this. |
|
|
|
Xen-specific NetBSD issues |
|
-------------------------- |
|
|
|
There are (at least) two additional things different about NetBSD as a |
|
dom0 kernel compared to hardware. |
|
|
|
One is that modules are not usable in DOM0 kernels, so one must |
|
compile in what's needed. It's not really that modules cannot work, |
|
but that modules must be built for XEN3_DOM0 because some of the |
|
defines change and the normal module builds don't do this. Basically, |
|
enabling Xen changes the kernel ABI, and the module build system |
|
doesn't cope with this. |
|
|
|
The other difference is that XEN3_DOM0 does not have exactly the same |
|
options as GENERIC. While it is debatable whether or not this is a |
|
bug, users should be aware of this and can simply add missing config |
|
items if desired. |
|
|
Updating NetBSD in a dom0 |
Updating NetBSD in a dom0 |
------------------------- |
------------------------- |
Line 411 improves performance. The other is that
|
Line 454 improves performance. The other is that
|
failed to work. TODO: give working/notworking NetBSD versions for |
failed to work. TODO: give working/notworking NetBSD versions for |
sparse vnd. Note that the use of file/vnd for Xen is not really |
sparse vnd. Note that the use of file/vnd for Xen is not really |
different than creating a file-backed virtual disk for some other |
different than creating a file-backed virtual disk for some other |
purpose, except that xentools handles the vnconfig commands. |
purpose, except that xentools handles the vnconfig commands. To |
|
create an empty 4G virtual disk, simply do |
|
|
|
dd if=/dev/zero of=foo-xbd0 bs=1m count=4096 |
|
|
With the lvm style, one creates logical devices. They are then used |
With the lvm style, one creates logical devices. They are then used |
similarly to vnds. |
similarly to vnds. |
Line 419 similarly to vnds.
|
Line 465 similarly to vnds.
|
Virtual Networking |
Virtual Networking |
------------------ |
------------------ |
|
|
TODO: explain xvif concept, and that it's general. |
Xen provides virtual ethernets, each of which connects the dom0 and a |
|
domU. For each virtual network, there is an interface "xvifN.M" in |
There are two normal styles: bridging and NAT. |
the dom0, and in domU index N, a matching interface xennetM (NetBSD |
|
name). The interfaces behave as if there is an Ethernet with two |
|
adaptors connected. From this primitive, one can construct various |
|
configurations. We focus on two common and useful cases for which |
|
there are existing scripts: bridging and NAT. |
|
|
With bridging, the domU perceives itself to be on the same network as |
With bridging, the domU perceives itself to be on the same network as |
the dom0. For server virtualization, this is usually best. |
the dom0. For server virtualization, this is usually best. Bridging |
|
is accomplished by creating a bridge(4) device and adding the dom0's |
|
physical interface and the various xvifN.0 interfaces to the bridge. |
|
One specifies "bridge=bridge0" in the domU config file. The bridge |
|
must be set up already in the dom0; an example /etc/ifconfig.bridge0 |
|
is: |
|
|
|
create |
|
up |
|
!brconfig bridge0 add wm0 |
|
|
With NAT, the domU perceives itself to be behind a NAT running on the |
With NAT, the domU perceives itself to be behind a NAT running on the |
dom0. This is often appropriate when running Xen on a workstation. |
dom0. This is often appropriate when running Xen on a workstation. |
|
|
One can construct arbitrary other configurations, but there is no |
|
script support. |
|
|
|
Sizing domains |
Sizing domains |
-------------- |
-------------- |
|
|
Line 444 create a new file and vnconfig it (or lv
|
Line 500 create a new file and vnconfig it (or lv
|
just like updating physical disks, but without having to be there and |
just like updating physical disks, but without having to be there and |
without those pesky connectors. |
without those pesky connectors. |
|
|
|
domU kernels |
|
------------ |
|
|
|
On a physical computer, the BIOS reads sector 0, and a chain of boot |
|
loaders finds and loads a kernel. Normally this comes from the root |
|
filesystem. With Xen domUs, the process is totally different. The |
|
normal path is for the domU kernel to be a file in the dom0's |
|
filesystem. At the request of the dom0, Xen loads that kernel into a |
|
new domU instance and starts execution. While domU kernels can be |
|
anyplace, reasonable places to store domU kernels on the dom0 are in / |
|
(so they are near the dom0 kernel), in /usr/pkg/etc/xen (near the |
|
config files), or in /u0/xen (where the vdisks are). |
|
|
|
See the VPS section near the end for discussion of alternate ways to |
|
obtain domU kernels. |
|
|
Config files |
Config files |
------------ |
------------ |
|
|
TODO: give example config files. Use both lvm and vnd. |
The following is an example domain configuration file |
|
"/usr/pkg/etc/xen/foo", lightly sanitized from a known working on Xen |
|
4.1 (NetBSD 5 amd64 dom0 and NetBSD 6 i386 domU): |
|
|
|
# -*- mode: python; -*- |
|
|
|
kernel = "/netbsd-XEN3PAE_DOMU-i386-foo.gz" |
|
memory = 1024 |
|
#cpu = -1 |
|
vif = [ 'mac=aa:00:00:d1:00:09,bridge=bridge0' ] |
|
disk = [ 'file:/n0/xen/foo-wd0,0x1,w', |
|
'file:/n0/xen/foo-wd1,0x2,w' ] |
|
root = "xbd0" |
|
autorestart = True |
|
|
|
The domain will have the same name as the file. The kernel has the |
|
host/domU name in it, so that on the dom0 one can update the various |
|
domUs independently. The vif line causes an interface to be provided, |
|
with a specific mac address (do not reuse MAC addresses!), in bridge |
|
mode. Two disks are provided, and they are writable. |
|
|
|
TODO: explain if the root line is really necessary. |
|
TODO: explain or remove autorestart. |
|
|
|
TODO: Add an example with lvm |
|
|
TODO: explain the mess with 3 arguments for disks and how to cope (0x1). |
TODO: explain, someplace the mess with 3 arguments for disks and how to cope (0x1). |
|
|
Starting domains |
Starting domains |
---------------- |
---------------- |
Line 464 Creating specific unprivileged domains (
|
Line 560 Creating specific unprivileged domains (
|
|
|
Creating domUs is almost entirely independent of operating system. We |
Creating domUs is almost entirely independent of operating system. We |
first explain NetBSD, and then differences for Linux and Solaris. |
first explain NetBSD, and then differences for Linux and Solaris. |
|
Note that you must have already completed the dom0 setup so that "xm |
|
list" (or "xl list") works. |
|
|
Creating an unprivileged NetBSD domain (domU) |
Creating an unprivileged NetBSD domain (domU) |
--------------------------------------------- |
--------------------------------------------- |
|
|
Once you have *domain0* running, you need to start the xen tool daemon |
|
(`/usr/pkg/share/examples/rc.d/xend start`) and the xen backend daemon |
|
(`/usr/pkg/share/examples/rc.d/xenbackendd start` for Xen3\*, |
|
`/usr/pkg/share/examples/rc.d/xencommons start` for Xen4.\*). Make sure |
|
that `/dev/xencons` and `/dev/xenevt` exist before starting `xend`. You |
|
can create them with this command: |
|
|
|
# cd /dev && sh MAKEDEV xen |
|
|
|
xend will write logs to `/var/log/xend.log` and |
|
`/var/log/xend-debug.log`. You can then control xen with the xm tool. |
|
'xm list' will show something like: |
|
|
|
# xm list |
|
Name Id Mem(MB) CPU State Time(s) Console |
|
Domain-0 0 64 0 r---- 58.1 |
|
|
|
'xm create' allows you to create a new domain. It uses a config file in |
'xm create' allows you to create a new domain. It uses a config file in |
PKG\_SYSCONFDIR for its parameters. By default, this file will be in |
PKG\_SYSCONFDIR for its parameters. By default, this file will be in |
`/usr/pkg/etc/xen/`. On creation, a kernel has to be specified, which |
`/usr/pkg/etc/xen/`. On creation, a kernel has to be specified, which |
Line 608 working vif-bridge is also provided with
|
Line 689 working vif-bridge is also provided with
|
|
|
#!/bin/sh |
#!/bin/sh |
#============================================================================ |
#============================================================================ |
# $NetBSD: howto.mdwn,v 1.36 2014/12/24 16:02:49 gdt Exp $ |
# $NetBSD: howto.mdwn,v 1.46 2014/12/26 16:43:51 gdt Exp $ |
# |
# |
# /usr/pkg/etc/xen/vif-bridge |
# /usr/pkg/etc/xen/vif-bridge |
# |
# |
Line 998 TODO: Perhaps reference panix, prmgr, am
|
Line 1079 TODO: Perhaps reference panix, prmgr, am
|
|
|
TODO: Somewhere, discuss pvgrub and py-grub to load the domU kernel |
TODO: Somewhere, discuss pvgrub and py-grub to load the domU kernel |
from the domU filesystem. |
from the domU filesystem. |
|
|
|
Using npf |
|
--------- |
|
|
|
In standard kernels, npf is a module, and thus cannot be loadeed in a |
|
DOMU kernel. |
|
|
|
TODO: explain how to compile npf into a custom kernel, answering: |
|
http://mail-index.netbsd.org/netbsd-users/2014/12/26/msg015576.html |