Sparc Virtualization

From NSSKB

Jump to: navigation, search

Contents

Virtualize A Sun SPARC Workstation Using QEMU

Recently (March 2015) we had a customer contact us for some urgent assistance with some legacy Sun SPARC workstations.

The background was they had a number of SPARC-20 workstations which had been last used around 10 years ago when they were part of their main business processing. When they updated systems to run on Linux workstations, they had retired the SPARC-20s from use.

As often happens, they now had to revisit the old processes which required returning the Sun Workstations to operation. Due to the amazing build quality, they did boot up and they were able to access the precious data but were now left with a concern they needed to make sure these were backed up and were reliable.

With the take-over by Oracle, SUN are no longer around in the way they once were and these were already ancient and unsupported boxes when they were turned off 10 years ago.

We were contacted and asked if there was any way to help get these, now critical, servers into the main backup schedule and guard against hardware failure - a distinct probablity, given the age of the hardware.

QEMU To The Rescue

FIRSTLY, THIS INFORMATION IS PROVIDED AS-IS. WE DO NOT PROVIDE ANY WARRANTY AND WILL NOT BE RESPONSIBLE FOR ANY ADVERSE CONSEQUENCES AS A RESULT OF FOLLOWING OR FAILING TO PROPERLY FOLLOW ANYTHING CONTAINED IN THIS ARTICLE.


While many are familiar with the typical use of QEMU to provide virtual x86 based virtual machines, QEMU is actually an accomplished all-round virtualization environment. Critically for this client, QEMU also supports emulation of the SUN SPARC series CPUs and, specifically, the Sun SPARC-20 workstations.

We knew that if we could take a disk image of the running SPARC-20 disk, we could then run a SPARC virtual machine using QEMU and move the whole environment into a virtual environment, taking the risks of the old hardware out of the equation.

Check Your Hardware

Firstly, we need to know some information about the hardware. Log in as root :

uname -a
SunOS sunhost 5.6 Generic sun4m sparc SUNW,SPARCstation-20
ifconfig -a
lo0: flags=849<UP,LOOPBACK,RUNNING,MULTICAST> mtu 8232
       inet 127.0.0.1 netmask ff000000 
hme0: flags=863<UP,BROADCAST,NOTRAILERS,RUNNING,MULTICAST> mtu 1500
       inet 172.16.7.6 netmask ffffff00 broadcast 172.16.7.255
       ether 8:0:23:63:b3:53 

We will need the MAC address later but meantime, the sun4m and SPARCstation-20, from the uname -a, confirms this is something QEMU can emulate.

Image The SPARC Disk

To begin, we had a look at the running disk on the SPARC-20 :

# df
/                  (/dev/dsk/c0t3d0s0 ):   89598 blocks    32729 files
/usr               (/dev/dsk/c0t3d0s6 ):  582578 blocks   311175 files
/proc              (/proc             ):       0 blocks     1993 files
/dev/fd            (fd                ):       0 blocks        0 files
/var               (/dev/dsk/c0t3d0s1 ):   51138 blocks    16812 files
/export/home       (/dev/dsk/c0t3d0s7 ): 1630220 blocks   418674 files
/opt               (/dev/dsk/c0t3d0s5 ):  126890 blocks    50932 files
/tmp               (swap              ):  667104 blocks    16510 files
/apps              (caddata:/apps     ):94783744 blocks 14073299 files

So, using our knowledge of the Sun disk operation, we know the whole disk slice is /dev/rdsk/c0t3d0s2. We'll come back to that shortly.

For the QEMU emulation, we need to set a couple of parameters to match the hardware emulation as it has some subtle differences from the real physical hardware, but not too much for our situation.

Reconfigure The VM On Boot

We want the rebooted (virtual) server to reconfigure the device files to match the new hardware, so we start with a reconfigure request :

# touch /reconfigure

Ensure The NIC le0 Is Configured

The original hardware uses NIC designated as hme0 but our virtual NIC is a Lance device, with designation le0. We need to make sure the rebooting VM configures le0 instead of hme0 :

# mv /etc/hostname.hme0 /etc/hostname.le0

Ensure SCSI Disk Drivers Load

The QEMU virtual machine requires the SCSI disk drivers to load in a particular order. This is achieved by setting the appropriate SCSI option in the system configuration file, /etc/system

# echo "set scsi_options = 0x58" >> /etc/system

MAKE SURE TO ENTER >> and not a single > ! A single > will overwrite the file which is not what you want !

Take The Disk Image

From our Linux server, we now use rsh to take a copy of the live, running disk. (If you can connect the powered down disk to the server, all the better as it avoids a filesystem recovery on first boot of the VM).

rsh sunhost "cat /dev/rdsk/c0t3d0s2" > disk3.raw

Once this completes, we have a disk image of the running disk, but with a caveat ! The image does not copy the 'spare' tracks on the SUN disk. To make the disk size match the expected size for SunOS, we need to add some extra zero's to the end of the disk.

# fdisk disk3.raw 

Command (m for help): p

Disk disk3.raw (Sun disk label): 19 heads, 80 sectors, 2733 cylinders
Units = cylinders of 1520 * 512 bytes

    Device Flag    Start       End    Blocks   Id  System
disk3.raw1             0        87     66120    2  SunOS root
disk3.raw2            87       131     33440    7  SunOS var
disk3.raw3             0      2733   2077080    5  Whole disk
disk3.raw4  u        131       476    262200    3  SunOS swap
disk3.raw6           476       611    102600    0  Unassigned
disk3.raw7           611      1555    717440    4  SunOS usr
disk3.raw8          1555      2733    895280    8  SunOS home

Command (m for help): q

From this we see the size is 1520 * 512 bytes for a cylinder, so we add 1 extra cylinder using these parameters :


linuxserver# dd if=/dev/zero of=extracyl bs=512 count=1520
1520+0 records in
1520+0 records out
778240 bytes (778 kB) copied, 0.00519847 s, 150 MB/s
linuxserver# cat extracyl >> disk3.raw

Return The Original Disk To The Original State

Optionally, to clean up in case you need to restart the physical hardare, remove the changes made before imaging :

# rm /reconfigure
# mv /etc/hostname.le0 /etc/hostname.hme0

And edit /etc/system to remove the scsi_options line.

Starting The Virtual Machine

We have the QEMU 2.3 RC build in /opt/qemu23/ on our Linux server.

To start the SPARC VM, we run :

/opt/qemu23/bin/qemu-system-sparc -drive file=disk3.raw,unit=3,format=raw -nographic \
  -m 512 -bios ss20_v2.25_rom -net nic,macaddr=08:00:23:63:b3:53 -net bridge,br=br1 \
  -cpu "TI SuperSparc 60" -M SS-20 -serial tcp::10023,server,nowait \
  -monitor tcp::10123,server,nowait

The MAC address used is the one from the original server which ensures the hostid and any network dependencies all match (e.g. license managers etc.).

To see the booting server, telnet to the Linux server, port 10023.

To execute QEMU commands, telnet to the Linux server, port 10123. Here you can use disk clone commands to make a disk snapshot for backups etc.

We don't provide the SPARC BIOS ROMs - these can be found in various places, such as http://home.earthlink.net/~reif/

Personal tools