Add Fedora support
cover Add Fedora support
Hi Stefanao,
Following series adds documentation on how to use stage1-xen on Fedora. It also adds continuous build support using CircleCI.
Xen, Qemu, rkt and stage1 ACI image are built using a Fedora based container. This setup allows for a reproducible build environment that we can use locally and also within a CI system.
Below is an overview of the series -
build/fedora: Add buildroot-README.md
build/fedora: Add buildroot-Dockerfile
build/fedora: Add run
build/fedora directory is introduced. In this directory we can maintain documentation, scripts and patches relating to Fedora support for stage1-xen.
buildroot-README.md describes a two stage container build process. This is modeled on how we do builds for distro packages, but using containers instead of a mock/chroot environment. The build artifact produced by run script is a tarball, instead of a rpm or deb file.
build/fedora: Add source_path.sh
build/fedora: Add xen-unstable-runit/* scripts
Scripts used within build artifact tarball.
.circleci/config.yml: Add
README.md: Add CircleCI badge
Adds CircleCI support. Here [1][2] is a temporary repo with Circle CI support enabled.
build/fedora: Add RUNNING_STAGE1_XEN.md
BUILDING.md: Add Fedora instructions
Update docs.
Please let me know your comments. Thank you!
Best,
Rajiv
[1]: https://github.com/lambda-linux-fedora/stage1-xen/tree/wip
[2]: https://circleci.com/gh/lambda-linux-fedora/stage1-xen/tree/wip
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 1/10 .gitignore: Add
From: Rajiv M Ranganath <[email protected]>
--- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore
.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +# build/fedora +build/fedora/binutils-*.tar
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 2/10 build/fedora: Add `buildroot-README.md`
In reply to Rajiv RanganathFrom: Rajiv M Ranganath <[email protected]>
--- build/fedora/buildroot-README.md | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 build/fedora/buildroot-README.md
build/fedora/buildroot-README.md new file +50 -0
@@ -0,0 +1,50 @@ +## stage1-xen Fedora Buildroot + +stage1-xen build artifacts for Fedora is built in two phases. In the first phase +a docker container is prepared with all the build dependencies. We refer to it +as `stage1-xen-fedora-buildroot`. In the next phase we execute the `run` script +that uses `stage1-xen-fedora-buildroot` and to produce the build artifacts. + +### Building `stage1-xen-fedora-buildroot` + +`stage1-xen-fedora-buildroot` has a external dependency +on [`binutils`](https://github.com/lambda-linux-fedora/binutils) package that is +compiled with `i386pe` support. You can download the pre-built RPMs +from [here](https://drive.google.com/open?id=0B_tTbuxmuRzIR05wQ3E1eWVyaGs). +Please download `binutils-2.26.1-1.1.fc25.tar`. + +To build docker image + +``` +cd stage1-xen/build/fedora + +docker build -f buildroot-Dockerfile -t stage1-xen-fedora-buildroot . +``` + +### Running `stage1-xen-fedora-buildroot` + +``` +cd stage1-xen + +docker run --rm \ + -v `pwd`:/root/gopath/src/github.com/rkt/stage1-xen \ + -v /tmp:/tmp \ + -t -i stage1-xen-fedora-buildroot \ + /sbin/my_init -- /root/bin/run +``` + +The generated build artifacts are in `/tmp` directory. + +To debug build issues - + +``` +cd stage1-xen + +docker run --rm \ + -v `pwd`:/root/gopath/src/github.com/rkt/stage1-xen \ + -v /tmp:/tmp \ + -t -i stage1-xen-fedora-buildroot \ + /sbin/my_init -- /bin/bash +``` + +Also see section on `ipdb` in `buildroot-Dockerfile`.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 02/10] build/fedora: Add `buildroot-README.md`
build/fedora/buildroot-README.md line 14
Quoted 5 lines · Rajiv Ranganath
+
stage1-xen-fedora-buildroothas a external dependencybuild/fedora/buildroot-README.md new file +4
-0+on [`binutils`](https://github.com/lambda-linux-fedora/binutils) package that is +compiled with `i386pe` support. You can download the pre-built RPMs +from [here](https://drive.google.com/open?id=0B_tTbuxmuRzIR05wQ3E1eWVyaGs). +Please download `binutils-2.26.1-1.1.fc25.tar`.
Note you shouldn't need to do this in Fedora 26 and later as i386pep support was added to binutils (see
https://bugzilla.redhat.com/show_bug.cgi?id=1376870 ).
Michael Young
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 02/10] build/fedora: Add `buildroot-README.md`
In reply to Rajiv RanganathQuoted 1 line · Rajiv Ranganath
From: Rajiv M Ranganath <[email protected]>
In addition to the instructions below, please mention how to build stage1-xen manually by installing the dependencies listed in buildroot-Dockerfile and executing build/fedora/run by hand.
Quoted 51 lines
build/fedora/buildroot-README.md | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 build/fedora/buildroot-README.mdbuild/fedora/buildroot-README.md new file +40
-0@@ -0,0 +1,50 @@ +## stage1-xen Fedora Buildroot + +stage1-xen build artifacts for Fedora is built in two phases. In the first phase +a docker container is prepared with all the build dependencies. We refer to it +as `stage1-xen-fedora-buildroot`. In the next phase we execute the `run` script +that uses `stage1-xen-fedora-buildroot` and to produce the build artifacts. + +### Building `stage1-xen-fedora-buildroot` + +`stage1-xen-fedora-buildroot` has a external dependency +on [`binutils`](https://github.com/lambda-linux-fedora/binutils) package that is +compiled with `i386pe` support. You can download the pre-built RPMs +from [here](https://drive.google.com/open?id=0B_tTbuxmuRzIR05wQ3E1eWVyaGs). +Please download `binutils-2.26.1-1.1.fc25.tar`. + +To build docker image + +``` +cd stage1-xen/build/fedora + +docker build -f buildroot-Dockerfile -t stage1-xen-fedora-buildroot . +``` + +### Running `stage1-xen-fedora-buildroot` + +``` +cd stage1-xen + +docker run --rm \ + -v `pwd`:/root/gopath/src/github.com/rkt/stage1-xen \ + -v /tmp:/tmp \ + -t -i stage1-xen-fedora-buildroot \ + /sbin/my_init -- /root/bin/run +``` + +The generated build artifacts are in `/tmp` directory. + +To debug build issues - + +```
build/fedora/buildroot-README.md line 50
Quoted 10 lines
build/fedora/buildroot-README.md new file +10
-0+cd stage1-xen + +docker run --rm \ + -v `pwd`:/root/gopath/src/github.com/rkt/stage1-xen \ + -v /tmp:/tmp \ + -t -i stage1-xen-fedora-buildroot \ + /sbin/my_init -- /bin/bash +``` + +Also see section on `ipdb` in `buildroot-Dockerfile`.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 3/10 build/fedora: Add `buildroot-Dockerfile`
In reply to Rajiv RanganathFrom: Rajiv M Ranganath <[email protected]>
--- build/fedora/buildroot-Dockerfile | 108 +++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 build/fedora/buildroot-Dockerfile
build/fedora/buildroot-Dockerfile new file +108 -0
@@ -0,0 +1,108 @@ +# tarballs checksum +# ----------------- +# 974b3091232d781c4fc410ccca98fb62ba9febe9e6a988e348804483c4f66742 binutils-2.26.1-1.1.fc25.tar + +FROM lambdalinuxfedora/baseimage-fedora + +CMD ["/sbin/my_init"] + +COPY [ \ + "./binutils-2.26.1-1.1.fc25.tar", \ + \ + "./run", \ + "/tmp/docker-build/" \ +] + +RUN \ + # dnf + echo "Running dnf update..." && \ + dnf update -y && \ + dnf install -y less && \ + dnf install -y sudo && \ + \ + # circleci container requirements + # https://circleci.com/docs/2.0/custom-images/#adding-required-and-custom-tools-or-files + dnf install -y git && \ + dnf install -y openssh-clients && \ + dnf install -y tar && \ + dnf install -y gzip && \ + dnf install -y ca-certificates && \ + \ + # install `binutils` + pushd /tmp/docker-build && \ + # verify checksum + echo "974b3091232d781c4fc410ccca98fb62ba9febe9e6a988e348804483c4f66742 binutils-2.26.1-1.1.fc25.tar" | sha256sum -c - && \ + tar xvf binutils-2.26.1-1.1.fc25.tar && \ + dnf install -y ./binutils/2.26.1/1.1.fc25/x86_64/binutils-2.26.1-1.1.fc25.x86_64.rpm && \ + popd && \ + \ + dnf install -y @buildsys-build && \ + \ + # Having `ipdb` around is useful when debugging `run` script. Uncomment this + # section as required + # dnf install -y python2-devel && \ + # dnf install -y python-pip && \ + # su -l root -c "pip2 install --user ipdb==0.8 ipython==5.3.0" && \ + \ + # Note: xen and qemu has some duplicate package dependencies. We are + # explicitly calling out dependencies for xen and qemu + # + # xen build dependencies + dnf install -y bridge-utils && \ + dnf install -y gettext && \ + dnf install -y glib2-devel && \ + dnf install -y glibc-devel.i686 && \ + dnf install -y grub2 && \ + dnf install -y iasl && \ + dnf install -y libaio-devel && \ + dnf install -y libuuid-devel && \ + dnf install -y ncurses-devel && \ + dnf install -y openssl-devel && \ + dnf install -y pixman-devel && \ + dnf install -y python2-devel && \ + dnf install -y wget && \ + dnf install -y yajl-devel && \ + \ + # qemu build dependencies + dnf install -y glib2-devel && \ + dnf install -y libaio-devel && \ + dnf install -y libattr-devel && \ + dnf install -y libcap-devel && \ + dnf install -y libcap-ng-devel && \ + dnf install -y pixman-devel && \ + dnf install -y zlib-devel && \ + \ + # rkt build dependencies + dnf install -y autoconf && \ + dnf install -y automake && \ + dnf install -y git && \ + dnf install -y glibc-static && \ + dnf install -y gnupg && \ + dnf install -y golang && \ + dnf install -y libacl-devel && \ + dnf install -y squashfs-tools && \ + dnf install -y systemd-devel && \ + dnf install -y wget && \ + \ + # stage1-xen build dependencies + dnf install -y bc && \ + dnf install -y busybox && \ + dnf install -y glide && \ + dnf install -y golang && \ + dnf install -y jq && \ + dnf install -y libacl-devel && \ + dnf install -y wget && \ + \ + # copy `run` file + su -l root -c "mkdir /root/bin" && \ + su -l root -c "cp /tmp/docker-build/run /root/bin" && \ + \ + # create `stage1-xen` directory + mkdir -p /root/gopath/src/github.com/rkt/stage1-xen && \ + \ + # cleanup + rm -rf /tmp/docker-build && \ + dnf clean all && \ + rm -rf /var/cache/dnf/* && \ + rm -rf /tmp/* && \ + rm -rf /var/tmp/*
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 4/10 build/fedora: Add `run`
In reply to Rajiv RanganathFrom: Rajiv M Ranganath <[email protected]>
--- build/fedora/run | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 build/fedora/run
build/fedora/run new file +87 -0
@@ -0,0 +1,87 @@ +#!/usr/bin/python2 + +import shlex +import subprocess +import sys +import os + + +# helper function to capture stdout from a long running process +def subprocess_stdout(cmd, cwd, env): + p = subprocess.Popen( + shlex.split(cmd), cwd=cwd, env=env, stdout=subprocess.PIPE) + while p.poll() is None: + l = p.stdout.readline() + sys.stdout.write(l) + + +env = os.environ.copy() + +# build and install xen-unstable +print "Cloning xen-unstable..." +cmd = 'git clone git://xenbits.xen.org/xen.git' +subprocess.check_output(shlex.split(cmd), cwd='/root') + +steps = [ + './configure --prefix=/opt/xen-unstable --with-system-qemu=/opt/xen-unstable/lib/xen/bin/qemu-system-i386 --disable-stubdom --disable-qemu-traditional --disable-rombios --sysconfdir=/opt/xen-unstable/etc --enable-rpath --disable-systemd', + 'make', + 'make install BOOT_DIR=/opt/xen-unstable/boot DEBUG_DIR=/opt/xen-unstable/lib/debug EFI_DIR=/opt/xen-unstable/boot/efi/EFI/xen' +] +for cmd in steps: + cwd = '/root/xen' + subprocess_stdout(cmd, cwd, env) + +# build and install qemu-unstable +print "Cloning qemu-unstable..." +cmd = 'git clone git://git.qemu.org/qemu.git' +subprocess.check_output(shlex.split(cmd), cwd='/root') + +steps = [ + './configure --prefix=/opt/qemu-unstable --enable-xen --target-list=i386-softmmu --extra-cflags="-I/opt/xen-unstable/include" --extra-ldflags="-L/opt/xen-unstable/lib -Wl,-rpath,/opt/xen-unstable/lib" --disable-kvm --enable-virtfs --enable-linux-aio', + 'make', 'make install' +] +for cmd in steps: + cwd = '/root/qemu' + subprocess_stdout(cmd, cwd, env) + +cmd = 'cp i386-softmmu/qemu-system-i386 /opt/xen-unstable/lib/xen/bin/qemu-system-i386' +subprocess.check_output(shlex.split(cmd), cwd='/root/qemu') + +# build rkt +print "Cloning rkt..." +cmd = 'git clone https://github.com/rkt/rkt.git' +subprocess.check_output(shlex.split(cmd), cwd='/root') + +steps = [ + './autogen.sh', './configure --disable-tpm --with-stage1-flavors=coreos', + 'make' +] +for cmd in steps: + cwd = '/root/rkt' + subprocess_stdout(cmd, cwd, env) + +# build stage1-xen +env['GOPATH'] = '/root/gopath' +cwd = '/root/gopath/src/github.com/rkt/stage1-xen' +cmd = 'bash build.sh' +subprocess_stdout(cmd, cwd, env) + +# install build artifacts to `/opt/` +steps = [ + 'mkdir -p /opt/stage1-xen/bin', 'mkdir -p /opt/stage1-xen/aci', + 'cp /root/rkt/build-rkt-1.28.1+git/target/bin/rkt /opt/stage1-xen/bin/rkt', + 'cp /root/gopath/src/github.com/rkt/stage1-xen/stage1-xen.aci /opt/stage1-xen/aci/stage1-xen.aci', + 'cp /root/gopath/src/github.com/rkt/stage1-xen/build/fedora/source_path.sh /opt/stage1-xen/bin/source_path.sh', + 'cp -r /root/gopath/src/github.com/rkt/stage1-xen/build/fedora/xen-unstable-runit /opt/xen-unstable-runit' +] +for cmd in steps: + cwd = '/root' + subprocess_stdout(cmd, cwd, env) + +cwd = '/opt' +cmd = 'tar zcvf /root/stage1-xen-build.tar.gz qemu-unstable/ stage1-xen/ xen-unstable/ xen-unstable-runit/' +subprocess_stdout(cmd, cwd, env) + +cwd = '/root' +cmd = 'mv /root/stage1-xen-build.tar.gz /tmp' +subprocess_stdout(cmd, cwd, env)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 04/10] build/fedora: Add `run`
Quoted 1 line · Rajiv Ranganath
From: Rajiv M Ranganath <[email protected]>
This is great, just a couple of comments. Please split it into two
scripts: one to build the dependecies (xen, qemu, etc.), and the other to build stage1-xen. Of course, you could have one `run' script that calls both scripts for convenience.
That way, a user could call the dependency builder once on her system, then call the stage1-xen builder as many times as needed. The script will be more reusable.
You won't like this final suggestion, but I'll try anyway :-) I would prefer if this script was in bash. I have nothing against python (in fact I know python better than other scripting languages) but I try to minimize the number of languages required to contribute to stage1-xen. But if it is python or nothing, I'll take python.
Quoted 26 lines
build/fedora/run | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 build/fedora/runbuild/fedora/run new file +16
-0@@ -0,0 +1,87 @@ +#!/usr/bin/python2 + +import shlex +import subprocess +import sys +import os + + +# helper function to capture stdout from a long running process +def subprocess_stdout(cmd, cwd, env): + p = subprocess.Popen( + shlex.split(cmd), cwd=cwd, env=env, stdout=subprocess.PIPE) + while p.poll() is None: + l = p.stdout.readline() + sys.stdout.write(l) +
build/fedora/run line 26
Quoted 10 lines
build/fedora/run new file +10
-0+ +env = os.environ.copy() + +# build and install xen-unstable +print "Cloning xen-unstable..." +cmd = 'git clone git://xenbits.xen.org/xen.git' +subprocess.check_output(shlex.split(cmd), cwd='/root') + +steps = [ + './configure --prefix=/opt/xen-unstable --with-system-qemu=/opt/xen-unstable/lib/xen/bin/qemu-system-i386 --disable-stubdom --disable-qemu-traditional --disable-rombios --sysconfdir=/opt/xen-unstable/etc --enable-rpath --disable-systemd',
I think it is fine to install things under /opt by default, but I would like it to be configurable. A global variable at the top of the script to set the destination directory is good enough.
Quoted 5 lines
build/fedora/run new file +5
-0+ 'make', + 'make install BOOT_DIR=/opt/xen-unstable/boot DEBUG_DIR=/opt/xen-unstable/lib/debug EFI_DIR=/opt/xen-unstable/boot/efi/EFI/xen' +] +for cmd in steps: + cwd = '/root/xen'
build/fedora/run line 41
Quoted 10 lines
build/fedora/run new file +10
-0+ subprocess_stdout(cmd, cwd, env) + +# build and install qemu-unstable +print "Cloning qemu-unstable..." +cmd = 'git clone git://git.qemu.org/qemu.git' +subprocess.check_output(shlex.split(cmd), cwd='/root') + +steps = [ + './configure --prefix=/opt/qemu-unstable --enable-xen --target-list=i386-softmmu --extra-cflags="-I/opt/xen-unstable/include" --extra-ldflags="-L/opt/xen-unstable/lib -Wl,-rpath,/opt/xen-unstable/lib" --disable-kvm --enable-virtfs --enable-linux-aio', + 'make', 'make install'
Same here about the destination directory
Quoted 37 lines
build/fedora/run new file +36
-0+] +for cmd in steps: + cwd = '/root/qemu' + subprocess_stdout(cmd, cwd, env) + +cmd = 'cp i386-softmmu/qemu-system-i386 /opt/xen-unstable/lib/xen/bin/qemu-system-i386' +subprocess.check_output(shlex.split(cmd), cwd='/root/qemu') + +# build rkt +print "Cloning rkt..." +cmd = 'git clone https://github.com/rkt/rkt.git' +subprocess.check_output(shlex.split(cmd), cwd='/root') + +steps = [ + './autogen.sh', './configure --disable-tpm --with-stage1-flavors=coreos', + 'make' +] +for cmd in steps: + cwd = '/root/rkt' + subprocess_stdout(cmd, cwd, env) + +# build stage1-xen +env['GOPATH'] = '/root/gopath' +cwd = '/root/gopath/src/github.com/rkt/stage1-xen' +cmd = 'bash build.sh' +subprocess_stdout(cmd, cwd, env) + +# install build artifacts to `/opt/` +steps = [ + 'mkdir -p /opt/stage1-xen/bin', 'mkdir -p /opt/stage1-xen/aci', + 'cp /root/rkt/build-rkt-1.28.1+git/target/bin/rkt /opt/stage1-xen/bin/rkt', + 'cp /root/gopath/src/github.com/rkt/stage1-xen/stage1-xen.aci /opt/stage1-xen/aci/stage1-xen.aci', + 'cp /root/gopath/src/github.com/rkt/stage1-xen/build/fedora/source_path.sh /opt/stage1-xen/bin/source_path.sh', + 'cp -r /root/gopath/src/github.com/rkt/stage1-xen/build/fedora/xen-unstable-runit /opt/xen-unstable-runit' +] +for cmd in steps:
build/fedora/run line 87
Quoted 10 lines
build/fedora/run new file +10
-0+ cwd = '/root' + subprocess_stdout(cmd, cwd, env) + +cwd = '/opt' +cmd = 'tar zcvf /root/stage1-xen-build.tar.gz qemu-unstable/ stage1-xen/ xen-unstable/ xen-unstable-runit/' +subprocess_stdout(cmd, cwd, env) + +cwd = '/root' +cmd = 'mv /root/stage1-xen-build.tar.gz /tmp' +subprocess_stdout(cmd, cwd, env)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 5/10 build/fedora: Add `source_path.sh`
In reply to Rajiv RanganathFrom: Rajiv M Ranganath <[email protected]>
--- build/fedora/source_path.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 build/fedora/source_path.sh
build/fedora/source_path.sh new file +3 -0
@@ -0,0 +1,3 @@ +#!/bin/sh + +export PATH=/opt/xen-unstable/sbin:/opt/xen-unstable/bin:/opt/stage1-xen/bin:/opt/qemu-unstable/bin:$PATH
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 6/10 build/fedora: Add `xen-unstable-runit/*` scripts
In reply to Rajiv RanganathFrom: Rajiv M Ranganath <[email protected]>
--- build/fedora/xen-unstable-runit/setup.sh | 21 ++++++++++++++++++++ build/fedora/xen-unstable-runit/teardown.sh | 21 ++++++++++++++++++++ .../xen-init-dom0-disk-backend/run | 8 ++++++++ build/fedora/xen-unstable-runit/xen-init-dom0/run | 6 ++++++ build/fedora/xen-unstable-runit/xenconsoled/run | 10 ++++++++++ build/fedora/xen-unstable-runit/xenstored/run | 20 +++++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100755 build/fedora/xen-unstable-runit/setup.sh create mode 100755 build/fedora/xen-unstable-runit/teardown.sh create mode 100755 build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run create mode 100755 build/fedora/xen-unstable-runit/xen-init-dom0/run create mode 100755 build/fedora/xen-unstable-runit/xenconsoled/run create mode 100755 build/fedora/xen-unstable-runit/xenstored/run
build/fedora/xen-unstable-runit/setup.sh new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/bash + +set -e +set -o pipefail + +# runit RPM creates `/etc/service` directory +if [ ! -d "/etc/service" ]; then + echo "/etc/service directory not found. Please install runit RPM." + exit 1 +fi + +runit_services="xenconsoled xen-init-dom0 xen-init-dom0-disk-backend xenstored" + +pushd /etc/service > /dev/null +for service in $runit_services; do + ln -sf /opt/xen-unstable-runit/$service $service +done +popd > /dev/null + +echo "Successfully created symlinks in /etc/service directory." +exit 0
build/fedora/xen-unstable-runit/teardown.sh new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/bash + +set -e +set -o pipefail + +# runit RPM creates `/etc/service` directory +if [ ! -d "/etc/service" ]; then + echo "/etc/service directory not found." + exit 1 +fi + +runit_services="xenconsoled xen-init-dom0 xen-init-dom0-disk-backend xenstored" + +pushd /etc/service > /dev/null +for service in $runit_services; do + rm -f $service +done +popd > /dev/null + +echo "Successfully deleted symlinks in /etc/service directory." +exit 0
build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run new file +8 -0
@@ -0,0 +1,8 @@ +#!/bin/sh +sv check xenstored >/dev/null || exit 1 +sv check xenconsoled >/dev/null || exit 1 + +# In case of failure, allow user to run teardown script +sleep 5s + +exec /opt/xen-unstable/lib/xen/bin/qemu-system-i386 -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -monitor /dev/null -serial /dev/null -parallel /dev/null -nodefaults -no-user-config
build/fedora/xen-unstable-runit/xen-init-dom0/run new file +6 -0
@@ -0,0 +1,6 @@ +#!/bin/sh +sv check xenstored >/dev/null || exit 1 + +/opt/xen-unstable/lib/xen/bin/xen-init-dom0 + +exec chpst -b xen-init-dom0 runit-pause
build/fedora/xen-unstable-runit/xenconsoled/run new file +10 -0
@@ -0,0 +1,10 @@ +#!/bin/sh +sv check xen-init-dom0 >/dev/null || exit 1 + +[ ! -d /var/log/xen/console ] && mkdir -p /var/log/xen/console + +# In case of failure, allow user to run teardown script +sleep 5s + +# --log=[none|guest|hv|all] +exec /opt/xen-unstable/sbin/xenconsoled -i --log=none
build/fedora/xen-unstable-runit/xenstored/run new file +20 -0
@@ -0,0 +1,20 @@ +#!/bin/sh +[ ! -d /var/run/xen ] && mkdir -p /var/run/xen +[ ! -d /var/run/xenstored ] && mkdir -p /var/run/xenstored +[ ! -d /var/log/xen ] && mkdir -p /var/log/xen +[ ! -d /var/lib/xen ] && mkdir -p /var/lib/xen +[ ! -d /var/lib/xen/dump ] && mkdir -p /var/lib/xen/dump +[ ! -d /var/lib/xen/xenpaging ] && mkdir -p /var/lib/xen/paging +[ ! -d /var/lib/xenstored ] && mkdir -p /var/lib/xenstored +modprobe -q xen-evtchn || exit 1 +modprobe -q xen-gntdev || exit 1 +modprobe -q xen-gntalloc || exit 1 +mountpoint -q /proc/xen || mount -t xenfs xenfs /proc/xen +mountpoint -q /var/lib/xenstored || mount -t tmpfs xenstored /var/lib/xenstored +grep -q "control_d" /proc/xen/capabilities || exit 1 + +# In case of failure, allow user to run teardown script +sleep 5s + +# Use `--trace-file /var/log/xen/xenstored-trace.log` for logs +exec /opt/xen-unstable/sbin/xenstored --no-fork
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 06/10] build/fedora: Add `xen-unstable-runit/*` scripts
Quoted 24 lines · Rajiv Ranganath
From: Rajiv M Ranganath <[email protected]>
--- build/fedora/xen-unstable-runit/setup.sh | 21 ++++++++++++++++++++ build/fedora/xen-unstable-runit/teardown.sh | 21 ++++++++++++++++++++ .../xen-init-dom0-disk-backend/run | 8 ++++++++ build/fedora/xen-unstable-runit/xen-init-dom0/run | 6 ++++++ build/fedora/xen-unstable-runit/xenconsoled/run | 10 ++++++++++ build/fedora/xen-unstable-runit/xenstored/run | 20 +++++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100755 build/fedora/xen-unstable-runit/setup.sh create mode 100755 build/fedora/xen-unstable-runit/teardown.sh create mode 100755 build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run create mode 100755 build/fedora/xen-unstable-runit/xen-init-dom0/run create mode 100755 build/fedora/xen-unstable-runit/xenconsoled/run create mode 100755 build/fedora/xen-unstable-runit/xenstored/runbuild/fedora/xen-unstable-runit/setup.sh new file +0
-0
build/fedora/xen-unstable-runit/setup.sh line 4
Quoted 4 lines
build/fedora/xen-unstable-runit/setup.sh new file +4
-0@@ -0,0 +1,21 @@ +#!/bin/bash + +set -e +set -o pipefail
In most of my script I tend not to use pipefail because if I use a pipe is exactly because one of the commands might fail. I do it on purpose. This script doesn't even have any pipes, I would drop it.
build/fedora/xen-unstable-runit/setup.sh line 18
Quoted 13 lines
build/fedora/xen-unstable-runit/setup.sh new file +13
-0+# runit RPM creates `/etc/service` directory +if [ ! -d "/etc/service" ]; then + echo "/etc/service directory not found. Please install runit RPM." + exit 1 +fi + +runit_services="xenconsoled xen-init-dom0 xen-init-dom0-disk-backend xenstored" + +pushd /etc/service > /dev/null +for service in $runit_services; do + ln -sf /opt/xen-unstable-runit/$service $service +done +popd > /dev/null
pushd and popd are not useful in this script, I would remove them
build/fedora/xen-unstable-runit/teardown.sh line 4
Quoted 12 lines
build/fedora/xen-unstable-runit/setup.sh new file +2
-0+echo "Successfully created symlinks in /etc/service directory." +exit 0build/fedora/xen-unstable-runit/teardown.sh new file +4
-0@@ -0,0 +1,21 @@ +#!/bin/bash + +set -e +set -o pipefail
same comment on pipefail
build/fedora/xen-unstable-runit/teardown.sh line 18
Quoted 13 lines
build/fedora/xen-unstable-runit/teardown.sh new file +13
-0+# runit RPM creates `/etc/service` directory +if [ ! -d "/etc/service" ]; then + echo "/etc/service directory not found." + exit 1 +fi + +runit_services="xenconsoled xen-init-dom0 xen-init-dom0-disk-backend xenstored" + +pushd /etc/service > /dev/null +for service in $runit_services; do + rm -f $service +done +popd > /dev/null
same comment on pushd and popd
build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run line 1
Quoted 9 lines
build/fedora/xen-unstable-runit/teardown.sh new file +2
-0+echo "Successfully deleted symlinks in /etc/service directory." +exit 0build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run new file +1
-0@@ -0,0 +1,8 @@ +#!/bin/sh
Why /bin/sh instead of bash? The container should have bash installed, right?
If we are using bash, I would consider adding a set -e, also in the other sh scripts below.
Quoted 51 lines
build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run new file +7
-0+sv check xenstored >/dev/null || exit 1 +sv check xenconsoled >/dev/null || exit 1 + +# In case of failure, allow user to run teardown script +sleep 5s + +exec /opt/xen-unstable/lib/xen/bin/qemu-system-i386 -xen-domid 0 -xen-attach -name dom0 -nographic -M xenpv -monitor /dev/null -serial /dev/null -parallel /dev/null -nodefaults -no-user-configbuild/fedora/xen-unstable-runit/xen-init-dom0/run new file +6
-0@@ -0,0 +1,6 @@ +#!/bin/sh +sv check xenstored >/dev/null || exit 1 + +/opt/xen-unstable/lib/xen/bin/xen-init-dom0 + +exec chpst -b xen-init-dom0 runit-pausebuild/fedora/xen-unstable-runit/xenconsoled/run new file +10
-0@@ -0,0 +1,10 @@ +#!/bin/sh +sv check xen-init-dom0 >/dev/null || exit 1 + +[ ! -d /var/log/xen/console ] && mkdir -p /var/log/xen/console + +# In case of failure, allow user to run teardown script +sleep 5s + +# --log=[none|guest|hv|all] +exec /opt/xen-unstable/sbin/xenconsoled -i --log=nonebuild/fedora/xen-unstable-runit/xenstored/run new file +10
-0@@ -0,0 +1,20 @@ +#!/bin/sh +[ ! -d /var/run/xen ] && mkdir -p /var/run/xen +[ ! -d /var/run/xenstored ] && mkdir -p /var/run/xenstored +[ ! -d /var/log/xen ] && mkdir -p /var/log/xen +[ ! -d /var/lib/xen ] && mkdir -p /var/lib/xen +[ ! -d /var/lib/xen/dump ] && mkdir -p /var/lib/xen/dump +[ ! -d /var/lib/xen/xenpaging ] && mkdir -p /var/lib/xen/paging +[ ! -d /var/lib/xenstored ] && mkdir -p /var/lib/xenstored +modprobe -q xen-evtchn || exit 1 +modprobe -q xen-gntdev || exit 1
build/fedora/xen-unstable-runit/xenstored/run line 20
Quoted 10 lines
build/fedora/xen-unstable-runit/xenstored/run new file +10
-0+modprobe -q xen-gntalloc || exit 1 +mountpoint -q /proc/xen || mount -t xenfs xenfs /proc/xen +mountpoint -q /var/lib/xenstored || mount -t tmpfs xenstored /var/lib/xenstored +grep -q "control_d" /proc/xen/capabilities || exit 1 + +# In case of failure, allow user to run teardown script +sleep 5s + +# Use `--trace-file /var/log/xen/xenstored-trace.log` for logs +exec /opt/xen-unstable/sbin/xenstored --no-fork
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 7/10 .circleci/config.yml: Add
In reply to Rajiv RanganathFrom: Rajiv M Ranganath <[email protected]>
--- .circleci/config.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .circleci/config.yml
.circleci/config.yml new file +21 -0
@@ -0,0 +1,21 @@ +version: 2 +jobs: + build: + working_directory: /root + docker: + - image: lambdalinuxfedora/stage1-xen-fedora-buildroot:1708171409 + command: /sbin/my_init + steps: + - run: + # We create `stage1-xen` directory in Dockerfile for local dev + # environment. Removing it here so CircleCI checkout step can work + # correctly + name: Removing stage1-xen directory from GOPATH... + command: | + rm -rf /root/gopath/src/github.com/rkt/stage1-xen + - checkout: + path: /root/gopath/src/github.com/rkt/stage1-xen + - run: + name: Starting run... + command: | + /root/bin/run
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 07/10] .circleci/config.yml: Add
Quoted 1 line · Rajiv Ranganath
From: Rajiv M Ranganath <[email protected]>
Does .circleci need to be in the top directory or could it be under fedora? If possible, I think it would make more sense to introduce it there.
Quoted 24 lines
--- .circleci/config.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .circleci/config.yml.circleci/config.yml new file +11
-0@@ -0,0 +1,21 @@ +version: 2 +jobs: + build: + working_directory: /root + docker: + - image: lambdalinuxfedora/stage1-xen-fedora-buildroot:1708171409 + command: /sbin/my_init + steps: + - run: + # We create `stage1-xen` directory in Dockerfile for local dev + # environment. Removing it here so CircleCI checkout step can work
.circleci/config.yml line 21
Quoted 10 lines
.circleci/config.yml new file +10
-0+ # correctly + name: Removing stage1-xen directory from GOPATH... + command: | + rm -rf /root/gopath/src/github.com/rkt/stage1-xen + - checkout: + path: /root/gopath/src/github.com/rkt/stage1-xen + - run: + name: Starting run... + command: | + /root/bin/run
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 07/10] .circleci/config.yml: Add
Quoted 7 lines · Stefano Stabellini
Quoted 1 line · Rajiv Ranganath
From: Rajiv M Ranganath <[email protected]>
Does .circleci need to be in the top directory or could it be under fedora? If possible, I think it would make more sense to introduce it there.
I would have also preferred the .circleci/ directory to be under build/fedora/.
However, I could not find an option to change this directory. From their documentation [1], I get a sense that this path is hardcoded.
Best,
Rajiv
[1]: https://circleci.com/docs/2.0/configuration-reference/
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 07/10] .circleci/config.yml: Add
Quoted 9 lines · Rajiv Ranganath
Quoted 7 lines · Stefano Stabellini
Quoted 1 line · Rajiv Ranganath
From: Rajiv M Ranganath <[email protected]>
Does .circleci need to be in the top directory or could it be under fedora? If possible, I think it would make more sense to introduce it there.
Quoted 5 lines
I would have also preferred the
.circleci/directory to be underbuild/fedora/.However, I could not find an option to change this directory. From their documentation [1], I get a sense that this path is hardcoded.
Oh well. In that case, we'll keep it in the root directory. Thanks for checking.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 8/10 README.md: Add CircleCI badge
In reply to Rajiv RanganathFrom: Rajiv M Ranganath <[email protected]>
--- README.md | 2 ++ 1 file changed, 2 insertions(+)
README.md +2 -0
@@ -1,5 +1,7 @@ # stage1-xen - A Xen based stage1 for CoreOS rkt +[](https://circleci.com/gh/rkt/stage1-xen/tree/master) + ## Goal CoreOS rkt is a modular container engine with [three stages of execution](https://coreos.com/rkt/docs/latest/devel/stage1-implementors-guide.html). Stage1 is responsible for creating the execution environment for the contained applications.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 08/10] README.md: Add CircleCI badge
Quoted 1 line · Rajiv Ranganath
From: Rajiv M Ranganath <[email protected]>
Quoted 10 lines
--- README.md | 2 ++ 1 file changed, 2 insertions(+)README.md +0
-0
README.md line 7
Quoted 7 lines
README.md +2
-0@@ -1,5 +1,7 @@ # stage1-xen - A Xen based stage1 for CoreOS rkt +[](https://circleci.com/gh/rkt/stage1-xen/tree/master) + ## Goal CoreOS rkt is a modular container engine with [three stages of execution](https://coreos.com/rkt/docs/latest/devel/stage1-implementors-guide.html). Stage1 is responsible for creating the execution environment for the contained applications.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 9/10 build/fedora: Add `RUNNING_STAGE1_XEN.md`
In reply to Rajiv Ranganath--- build/fedora/RUNNING_STAGE1_XEN.md | 383 ++++++++++++++++++++++++++++++++++++ 1 file changed, 383 insertions(+) create mode 100644 build/fedora/RUNNING_STAGE1_XEN.md
build/fedora/RUNNING_STAGE1_XEN.md new file +383 -0
@@ -0,0 +1,383 @@ +# Running Stage1 Xen on Fedora + +This document outlines the steps to get started with stage1-xen on Fedora. They are – + + * [Preparing your machine and installing minimal Fedora](#preparing_your_machine_and_installing_minimal_fedora) + * [Booting into Xen](#booting_into_xen) + * [Launching Xen services](#launching_xen_services) + * [Setting up Xen networking](#setting_up_xen_networking) + * [Running stage1-xen](#running_stage1-xen) + +<a name="preparing_your_machine_and_installing_minimal_fedora"></a> +## Preparing your machine and installing minimal Fedora + +On x86 platform there are two ways to start an operating system or a hypervisor. They are – + + * Legacy BIOS Mode + * EFI Mode + +Latest operating systems and hypervisors including Fedora and Xen has support for EFI mode. If you are unfamiliar with EFI we recommend checking out this [article](http://www.rodsbooks.com/efi-bootloaders/principles.html). + +By default, most BIOS now boot using EFI Mode. In your BIOS menu, there might be an option to toggle _Legacy BIOS Mode_. Do not toggle that option. + +### Enable VT-x and VT-d + +Please ensure that you have enabled VT-x and if available VT-d. + +### Disable Secure Boot + +As we will be booting a custom build of Xen, we need to disable secure boot. You will find an option in your BIOS menu to disable secure boot. + +### Installing minimal Fedora + +The default Fedora installation installs packages that we do not require when running Xen. We recommend doing a minimal Fedora as follows. + + 1. Download Net Install image + + 2. Prepare a USB drive + + 3. Do a minimal Fedora Install + +You can download the Fedora net install image [here](https://alt.fedoraproject.org/). You can select either the Fedora Server or Fedora Workstation image, it doesn't really matter. + +After downloading the net install images, please copy the raw image onto a USB drive. Please see [this](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-making-usb-media.html) link on how to prepare USB drive. + +EFI BIOS comes with a _BIOS Boot Menu_ using which you can select the device to boot from. Insert the USB drive, then go into your BIOS Boot Menu and boot using the USB drive. This should start the Fedora Network Installer. + +In the Fedora Installer, there is a section for under _SOFTWARE_ called _SOFTWARE SELECTION_. In this section please **select** either _Minimal Install_ or _Basic Desktop_, **without** any add-ons. + +**Note:** If there is existing data on the hard disk, please ensure that _INSTALLATION DESTINATION_ under _SYSTEM_ section is appropriately configured. + +Then click on _Begin Installation_ to complete the installation. + +Once the installation is complete, please disable SELinux by editing `/etc/selinux/config`. + +You now have a minimal Fedora Installation, which is good for working with Xen. + +<a name="booting_into_xen"></a> +## Booting into Xen + +Log into Fedora as root and copy over `stage1-xen-build.tar.gz`. Extract `stage1-xen-build.tar.gz` into `/opt` directory. + +```shell +[root@localhost ~]# tar zxvf stage1-xen-build.tar.gz -C /opt + +[root@localhost ~]# ls /opt +qemu-unstable stage1-xen xen-unstable xen-unstable-runit +``` + +This will extract all the build artifacts into `/opt` directory. + +Next we will create a BIOS Boot Menu entry to boot `xen-4.10-unstable.efi`. This will start Xen hypervisor. Xen will then start Fedora as Dom-0 guest. + +On Fedora, EFI system partition (ESP) is usually mounted at `/boot/efi`. This is a `vfat` partition. You can check if EFI system partition is mounted as follows – + +```shell +[root@localhost ~]# mount | grep '\/boot\/efi' +/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro) +``` + +Create a directory for Xen under `/boot/efi/EFI` and copy over `xen-4.10-unstable.efi`. + +```shell +[root@localhost ~]# mkdir -p /boot/efi/EFI/xen +[root@localhost ~]# cp /opt/xen-unstable/boot/efi/EFI/xen/xen-4.10-unstable.efi /boot/efi/EFI/xen/ +``` + +Inspect `/boot/efi/EFI/fedora/grub.cfg`. Under section `### BEGIN /etc/grub.d/10_linux ###` you will find `menuentry` for Fedora kernel and initrd. Look for `linuxefi` and `initrdefi`. Copy over the `vmlinuz` and `initramfs` files that you want to use for your Dom-0 into `/boot/efi/EFI/xen` directory. + +```shell +[root@localhost ~]# cp /boot/vmlinuz-A.B.C-D.fcXX.x86_64 /boot/efi/EFI/xen/ + +[root@localhost ~]# cp /boot/initramfs-A.B.C-D.fcXX.x86_64.img /boot/efi/EFI/xen/ +``` + +Now in `/boot/efi/EFI/xen/` you should have the following files. + +```shell +[root@localhost ~]# ls /boot/efi/EFI/xen/ +initramfs-A.B.C-D.fcXX.x86_64.img vmlinuz-A.B.C-D.fcXX.x86_64 xen-4.10-unstable.efi +``` + +Next create a file `xen-4.10-unstable.cfg` in `/boot/efi/EFI/xen/`. This is the [configuration file](https://xenbits.xen.org/docs/unstable/misc/efi.html) that Xen EFI loader will use to load Dom-0 kernel and initrd. + +Following are contents of `xen-4.10-unstable.cfg` + +``` +[global] +default=fedora-A.B.C-D.fc25 + +[fedora-A.B.C-D.fc25] +options=console=vga,com1 com1=115200,8n1 iommu=verbose ucode=scan flask=disabled conring_size=2097152 loglvl=all autoballoon=0 dom0_mem=4096M,max:4096M +kernel=vmlinuz-A.B.C-D.fc25.x86_64 root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ro rhgb console=hvc0 console=tty0 +ramdisk=initramfs-A.B.C-D.fc25.x86_64.img +``` + +You can find the boot parameters for `kernel=` from `linuxefi` entry in `/boot/efi/EFI/fedora/grub.cfg` Adjust `dom0_mem` appropriately leaving sufficient room for dom-U guests. + +We can now use `efibootmgr` to create a boot entry for Xen. If this the first time you are using `efibootmgr` please checkout the man pages by doing `man efibootmgr`. + +Use `efibootmgr -v` to list all the EFI boot entires. + +```shell +[root@localhost ~]# efibootmgr -v +BootCurrent: 0002 +Timeout: 2 seconds +BootOrder: ... + +[...] + +Boot0001* Xen HD(1,GPT,7d511991-1c25-4e33-900b-1d61d7752f19,0x800,0x82000)/File(\EFI\xen\xen-4.10-unstable.efi) +Boot0002* Fedora HD(1,GPT,7d511991-1c25-4e33-900b-1d61d7752f19,0x800,0x82000)/File(\EFI\fedora\shim.efi) + +[...] +``` + +In the above example there is already an entry for Xen with a boot number of `1`. Fedora is at boot number `2`. Your entires would look different. You won't have the Xen entry as yet! We are showing you an example where the Xen boot entry has already been created. + +Let us now create a boot entry for Xen. First we need to identify the disk and the partition number for EFI system partition. In most cases it is at `/dev/sda1`. You can identify this by doing – + +```shell +[root@localhost ~]# df /boot/efi +Filesystem 1K-blocks Used Available Use% Mounted on +/dev/sda1 262128 63019 199109 25% /boot/efi + +[root@localhost ~]# sgdisk -p /dev/sda +Disk /dev/sda: 976773168 sectors, 465.8 GiB +Logical sector size: 512 bytes + +[...] + +Number Start (sector) End (sector) Size Code Name + 1 2048 534527 260.0 MiB EF00 EFI System Partition +``` + +You can now create boot entry for Xen using the following command. Adjust `/dev/sda` and `-p 1`, according to where your EFI system partition is located. + +```shell +[root@localhost ~]# efibootmgr -c -w -L Xen -d /dev/sda -p 1 -l '\EFI\xen\xen-4.10-unstable.efi' +BootCurrent: ... +Timeout: 2 seconds +BootOrder: 0001,0002,0000,0010,0011,0012,0013,0017,0018,0019,001A,001B,001C + +[...] + +Boot0002* Fedora + +[...] + +Boot0001* Xen +``` + +The output indicates that a boot entry for Xen is created with a boot number of `1`. + +We will now show you how to delete an existing boot entry. + +**Note:** Be careful when deleting boot entires that you have not created. Do not delete Fedora or any entry unless you really know what you are doing. You have been warned! + +```shell +[root@localhost ~]# efibootmgr -b <boot_num> -B + +[root@localhost ~]# efibootmgr -b 1 -B +BootCurrent: ... +BootOrder: ... + +[...] + +Boot0002* Fedora +Boot0010 Setup + +[...] +``` + +Once we have created a boot entry we can now boot into Xen. Restart machine and from the BIOS boot menu select **Xen**. You'll see Xen starting followed by Linux. + +After booting into Linux, you can see if have successfully booted Xen by checking out `dmesg`. + +```shell +[root@localhost ~]# dmesg | grep [Xx]en +[ 0.000000] Xen: [mem 0x0000000000000000-0x0000000000057fff] usable + +[...] + +[ 0.000000] Hypervisor detected: Xen +[ 0.000000] Setting APIC routing to Xen PV. +[ 0.000000] Booting paravirtualized kernel on Xen +[ 0.000000] Xen version: 4.10-unstable (preserve-AD) +[ 0.001000] Xen: using vcpuop timer interface +[ 0.001000] installing Xen timer for CPU 0 +``` + +If you don't see Xen mentioned in your `dmesg`, then please check the previous steps. + +<a name="launching_xen_services"></a> +## Launching Xen services + +In Dom-0, we need to launch services required by Xen. These services are managed using [`runit`](http://smarden.org/runit/) process supervisor. You can download and install `runit` RPMs for Fedora from [here](https://drive.google.com/open?id=0B_tTbuxmuRzIR05wQ3E1eWVyaGs). + +```shell +(ensure correct checksum on the downloaded binary) +[root@localhost ~]# echo "10cc62ffc040c49efa0dd85cbacd70c0712a7c10c58717a376610b786bc49d19 runit-2.1.2-1.1.fc25.tar" | sha256sum -c - +runit-2.1.2-1.1.fc25.tar: OK + +[root@localhost ~]# tar xvf runit-2.1.2-1.1.fc25.tar + +[root@localhost ~]# dnf install -y ./runit/2.1.2/1.1.fc25/x86_64/runit-2.1.2-1.1.fc25.x86_64.rpm + +[root@localhost ~]# pgrep -af runsvdir +1679 runsvdir -P -H /etc/service log: .......................................................... +``` + +In `/opt/xen-unstable-runit` we provide two scripts to manage Xen services. + + * `setup.sh` + * `teardown.sh` + +`setup.sh` is used to setup Xen services. If you are going to be running Fedora directly without Xen, please use `teardown.sh` prior to shutting down Domain-0. This will disable launching Xen services under Fedora without Xen. + +Run `setup.sh` + +```shell +[root@localhost ~]# /opt/xen-unstable-runit/setup.sh +Successfully created symlinks in /etc/service directory. +``` + +You can verify Xen services are running correctly by doing the following – + +```shell +[root@localhost ~]# ls /etc/service | xargs -L 1 -I {} sv status {} +run: xenconsoled: (pid 29673) 115s +run: xen-init-dom0: (pid 29672) 115s +run: xen-init-dom0-disk-backend: (pid 29675) 115s +run: xenstored: (pid 29674) 115s + +[root@localhost ~]# source /opt/stage1-xen/bin/source_path.sh + +[root@localhost ~]# xl info +host : localhost.localdomain +release : 4.11.12-200.fc25.x86_64 +version : #1 SMP Fri Jul 21 16:41:43 UTC 2017 +machine : x86_64 + +[...] + +cc_compile_domain : [unknown] +cc_compile_date : Fri Aug 18 06:32:55 UTC 2017 +build_id : 4a65e1ae96407a8dd47f318db4bdf7d3 +xend_config_format : 4 + +[root@localhost ~]# xl list +Name ID Mem VCPUs State Time(s) +Domain-0 0 4096 4 r----- 121.2 +``` + +<a name="setting_up_xen_networking"></a> +## Setting up Xen networking + +There are multiple ways to do networking on Xen. Two common configurations are [bridging](https://wiki.xenproject.org/wiki/Xen_Networking#Bridging) and [NAT](https://wiki.xenproject.org/wiki/Xen_Networking#Network_Address_Translation). Bridging is the default and most simple configuration to setup. However wireless device drivers are unable to do bridging. To overcome this limitation, we setup an internal bridge and then use NAT to send packets externally. This setup works for both wired and wireless devices. + +```shell +[root@localhost ~]# ip link show +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 +2: enp0s31f6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 + link/ether c8:5b:76:71:40:c8 brd ff:ff:ff:ff:ff:f +3: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000 + link/ether e4:a7:a0:93:9f:13 brd ff:ff:ff:ff:ff:f +``` + +We have two devices `enp0s31f6` which is a wired ethernet device and `wlp4s0` which is a wireless ethernet device. We will use `wlp4s0` in the following example. However similar approach would also work for `enp0s31f6` device. You can also adjust the private network 10.1.1.0/24 to a non-overlapping private subnet. + +```shell +[root@localhost ~]# brctl show +bridge name bridge id STP enabled interfaces + +[root@localhost ~]# ip link add xenbr0 type bridge + +[root@localhost ~]# ip addr add 10.1.1.1/24 dev xenbr0 + +[root@localhost ~]# ip link set xenbr0 up + +[root@localhost ~]# modprobe dummy + +[root@localhost ~]# ip link set dummy0 up + +[root@localhost ~]# brctl addif xenbr0 dummy0 + +[root@localhost ~]# brctl show +bridge name bridge id STP enabled interfaces +xenbr0 8000.d21b5c4113b7 no dummy0 + +[root@localhost ~]# iptables -I FORWARD -j ACCEPT + +[root@localhost ~]# iptables -t nat -I POSTROUTING --out-interface wlp4s0 -j MASQUERADE + +[root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward +``` + +With this configuration we can launch Dom-U Xen guests using the following configuration setting. + +``` +# Network configuration +vif = ['bridge=xenbr0'] +``` + +Then from within the guest, we will need to setup `eth0` interface with a static IP address in the range of 10.1.1.0/24 and gateway as 10.1.1.1. + +<a name="running_stage1-xen"></a> +## Running stage1-xen + +Once we have Xen setup, it is fairly straightforward to run stage1-xen. We provide a script to source all the required binaries from Xen, QEMU and rkt into our path. + +```shell +[root@localhost ~]# source /opt/stage1-xen/bin/source_path.sh +``` + +We can now download images using `rkt` and run them under stage1-xenbits + +```shell +[root@localhost ~]# rkt --insecure-options=image fetch docker://alpine +Downloading sha256:88286f41530 [=============================] 1.99 MB / 1.99 MB +sha512-f84f971f8e01284f4ad0c3cf3efaa770 + +[root@localhost ~]# rkt run sha512-f84f971f8e01284f4ad0c3cf3efaa770 \ + --interactive --insecure-options=image \ + --stage1-path=/opt/stage1-xen/aci/stage1-xen.aci +``` + +Within the container, we can see we are running as a Xen PV guest, and using 9pfs + +```shell +/ # dmesg | grep [Xx]en +[ 0.000000] Xen: [mem 0x0000000000000000-0x000000000009ffff] usable +[ 0.000000] Xen: [mem 0x00000000000a0000-0x00000000000fffff] reserved +[ 0.000000] Xen: [mem 0x0000000000100000-0x000000003fffffff] usable +[ 0.000000] Hypervisor detected: Xen +[ 0.000000] Booting paravirtualized kernel on Xen +[ 0.000000] Xen version: 4.10-unstable (preserve-AD) +[ 0.000000] xen:events: Using FIFO-based ABI + +[...] + +[ 1.605990] Initialising Xen transport for 9pfs +``` + +From Domain-0, we can run `rkt` and `xl` to get the details of the container. + +```shell +[root@localhost ~]# rkt list +UUID APP IMAGE NAME STATE CREATED STARTED NETWORKS +222083ec alpine registry-1.docker.io/library/alpine:latest running 4 minutes ago 4 minutes ago default:ip4=172.16.28.15 + +[root@localhost ~]# xl list +Name ID Mem VCPUs State Time(s) +Domain-0 0 4093 4 r----- 1056.9 +222083ec-d6da-4347-b261-0a733bae6802 1 1024 2 -b---- 2.2 + +[root@localhost ~]# rkt stop 222083ec +"222083ec-d6da-4347-b261-0a733bae6802" + +[root@localhost ~]# xl list +Name ID Mem VCPUs State Time(s) +Domain-0 0 4093 4 r----- 1058.5 +```
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 09/10] build/fedora: Add `RUNNING_STAGE1_XEN.md`
On Mon, 21 Aug 2017, Rajiv Ranganath wrote:
This is a great and well detailed document. I have a few suggestions below to provide some info for people that wants to do it manually.
Quoted 61 lines
--- build/fedora/RUNNING_STAGE1_XEN.md | 383 ++++++++++++++++++++++++++++++++++++ 1 file changed, 383 insertions(+) create mode 100644 build/fedora/RUNNING_STAGE1_XEN.mdbuild/fedora/RUNNING_STAGE1_XEN.md new file +50
-0@@ -0,0 +1,383 @@ +# Running Stage1 Xen on Fedora + +This document outlines the steps to get started with stage1-xen on Fedora. They are – + + * [Preparing your machine and installing minimal Fedora](#preparing_your_machine_and_installing_minimal_fedora) + * [Booting into Xen](#booting_into_xen) + * [Launching Xen services](#launching_xen_services) + * [Setting up Xen networking](#setting_up_xen_networking) + * [Running stage1-xen](#running_stage1-xen) + +<a name="preparing_your_machine_and_installing_minimal_fedora"></a> +## Preparing your machine and installing minimal Fedora + +On x86 platform there are two ways to start an operating system or a hypervisor. They are – + + * Legacy BIOS Mode + * EFI Mode + +Latest operating systems and hypervisors including Fedora and Xen has support for EFI mode. If you are unfamiliar with EFI we recommend checking out this [article](http://www.rodsbooks.com/efi-bootloaders/principles.html). + +By default, most BIOS now boot using EFI Mode. In your BIOS menu, there might be an option to toggle _Legacy BIOS Mode_. Do not toggle that option. + +### Enable VT-x and VT-d + +Please ensure that you have enabled VT-x and if available VT-d. + +### Disable Secure Boot + +As we will be booting a custom build of Xen, we need to disable secure boot. You will find an option in your BIOS menu to disable secure boot. + +### Installing minimal Fedora + +The default Fedora installation installs packages that we do not require when running Xen. We recommend doing a minimal Fedora as follows. + + 1. Download Net Install image + + 2. Prepare a USB drive + + 3. Do a minimal Fedora Install + +You can download the Fedora net install image [here](https://alt.fedoraproject.org/). You can select either the Fedora Server or Fedora Workstation image, it doesn't really matter. + +After downloading the net install images, please copy the raw image onto a USB drive. Please see [this](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-making-usb-media.html) link on how to prepare USB drive. + +EFI BIOS comes with a _BIOS Boot Menu_ using which you can select the device to boot from. Insert the USB drive, then go into your BIOS Boot Menu and boot using the USB drive. This should start the Fedora Network Installer. + +In the Fedora Installer, there is a section for under _SOFTWARE_ called _SOFTWARE SELECTION_. In this section please **select** either _Minimal Install_ or _Basic Desktop_, **without** any add-ons. + +**Note:** If there is existing data on the hard disk, please ensure that _INSTALLATION DESTINATION_ under _SYSTEM_ section is appropriately configured. +
build/fedora/RUNNING_STAGE1_XEN.md line 60
Quoted 10 lines
build/fedora/RUNNING_STAGE1_XEN.md new file +10
-0+Then click on _Begin Installation_ to complete the installation. + +Once the installation is complete, please disable SELinux by editing `/etc/selinux/config`. + +You now have a minimal Fedora Installation, which is good for working with Xen. + +<a name="booting_into_xen"></a> +## Booting into Xen + +Log into Fedora as root and copy over `stage1-xen-build.tar.gz`. Extract `stage1-xen-build.tar.gz` into `/opt` directory.
The doc is good. As for other patches in this series, I spend a couple of words on the build without a Docker container. In this case, I would say:
"Build and Install Xen and stage1-xen. Please see buildroot-README.md on how to do it. If you follow the automatic build with Docker, then copy over stage1-xen-build.tar.gz. Extract stage1-xen-build.tar.gz into /opt directory."
Quoted 145 lines
build/fedora/RUNNING_STAGE1_XEN.md new file +145
-0+```shell +[root@localhost ~]# tar zxvf stage1-xen-build.tar.gz -C /opt + +[root@localhost ~]# ls /opt +qemu-unstable stage1-xen xen-unstable xen-unstable-runit +``` + +This will extract all the build artifacts into `/opt` directory. + +Next we will create a BIOS Boot Menu entry to boot `xen-4.10-unstable.efi`. This will start Xen hypervisor. Xen will then start Fedora as Dom-0 guest. + +On Fedora, EFI system partition (ESP) is usually mounted at `/boot/efi`. This is a `vfat` partition. You can check if EFI system partition is mounted as follows – + +```shell +[root@localhost ~]# mount | grep '\/boot\/efi' +/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro) +``` + +Create a directory for Xen under `/boot/efi/EFI` and copy over `xen-4.10-unstable.efi`. + +```shell +[root@localhost ~]# mkdir -p /boot/efi/EFI/xen +[root@localhost ~]# cp /opt/xen-unstable/boot/efi/EFI/xen/xen-4.10-unstable.efi /boot/efi/EFI/xen/ +``` + +Inspect `/boot/efi/EFI/fedora/grub.cfg`. Under section `### BEGIN /etc/grub.d/10_linux ###` you will find `menuentry` for Fedora kernel and initrd. Look for `linuxefi` and `initrdefi`. Copy over the `vmlinuz` and `initramfs` files that you want to use for your Dom-0 into `/boot/efi/EFI/xen` directory. + +```shell +[root@localhost ~]# cp /boot/vmlinuz-A.B.C-D.fcXX.x86_64 /boot/efi/EFI/xen/ + +[root@localhost ~]# cp /boot/initramfs-A.B.C-D.fcXX.x86_64.img /boot/efi/EFI/xen/ +``` + +Now in `/boot/efi/EFI/xen/` you should have the following files. + +```shell +[root@localhost ~]# ls /boot/efi/EFI/xen/ +initramfs-A.B.C-D.fcXX.x86_64.img vmlinuz-A.B.C-D.fcXX.x86_64 xen-4.10-unstable.efi +``` + +Next create a file `xen-4.10-unstable.cfg` in `/boot/efi/EFI/xen/`. This is the [configuration file](https://xenbits.xen.org/docs/unstable/misc/efi.html) that Xen EFI loader will use to load Dom-0 kernel and initrd. + +Following are contents of `xen-4.10-unstable.cfg` + +``` +[global] +default=fedora-A.B.C-D.fc25 + +[fedora-A.B.C-D.fc25] +options=console=vga,com1 com1=115200,8n1 iommu=verbose ucode=scan flask=disabled conring_size=2097152 loglvl=all autoballoon=0 dom0_mem=4096M,max:4096M +kernel=vmlinuz-A.B.C-D.fc25.x86_64 root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ro rhgb console=hvc0 console=tty0 +ramdisk=initramfs-A.B.C-D.fc25.x86_64.img +``` + +You can find the boot parameters for `kernel=` from `linuxefi` entry in `/boot/efi/EFI/fedora/grub.cfg` Adjust `dom0_mem` appropriately leaving sufficient room for dom-U guests. + +We can now use `efibootmgr` to create a boot entry for Xen. If this the first time you are using `efibootmgr` please checkout the man pages by doing `man efibootmgr`. + +Use `efibootmgr -v` to list all the EFI boot entires. + +```shell +[root@localhost ~]# efibootmgr -v +BootCurrent: 0002 +Timeout: 2 seconds +BootOrder: ... + +[...] + +Boot0001* Xen HD(1,GPT,7d511991-1c25-4e33-900b-1d61d7752f19,0x800,0x82000)/File(\EFI\xen\xen-4.10-unstable.efi) +Boot0002* Fedora HD(1,GPT,7d511991-1c25-4e33-900b-1d61d7752f19,0x800,0x82000)/File(\EFI\fedora\shim.efi) + +[...] +``` + +In the above example there is already an entry for Xen with a boot number of `1`. Fedora is at boot number `2`. Your entires would look different. You won't have the Xen entry as yet! We are showing you an example where the Xen boot entry has already been created. + +Let us now create a boot entry for Xen. First we need to identify the disk and the partition number for EFI system partition. In most cases it is at `/dev/sda1`. You can identify this by doing – + +```shell +[root@localhost ~]# df /boot/efi +Filesystem 1K-blocks Used Available Use% Mounted on +/dev/sda1 262128 63019 199109 25% /boot/efi + +[root@localhost ~]# sgdisk -p /dev/sda +Disk /dev/sda: 976773168 sectors, 465.8 GiB +Logical sector size: 512 bytes + +[...] + +Number Start (sector) End (sector) Size Code Name + 1 2048 534527 260.0 MiB EF00 EFI System Partition +``` + +You can now create boot entry for Xen using the following command. Adjust `/dev/sda` and `-p 1`, according to where your EFI system partition is located. + +```shell +[root@localhost ~]# efibootmgr -c -w -L Xen -d /dev/sda -p 1 -l '\EFI\xen\xen-4.10-unstable.efi' +BootCurrent: ... +Timeout: 2 seconds +BootOrder: 0001,0002,0000,0010,0011,0012,0013,0017,0018,0019,001A,001B,001C + +[...] + +Boot0002* Fedora + +[...] + +Boot0001* Xen +``` + +The output indicates that a boot entry for Xen is created with a boot number of `1`. + +We will now show you how to delete an existing boot entry. + +**Note:** Be careful when deleting boot entires that you have not created. Do not delete Fedora or any entry unless you really know what you are doing. You have been warned! + +```shell +[root@localhost ~]# efibootmgr -b <boot_num> -B + +[root@localhost ~]# efibootmgr -b 1 -B +BootCurrent: ... +BootOrder: ... + +[...] + +Boot0002* Fedora +Boot0010 Setup + +[...] +``` + +Once we have created a boot entry we can now boot into Xen. Restart machine and from the BIOS boot menu select **Xen**. You'll see Xen starting followed by Linux. + +After booting into Linux, you can see if have successfully booted Xen by checking out `dmesg`. + +```shell +[root@localhost ~]# dmesg | grep [Xx]en +[ 0.000000] Xen: [mem 0x0000000000000000-0x0000000000057fff] usable + +[...] + +[ 0.000000] Hypervisor detected: Xen +[ 0.000000] Setting APIC routing to Xen PV. +[ 0.000000] Booting paravirtualized kernel on Xen +[ 0.000000] Xen version: 4.10-unstable (preserve-AD)
build/fedora/RUNNING_STAGE1_XEN.md line 216
Quoted 10 lines
build/fedora/RUNNING_STAGE1_XEN.md new file +10
-0+[ 0.001000] Xen: using vcpuop timer interface +[ 0.001000] installing Xen timer for CPU 0 +``` + +If you don't see Xen mentioned in your `dmesg`, then please check the previous steps. + +<a name="launching_xen_services"></a> +## Launching Xen services + +In Dom-0, we need to launch services required by Xen. These services are managed using [`runit`](http://smarden.org/runit/) process supervisor. You can download and install `runit` RPMs for Fedora from [here](https://drive.google.com/open?id=0B_tTbuxmuRzIR05wQ3E1eWVyaGs).
Similar to above, I would say:
"In Dom-0, we need to launch the services required by Xen. If you installed Xen by yourself, please make sure that the xencommons init script has been started at boot. Otherwise, the boot services are managed using [runit]" ...
Quoted 103 lines
build/fedora/RUNNING_STAGE1_XEN.md new file +103
-0+```shell +(ensure correct checksum on the downloaded binary) +[root@localhost ~]# echo "10cc62ffc040c49efa0dd85cbacd70c0712a7c10c58717a376610b786bc49d19 runit-2.1.2-1.1.fc25.tar" | sha256sum -c - +runit-2.1.2-1.1.fc25.tar: OK + +[root@localhost ~]# tar xvf runit-2.1.2-1.1.fc25.tar + +[root@localhost ~]# dnf install -y ./runit/2.1.2/1.1.fc25/x86_64/runit-2.1.2-1.1.fc25.x86_64.rpm + +[root@localhost ~]# pgrep -af runsvdir +1679 runsvdir -P -H /etc/service log: .......................................................... +``` + +In `/opt/xen-unstable-runit` we provide two scripts to manage Xen services. + + * `setup.sh` + * `teardown.sh` + +`setup.sh` is used to setup Xen services. If you are going to be running Fedora directly without Xen, please use `teardown.sh` prior to shutting down Domain-0. This will disable launching Xen services under Fedora without Xen. + +Run `setup.sh` + +```shell +[root@localhost ~]# /opt/xen-unstable-runit/setup.sh +Successfully created symlinks in /etc/service directory. +``` + +You can verify Xen services are running correctly by doing the following – + +```shell +[root@localhost ~]# ls /etc/service | xargs -L 1 -I {} sv status {} +run: xenconsoled: (pid 29673) 115s +run: xen-init-dom0: (pid 29672) 115s +run: xen-init-dom0-disk-backend: (pid 29675) 115s +run: xenstored: (pid 29674) 115s + +[root@localhost ~]# source /opt/stage1-xen/bin/source_path.sh + +[root@localhost ~]# xl info +host : localhost.localdomain +release : 4.11.12-200.fc25.x86_64 +version : #1 SMP Fri Jul 21 16:41:43 UTC 2017 +machine : x86_64 + +[...] + +cc_compile_domain : [unknown] +cc_compile_date : Fri Aug 18 06:32:55 UTC 2017 +build_id : 4a65e1ae96407a8dd47f318db4bdf7d3 +xend_config_format : 4 + +[root@localhost ~]# xl list +Name ID Mem VCPUs State Time(s) +Domain-0 0 4096 4 r----- 121.2 +``` + +<a name="setting_up_xen_networking"></a> +## Setting up Xen networking + +There are multiple ways to do networking on Xen. Two common configurations are [bridging](https://wiki.xenproject.org/wiki/Xen_Networking#Bridging) and [NAT](https://wiki.xenproject.org/wiki/Xen_Networking#Network_Address_Translation). Bridging is the default and most simple configuration to setup. However wireless device drivers are unable to do bridging. To overcome this limitation, we setup an internal bridge and then use NAT to send packets externally. This setup works for both wired and wireless devices. + +```shell +[root@localhost ~]# ip link show +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 +2: enp0s31f6: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 + link/ether c8:5b:76:71:40:c8 brd ff:ff:ff:ff:ff:f +3: wlp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000 + link/ether e4:a7:a0:93:9f:13 brd ff:ff:ff:ff:ff:f +``` + +We have two devices `enp0s31f6` which is a wired ethernet device and `wlp4s0` which is a wireless ethernet device. We will use `wlp4s0` in the following example. However similar approach would also work for `enp0s31f6` device. You can also adjust the private network 10.1.1.0/24 to a non-overlapping private subnet. + +```shell +[root@localhost ~]# brctl show +bridge name bridge id STP enabled interfaces + +[root@localhost ~]# ip link add xenbr0 type bridge + +[root@localhost ~]# ip addr add 10.1.1.1/24 dev xenbr0 + +[root@localhost ~]# ip link set xenbr0 up + +[root@localhost ~]# modprobe dummy + +[root@localhost ~]# ip link set dummy0 up + +[root@localhost ~]# brctl addif xenbr0 dummy0 + +[root@localhost ~]# brctl show +bridge name bridge id STP enabled interfaces +xenbr0 8000.d21b5c4113b7 no dummy0 + +[root@localhost ~]# iptables -I FORWARD -j ACCEPT + +[root@localhost ~]# iptables -t nat -I POSTROUTING --out-interface wlp4s0 -j MASQUERADE + +[root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward +``` + +With this configuration we can launch Dom-U Xen guests using the following configuration setting. + +```
build/fedora/RUNNING_STAGE1_XEN.md line 330
Quoted 10 lines
build/fedora/RUNNING_STAGE1_XEN.md new file +10
-0+# Network configuration +vif = ['bridge=xenbr0'] +``` + +Then from within the guest, we will need to setup `eth0` interface with a static IP address in the range of 10.1.1.0/24 and gateway as 10.1.1.1. + +<a name="running_stage1-xen"></a> +## Running stage1-xen + +Once we have Xen setup, it is fairly straightforward to run stage1-xen. We provide a script to source all the required binaries from Xen, QEMU and rkt into our path.
As for the previous cases:
"If you installed Xen on your system by yourself, xl is on your path already. Otherwise" ...
Quoted 44 lines
build/fedora/RUNNING_STAGE1_XEN.md new file +43
-0+ +```shell +[root@localhost ~]# source /opt/stage1-xen/bin/source_path.sh +``` + +We can now download images using `rkt` and run them under stage1-xenbits + +```shell +[root@localhost ~]# rkt --insecure-options=image fetch docker://alpine +Downloading sha256:88286f41530 [=============================] 1.99 MB / 1.99 MB +sha512-f84f971f8e01284f4ad0c3cf3efaa770 + +[root@localhost ~]# rkt run sha512-f84f971f8e01284f4ad0c3cf3efaa770 \ + --interactive --insecure-options=image \ + --stage1-path=/opt/stage1-xen/aci/stage1-xen.aci +``` + +Within the container, we can see we are running as a Xen PV guest, and using 9pfs + +```shell +/ # dmesg | grep [Xx]en +[ 0.000000] Xen: [mem 0x0000000000000000-0x000000000009ffff] usable +[ 0.000000] Xen: [mem 0x00000000000a0000-0x00000000000fffff] reserved +[ 0.000000] Xen: [mem 0x0000000000100000-0x000000003fffffff] usable +[ 0.000000] Hypervisor detected: Xen +[ 0.000000] Booting paravirtualized kernel on Xen +[ 0.000000] Xen version: 4.10-unstable (preserve-AD) +[ 0.000000] xen:events: Using FIFO-based ABI + +[...] + +[ 1.605990] Initialising Xen transport for 9pfs +``` + +From Domain-0, we can run `rkt` and `xl` to get the details of the container. + +```shell +[root@localhost ~]# rkt list +UUID APP IMAGE NAME STATE CREATED STARTED NETWORKS +222083ec alpine registry-1.docker.io/library/alpine:latest running 4 minutes ago 4 minutes ago default:ip4=172.16.28.15 + +[root@localhost ~]# xl list +Name ID Mem VCPUs State Time(s)
build/fedora/RUNNING_STAGE1_XEN.md line 383
Quoted 10 lines
build/fedora/RUNNING_STAGE1_XEN.md new file +10
-0+Domain-0 0 4093 4 r----- 1056.9 +222083ec-d6da-4347-b261-0a733bae6802 1 1024 2 -b---- 2.2 + +[root@localhost ~]# rkt stop 222083ec +"222083ec-d6da-4347-b261-0a733bae6802" + +[root@localhost ~]# xl list +Name ID Mem VCPUs State Time(s) +Domain-0 0 4093 4 r----- 1058.5 +```
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 10/10 BUILDING.md: Add Fedora instructions
In reply to Rajiv Ranganath--- BUILDING.md | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)
BUILDING.md +30 -5
@@ -1,7 +1,13 @@ # Build -stage1-xen requires new Xen and QEMU versions at the time of writing. You are unlikely to find them already packaged with your distro. This document describes how to build and install the latest Xen and QEMU from scratch. In addition, given that CoreOS rkt is also missing from reasonably new distros such as Ubuntu Xenial Xerus, I added instructions on how to build that too. The document includes the dependencies needed for the build based on Ubuntu Xenial Xerus. +stage1-xen requires new Xen and QEMU versions at the time of writing. You are unlikely to find them already packaged with your distro. This document describes how to build and install the latest Xen, QEMU and rkt from scratch for Ubuntu Xenial Xerus and Fedora. -## Building Xen + * [Ubuntu Xenial Xerus](#build_ubuntu) + * [Fedora](#build_fedora) + +<a name="build_ubuntu"></a> +## Ubuntu Xenial Xerus + +### Building Xen ``` apt-get install git build-essential python-dev gettext uuid-dev libncurses5-dev libyajl-dev libaio-dev pkg-config libglib2.0-dev libssl-dev libpixman-1-dev bridge-utils wget libfdt-dev bin86 bcc liblzma-dev iasl libc6-dev-i386
@@ -17,7 +23,7 @@ reboot Make sure to select Xen at boot, or edit /boot/grub/grub.cfg to make it the default, changing "set default="0" to point to the appropriate entry below (the one booting xen.gz), which could be entry number "4" for example. -## Building QEMU +### Building QEMU ``` apt-get install libglib2.0-dev libpixman-1-dev libcap-dev libattr1-dev
@@ -54,7 +60,7 @@ make install cp i386-softmmu/qemu-system-i386 /usr/lib/xen/bin/ ``` -## Building CoreOS rkt +### Building CoreOS rkt ``` apt-get install golang automake libacl1-dev libsystemd-dev ./configure --disable-tpm --with-stage1-flavors=coreos
@@ -62,7 +68,7 @@ make cp build-rkt-1.26.0+git/target/bin/rkt /usr/sbin ``` -## Building stage1-xen +### Building stage1-xen ``` apt-get install busybox-static jq
@@ -72,3 +78,22 @@ export GOPATH=/path/to/gopath bash build.sh cp stage1-xen.aci /home/username ``` + +<a name="build_fedora"></a> +## Fedora + +On Fedora we build stage1-xen artifacts (Xen, QEMU and rkt) in a docker container as follows – + +``` +cd stage1-xen + +docker pull lambdalinuxfedora/stage1-xen-fedora-buildroot + +docker run --rm \ + -v `pwd`:/root/gopath/src/github.com/rkt/stage1-xen \ + -v /tmp:/tmp \ + -t -i lambdalinuxfedora/stage1-xen-fedora-buildroot \ + /sbin/my_init -- /root/bin/run +``` + +Once `docker run` completes, the build artifact `stage1-xen-build.tar.gz` is generated in `/tmp` directory. Please see [RUNNING_STAGE1_XEN.md](build/fedora/RUNNING_STAGE1_XEN.md) for details on how to setup Fedora for running stage1-xen.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [stage1-xen (RFC) PATCH 10/10] BUILDING.md: Add Fedora instructions
BUILDING.md line 2
Quoted 12 lines · Rajiv Ranganath
--- BUILDING.md | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)BUILDING.md +1
-1@@ -1,7 +1,13 @@ # Build -stage1-xen requires new Xen and QEMU versions at the time of writing. You are unlikely to find them already packaged with your distro. This document describes how to build and install the latest Xen and QEMU from scratch. In addition, given that CoreOS rkt is also missing from reasonably new distros such as Ubuntu Xenial Xerus, I added instructions on how to build that too. The document includes the dependencies needed for the build based on Ubuntu Xenial Xerus. +stage1-xen requires new Xen and QEMU versions at the time of writing. You are unlikely to find them already packaged with your distro. This document describes how to build and install the latest Xen, QEMU and rkt from scratch for Ubuntu Xenial Xerus and Fedora.
I would clarify that the build and installation method for Ubuntu and the one for Fedora use very different approaches. I would add:
... "for Ubuntu Xenial Xerus and Fedora. Differently from the documentation for Ubuntu, the documentation for Fedora uses a separate Docker container for the build."
BUILDING.md line 5
Quoted 3 lines
BUILDING.md +2
-1-## Building Xen + * [Ubuntu Xenial Xerus](#build_ubuntu) + * [Fedora](#build_fedora)
[Fedora via container]
Quoted 47 lines
BUILDING.md +16
-3+<a name="build_ubuntu"></a> +## Ubuntu Xenial Xerus + +### Building Xen ``` apt-get install git build-essential python-dev gettext uuid-dev libncurses5-dev libyajl-dev libaio-dev pkg-config libglib2.0-dev libssl-dev libpixman-1-dev bridge-utils wget libfdt-dev bin86 bcc liblzma-dev iasl libc6-dev-i386@@ -17,7 +23,7 @@ reboot Make sure to select Xen at boot, or edit /boot/grub/grub.cfg to make it the default, changing "set default="0" to point to the appropriate entry below (the one booting xen.gz), which could be entry number "4" for example. -## Building QEMU +### Building QEMU ``` apt-get install libglib2.0-dev libpixman-1-dev libcap-dev libattr1-dev@@ -54,7 +60,7 @@ make install cp i386-softmmu/qemu-system-i386 /usr/lib/xen/bin/ ``` -## Building CoreOS rkt +### Building CoreOS rkt ``` apt-get install golang automake libacl1-dev libsystemd-dev ./configure --disable-tpm --with-stage1-flavors=coreos@@ -62,7 +68,7 @@ make cp build-rkt-1.26.0+git/target/bin/rkt /usr/sbin ``` -## Building stage1-xen +### Building stage1-xen ``` apt-get install busybox-static jq@@ -72,3 +78,22 @@ export GOPATH=/path/to/gopath bash build.sh cp stage1-xen.aci /home/username ``` + +<a name="build_fedora"></a> +## Fedora + +On Fedora we build stage1-xen artifacts (Xen, QEMU and rkt) in a docker container as follows – + +``` +cd stage1-xen +
BUILDING.md export GOPATH=/path/to/gopath · line 99
Quoted 10 lines
BUILDING.md +10
-0+docker pull lambdalinuxfedora/stage1-xen-fedora-buildroot + +docker run --rm \ + -v `pwd`:/root/gopath/src/github.com/rkt/stage1-xen \ + -v /tmp:/tmp \ + -t -i lambdalinuxfedora/stage1-xen-fedora-buildroot \ + /sbin/my_init -- /root/bin/run +``` + +Once `docker run` completes, the build artifact `stage1-xen-build.tar.gz` is generated in `/tmp` directory. Please see [RUNNING_STAGE1_XEN.md](build/fedora/RUNNING_STAGE1_XEN.md) for details on how to setup Fedora for running stage1-xen.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 40 lines · Rajiv Ranganath
Hi Stefanao,
Following series adds documentation on how to use stage1-xen on Fedora. It also adds continuous build support using CircleCI.
Xen, Qemu, rkt and stage1 ACI image are built using a Fedora based container. This setup allows for a reproducible build environment that we can use locally and also within a CI system.
Below is an overview of the series -
build/fedora: Add
buildroot-README.md
build/fedora: Addbuildroot-Dockerfile
build/fedora: Addrun
build/fedoradirectory is introduced. In this directory we can maintain documentation, scripts and patches relating to Fedora support for stage1-xen.
buildroot-README.mddescribes a two stage container build process. This is modeled on how we do builds for distro packages, but using containers instead of a mock/chroot environment. The build artifact produced byrunscript is a tarball, instead of a rpm or deb file.build/fedora: Add
source_path.sh
build/fedora: Addxen-unstable-runit/*scriptsScripts used within build artifact tarball.
.circleci/config.yml: Add
README.md: Add CircleCI badgeAdds CircleCI support. Here [1][2] is a temporary repo with Circle CI support enabled.
build/fedora: Add
RUNNING_STAGE1_XEN.md
BUILDING.md: Add Fedora instructionsUpdate docs.
Quoted 7 lines
Please let me know your comments. Thank you!
Best,
Rajiv[1]: https://github.com/lambda-linux-fedora/stage1-xen/tree/wip
[2]: https://circleci.com/gh/lambda-linux-fedora/stage1-xen/tree/wip
Hi Rajiv,
Thank you very much for your work on this! From an high level, I think it is very good.
One thing I would like to ask is that you make it just a bit more modular. I think it is OK to use a Docker container for the build, but I would like to support users that prefer to build on their own system by calling build/fedora/run manually, the same script used by the Docker container.
I don't think it would be a lot of effort to change the docs and the script to allow that but it would be of great benefit.
I'll add more comments on the patches.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel