Real-Time Java in a Zone
By Jim Connors 17 June 2008
As is often the case, Sun's technologies and offerings are being
applied in ways which we hadn't necessarily anticipated. Yet
another example has reared its head in the govenrment/military
space where customers have expressed interest in using Sun's Java
Real-Time System with Solaris
Trusted Extensions. As it stands right now, Java RTS
will neither operate nor install within the confines of such an
environment. Let's investigate why this is so, and see what
current opportunities there are for working around this
shortcoming.
So what is it that causes Trusted Extensions and Java RTS not to
play together nicely? It happens to revolve around
Trusted Extension's extensive usage of Solaris
zones to limit access between differing security
levels. Solaris packages must be specifically configured to
accommodate zones, which has yet to formally take place with Java
RTS. As zones are a core component of Solaris, we can, for
the sake of simplicity, just use standard Solaris to demonstrate
how we can work around this temporary limitation. These
modifications should apply to Trusted Extensions just as
well. To get Java RTS to work within a zone, follow
these steps:
1. Install the Java RTS cyclic driver (only) in the global zone.
global# mkdir -p /zone bash-3.00# zonecfg -z rtjzone rtjzone: No such zone configured Use 'create' to begin configuring a new zone. zonecfg:rtjzone> create zonecfg:rtjzone> set zonepath=/zone/rtjzone zonecfg:rtjzone> verify zonecfg:rtjzone> commit zonecfg:rtjzone> exit
global# zoneadm list -vc ID NAME STATUS PATH BRAND IP 0 global running / native shared - rtjzone configured /zone/rtjzone native shared
global# zoneadm -z rtjzone install Preparing to install zone <rtjzone>. Creating list of files to copy from the global zone. Copying <6984> files to the zone. Initializing zone product registry. Determining zone package initialization order. Preparing to initialize <1074> packages on the zone. Initialized <1074> packages on zone. Zone <rtjzone> is initialized. Installation of <1> packages was skipped. The file </zone/rtjzone/root/var/sadm/system/logs/install_log> contains a log of the zone installation.
3. Modify the zone to allow access to the cyclic device, and
to allow additional privileges
global# zonecfg -z rtjzone zonecfg:rtjzone> set limitpriv=default,proc_priocntl,proc_lock_memory,proc_clock_highres zonecfg:rtjzone> add device zonecfg:rtjzone:device> set match=/dev/cyclic zonecfg:rtjzone:device> end zonecfg:rtjzone> verify zonecfg:rtjzone> commit zonecfg:rtjzone> exit global# zoneadm -z rtjzone rebootNote: One privilege that is useful with Java RTS is sys_res_config. This is typically used to assign a real-time process to a processor set. Unfortunately zones cannot currently be given this privilege. You can however, from the global zone, assign a processor set to a zone, which might be a reasonable workaround.
4. Get a copy of the SUNWrtjv package and modify it so
that it will install in a zone. The postinstall script and
postremove script must
replaced with those provided by these hyperlinks just mentioned.
rtjzone# cd /scratch rtjzone# ls SUNWrtjv postinstall postremove rtjzone# cp postinstall SUNWrtjv/install/ rtjzone# cp postremove SUNWrtjv/install/5. Modify the SUNWrtjv pkgmap file with the appropriate sizes, checksums and last access dates. The source code for a sample C program, called pkgmap_info, which prints out the necessary information, can be found here.
rtjzone# cd SUNWrtjvReplace the postinstall and postremove entries in the pkgmap file with those produced by the pkgmap_info program. You cannot simply use the example data above because the last access times will not match. Doing so will cause the install to fail.
rtjzone# grep post pkgmap 1 i postinstall 5402 42894 1194344457 1 i postremove 2966 34854 1194344457 rtjzone# cp pkgmap_info.c /tmp rtjzone# cc -o /tmp/pkgmap_info /tmp/pkgmap_info.c rtjzone# cd /scratch/SUNWrtjv/install/ rtjzone# /tmp/pkgmap_info postinstall postinstall 5820 9488 1213727841 rtjzone# /tmp/pkgmap_info postremove postremove 3092 45039 1213727538
rtjzone# /opt/SUNWrtjv/bin/java -version
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13_Java-RTS-2.0_01-b08_RTSJ-1.0.2)
Java Real-Time System HotSpot(TM) Client VM (build 1.5.0_13-b08, mixed mode)
We hope to more formally support Solaris zones usage with Java RTS
in the future. In the interim this workaround can help you get
started. Many thanks to Jim Clarke, who did the lion's share
of the legwork to find this solution.