ConcurrentReal-Time-Logo

リアルタイムテクニカルドキュメント リアルタイムコンテナ編 最終更新 2021.04.12

外部リンクを除く、以下のドキュメントの著作権は、特に記載の無い限りConcurrent Real-Time社に帰属します。
下記ドキュメントの弊社を除く営利目的の利用は禁じますが、ウィキペディアからの参照や社内教育、
大学等の非営利の目的であれば、ご自身の責任において自由に利用して頂いてかまいません。
ドキュメントの内容は予告無く変更する事がありますが、出来る限りリンクが消滅しないように保存しています。
ここに、記載した商品名は、一般に各社の商標または登録商標です。
外部リンク先の著作権は、各サイトの著作権表示をご覧ください。弊社著作権についてのポリシーは、 [hand.right] こちらをご覧ください。


RedHawk リアルタイムコンテナイメージは、Concurrent Real-Timeによって開発されたXの動作するコンテナイメージです。 RedHawk7.0以上のベアメタルOSで、DockerあるいはPodmanを動作させ、その上のリアルタイムコンテナとして、利用可能です。
RedHawkの動作する最新ハードウェア上で、レガシィシステムのプログラムを、ほぼ変更なく動作させることができます。
一般的な制限事項は、ベアメタル側のカーネルとドライバをコンテナから呼び出すため、コンテナから利用するライブラリとドライバが密に結びついているものは、移植する必要があります。
この代表的なものは、Nvidia-GLXドライバとライブラリであり、RedHawkコンテナには、ベアメタル側と同一のGLXライブラリを含みます。 従って、CUDAプログラムのバイナリであるCUbinファイルは動作しないことがあります。
現在利用可能なコンテナイメージは、6.0.2,6.5.6,7.2.0です。


[hand.right] RedHawk8.x上のDocer-CEについて

    RedHawk8.xの上で、動作確認済みの手順は以下の通りです。

(1) Podmanをアンインストールする。

	RedHwk8.0.xの場合
	# rpm -e \
		runc-1.0.0-70.rc92.module_el8.3.0+699+d61d9c41.x86_64 \
		buildah-1.11.6-7.module_el8.2.0+305+5e198a41.x86_64 \
		cockpit-podman-12-1.module_el8.2.0+305+5e198a41.noarch \
		podman-1.6.4-10.module_el8.2.0+305+5e198a41.x86_64 

	RedHwk8.2.xの場合
	# rpm -e \
		cockpit-podman-12-1.module_el8.2.0+305+5e198a41.noarch \
		podman-catatonit-2.2.1-7.module_el8.3.0+699+d61d9c41.x86_64 \
		podman-2.2.1-7.module_el8.3.0+699+d61d9c41.x86_64 

(2) Docker CEをインストールする

	# rpm -Uvh --nodigest --nofiledigest \
		containerd.io-1.4.4-3.1.el8.x86_64.rpm \
		fuse3-3.2.1-12.el8.x86_64.rpm \
		fuse3-libs-3.2.1-12.el8.x86_64.rpm \
		libslirp-4.3.1-2.el8.x86_64.rpm \
		docker-ce-20.10.5-3.el8.x86_64.rpm \
		docker-ce-cli-20.10.5-3.el8.x86_64.rpm \
		docker-ce-rootless-extras-20.10.5-3.el8.x86_64.rpm

[hand.right] コンテナ上のpulseaudioについて

    コンテナで、pulseaudioを動作させる手順は以下の通りです。

(1) ベアメタル側の /etc/pulse/default.pa に、下記 socket=...の記述を追加する。
注意:下記の様に2行必要。

	
		:
	load-module module-native-protocol-unix
	load-module module-native-protocol-unix socket=/tmp/.pulseaudio.socket
		:

(2) あるいは、ベアメタル側でコンテナ実行前に、以下のコマンドを実行する。

	# pacmd load-module module-native-protocol-unix socket=/tmp/.pulseaudio.socket


(3) コンテナ側の /etc/pulse/client.conf に、下記の記述を追加する。

        default-server = unix:/tmp/.pulseaudio.socket
        autospawn = no
        enable-shm = false


(4) コンテナを起動後、以下の環境変数を設定して、ベアメタル側のpulseaudioとリモート通信を行う。

        # export PULSE_SERVER=unix:/tmp/.pulseaudio.socket
        # export PULSE_COOKIE=/tmp/.pulseaudio.cookie

[hand.right] RedHawk8がベアメタルOSであるコンテナーでXorgから「chvt 1」を実行すると、ベアメタルOSのXorgがハングする。

    コンテナ上で、以下の手順でchvt.shを作成してください。
chvt.shはchvt 1の実行を回避するためのシェルスクリプトです。


# mv /usr/bin/chvt /usr/bin/chvt.bin
# ln -s /usr/bin/chvt.sh /usr/bin/chvt

下記の/usr/bin/chvt.shを作成する。

# cat /usr/bin/chvt.sh

#!/bin/sh
#
# This is a shell script to avoid running chvt 1.
# Running "chvt 1" from Xorg in a container where RedHawk8 is a bare metal OS causes the system to hang.
# Concurrent Real-Time
#
if [ -z "$1" ]
then
	exit 1
fi
if [ "$1" == "1" ]
then
	echo "Error: change foreground virtual terminal number."
	echo "You cannot run \"chvt 1\" from the container."
	echo "Normally \"chvt 2\" is used."
	echo -e "\tchvt N"
	echo -e "\t(with N in the range 2-12)"
else
	/usr/bin/chvt.bin $1
fi

[hand.right] コンテナーで「uname」を実行すると、ベアメタルOSの結果が返る。

    この結果はコンテナの仕様ですが、コンテナ上で以下の手順でuname.shを作成し、RPMインストラー等の誤動作を回避することが出来ます。


	# mv /usr/bin/uname /usr/bin/uname.bin
	# ln -s /usr/bin/uname.sh /usr/bin/uname
	下記の/usr/bin/uname.shを作成する。

#!/bin/sh
usage()
{
	echo "Usage: uname [OPTION]..."
	echo "Print certain system information.  With no OPTION, same as -s."
	echo ""
  	echo "  -a, --all                print all information, in the following order,"
        echo "                             except omit -p and -i if unknown:"
  	echo "  -s, --kernel-name        print the kernel name"
  	echo "  -n, --nodename           print the network node hostname"
  	echo "  -r, --kernel-release     print the kernel release"
  	echo "  -v, --kernel-version     print the kernel version"
  	echo "  -m, --machine            print the machine hardware name"
  	echo "  -p, --processor          print the processor type or "unknown""
  	echo "  -i, --hardware-platform  print the hardware platform or "unknown""
  	echo "  -o, --operating-system   print the operating system"
	if [ "$LANG" == "ja_JP.UTF-8" ]
	then
      	echo "      --help     この使い方を表示して終了"
      	echo "      --version  バージョン情報を表示して終了"
	else
      	echo "      --help     display this help and exit"
      	echo "      --version  output version information and exit"
	fi
	echo ""
	echo "Report uname bugs to bug-coreutils@gnu.org"
	echo "GNU coreutils home page: "
	echo "General help using GNU software: "
	echo "Report uname translation bugs to "
	echo "For complete documentation, run: info coreutils 'uname invocation'"
}

#注6.0.2を模擬する場合
	R="2.6.36.4-RedHawk"$FLAVOR 
	V="#1 SMP PREEMPT Thu Feb 26 16:18:08 JST 2015"
#注6.5.6を模擬する場合
	R="3.10.82-rt89-RedHawk-6.5.6"$FLAVOR 
	V="#1 SMP PREEMPT Wed Oct 21 16:50:54 EDT 2015"
#7.2を模擬する場合
	R="4.1.15-rt17-RedHawk-7.2"$FLAVOR 
	V="#1 SMP PREEMPT Wed Mar 9 18:01:52 EST 2016"

FLAVOR=`cat /proc/ccur/flavor`
S=`/bin/uname.bin -s`
N=`/bin/uname.bin -n`
M=`/bin/uname.bin -m`
P=`/bin/uname.bin -p`
I=`/bin/uname.bin -i`
O=`/bin/uname.bin -o`
case "$1" in
  	-a)			echo $S" "$N" "$R" "$V" "$M" "$P" "$I" "$O ;;
	--all)			echo $S" "$N" "$R" "$V" "$M" "$P" "$I" "$O ;;
  	-s) 			echo $S;;
	--kernel-name)		echo $S;;
  	-n) 			echo $N;;
  	--nodename)		echo $N;;
  	-r)			echo $R;;
	--kernel-release)	echo $R;;
  	-v)			echo $V;;
  	--kernel-version)	echo $V;;
  	-m)			echo $M;;
  	-p)			echo $P;;
  	-i)			echo $I;;
  	-o)			echo $O;;
	--operating-system)	echo $O;;
      --help) usage ;;
      --version)
	echo "uname (GNU coreutils) 8.4"
	echo "Copyright (C) 2010 Free Software Foundation, Inc."
	echo "License GPLv3+: GNU GPL version 3 or later ."
	echo "This is free software: you are free to change and redistribute it."
	echo "There is NO WARRANTY, to the extent permitted by law."
	echo ""
	if [ "$LANG" == "ja_JP.UTF-8" ]
	then
	echo "作者 David MacKenzie."
	else
	echo "Written by David MacKenzie."
	fi
	;;
	"") echo $S;;
    *) usage ;;
esac
exit 0;



[hand.right] コンテナXのデュアルヘッド構成例。

    以下のように、2枚のNvidiaカードを使って専用キーボード、マウスを構成し、ベアメタルとコンテナのXを独立して構成出来ます。
この構成例では、
PCI:23:0:0のカードと/dev/input/event[35]をベアメタル専用に、
PCI:6:0:0 のカードと/dev/input/enevt[68]をコンテナ専用にXorg.confに記述しています。
この構成の重要な点は、コンテナ内でXを起動する時に、-sharevtsで、vt1をベアメタルとコンテナで共用している事です。
/usr/bin/X :0 -sharevts vt1 -auth /root/.Xauthority -ac
通常、このオプション指定はdocker-startgnome.sh内で行われます。

# ls -l /dev/input/by-path/*usb*-event-kbd* /dev/input/by-path/*usb*-event-mouse*
lrwxrwxrwx 1 root root 9  8月 27 13:20 /dev/input/by-path/pci-0000:00:14.0-usb-0:14:1.0-event-mouse -> ../event5
lrwxrwxrwx 1 root root 9  8月 27 13:20 /dev/input/by-path/pci-0000:00:14.0-usb-0:4:1.0-event-kbd -> ../event3
lrwxrwxrwx 1 root root 9  8月 27 13:27 /dev/input/by-path/pci-0000:00:14.0-usb-0:8.1:1.0-event-mouse -> ../event8
lrwxrwxrwx 1 root root 9  8月 27 13:21 /dev/input/by-path/pci-0000:00:14.0-usb-0:8.2:1.0-event-kbd -> ../event6


[DualHead.png]

#
# ベアメタル側 /etc/X11/xorg.conf
#
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
Option "IsolateDevice"  "PCI:23:0:0"
Option "Sharevts"  "True"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection
Section "InputClass"
	Identifier	"ContainerDevice"
	MatchDevicePath	"/dev/input/event[68]"
	Option	"Ignore"	"True"
EndSection

Section "InputClass"
	Identifier	"HostDevice"
	MatchDevicePath	"/dev/input/enevt[35]"
	Option	"Ignore"	"False"
    Driver         "evdev"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection


Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
        BusID       "PCI:23:0:0"
        Option "UseDisplayDevice" "DP-3"
	Option "ProbeAllGpus" "false"
        Option "MultiGPU" "no"
EndSection


Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "SERVERFLAGS"
        Option "MaxClients"     "512"
#        Option "DontVTSwitch"   "yes"
        Option "BlankTime"      "0"
        Option "StandbyTime"    "0"
        Option "SuspendTime"    "0"
        Option "OffTime"        "0"
        Option "AutoAddGPU" "false"
EndSection


#
# コンテナ側 /etc/X11/xorg.conf
#
Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
Option "IsolateDevice"  "PCI:6:0:0"
EndSection

Section "Files"
    FontPath        "/usr/share/fonts/default/Type1"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "evdev"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputClass"
        Identifier      "HostDevice"
        MatchDevicePath "/dev/input/event[35]"
        Option  "Ignore"        "True"
EndSection
Section "InputClass"
        Identifier      "ContainerDevice"
        MatchDevicePath "/dev/input/enevt[68]"
        Option  "Ignore"        "False"
    Driver         "evdev"
EndSection



Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "evdev"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID       "PCI:6:0:0"
	Option "ProbeAllGpus" "false"
	Option "MultiGPU" "no"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "SERVERFLAGS"
        Option "MaxClients"	"512"
	Option "DontVTSwitch"	"yes"
	Option "BlankTime"	"0"
	Option "StandbyTime"	"0"
	Option "SuspendTime"	"0"
	Option "OffTime"	"0"
	#Option "AutoEnableDevices" "false"
	Option "AutoAddGPU" "false"
EndSection



[back]Back