Skip to content

Instantly share code, notes, and snippets.

# number of VMs to boot:
vm_num=10
for i in `seq 0 $vm_num`; do
# here we launch $vm_num `xl create` commands in parallel
( xl create /path/to/config/file$i.cfg &> out_$i.log) &
done
wait # wait for all the `xl create` commands to return before continuing further
@olivierpierre
olivierpierre / pigzc.sh
Created July 13, 2016 19:01
Compress a directory tree into a tarball using pigz
#!/bin/sh
if [ "$1" == "" ]; then
echo "Usage: $0 <folder to compress>"
exit
fi
NAME=`basename $1`
tar -c --use-compress-program=pigz -f $NAME.tar.gz $NAME
@olivierpierre
olivierpierre / pigzu.sh
Created July 13, 2016 19:02
Uncompress a directory tree contained in a tarball with pigz
#!/bin/sh
if [ "$1" == "" ]; then
echo "Usage: $0 <file to uncompress>"
exit
fi
pigz -dc $1 | tar xf -
#!/bin/bash
set -euo pipefail
if [ "$1" == "" ] || [ "$2" == "" ]; then
echo "usage: $0 <vm_name> <cmd>"
exit
fi
ssh root@$1 ${*:2} 2>&1 | sed "s/^/[$1] /"
#!/bin/bash
set -euo pipefail
SCRIPT_RUN_SINGLE="/root/Xen_scripts/vm_run_cmd.sh"
if [ "$#" -lt 4 ]; then
echo "usage: $0 <prefix> <start> <stop> <cmd>"
exit
fi
#!/bin/bash
# This prints the total CPU usage for the whole system (in terms of number of cores used)
top -bn1 | tr -s " " | sed -r "s/^ //" | cut -d " " -f 9 | grep -E ^[0-9]+\.[0-9]+$ | awk -v procs=`cat /proc/cpuinfo | grep cessor | wc -l` 'BEGIN{sum=0} {sum+=$0} END{print sum/procs}'
#!/bin/sh
#
# Copyright IBM, Corp. 2010
#
# Authors:
# Anthony Liguori <aliguori@us.ibm.com>
#
# This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory.
@olivierpierre
olivierpierre / cheri-vm.md
Last active June 14, 2020 18:56
FreeBSD guest with CHERI toolchain and emulator inside, for a Linux host

Host requirements

  • wget
  • qemu/kvm

Get the FreeBSD 11.3 VM disk image:

wget ftp://ftp.freebsd.org/pub/FreeBSD/releases/VM-IMAGES/11.3-RELEASE/amd64/Latest/FreeBSD-11.3-RELEASE-amd64.qcow2.xz
unxz FreeBSD-11.3-RELEASE-amd64.qcow2.xz
@@ -58,7 +58,7 @@
void print();
/* getters and setters */
- void updateAuthor(const char *newTitle);
+ void updateAuthor(const char *newAuthor);
char *getAuthor();
private:
@@ -74,7 +74,7 @@