mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 01:29:07 +00:00
clear-containers: Add script to launch base OS and kernel
This commit adds the script qemu.sh that will be used in a docker container (created with Dockerfile). This script will crate qemu instance to lauch a Clear Container base OS with a kernel generated with moby. Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
parent
f2569c0e75
commit
b485f729e8
@ -70,6 +70,17 @@ following command:
|
||||
./bin/moby build ./projects/clear-containers/clear-containers.yml
|
||||
```
|
||||
|
||||
3. Test kernel
|
||||
|
||||
The Makefile target `qemu-lite` from `projects/clear-containers/tools`
|
||||
will launch the Clear Containers base OS and the
|
||||
with kernel built with moby. Use the `root` user to access to the test system,
|
||||
it will ask to setup a password.
|
||||
|
||||
```
|
||||
cd projects/clear-containers/tools
|
||||
make qemu-lite
|
||||
```
|
||||
|
||||
The file `clear-containers-bzImage` is not a bzImage\*. The file
|
||||
is a vmlinux image, see TODO. The [cc-oci-runtime] project can be
|
||||
|
10
projects/clear-containers/tools/Dockerfile
Normal file
10
projects/clear-containers/tools/Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM fedora:25
|
||||
|
||||
RUN dnf install -y 'dnf-command(config-manager)'
|
||||
RUN dnf config-manager --add-repo \
|
||||
http://download.opensuse.org/repositories/home:clearlinux:preview:clear-containers-2.1/Fedora\_25/home:clearlinux:preview:clear-containers-2.1.repo
|
||||
|
||||
RUN dnf install -y qemu-lite clear-containers-image linux-container
|
||||
COPY qemu.sh /bin/qemu.sh
|
||||
WORKDIR /root
|
||||
ENTRYPOINT ["qemu.sh"]
|
35
projects/clear-containers/tools/Makefile
Normal file
35
projects/clear-containers/tools/Makefile
Normal file
@ -0,0 +1,35 @@
|
||||
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
|
||||
MKFILE_DIR := $(dir $(MKFILE_PATH))
|
||||
ifdef http_proxy
|
||||
BUILD_PROXY = --build-arg http_proxy=$(http_proxy)
|
||||
RUN_PROXY = --env http_proxy=$(http_proxy)
|
||||
endif
|
||||
|
||||
ifdef https_proxy
|
||||
BUILD_PROXY += --build-arg https_proxy=$(https_proxy)
|
||||
RUN_PROXY += --env https_proxy=$(https_proxy)
|
||||
endif
|
||||
|
||||
CMDLINE_FILE=clear-containers-cmdline
|
||||
KERNEL_FILE=clear-containers-bzImage
|
||||
|
||||
IMAGE=qemu-lite
|
||||
|
||||
docker_image: Dockerfile
|
||||
docker build $(BUILD_PROXY) -t clearcontainers/$(IMAGE) .
|
||||
|
||||
qemu-lite: docker_image $(KERNEL_FILE) $(CMDLINE_FILE)
|
||||
docker run --privileged --rm -ti \
|
||||
-v $$(pwd)/$(CMDLINE_FILE):/root/clear-containers-cmdline \
|
||||
-v $$(pwd)/$(KERNEL_FILE):/root/clear-containers-vmlinux \
|
||||
clearcontainers/$(IMAGE) \
|
||||
bash
|
||||
|
||||
$(KERNEL_FILE):
|
||||
$(MKFILE_DIR)/../../../bin/moby build $(MKFILE_DIR)/../clear-containers.yml
|
||||
|
||||
push: docker_image
|
||||
docker push clearcontainers/$(IMAGE)
|
||||
|
||||
clean:
|
||||
rm -rf *-bzImage *-cmdline *.img
|
49
projects/clear-containers/tools/qemu.sh
Executable file
49
projects/clear-containers/tools/qemu.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
function die {
|
||||
echo >&2 "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
img=/usr/share/clear-containers/clear-containers.img
|
||||
img=$(readlink -f "$img")
|
||||
img_size=$(du -b "${img}" | awk '{print $1}')
|
||||
|
||||
kernel="$(pwd)/clear-containers-vmlinux"
|
||||
kernel_cmdline_file="$(pwd)/clear-containers-cmdline"
|
||||
[ -f "${img}" ] || die "Image s required"
|
||||
[ -f "${kernel}" ] || die "Kernel is required"
|
||||
[ -f ${kernel_cmdline_file} ] || \
|
||||
die "Kernel cmdline file is required"
|
||||
|
||||
kernel_cmdline=$(cat "$kernel_cmdline_file")
|
||||
|
||||
cmd="/usr/bin/qemu-lite-system-x86_64"
|
||||
cmd="$cmd -machine pc-lite,accel=kvm,kernel_irqchip,nvdimm"
|
||||
cmd="$cmd -device nvdimm,memdev=mem0,id=nv0"
|
||||
#image
|
||||
cmd="$cmd -object memory-backend-file,id=mem0,mem-path=${img},size=${img_size}"
|
||||
#memory
|
||||
cmd="$cmd -m 2G,slots=2,maxmem=3G"
|
||||
#kernel
|
||||
cmd="$cmd -kernel ${kernel}"
|
||||
cmd="$cmd -append '${kernel_cmdline}'"
|
||||
#cpu
|
||||
cmd="$cmd -smp 2,sockets=1,cores=2,threads=1"
|
||||
cmd="$cmd -cpu host"
|
||||
#clock
|
||||
cmd="$cmd -rtc base=utc,driftfix=slew"
|
||||
cmd="$cmd -no-user-config"
|
||||
cmd="$cmd -nodefaults"
|
||||
cmd="$cmd -global"
|
||||
cmd="$cmd kvm-pit.lost_tick_policy=discard"
|
||||
#console
|
||||
cmd="$cmd -device virtio-serial-pci,id=virtio-serial0"
|
||||
cmd="$cmd -chardev stdio,id=charconsole0,signal=off"
|
||||
cmd="$cmd -device virtconsole,chardev=charconsole0,id=console0"
|
||||
cmd="$cmd -nographic"
|
||||
cmd="$cmd -vga none"
|
||||
|
||||
eval "$cmd"
|
Loading…
Reference in New Issue
Block a user