Skip to content

Instantly share code, notes, and snippets.

@jshen28
jshen28 / build-swtpm.sh
Created July 2, 2023 02:06 — forked from Jacobboogiebear/build-swtpm.sh
A quick script to build swtpm and libtpm on Ubuntu 20.04 (created for WSL2 and WSLg)
sudo apt-get install git g++ gcc automake autoconf libtool make gcc libc-dev libssl-dev pkg-config libtasn1-6-dev libjson-glib-dev expect gawk socat libseccomp-dev -y
cd ~
git clone https://github.com/stefanberger/swtpm.git
git clone https://github.com/stefanberger/libtpms.git
cd libtpms
./autogen.sh --prefix=/usr --with-tpm2 --with-openssl
make
sudo make install
cd ../swtpm
./autogen.sh --prefix=/usr
@jshen28
jshen28 / netlink_demo.c
Created May 21, 2022 23:23 — forked from supermartian/netlink_demo.c
Netlink programming demo.

Simple vsock setup for QEMU

Configuration

Host Kernel: rawhide 4.13.0-0.rc6.git4.2.fc28.x86_64 (on Fedora 24)

QEMU is mainline built from sources: QEMU emulator version 2.10.50 (v2.10.0-105-g223cd0e)

Guest: clear-17460-kvm.img (which has vsock support)

Overview

For those that are unfamiliar with the project, PyPy is an implementation of the Python language that features a JIT Compiler. I have noticed a huge performance benefit in some personal projects by switching to PyPy. I have always been curious how it would perform on a large and complex project like OpenStack, but my early experiments ran into massive roadblocks around broken dependencies.

It has been six months since I last looked, so I figured it was time to try it again. Support has come a long way and, now that lxml is working, we are close enough to get a Proof-of-Concept running. Read on for instructions on running nova with PyPy.

Preparation

Start out with a base ubuntu 12.04 (precise) install and run devstack. I won't go through the details of getting devstack running here, because there are already instructions on the devstack site.

6ee73781-6d8c-40f7-b953-ecf30f4a3309] Failed to build and run instance: libvirt.libvirtError: internal error: Process exited prior to exec: libvirt:  error : Unable to move /dev/termination-log mount to /run/libvirt/qemu/631-instance-0000c3a2.termination-log: Permission denied
2021-03-17 04:19:59.124 1255432 ERROR nova.compute.manager [instance: 6ee73781-6d8c-40f7-b953-ecf30f4a3309] Traceback (most recent call last):
2021-03-17 04:19:59.124 1255432 ERROR nova.compute.manager [instance: 6ee73781-6d8c-40f7-b953-ecf30f4a3309]   File "/var/lib/openstack/lib/python3.8/site-packages/nova/compute/manager.py", line 2394, in _build_and_run_instance
2021-03-17 04:19:59.124 1255432 ERROR nova.compute.manager [instance: 6ee73781-6d8c-40f7-b953-ecf30f4a3309]     self.driver.spawn(context, instance, image_meta,
2021-03-17 04:19:59.124 1255432 ERROR nova.compute.manager [instance: 6ee73781-6d8c-40f7-b953-ecf30f4a3309]   File "/var/lib/openstack/lib/python3.8/site-packages/nova/virt/libvirt/driver.py", line 3753, in s
@jshen28
jshen28 / route_dump.c
Created June 7, 2020 10:11 — forked from cl4u2/route_dump.c
Linux route monitoring example
/*
iflist.c : retrieve network interface information thru netlink sockets
(c) Jean Lorchat @ Internet Initiative Japan - Innovation Institute
v1.0 : initial version - Feb 19th 2010
This file was obtained at the following address :
http://www.iijlab.net/~jean/iflist.c
@jshen28
jshen28 / route_dump.c
Created June 7, 2020 10:11 — forked from cl4u2/route_dump.c
Linux route monitoring example
/*
iflist.c : retrieve network interface information thru netlink sockets
(c) Jean Lorchat @ Internet Initiative Japan - Innovation Institute
v1.0 : initial version - Feb 19th 2010
This file was obtained at the following address :
http://www.iijlab.net/~jean/iflist.c
ISO_FILE ?= ubuntu.iso
VM_NAME ?= vm06
PATH_TO_HDD ?= $(PWD)/$(VM_NAME).qcow2
.PHONY: mkiso
run: $(VM_NAME).qcow2
/usr/bin/qemu-system-x86_64 \
-m 1024 \
-vnc 0.0.0.0:41 \
@jshen28
jshen28 / multicast-openstack.md
Created August 26, 2019 06:06 — forked from djoreilly/multicast-openstack.md
Multicast on OpenStack

Multicast on OpenStack

The following works with Neutron VLAN provider networks, and requires configuration on the physical switches. Multicast works on br-int because the ML2 OVS driver/agent uses OVS in standalone mode (no external controller). The packets on br-int hit the NORMAL flow action, and so get treated by the ovs-vswitchd code that does IGMP snooping (when enabled). All IGMP packets are sent to the slow path (userspace ovs-vswitchd).

The following will not work on Neutron tunnel backed networks (VxLAN, GRE), as the neutron-openvswitch-agent hardcodes flows on br-tun that treats multicast the same as broadcasts and the NORMAL action is not used.

+----------------------------+      +----------------------------+
|      +----+    +----+      |      |      +----+    +----+      |
|      | VM |    | VM |      |      |      | VM |    | VM |      |
|      +-+--+    +--+-+      |      |      +-+--+    +--+-+      |
@jshen28
jshen28 / howto_deb_repackage.txt
Created May 20, 2019 03:28 — forked from shamil/howto_deb_repackage.txt
Howto repackage deb packages
Use folowing steps to repackage dep package:
1: Extract deb package
# dpkg-deb -x <package.deb> <dir>
2: Extract control-information from a package
# dpkg-deb -e <package.deb> <dir/DEBIAN>
3. After completed to make changes to the package, repack the deb
# dpkg-deb -b <dir> <new-package.deb>