Skip to content

Instantly share code, notes, and snippets.

@paboldin
Last active May 14, 2020 13:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paboldin/9e5c0f64b2f98d99dfa228d7dc812c4f to your computer and use it in GitHub Desktop.
Save paboldin/9e5c0f64b2f98d99dfa228d7dc812c4f to your computer and use it in GitHub Desktop.
qemu-system-s390x emulator on Ubuntu how-to
--- qemu-2.5+dfsg/debian/rules 2016-04-19 18:48:46.000000000 +0300
+++ qemu-2.5+dfsg.new/debian/rules 2017-07-25 23:38:18.882758751 +0300
@@ -132,9 +132,13 @@ ifeq ($(enable_linux_user),enable)
$(MAKE) -C user-static-build V=${V} $(foreach t,${user_targets},subdir-${t}-linux-user)
endif
-ifneq ($(filter $(DEB_HOST_ARCH),s390 s390x),)
- $(MAKE) -C qemu-build/pc-bios/s390-ccw V=${V}
-endif
+#ifneq ($(filter $(DEB_HOST_ARCH),s390 s390x),)
+ $(MAKE) -C qemu-build/pc-bios/s390-ccw V=${V} \
+ CC=s390x-linux-gnu-gcc-5 \
+ AS=s390x-linux-gnu-as \
+ CPP="s390x-linux-gnu-gcc-5 -E" \
+ STRIP="s390x-linux-gnu-strip"
+#endif
touch $@
clean: debian/control
@@ -223,9 +227,9 @@ endif
ifneq ($(filter $(DEB_HOST_ARCH),ppc64 ppc64el powerpc),)
install -D -m755 debian/kvm.powerpc debian/qemu-kvm/usr/bin/kvm
endif
-ifneq ($(filter $(DEB_HOST_ARCH),s390 s390x),)
+#ifneq ($(filter $(DEB_HOST_ARCH),s390 s390x),)
install -D -m755 qemu-build/pc-bios/s390-ccw/s390-ccw.img debian/qemu-system-s390x/usr/share/qemu/s390-ccw.img
-endif
+#endif
ifeq ($(VENDOR),UBUNTU)
# apport hook is ubuntu-specific
@@ -296,7 +300,7 @@ endif
dh_installinit -pqemu-guest-agent
endif
dh_link ${ai}
- dh_strip ${ai}
+ #dh_strip ${ai}
dh_compress ${ai}
dh_fixperms ${ai}
dh_makeshlibs ${ai}
--- qemu-2.5+dfsg/pc-bios/s390-ccw/Makefile 2015-12-12 14:16:02.000000000 +0200
+++ qemu-2.5+dfsg.new/pc-bios/s390-ccw/Makefile 2017-07-25 23:36:24.634406520 +0300
@@ -20,7 +20,7 @@ s390-ccw.elf: $(OBJECTS)
$(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS)," Building $(TARGET_DIR)$@")
s390-ccw.img: s390-ccw.elf
- $(call quiet-command,strip --strip-unneeded $< -o $@," Stripping $(TARGET_DIR)$@")
+ $(call quiet-command,$(STRIP) --strip-unneeded $< -o $@," Stripping $(TARGET_DIR)$@")
$(OBJECTS): Makefile

How to build s390x emulator (tcg) on Ubuntu 16.04:

  1. Download qemu's source code using apt:
$ apt source qemu
  1. Install all build requirements according to [1]:
$ sudo mk-build-deps -i -r qemu
  1. Install s390x cross compiler:
$ sudo apt install -y gcc-5-multilib-s390x-linux-gnu
  1. Change debian/rules to always build s390x bootloader via cross-compiler, by applying the provided patch:
$ cd qemu-2.5+dfsg
$ patch -p1 < ~/qemu-s390x-debian-rules.patch
  1. Build according to [1], this will take some time:
$ fakeroot debian/rules binary
...
  1. Install resulting qemu-system-s390x package:
$ sudo apt install ../qemu-system-s390x_2.5+dfsg-5ubuntu10.14_amd64.deb
  1. Use virt-manager[2] to setup the host, don't use CDROMs as they are not supported. Rather, download and use latest debian's installer kernel and initrd:
$ wget -c http://ftp.debian.org/debian/dists/stable/main/installer-s390x/current/images/generic/kernel.debian \
  http://ftp.debian.org/debian/dists/stable/main/installer-s390x/current/images/generic/initrd.debian
  1. Use above as initrd and kernel on 'Boot Options' tab under 'Direct kernel boot'. Installation only possible via console.

[1] https://wiki.debian.org/BuildingAPackage

[2] https://virt-manager.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment