Sun Fire T2000でLogical Domains (LDoms)を使う

LDoms はSunが開発したハイパーバイザータイプの仮想化技術です。 UltraSPARC T(sun4v)アーキテクチャでのみ使用可能です。 ホストのリソースを分割してゲストに割り当てることができます。


LDomsソフトウエアのインストール

デフォルト(a)のHardeningにすると使いにくいので(b)にします。
なお、-d NONEとしてSecurity Toolkitをインストールしないことにもできます。

% unzip LDoms_Manager-1_1.zip
# LDoms_Manager-1_1/Install/install-ldm
Welcome to the LDoms installer.

You are about to install the domain manager package that will enable
you to create, destroy and control other domains on your system. Given
the capabilities of the domain manager, you can now change the security
configuration of this Solaris instance using the Solaris Security
Toolkit.

Select a security profile from this list:

a) Hardened Solaris configuration for LDoms (recommended)
b) Standard Solaris configuration
c) Your custom-defined Solaris security configuration profile

Enter a, b, or c [a]: b
If you wish to apply a different Solaris security configuration later,
the Solaris Security Toolkit is installed in /opt/SUNWjass and can be
used to apply the recommended secure Solaris configuration for a
Control Domain with '/opt/SUNWjass/bin/jass-execute -d ldm_control-secure.driver'.
Installing LDoms and Solaris Security Toolkit packages.
pkgadd -n -d "/media/Solaris/LDoms/LDoms_Manager-1_1/Product" -a pkg_admin SUNWldm.v
Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.

<SUNWldm> のインストールに成功しました。
pkgadd -n -d "/media/Solaris/LDoms/LDoms_Manager-1_1/Product" -a pkg_admin SUNWjass
Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.

<SUNWjass>> のインストールに成功しました。

Verifying that all packages are fully installed.  OK.
Enabling services: svc:/ldoms/ldmd:default
Solaris Security Toolkit was not applied. Bypassing the use of the
Solaris Security Toolkit is _not_ recommended and should only be
performed when alternative hardening steps are to be taken.
# cd /usr/sbin
# ln -s /opt/SUNWldm/bin/ldm .
# rehash

LDomsの設定

制御ドメインの設定

まず最初に制御ドメインを以下のように設定します。
ZFSを使用する場合は制御ドメインに4GB以上のメモリを割り当てろ、 みたいなことがSunのドキュメントに記載されていますので、それを考慮し ます。
なお、プラットフォームはSun Fire T2000(UltraSPARC T1 8core/8GBメ モリモデル)を仮定しています。

# ldm list
NAME             STATE    FLAGS   CONS    VCPU  MEMORY   UTIL  UPTIME
primary          active   -n-cv   SP      16    7968M    0.0%  5h 37m

# ldm add-vds primary-vds0 primary
# ldm add-vcc port-range=5000-5100 primary-vcc0 primary
# ldm add-vsw net-dev=e1000g0 primary-vsw0 primary
# ldm add-vsw net-dev=e1000g1 primary-vsw1 primary
# mv /etc/hostname.e1000g0 /etc/hostname.vsw0
# mv /etc/hostname.e1000g1 /etc/hostname.vsw1
# mv /etc/hostname6.e1000g0 /etc/hostname6.vsw0
# mv /etc/hostname6.e1000g1 /etc/hostname6.vsw1
# ldm set-mau 2 primary
# ldm set-vcpu 8 primary
# ldm set-memory 3968M primary
# ldm list-spconfig
factory-default [next]

# ldm add-spconfig initial
# ldm list-spconfig
factory-default
initial [next]

再起動します。

# touch /reconfigure
# init 6

仮想コンソールを有効にします。

# svcadm enable vntsd
# svcs vntsd
online         20:19:24 svc:/ldoms/vntsd:default

制御ドメインの状態

# ldm list-bindings primary
NAME             STATE      FLAGS   CONS    VCPU  MEMORY   UTIL  UPTIME
primary          active     -n-cv-  SP      8     3968M    0.1%  14h 43m

MAC
    00:14:4f:xx:xx:xx

HOSTID
    0x8xxxxxxx

VCPU
    VID    PID    UTIL STRAND
    0      4      1.7%   100%
    1      5      0.0%   100%
    2      6      0.1%   100%
    3      7      0.0%   100%
    4      8      0.2%   100%
    5      9      0.2%   100%
    6      10     0.0%   100%
    7      11     0.0%   100%

MAU
    ID     CPUSET
    0      (4, 5, 6, 7)
    1      (8, 9, 10, 11)

MEMORY
    RA               PA               SIZE
    0x8000000        0x8000000        3968M

VARIABLES
    auto-boot?=false

    boot-device=/pci@780/pci@0/pci@9/scsi@0/disk@0,0:a disk net
    keyboard-layout=Japanese

IO
    DEVICE           PSEUDONYM        OPTIONS
    pci@780          bus_a
    pci@7c0          bus_b

VCC
    NAME             PORT-RANGE
    primary-vcc0     5000-5100

VSW
    NAME             MAC               NET-DEV   DEVICE     DEFAULT-VLAN-ID PVID VID MODE
    primary-vsw0     00:14:4f:xx:xx:xx e1000g0   switch@0   1               1
    primary-vsw1     00:14:4f:xx:xx:xx e1000g1   switch@1   1               1

VDS
    NAME             VOLUME         OPTIONS          MPGROUP    DEVICE
    primary-vds0

VCONS
    NAME             SERVICE                     PORT    SP

ゲストドメインの設定

LDoms用ボリュームを用意します。

# zfs create pool/ldoms

ゲストドメイン用のイメージボリュームをZVOLを使って用意します。

# zfs create -V 18G pool/ldoms/ldom1.img
# ldm add-vdsdev /dev/zvol/dsk/pool/ldoms/ldom1.img ldom1.img@primary-vds0

インストール用DVDイメージを用意します。

# ldm add-vdsdev /media/Solaris/10/u7/sol-10-u7-ga-sparc-dvd.iso sol10u7@primary-vds0

ゲストドメインを作成します。

# ldm add-domain ldom1
# ldm add-vcpu 2 ldom1
# ldm add-memory 1G ldom1
# ldm add-vnet vnet1 primary-vsw0 ldom1
# ldm add-vdisk vdisk1 ldom1.img@primary-vds0 ldom1
# ldm add-vdisk viso sol10u7@primary-vds0 ldom1
# ldm set-var auto-boot\?=false ldom1
# ldm set-var boot-device=vdisk ldom1
# ldm bind-domain ldom1

ゲストドメインを起動します。

# ldm start-domain ldom1

ゲストドメインに接続します。

# telnet localhost 5000
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Connecting to console "ldom1" in group "ldom1" ....
Press ~? for control options ..


Sun Fire T200, No Keyboard
Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
OpenBoot 4.30.0, 1024 MB memory available, Serial #xxxxxxxx.
Ethernet address 0:14:4f:xx:xx:xx, Host ID: xxxxxxxx.



{0} ok

状態を表示します。

{0} ok show-devs
/cpu@1
/cpu@0
/virtual-devices@100
/virtual-memory
/memory@m0,10000000
/aliases
/options
/openprom
/chosen
/packages
/virtual-devices@100/channel-devices@200
/virtual-devices@100/console@1
/virtual-devices@100/ncp@4
/virtual-devices@100/flashprom@0
/virtual-devices@100/channel-devices@200/disk@1
/virtual-devices@100/channel-devices@200/disk@0
/virtual-devices@100/channel-devices@200/network@0
/openprom/client-services
/packages/obp-tftp
/packages/kbd-translator
/packages/SUNW,asr
/packages/dropins
/packages/terminal-emulator
/packages/disk-label
/packages/deblocker
/packages/SUNW,builtin-drivers
{0} ok devalias
viso                     /virtual-devices@100/channel-devices@200/disk@1
vdisk1                   /virtual-devices@100/channel-devices@200/disk@0
vnet1                    /virtual-devices@100/channel-devices@200/network@0
net                      /virtual-devices@100/channel-devices@200/network@0
disk                     /virtual-devices@100/channel-devices@200/disk@0
virtual-console          /virtual-devices/console@1
name                     aliases

DVDイメージから起動します。

{0} ok boot /virtual-devices@100/channel-devices@200/disk@1:f -v

ただし、DVDブートがサポートされていないU3/U4はDVDからブートしても インストール途中でおかしくなりますので、ネットワークブートを使う必要 があります。


LDomsソフトウエアのアップデート

# ldm stop -a
# ldm ls-constaints -x ldm-name > ldm-name.xml
# svcadm disable ldmd
# pkgrm SUNWldm
# pkgadd -d path-to-1.1-sw-bundle-products SUNWldm
# svcadm enable ldmd
# ldm start -a