Running AIX 7.2 TL3SP1 on x86_64 via qemu-system-ppc64

Who would not wish to run the best operating system on earth on his pity Intel Laptop ? I will describe here what I have done with the help of others and share some of my findings and recommendations how to get this going.

For this exercise Im using Linux Mint 19 x86_64 and current qemu compiled from source which you can get from here https://github.com/qemu/qemu

One should get the similar output from the compilation

$ git clone git://git.qemu.org/qemu.git
$ cd gemu 
$ mkdir build
$ cd build
$ ../configure
$ make
$ su 
# make install 
# exit 
$  qemu-system-ppc64 --version
QEMU emulator version 3.0.50 (v3.0.0-614-g19b599f766-dirty)
Copyright (c) 2003-2017 Fabrice Bellard and the QEMU Project developers

So once we have qemu installed we can then move on to get an actual AIX ISO, which I cannot obviously share, but I will link some already made documentation how to get it done if you already have a Power environment with AIX on

https://www.ibm.com/developerworks/community/blogs/cgaix/resource/AIX_QEMU_blog.pdf?lang=en_us

Next I will share my tun-tap scripts as well as the installer loader and normal loader scripts for the AIX

Here is my standard Linux networking script that I use for various VMs and simulators (VirtualBox, Alphavm-free, simh, hercules )

#Setup tap and bridge 
tunctl -t tap0 -u user
ifconfig tap0 up
brctl addbr br0
brctl addif br0 enp0s25 vboxnet0 
brctl setfd br0 0
ifconfig enp0s25 10.0.2.1 up 
ifconfig br0 10.0.2.2 netmask 255.255.255.0 broadcast 10.0.2.255 up
brctl addif br0 tap0 vboxnet0 
ifconfig tap0 0.0.0.0
sysctl net.ipv4.ip_forward=1
iptables -A FORWARD --in-interface enp0s25 -j ACCEPT
iptables --table nat -A POSTROUTING --out-interface wlp9s0 -j MASQUERADE

Please change accordingly to your need, enp0s25 is eth0, wlp9s0 is wlan0 that is internet connected.

Here is a slightly modified /etc/qemu-ifup

#! /bin/sh
# Script to bring a network (tap) device for qemu up.
# The idea is to add the tap device to the same bridge
# as we have default routing to.

# in order to be able to find brctl
PATH=$PATH:/sbin:/usr/sbin
ip=$(which ip)

if [ -n "$ip" ]; then
ip link set "$1" up
else
brctl=$(which brctl)
if [ ! "$ip" -o ! "$brctl" ]; then
echo "W: $0: not doing any bridge processing: neither ip nor brctl utility not found" >&2
exit 0
fi
ifconfig "$1" 0.0.0.0 up
fi

switch=$(ip route ls |
awk '/^default / {
for(i=0;i<NF;i++) { if ($i == "dev") { print $(i+1); next; } }
}'
)

switch=br0

# only add the interface to default-route bridge if we
# have such interface (with default route) and if that
# interface is actually a bridge.
# It is possible to have several default routes too
for br in $switch; do
if [ -d /sys/class/net/$br/bridge/. ]; then
if [ -n "$ip" ]; then
ip link set "$1" master "$br"
else
brctl addif $br "$1"
fi
exit # exit with status of the previous command
fi
done

echo "W: $0: no bridge for guest interface found" >&2

Next is my AIX 7.2 TL3SP1 installation loader script

qemu-system-ppc64 -cpu POWER8 -machine pseries -m 2048 -serial stdio -drive file=disk.img,if=none,id=drive-virtio-disk0 -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=drive-virtio-disk0 -cdrom aix.iso -prom-env "boot-command=dev / 0 0 s\" ibm,aix-diagnostics\" property boot cdrom:\ppc\chrp\bootfile.exe -s verbose" -net nic -net tap -display vnc=:1

And here is the simulation loader script

qemu-system-ppc64 -cpu POWER8 -machine pseries -m 2048 -serial stdio -drive file=disk.img,if=none,id=drive-virtio-disk0 -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=drive-virtio-disk0 -cdrom aix.iso -prom-env boot-command='boot disk: ' -net nic -net tap -display vnc=:1

My disk.img is a standard qcow2 compressed image format (100 G)

Once the system is installed ( please use this reference https://www.ibm.com/developerworks/community/blogs/cgaix/resource/AIX_QEMU_blog.pdf?lang=en_us )

Be patient once it all loads (takes approx 5 minutes on my Panasonic CF-53 ToughBook  with Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz

Following are my additional steps that I have done after loggin in the first time after install (the /etc/motd is my own custom one)

AIX 7.2 networking

# ifconfig en0 10.0.2.10 up
# route add 0 10.0.2.2 
# chdev -l inet0 -a hostname=asterix
Add following to 

# echo "nameserver 8.8.8.8" > /etc/resolv.conf 

To make it persistent created a scritp in /etc/network.sh

#!/bin/ksh
echo "nameserver 8.8.8.8" > /etc/resolv.conf
ifconfig en0 10.0.2.10 up
route add 0 10.0.2.2

And made it executable of course

# chmod +x /etc/network.sh

Then added last entry to /etc/inittab so next time we boot, network works

customnet:2:once:/etc/network.sh 2>&1

Test the above, reboot the machine by issuing halt command an re-loading it.

Important thing to notice here – do not use the -serial stdio interface in your terminal for normal work. CTRL-C will kill the qemu simulation and thats something you don’t want. So setup sshd instead (I have allowed remote root user for simplicitys sake here) and connect to your guest AIX via ssh from the Linux host !

Connect to the AIX guest (you can then make as many ssh sessions as needed, once AIX guest is booted its quite fast to use taking into consideration all Power8 instructions are simulated by qemu)

Here are the details about the guest AIX

AIX Version 7
Copyright IBM Corporation, 1982, 2018.
Console login: root
root's Password: 

Welcome to AIX 7.2 running via Qemu-system-ppc64 in X86_64 
-------------------------------------------------------------
Last unsuccessful login: Sat Nov 3 13:04:35 CET 2018 on /dev/vty0 from localhost
Last login: Sun Nov 4 20:12:27 CET 2018 on /dev/pts/1 from 10.0.2.2

[root@asterix ~]# prtconf 
System Model: IBM pSeries (emulated by qemu)
Machine Serial Number: Not Available
Processor Type: PowerPC_POWER8
Processor Implementation Mode: POWER 8
Processor Version: PV_8_Compat
Number Of Processors: 1
Processor Clock Speed: 1000 MHz
CPU Type: 64-bit
Kernel Type: 64-bit
LPAR Info: 0 aix_on_kvm
Memory Size: 2048 MB
Good Memory Size: 2048 MB
Platform Firmware level: Not Available
Firmware Version: SLOF,aik
Console Login: enable
Auto Restart: true
Full Core: false
NX Crypto Acceleration: Not Capable

Network Information
Host Name: asterix
IP Address: 
Sub Netmask: 
Gateway: 10.0.2.2
Name Server: 
Domain Name: 

Paging Space Information
Total Paging Space: 512MB
Percent Used: 1%

Volume Groups Information
============================================================================== 
Active VGs
============================================================================== 
rootvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk0 active 799 649 159..122..48..160..160
============================================================================== 

INSTALLED RESOURCE LIST

The following resources are installed on the machine.
+/- = Added or deleted from Resource List.
* = Diagnostic support not available.

Model Architecture: chrp
Model Implementation: Uni-Processor, PCI bus

+ sys0 System Object
+ sysplanar0 System Planar
* vio0 Virtual I/O Bus
* vscsi0 Virtual SCSI Client Adapter
* cd0 Virtual SCSI Optical Served by VIO Server
* ent0 Virtual I/O Ethernet Adapter (l-lan)
* vsa0 LPAR Virtual Serial Adapter
* vty0 Asynchronous Terminal
* pci0 PCI Bus
* scsi0 qemu_virtio-scsi-pci:0000:00:02.0 Virtio SCSI Client Adapter (f41a0800)
* hdisk0 qemu_virtio-scsi-pci:0000:00:02.0-LW_0 MPIO Other Virtio SCSI Disk Drive
+ L2cache0 L2 Cache
+ mem0 Memory
+ proc0 Processor

Configure YUM

Please read the documentation here about how to setup the environment
https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/ezinstall/ppc/README-yum

Since we have no tools yet installed I will use my Linux Host machine to download all the needed RPMs and then copy them to AIX guest via scp

// On the Linux Host machine 
$ mkdir AIX 
$ cd AIX 
$ wget https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/ezinstall/ppc/yum_bundle.tar

// On the AIX guest 
# mkdir /tmp/RPM
# cd /tmp/RPM
# scp user@10.0.2.2:/home/user/AIX/yum_bundle.tar . 
# tar -xv yum_bundle.tar

Install RPMs on the AIX guest

# cd /tmp/RPM
# rpm -ivh ca-certificates-2016.10.7-2.aix6.1.ppc.rpm
# rpm -ivh curl-7.52.1-1.aix6.1.ppc.rpm
# rpm -ivh db-4.8.24-3.aix6.1.ppc.rpm
# rpm -ivh gdbm-1.8.3-5.aix5.2.ppc.rpm
# rpm -ivh gettext-0.19.7-1.aix6.1.ppc.rpm
# rpm -ivh glib2-2.14.6-2.aix5.2.ppc.rpm
# rpm -ivh readline-6.1-2.aix6.1.ppc.rpm
# rpm -ivh sqlite-3.15.2-1.aix6.1.ppc.rpm
# rpm -ivh python-2.7.10-1.aix6.1.ppc.rpm
# rpm -ivh python-devel-2.7.10-1.aix6.1.ppc.rpm
# rpm -ivh python-iniparse-0.4-1.aix6.1.noarch.rpm
# rpm -ivh python-pycurl-7.19.3-1.aix6.1.ppc.rpm
# rpm -ivh python-tools-2.7.10-1.aix6.1.ppc.rpm
# rpm -ivh python-urlgrabber-3.10.1-1.aix6.1.noarch.rpm
# rpm -ivh pysqlite-1.1.7-2.aix6.1.ppc.rpm
# rpm -ivh yum-metadata-parser-1.1.4-2.aix6.1.ppc.rpm
# rpm -ivh yum-3.4.3-5.aix6.1.noarch.rpm

Now YUM is ready to install some tools

# yum install tcsh 
# yum install gcc

If there are problems with RPM db afterwards, simply rebuild it

# rpm --rebuilddb

I do not know how to work in Korn shell (default) too much so I have installed tcsh

# yum install tcsh

And setup the environment to use it  /etc/passwd entry for root

root:!:0:0::/home/root:/usr/bin/tcsh

And then configure tcsh prompt for the root user

# cd /home/root 
# cat .cshrc 
set prompt = '[%n@%m %c]# '

PKGSRC Q3-2018 test

Next I have tested pkgsrc build, please make sure you read the following https://wiki.netbsd.org/pkgsrc/how_to_use_pkgsrc_on_aix/

# ftp ftp.netbsd.org 
230 Guest login ok, access restrictions apply.
ftp> pas
Passive mode on.
ftp> bin
200 Type set to I.
ftp> cd /pub/pkgsrc/pkgsrc-2018Q3
ftp> get pkgsrc.tar.gz

# mv pkgsrc.tar.gz /tmp
# cd /tmp
# gunzip pkgsrc.tar.gz 
# tar -xvf pkgsrc.tar
# setenv CC /opt/freeware/bin/gcc 
# cd pkgsrc/bootsrap
# ./bootstrap

After bootstrap make sure we declare the following variables in TCSH

# setenv CC /opt/freeware/bin/gcc
# setenv USE_NATIVE_GCC yes

Then we can build pkgsrc packages as follows

# /usr/pkg/bin/bmake install clean

P.S

What does not work

  •  Bash (bash_64 cpu 95%)
  •  Wget – core dump
  •  Ruby (cpu 95%)
  •  ps (core dump) – using topas instead   (another workaround is to use /usr/sysv/bin/ps which is a RISC System/6000 binary, so you can move /usr/bin/ps away and symlink the above ) Thanks Russ !
  •  vmstat – using topas instead

Update on why things do not work 11.11.2018 

The problem is that on AIX binaries usually come in two forms – 32 bit ((RISC System/6000)   and 64-bit XCOFF  these files are usually identified as filename_32 and filename_64 under /opt/freeware/bin for example. Inside you get symlinks to either the 32 or 64 version of the file, so keep in mind that under Qemu not all 64-bit XCOFF binaries work as expected and some coredump. To fix this you need to change the symlinks to point to 32bit versions ( this fixes ruby, bash, wget, curl etc) however not the ps command since that is shipped by the OS as 64bit version only.

Video presentation is located here

Advertisements

About astr0baby

Please run Adblock or similar... we have been told to do so since Carl Sagan wrote the Contact .
Gallery | This entry was posted in Uncategorized. Bookmark the permalink.

5 Responses to Running AIX 7.2 TL3SP1 on x86_64 via qemu-system-ppc64

  1. Phill says:

    Why not use smitty mktcpip to set up the AIX network interface and dns resolution the standard way instead of a work-around?

  2. Russ says:

    AIX ships with a sysv verson of ps, this works OK and might do as a workaround for some situations. Just use the path /usr/sysv/bin/ps.

  3. Pingback: Valuable News – 2018/12/08 | 𝚟𝚎𝚛𝚖𝚊𝚍𝚎𝚗

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.