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.

42 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?

    • astr0baby says:

      Yeah .. I know, even though I have worked on many AIX systems I never really liked Smitty … but good point, smitty works in the emulation just fine.

      • darkfader says:

        smitty is just a layer on top on some intermediary commands on top of the actual commands.
        so there’s most certainly some chattr you can run instead of bothering with smitty :-)

      • astr0baby says:

        Yes, definitely, I do not like smitty actually, but most AIX admins are hammered to use it since child-hood :)

  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 | 𝚟𝚎𝚛𝚖𝚊𝚍𝚎𝚗

  4. golemwashere says:

    Hello,
    I have issues with the latest 7.2 GA installation with latest qemu-system-ppc64, the qcow2 disk is seen by the openfirmware but not by AIX , I have no available disks destinations.
    I am using
    -drive file=/data/disk.img,if=none,id=drive-virtio-disk0 \
    -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=drive-virtio-disk0 \

    seen as
    Populating /pci@800000020000000/scsi@2
    SCSI: Looking for devices
    100000000000000 DISK : “QEMU QEMU HARDDISK 2.5+”

    do you need to load some special drivers?
    Thanks
    g.

    • astr0baby says:

      You need to run AIX 7.2 TL3SP1 minimum, as the kernel in this Technology Level and Service Pack contains the needed virtio support.

      • golemwashere says:

        Thanks!
        I was using first AIX DVD instead of the huge AIX_v7.2_Install_7200-03-02-1846_flash_112018.iso which looks like it has neede drivers.
        I managed to install and bring up en0 on a tap device.
        FTP works fine but I have issues with openssh :
        connections always fail with ssh_dispatch_run_fatal: Connection to xxxx port 22: incorrect signature.

        I tried messing with KeyHex and Cypher algorithms in sshd_config.
        I tried regenerating ssh keys.
        I tried to downgrade openssh from OpenSSH_7.5.102.1600, to OpenSSH_7.5.102.1100 or OpenSSH_6.0.0.6204 but no luck
        I was considering downgrading openssl ( current version is 1.0.2.1601 )
        but there are some dependencies I’d rather not touch
        Do you have any suggestion?

      • astr0baby says:

        OpenSSH worked for me with no problems, I will spin-up the VM today and send you the software versions so you can check.

      • astr0baby says:

        Can you run your ssh connection with more verbosity ? ssh -vv
        Here are my OpenSSH and OpenSSL versions on the AIX side

        [root@asterix ~]# lslpp -L | grep ssh
        openssh.base.client 7.5.102.1500 CE F Open Secure Shell Commands
        openssh.base.server 7.5.102.1500 CE F Open Secure Shell Server
        openssh.man.en_US 7.5.102.1500 C F Open Secure Shell
        openssh.msg.en_US 7.5.102.1500 C F Open Secure Shell Messages –
        libssh2 1.8.0-3 C R A library implementing the
        libssh2-devel 1.8.0-3 C R Development files for libssh2
        [root@asterix ~]# lslpp -L | grep ssl
        openssl.base 1.0.2.1500 CE F Open Secure Socket Layer
        openssl.license 1.0.2.1500 C F Open Secure Socket License
        openssl.man.en_US 1.0.2.1500 C F Open Secure Socket Layer
        python-passlib 1.7.1-1 C R comprehensive password hashing

  5. golemwashere says:

    Hello, Thanks a lot for support…
    I think I was having problems with my tap and br devices (I had put IP both on tap0 and br0) …
    and having IPs on the same network for multiple devices might have confused ssh.
    I have you same exact versions.

    Starting from scratch I managed to reach by ssh the aixonqemu ip from the host mac
    but I can’t reach anything from inside to outside.

    currently I have qemu starting with
    -net nic -net tap
    this is creating a tap0 device

    on linux (latest Centos7),
    my first interface with its default gateway is ens192 on network 1.1.1.0/24 vlan1 and I wish to use my other interface ens224 on network 2.2.2.0/24 vlan2 (addresses changed to protect the innocent)

    this is what I am currently doing to configure br0

    ifconfig tap0 up
    brctl addbr br0
    brctl addif br0 tap0
    brctl addif br0 ens224
    brctl setfd br0 0
    ifconfig ens224 up
    ifconfig br0 up
    ifconfig br0 2.2.2.5 netmask 255.255.255.0

    on aixonqemu I configured en0 with 2.2.2.2 and that is reachable by the linux host
    (but not any other host in vlan2 , while hosts in lan reach 2.2.2.5)
    a tcpdump on en0 is showing all broadcast traffic for vlan2
    but from inside aixonqemu
    but I can’t reach anything but 2.2.2.5

    I think I need some masquerading with iptables,
    I tried something as

    iptables -A FORWARD -i tap0 -o ens192 -j ACCEPT
    iptables -t nat -A POSTROUTING -o ens192 -j MASQUERADE
    iptables -A FORWARD -i tap0 -o ens192 -m state –state ESTABLISHED,RELATED -j ACCEPT
    pls forgive my n00bness on tap and br0 devices,
    do you have any suggestion?

    • astr0baby says:

      Lets make this simple :)
      Below is the simplest network config you should use

      tunctl -t tap0 -u user
      ifconfig tap0 up
      brctl addbr br0
      brctl addif br0
      brctl setfd br0 0
      ifconfig br0 10.0.2.2 netmask 255.255.255.0 broadcast 10.0.2.255 up
      brctl addif br0 tap0
      ifconfig tap0 0.0.0.0
      sysctl net.ipv4.ip_forward=1
      iptables –table nat -A POSTROUTING –out-interface wlan0 -j MASQUERADE

      Explanation:
      bridge0 : 10.0.2.2 (would be the gateway for the aixonqemu

      Inside aixonqemu
      en0 : 10.0.2.10 (add default route 10.0.2.2 and DNS 8.8.8.8 or whatever else)

      Make sure we also portforward to the internet (I use wlan0 on my laptop so you need to adjust to whatever is your internet connected device) thus :

      sysctl net.ipv4.ip_forward=1
      iptables –table nat -A POSTROUTING –out-interface wlan0 -j MASQUERADE

  6. golemwashere says:

    dude you’re THE MAN!
    using br0 ip address on aixonqemu as gateway and masquerading on ens192 ( wlan0 ) works fine!
    now I could also install and use yum, bash (32bit) , etc
    Still not grokking much the tap0 / br0 stuff , I wished you could just publish on a layer2 interface the internal aix IP.
    My next fun would be testing samba on aix through some iptables portfowarding from my wlan0 interface.
    Thanks a lot again for insight!

  7. Hello
    i have the following issue: Trying to load: -s verbose from: /vdevice/v-scsi@71000003/disk@8200000000000000:\ppc\chrp\bootfile.exe … Successfully loaded

    AIX
    StarLED{814}
    All the time, doesn’t work

    can you help me please?

  8. The model of the laptop, affects something?.
    I ran it on a Thinkpad T520, with Centos 7

  9. LinuxRobto says:

    I have problem with
    #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
    Already chanage enp0s25 to eth0 but still does not work.
    The error say: It does not exist.
    Any issues please kindly help!!

    • astr0baby says:

      you have bridgeutils installed ?, also please remove the vboxnet0 from the brctl command (you probably do not want that if you do not
      wish to add vboxnet0 to the br0)

  10. MJ says:

    Hey astrobaby,

    Can you release for download your qemu disk image file with aix 7.2 installed?
    Im stuck with the basic shell of the diagnostic disk and I dont have a aix 7.2 to generate a mksysb from :(

  11. MJ says:

    Yeah, I remember a long time ago I tried rsync over ssh and it was painfully slow because of the encryption overhead of ssh.

  12. MJ says:

    Confirmed that /dev/random was introduced in AIX 5.2:

    “The AIX 5.2 base security provides new pseudo random number generator devices, /dev/random and /dev/urandomM, pseudo-device driver and configuration routines that select various hardware device interrupts to provide entropy. OpenSSH in AIX 5.2 is compiled to take advantage of the new device /dev/urandom. You will also need the latest OpenSSL version, openssl-0.9.6e-2.aix4.3.ppc.rpm (AIX Linux Toolbox), for OpenSSH to use the /dev/urandom device.”

    source: https://www.ibm.com/developerworks/systems/articles/openssh_updated.html

  13. MJ says:

    Hey Astr0, why you used POWER8 instead of POWER9?

  14. MJ says:

    I’m not sure,
    I’m asking because that in the reference guide that you linked, they have used POWER9. Thinking in simulation simplicity we can also use POWER7.

    I will bench to see.

    • astr0baby says:

      I have never used P9 really … would be great to see if P7 would boot the qemu-system-ppc64 has any speed advantage over P8 and P9. Would be great to know :)

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.