Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion output/create_kubevirt_yaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ let create_kubevirt_yaml source inspect
| TargetBIOS ->
"bios", Assoc []
| TargetUEFI ->
"efi", Assoc ["persistent", Bool true] in
let efi_config = ref ["persistent", Bool true] in
if source.s_uefi_secureboot then
List.push_back efi_config ("secureBoot", Bool true);
"efi", Assoc !efi_config in
List.push_back firmware ("bootloader", Assoc [bootloader]);

(* Clock, and eventually utc vs localtime. We could include
Expand Down
28 changes: 28 additions & 0 deletions test-data/phony-guests/guests.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,32 @@
</devices>
</domain>

<domain type='test'>
<name>windows-uefi-secureboot</name>
<memory>1048576</memory>
<os firmware='efi'>
<type>hvm</type>
<firmware>
<feature enabled='yes' name='enrolled-keys'/>
<feature enabled='yes' name='secure-boot'/>
</firmware>
<boot dev='hd'/>
</os>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='@abs_builddir@/win2k22-uefi.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<interface type='network'>
<mac address='00:11:22:33:44:56'/>
<source network='default'/>
<model type='virtio'/>
</interface>
<video>
<model type='vga' vram='16384' heads='1'/>
</video>
</devices>
</domain>

</node>
3 changes: 3 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ TESTS = \
test-o-kubevirt-fedora.sh \
test-o-kubevirt-oo-disk.sh \
test-o-kubevirt-windows.sh \
test-o-kubevirt-windows-uefi.sh \
test-o-libvirt.sh \
test-o-local-qcow2-compressed.sh \
test-o-null.sh \
Expand Down Expand Up @@ -298,6 +299,8 @@ EXTRA_DIST += \
test-o-kubevirt-oo-disk.sh \
test-o-kubevirt-windows.sh \
test-o-kubevirt-windows.yaml.expected \
test-o-kubevirt-windows-uefi.sh \
test-o-kubevirt-windows-uefi.yaml.expected \
test-o-libvirt.sh \
test-o-local-qcow2-compressed.sh \
test-o-null.sh \
Expand Down
60 changes: 60 additions & 0 deletions tests/test-o-kubevirt-windows-uefi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash -
# libguestfs virt-v2v test script
# Copyright (C) 2018-2025 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# Test -o kubevirt using phony Windows UEFI guest.

source ./functions.sh
set -e
set -x

skip_if_skipped
f=../test-data/phony-guests/win2k22-uefi.img
requires test -s $f

libvirt_uri="test://$abs_top_builddir/test-data/phony-guests/guests.xml"
export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win/drivers"

d=test-o-kubevirt-windows-uefi.d
rm -rf $d
cleanup_fn rm -r $d
mkdir $d

# Run virt-v2v -o kubevirt.
$VG virt-v2v --debug-gc \
-i libvirt -ic "$libvirt_uri" windows-uefi-secureboot \
-o kubevirt -on test -os $d

cat $d/test.yaml

# Check the disk was created.
test -f $d/test-sda

# Remove some parts of the yaml which change between runs.
sed -i \
-e 's/^\(# generated by virt-v2v\).*/\1/' \
-e 's,\(path: \).*/\(test-sda\),\1\2,' \
-e 's,\(virt-v2v-version: \).*,\1,' \
$d/test.yaml

# Check that it's really UEFI.
grep 'efi:' $d/test.yaml
grep 'secureBoot:' $d/test.yaml

# Compare yaml to the expected output.
diff -u test-o-kubevirt-windows-uefi.yaml.expected $d/test.yaml
56 changes: 56 additions & 0 deletions tests/test-o-kubevirt-windows-uefi.yaml.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
# generated by virt-v2v
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: test
labels:
libguestfs.org/virt-v2v-version:
libguestfs.org/osinfo: win2k22
libguestfs.org/source: test
spec:
template:
spec:
domain:
firmware:
bootloader:
efi:
persistent: true
secureBoot: true
resources:
clock:
timer:
hpet:
present: false
hyperv: {}
pit:
tickPolicy: delay
rtc:
tickPolicy: catchup
utc: {}
requests:
memory: 1024Mi
features: {}
cpu:
cores: 1
devices:
rng: {}
disks:
- disk:
bus: virtio
bootOrder: 1
name: disk-0
interfaces:
- name: net_default
masquerade: {}
macAddress: 00:11:22:33:44:56
model: virtio
volumes:
- hostDisk:
path: test-sda
type: Disk
name: disk-0
networks:
- networkName: default
name: net_default
terminationGracePeriodSeconds: 0
Loading