A script to launch real time guest 63/4563/5
authorYunhong Jiang <yunhong.jiang@linux.intel.com>
Fri, 4 Dec 2015 23:01:29 +0000 (18:01 -0500)
committerYunhong Jiang <yunhong.jiang@linux.intel.com>
Wed, 6 Jan 2016 03:32:48 +0000 (19:32 -0800)
Launch real time guest need special options like lock memory etc. A
script is used to achieved this. We invoke the qemu utility directly
instead of going through middle layer like libvirt, to get better
controll.

Change-Id: Ia6ad7313463e2f858516bddd4a4b58e95d8c943e
Signed-off-by: David Su <david.w.su@intel.com>
Signed-off-by: Yunhong Jiang <yunhong.jiang@linux.intel.com>
ci/envs/host-run-qemu.sh [new file with mode: 0755]

diff --git a/ci/envs/host-run-qemu.sh b/ci/envs/host-run-qemu.sh
new file mode 100755 (executable)
index 0000000..c7a2fec
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+##############################################################################
+## Copyright (c) 2015 Intel Corp.
+##
+## All rights reserved. This program and the accompanying materials
+## are made available under the terms of the Apache License, Version 2.0
+## which accompanies this distribution, and is available at
+## http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+source host-config
+
+cpumask () {
+    m=$((1<<${1}))
+    printf 0x%x ${m}
+}
+
+qmp_sock="/tmp/qmp-sock-$$"
+
+${qemu} -smp ${guest_cpus} -monitor unix:${qmp_sock},server,nowait -daemonize \
+    -cpu host,migratable=off,+invtsc,+tsc-deadline,pmu=off \
+    -realtime mlock=on -mem-prealloc -enable-kvm -m 1G \
+    -mem-path /mnt/hugetlbfs-1g \
+    -drive file=/root/workspace/image/guest.img,cache=none,aio=threads \
+    -netdev user,id=guest0,hostfwd=tcp::5555-:22 \
+    -device virtio-net-pci,netdev=guest0 \
+    -nographic -serial /dev/null -parallel /dev/null
+
+i=0
+for c in `echo ${host_isolcpus} | sed 's/,/ /g'` ; do
+    cpu[$i]=${c}
+    i=`expr $i + 1`
+done
+
+threads=`echo "info cpus" | nc -U ${qmp_sock} | grep thread_id | cut -d= -f3`
+
+# Bind QEMU processor threads to RT CPUs
+i=0
+for tid in ${threads} ; do
+    tid=`printf %d ${tid}`  # this is required to get rid of cr at end
+    mask=`cpumask ${cpu[$i]}`
+    taskset -p ${mask} ${tid}
+    i=`expr $i + 1`
+done