Skip to content

Commit 91a3a74

Browse files
Merge pull request #304 from igchor/qemu_ci
Add simple qemu run to CI
2 parents 4bc810c + d72951f commit 91a3a74

File tree

3 files changed

+168
-0
lines changed

3 files changed

+168
-0
lines changed

.github/workflows/pr_push.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,6 @@ jobs:
151151
GPU:
152152
needs: [Build]
153153
uses: ./.github/workflows/gpu.yml
154+
Qemu:
155+
needs: [Build]
156+
uses: ./.github/workflows/qemu.yml

.github/workflows/qemu.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Builds project on qemu with custom hmat settings
2+
name: Qemu
3+
4+
on: workflow_call
5+
6+
env:
7+
CI_BRANCH : "${{ github.head_ref || github.ref_name }}"
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
qemu-build:
14+
name: Qemu
15+
runs-on: ubuntu-22.04
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
20+
- name: Enable KVM
21+
run: |
22+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
23+
sudo udevadm control --reload-rules
24+
sudo udevadm trigger --name-match=kvm
25+
- name: Install qemu
26+
run: |
27+
sudo apt update && sudo apt install -y qemu-system genisoimage qemu-utils
28+
- name: Run ssh-keygen
29+
run: ssh-keygen -b 4096 -N '' -f ~/.ssh/id_rsa
30+
- name: Generate iso with user info
31+
run: |
32+
pub_key=$(cat ~/.ssh/id_rsa.pub)
33+
34+
cat > user-data << EOF
35+
#cloud-config
36+
37+
# Add a 'cxltest' user to the system with a password
38+
users:
39+
- default
40+
- name: cxltest
41+
gecos: CXL Test User
42+
primary_group: wheel
43+
groups: users
44+
sudo: ALL=(ALL) NOPASSWD:ALL
45+
lock_passwd: false
46+
ssh-authorized-keys:
47+
- $pub_key
48+
shell: /usr/bin/bash
49+
50+
# Set local logins
51+
chpasswd:
52+
list: |
53+
root:password
54+
cxltest:password
55+
expire: False
56+
EOF
57+
58+
cat > meta-data << EOF
59+
instance-id: cxl-test
60+
local-hostname: cxl-test
61+
EOF
62+
63+
sudo -Sk genisoimage -output ubuntu-cloud-init.iso -volid cidata -joliet -rock ./user-data ./meta-data
64+
- name: Download ubuntu image
65+
run: wget https://cloud-images.ubuntu.com/lunar/current/lunar-server-cloudimg-amd64.img
66+
- name: Resize image
67+
run: qemu-img resize ./lunar-server-cloudimg-amd64.img +4G
68+
- name: Run qemu
69+
run: |
70+
sudo qemu-system-x86_64 \
71+
-drive file=./lunar-server-cloudimg-amd64.img,format=qcow2,index=0,media=disk,id=hd \
72+
-cdrom ./ubuntu-cloud-init.iso \
73+
-machine q35,usb=off,hmat=on \
74+
-enable-kvm \
75+
-net nic -net user,hostfwd=tcp::2222-:22 \
76+
-m 3G \
77+
-smp 4 \
78+
-object memory-backend-ram,size=1G,id=ram0 \
79+
-object memory-backend-ram,size=1G,id=ram1 \
80+
-object memory-backend-ram,size=1G,id=ram2 \
81+
-numa node,nodeid=0,memdev=ram0,cpus=0-1 \
82+
-numa node,nodeid=1,memdev=ram1,cpus=2-3 \
83+
-numa node,nodeid=2,memdev=ram2,initiator=0 \
84+
-numa dist,src=0,dst=0,val=10 \
85+
-numa dist,src=0,dst=1,val=20 \
86+
-numa dist,src=0,dst=2,val=17 \
87+
-numa dist,src=1,dst=0,val=20 \
88+
-numa dist,src=1,dst=1,val=10 \
89+
-numa dist,src=1,dst=2,val=28 \
90+
-numa dist,src=2,dst=0,val=17 \
91+
-numa dist,src=2,dst=1,val=28 \
92+
-numa dist,src=2,dst=2,val=10 \
93+
-numa hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-latency,latency=10 \
94+
-numa hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-bandwidth,bandwidth=10485760 \
95+
-numa hmat-lb,initiator=0,target=1,hierarchy=memory,data-type=access-latency,latency=20 \
96+
-numa hmat-lb,initiator=0,target=1,hierarchy=memory,data-type=access-bandwidth,bandwidth=5242880 \
97+
-numa hmat-lb,initiator=0,target=2,hierarchy=memory,data-type=access-latency,latency=16 \
98+
-numa hmat-lb,initiator=0,target=2,hierarchy=memory,data-type=access-bandwidth,bandwidth=1048576 \
99+
-numa hmat-lb,initiator=1,target=0,hierarchy=memory,data-type=access-latency,latency=20 \
100+
-numa hmat-lb,initiator=1,target=0,hierarchy=memory,data-type=access-bandwidth,bandwidth=5242880 \
101+
-numa hmat-lb,initiator=1,target=1,hierarchy=memory,data-type=access-latency,latency=10 \
102+
-numa hmat-lb,initiator=1,target=1,hierarchy=memory,data-type=access-bandwidth,bandwidth=10485760 \
103+
-numa hmat-lb,initiator=1,target=2,hierarchy=memory,data-type=access-latency,latency=27 \
104+
-numa hmat-lb,initiator=1,target=2,hierarchy=memory,data-type=access-bandwidth,bandwidth=1048576 \
105+
-daemonize -display none
106+
- name: Run ssh keyscan
107+
run: |
108+
set +e
109+
ssh-keyscan -p 2222 -H 127.0.0.1 >> ~/.ssh/known_hosts
110+
while [ $? -ne 0 ]
111+
do
112+
echo "Trying to connect..."
113+
ps -aux | grep qemu
114+
sleep 5
115+
ssh-keyscan -p 2222 -H 127.0.0.1 >> ~/.ssh/known_hosts
116+
done
117+
- name: Run build on qemu
118+
run: |
119+
if [ ${{ github.event_name }} = 'pull_request' ]; then
120+
CI_REPO="${{ github.event.pull_request.head.repo.full_name }}"
121+
else
122+
CI_REPO="$GITHUB_REPOSITORY"
123+
fi
124+
125+
scp -P 2222 ${{github.workspace}}/scripts/qemu/run-build.sh [email protected]:/home/cxltest
126+
ssh [email protected] -p 2222 -t "bash /home/cxltest/run-build.sh https://github.com/$CI_REPO ${{env.CI_BRANCH}}"

scripts/qemu/run-build.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# Copyright (C) 2024 Intel Corporation
3+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
4+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
6+
set -x
7+
set -e
8+
9+
repo=$1
10+
branch=$2
11+
12+
echo password | sudo -Sk apt update
13+
echo password | sudo -Sk apt install -y git cmake gcc g++ numactl libnuma-dev libjemalloc-dev libtbb-dev libhwloc-dev
14+
15+
numactl -H
16+
17+
git clone $repo umf
18+
cd umf
19+
git checkout $branch
20+
21+
mkdir build
22+
cd build
23+
24+
cmake .. \
25+
-DCMAKE_BUILD_TYPE=Debug \
26+
-DUMF_BUILD_OS_MEMORY_PROVIDER=ON \
27+
-DUMF_ENABLE_POOL_TRACKING=ON \
28+
-DUMF_FORMAT_CODE_STYLE=OFF \
29+
-DUMF_DEVELOPER_MODE=ON \
30+
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON \
31+
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON \
32+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON \
33+
-DUMF_BUILD_EXAMPLES=ON \
34+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
35+
36+
make -j $(nproc)
37+
38+
ctest --output-on-failure
39+

0 commit comments

Comments
 (0)