Skip to content

Commit 1beebac

Browse files
committed
azure: install the patched qemu
1 parent 51a2bfb commit 1beebac

File tree

6 files changed

+49
-3
lines changed

6 files changed

+49
-3
lines changed

ansible/tasks/qemu.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
3+
- name: "Download the QEMU package with Azure's SNP patches"
4+
get_url:
5+
url: "https://github.com/jepio/AMDSEV/releases/download/v2024.02.24/snp-qemu_2024.10.28-0_amd64.deb"
6+
dest: "/tmp/snp-qemu.deb"
7+
mode: '0644'
8+
9+
- name: "Install the new QEMU package"
10+
become: true
11+
apt:
12+
deb: "/tmp/snp-qemu.deb"
13+
state: present
14+

ansible/vm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# reboot)
1010
- include_tasks: tasks/docker.yaml
1111
- include_tasks: tasks/update_host_kernel.yaml
12+
- include_tasks: tasks/qemu.yaml
1213
- include_tasks: tasks/rust.yaml
1314
- include_tasks: tasks/code.yaml
1415
- include_tasks: tasks/pull_images.yaml

bin/create_venv.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ THIS_DIR=$(dirname $(readlink -f $0))
66
PROJ_ROOT=${THIS_DIR}/..
77
VENV_PATH="${PROJ_ROOT}/venv"
88

9-
PYTHON=python3.10
109
PIP=${VENV_PATH}/bin/pip3
1110

1211
function pip_cmd {
@@ -16,7 +15,7 @@ function pip_cmd {
1615
pushd ${PROJ_ROOT} >> /dev/null
1716

1817
if [ ! -d ${VENV_PATH} ]; then
19-
${PYTHON} -m venv ${VENV_PATH}
18+
python3 -m venv ${VENV_PATH}
2019
fi
2120

2221
pip_cmd install -U pip setuptools wheel

bin/workon.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ else
4949
echo "sc2-deploy: WARN: neither SNP nor TDX is enabled"
5050
fi
5151

52+
if [ "$(sudo dmidecode -s system-manufacturer 2>/dev/null)" == "Microsoft Corporation" ]; then
53+
export SC2_ON_AZURE="yes"
54+
else
55+
export SC2_ON_AZURE="no"
56+
fi
57+
5258
# ----------------------------------
5359
# VM cache config
5460
# ----------------------------------
@@ -71,11 +77,17 @@ export PS1="(sc2-deploy) $PS1"
7177
# Splash
7278
# -----------------------------
7379

80+
if [ "$SC2_ON_AZURE" == "yes" ]; then
81+
tee_str="${TEE}-azure"
82+
else
83+
tee_str="${TEE}"
84+
fi
85+
7486
echo ""
7587
echo "----------------------------------"
7688
echo "CLI for SC2 Deployment Scripts"
7789
echo "CoCo Version: ${COCO_VERSION}"
78-
echo "TEE: ${TEE}"
90+
echo "TEE: ${tee_str}"
7991
echo "----------------------------------"
8092
echo ""
8193

tasks/sc2.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
install as operator_install,
2626
install_cc_runtime as operator_install_cc_runtime,
2727
)
28+
from tasks.util.azure import on_azure
2829
from tasks.util.containerd import restart_containerd
2930
from tasks.util.env import (
3031
COCO_ROOT,
@@ -142,6 +143,17 @@ def install_sc2_runtime(debug=False):
142143
)
143144
update_toml(dst_conf_path, updated_toml_str)
144145

146+
# If running on Azure, point QEMU to the system-wide qemu
147+
if on_azure():
148+
qemu_path = "/usr/local/bin/qemu-system-x86_64"
149+
updated_toml_str = """
150+
[hypervisor.qemu]
151+
path = "{qemu_path}"
152+
valid_hypervisor_paths = [ "{qemu_path}" ]
153+
""".format(qemu_path=qemu_path)
154+
155+
update_toml(dst_conf_path, updated_toml_str)
156+
145157
# Update containerd to point the SC2 runtime to the right config
146158
updated_toml_str = """
147159
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.kata-{runtime_name}.options]

tasks/util/azure.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from os import environ
2+
3+
4+
def on_azure():
5+
if "SC2_ON_AZURE" not in environ:
6+
return False
7+
8+
return environ["SC2_ON_AZURE"] == "yes"

0 commit comments

Comments
 (0)