detached 05c7b58

fix(vm): fix UUID consistency, cp error handling, and machine flag in QEMU profile builder

commit
05c7b58da92cd24bb5dade65ca9965eb7d5e4821
author
brice · · 2026-02-27 04:44 UTC
parent
74d97ff
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +13 -7
M test/vm/lib/qemu-profile.sh +13 -7
@@ -3,7 +3,8 @@
33 # Source this file then call: build_qemu_args PROFILE SECURE_BOOT SSH_PORT TEST_DIR
44 # Result is stored in the QEMU_ARGS array.
55
6-OVMF_CODE_NORMAL="/usr/share/edk2/x64/OVMF_CODE.4m.fd"
6+[[ "${BASH_SOURCE[0]}" == "${0}" ]] && { echo "Source this file, do not execute it directly." >&2; exit 1; }
7+
78 OVMF_CODE_SECBOOT="/usr/share/edk2/x64/OVMF_CODE.secboot.4m.fd"
89 OVMF_VARS_TEMPLATE="/usr/share/edk2/x64/OVMF_VARS.4m.fd"
910
@@ -13,22 +14,27 @@ build_qemu_args() {
1314 local ssh_port="$3"
1415 local test_dir="$4"
1516
17+ local machine_opts="q35,vmport=off"
18+ [[ "$secure_boot" == "on" ]] && machine_opts="q35,vmport=off,smm=on"
19+
20+ local sys_uuid
21+ sys_uuid="$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)"
22+
1623 QEMU_ARGS=()
1724
1825 # ── Machine & CPU ────────────────────────────────────────────────────────────
1926 QEMU_ARGS+=(-enable-kvm)
20- QEMU_ARGS+=(-machine q35,vmport=off)
27+ QEMU_ARGS+=(-machine "$machine_opts")
2128 QEMU_ARGS+=(-cpu host)
2229 QEMU_ARGS+=(-smp 4,cores=2,threads=2,sockets=1)
2330 QEMU_ARGS+=(-m 4096)
24- QEMU_ARGS+=(-uuid "$(cat /proc/sys/kernel/random/uuid 2>/dev/null || uuidgen)")
31+ QEMU_ARGS+=(-uuid "$sys_uuid")
2532
2633 # ── Firmware ─────────────────────────────────────────────────────────────────
2734 if [[ "$secure_boot" == "on" ]]; then
2835 local vars_copy
2936 vars_copy="$(mktemp /tmp/OVMF_VARS_XXXXXXXX.fd)"
30- cp "$OVMF_VARS_TEMPLATE" "$vars_copy"
31- QEMU_ARGS+=(-machine q35,vmport=off,smm=on) # override previous -machine
37+ cp "$OVMF_VARS_TEMPLATE" "$vars_copy" || { rm -f "$vars_copy"; return 1; }
3238 QEMU_ARGS+=(-global driver=cfi.pflash01,property=secure,value=on)
3339 QEMU_ARGS+=(-drive "if=pflash,readonly=on,format=raw,file=${OVMF_CODE_SECBOOT}")
3440 QEMU_ARGS+=(-drive "if=pflash,format=raw,file=${vars_copy}")
@@ -45,7 +51,7 @@ build_qemu_args() {
4551 case "$profile" in
4652 desktop)
4753 # Type 1: System
48- QEMU_ARGS+=(-smbios "type=1,manufacturer=Gigabyte Technology Co. Ltd.,product=B550 AORUS ELITE V2,version=1.0,serial=SN-DESKTOP-001,uuid=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid),sku=Default string,family=Desktop")
54+ QEMU_ARGS+=(-smbios "type=1,manufacturer=Gigabyte Technology Co. Ltd.,product=B550 AORUS ELITE V2,version=1.0,serial=SN-DESKTOP-001,uuid=${sys_uuid},sku=Default string,family=Desktop")
4955 # Type 2: Board
5056 QEMU_ARGS+=(-smbios "type=2,manufacturer=Gigabyte Technology Co. Ltd.,product=B550 AORUS ELITE V2,version=x.x,serial=SN-BOARD-DESKTOP,asset=Base Board Asset Tag,location=Default string")
5157 # Type 3: Chassis — desktop (type 3)
@@ -53,7 +59,7 @@ build_qemu_args() {
5359 ;;
5460 laptop)
5561 # Type 1: System — ThinkPad X1 Carbon Gen 10
56- QEMU_ARGS+=(-smbios "type=1,manufacturer=LENOVO,product=21CB,version=ThinkPad X1 Carbon Gen 10,serial=SN-LAPTOP-001,uuid=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid),sku=LENOVO_MT_21CB,family=ThinkPad X1 Carbon Gen 10")
62+ QEMU_ARGS+=(-smbios "type=1,manufacturer=LENOVO,product=21CB,version=ThinkPad X1 Carbon Gen 10,serial=SN-LAPTOP-001,uuid=${sys_uuid},sku=LENOVO_MT_21CB,family=ThinkPad X1 Carbon Gen 10")
5763 # Type 2: Board
5864 QEMU_ARGS+=(-smbios "type=2,manufacturer=LENOVO,product=21CB,version=SDK0J40697 WIN,serial=SN-BOARD-LAPTOP,asset=Not Available,location=Not Available")
5965 # Type 3: Chassis — notebook (type 10)
@@ -3,7 +3,8 @@
3 # Source this file then call: build_qemu_args PROFILE SECURE_BOOT SSH_PORT TEST_DIR3 # Source this file then call: build_qemu_args PROFILE SECURE_BOOT SSH_PORT TEST_DIR
4 # Result is stored in the QEMU_ARGS array.4 # Result is stored in the QEMU_ARGS array.
5 5
6-OVMF_CODE_NORMAL="/usr/share/edk2/x64/OVMF_CODE.4m.fd"6+[[ "${BASH_SOURCE[0]}" == "${0}" ]] && { echo "Source this file, do not execute it directly." >&2; exit 1; }
7+
7 OVMF_CODE_SECBOOT="/usr/share/edk2/x64/OVMF_CODE.secboot.4m.fd"8 OVMF_CODE_SECBOOT="/usr/share/edk2/x64/OVMF_CODE.secboot.4m.fd"
8 OVMF_VARS_TEMPLATE="/usr/share/edk2/x64/OVMF_VARS.4m.fd"9 OVMF_VARS_TEMPLATE="/usr/share/edk2/x64/OVMF_VARS.4m.fd"
9 10
@@ -13,22 +14,27 @@ build_qemu_args() {
13 local ssh_port="$3"14 local ssh_port="$3"
14 local test_dir="$4"15 local test_dir="$4"
15 16
17+ local machine_opts="q35,vmport=off"
18+ [[ "$secure_boot" == "on" ]] && machine_opts="q35,vmport=off,smm=on"
19+
20+ local sys_uuid
21+ sys_uuid="$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)"
22+
16 QEMU_ARGS=()23 QEMU_ARGS=()
17 24
18 # ── Machine & CPU ────────────────────────────────────────────────────────────25 # ── Machine & CPU ────────────────────────────────────────────────────────────
19 QEMU_ARGS+=(-enable-kvm)26 QEMU_ARGS+=(-enable-kvm)
20- QEMU_ARGS+=(-machine q35,vmport=off)27+ QEMU_ARGS+=(-machine "$machine_opts")
21 QEMU_ARGS+=(-cpu host)28 QEMU_ARGS+=(-cpu host)
22 QEMU_ARGS+=(-smp 4,cores=2,threads=2,sockets=1)29 QEMU_ARGS+=(-smp 4,cores=2,threads=2,sockets=1)
23 QEMU_ARGS+=(-m 4096)30 QEMU_ARGS+=(-m 4096)
24- QEMU_ARGS+=(-uuid "$(cat /proc/sys/kernel/random/uuid 2>/dev/null || uuidgen)")31+ QEMU_ARGS+=(-uuid "$sys_uuid")
25 32
26 # ── Firmware ─────────────────────────────────────────────────────────────────33 # ── Firmware ─────────────────────────────────────────────────────────────────
27 if [[ "$secure_boot" == "on" ]]; then34 if [[ "$secure_boot" == "on" ]]; then
28 local vars_copy35 local vars_copy
29 vars_copy="$(mktemp /tmp/OVMF_VARS_XXXXXXXX.fd)"36 vars_copy="$(mktemp /tmp/OVMF_VARS_XXXXXXXX.fd)"
30- cp "$OVMF_VARS_TEMPLATE" "$vars_copy"37+ cp "$OVMF_VARS_TEMPLATE" "$vars_copy" || { rm -f "$vars_copy"; return 1; }
31- QEMU_ARGS+=(-machine q35,vmport=off,smm=on) # override previous -machine
32 QEMU_ARGS+=(-global driver=cfi.pflash01,property=secure,value=on)38 QEMU_ARGS+=(-global driver=cfi.pflash01,property=secure,value=on)
33 QEMU_ARGS+=(-drive "if=pflash,readonly=on,format=raw,file=${OVMF_CODE_SECBOOT}")39 QEMU_ARGS+=(-drive "if=pflash,readonly=on,format=raw,file=${OVMF_CODE_SECBOOT}")
34 QEMU_ARGS+=(-drive "if=pflash,format=raw,file=${vars_copy}")40 QEMU_ARGS+=(-drive "if=pflash,format=raw,file=${vars_copy}")
@@ -45,7 +51,7 @@ build_qemu_args() {
45 case "$profile" in51 case "$profile" in
46 desktop)52 desktop)
47 # Type 1: System53 # Type 1: System
48- QEMU_ARGS+=(-smbios "type=1,manufacturer=Gigabyte Technology Co. Ltd.,product=B550 AORUS ELITE V2,version=1.0,serial=SN-DESKTOP-001,uuid=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid),sku=Default string,family=Desktop")54+ QEMU_ARGS+=(-smbios "type=1,manufacturer=Gigabyte Technology Co. Ltd.,product=B550 AORUS ELITE V2,version=1.0,serial=SN-DESKTOP-001,uuid=${sys_uuid},sku=Default string,family=Desktop")
49 # Type 2: Board55 # Type 2: Board
50 QEMU_ARGS+=(-smbios "type=2,manufacturer=Gigabyte Technology Co. Ltd.,product=B550 AORUS ELITE V2,version=x.x,serial=SN-BOARD-DESKTOP,asset=Base Board Asset Tag,location=Default string")56 QEMU_ARGS+=(-smbios "type=2,manufacturer=Gigabyte Technology Co. Ltd.,product=B550 AORUS ELITE V2,version=x.x,serial=SN-BOARD-DESKTOP,asset=Base Board Asset Tag,location=Default string")
51 # Type 3: Chassis — desktop (type 3)57 # Type 3: Chassis — desktop (type 3)
@@ -53,7 +59,7 @@ build_qemu_args() {
53 ;;59 ;;
54 laptop)60 laptop)
55 # Type 1: System — ThinkPad X1 Carbon Gen 1061 # Type 1: System — ThinkPad X1 Carbon Gen 10
56- QEMU_ARGS+=(-smbios "type=1,manufacturer=LENOVO,product=21CB,version=ThinkPad X1 Carbon Gen 10,serial=SN-LAPTOP-001,uuid=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid),sku=LENOVO_MT_21CB,family=ThinkPad X1 Carbon Gen 10")62+ QEMU_ARGS+=(-smbios "type=1,manufacturer=LENOVO,product=21CB,version=ThinkPad X1 Carbon Gen 10,serial=SN-LAPTOP-001,uuid=${sys_uuid},sku=LENOVO_MT_21CB,family=ThinkPad X1 Carbon Gen 10")
57 # Type 2: Board63 # Type 2: Board
58 QEMU_ARGS+=(-smbios "type=2,manufacturer=LENOVO,product=21CB,version=SDK0J40697 WIN,serial=SN-BOARD-LAPTOP,asset=Not Available,location=Not Available")64 QEMU_ARGS+=(-smbios "type=2,manufacturer=LENOVO,product=21CB,version=SDK0J40697 WIN,serial=SN-BOARD-LAPTOP,asset=Not Available,location=Not Available")
59 # Type 3: Chassis — notebook (type 10)65 # Type 3: Chassis — notebook (type 10)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close