1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
qemu 4.0.0 on aarch64: uefi firmware oversize
I'd like to enable uefi in my virtual machine, however qemu is always showing the same error: qemu-system-aarch64: Initialization of device cfi.pflash01 failed: device requires 67108864 bytes, block backend provides 786432 bytes
It's clearly impossible to fit a uefi firmware into 786432 bytes.
Environment: qemu-system-aarch64 with kvm on an amlogic s905d aarch64 dev board, running archlinuxarm, qemu in the repository is compiled with https://download.qemu.org/qemu-4.0.0.tar.xz
(My AAVMF_CODE.fd and AAVMF_VARS.fd are extracted from debian package qemu-efi-aarch64 0~20181115.85588389-3)
Below is my libvirt log.
2019-05-30 15:07:44.216+0000: starting up libvirt version: 5.3.0, qemu version: 4.0.0, kernel: 4.19.46-1-ARCH, hostname: jerry-n1.localdomain
LC_ALL=C \
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin \
HOME=/var/lib/libvirt/qemu/domain-2-debiantesting \
XDG_DATA_HOME=/var/lib/libvirt/qemu/domain-2-debiantesting/.local/share \
XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain-2-debiantesting/.cache \
XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain-2-debiantesting/.config \
QEMU_AUDIO_DRV=none \
/usr/bin/qemu-system-aarch64 \
-name guest=debiantesting,debug-threads=on \
-S \
-object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-2-debiantesting/master-key.aes \
-machine virt-4.0,accel=kvm,usb=off,dump-guest-core=off,gic-version=2 \
-cpu host \
-drive file=/opt/ovmf/aarch64/AAVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
-drive file=/var/lib/libvirt/qemu/nvram/debiantesting_VARS.fd,if=pflash,format=raw,unit=1 \
-m 1024 \
-overcommit mem-lock=off \
-smp 4,sockets=4,cores=1,threads=1 \
-uuid 508d100a-b4e5-4199-9ff9-ac6d40fe2896 \
-display none \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=25,server,nowait \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc \
-no-reboot \
-boot strict=on \
-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \
-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
-device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \
-device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \
-device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \
-device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \
-device qemu-xhci,p2=15,p3=15,id=usb,bus=pci.2,addr=0x0 \
-device virtio-scsi-pci,id=scsi0,bus=pci.3,addr=0x0 \
-device virtio-serial-pci,id=virtio-serial0,bus=pci.4,addr=0x0 \
-drive file=/mnt/hddp1/jerry/libvirt/aarch64-images/debiantesting.qcow2,format=qcow2,if=none,id=drive-scsi0-0-0-0 \
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,device_id=drive-scsi0-0-0-0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=2 \
-drive file=/mnt/hddp1/jerry/libvirt/aarch64-iso/debian-testing-arm64-netinst.iso,format=raw,if=none,id=drive-scsi0-0-0-1,readonly=on \
-device scsi-cd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,device_id=drive-scsi0-0-0-1,drive=drive-scsi0-0-0-1,id=scsi0-0-0-1,bootindex=1 \
-netdev tap,fd=27,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:d5:28:6d,bus=pci.1,addr=0x0 \
-chardev pty,id=charserial0 \
-serial chardev:charserial0 \
-chardev socket,id=charchannel0,fd=28,server,nowait \
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 \
-object rng-random,id=objrng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.5,addr=0x0 \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on
2019-05-30 15:07:44.216+0000: Domain id=2 is tainted: host-cpu
char device redirected to /dev/pts/2 (label charserial0)
2019-05-30T15:07:46.701125Z qemu-system-aarch64: Initialization of device cfi.pflash01 failed: device requires 67108864 bytes, block backend provides 786432 bytes
2019-05-30 15:07:46.779+0000: shutting down, reason=failed
(END)
# /etc/libvirt/qemu.conf
nvram = [
"/opt/ovmf/aarch64/AAVMF_CODE.fd:/opt/ovmf/aarch64/AAVMF_VARS.fd"
]
This is a bug in the debian package that you mention. The 2MB firmware executable (QEMU_EFI.fd) and the 768KB varstore template (QEMU_VARS.fd) that the edk2 ArmVirtQemu platform build produces cannot be passed directly to QEMU. Both files have to be padded to 64MB first. The padding is generally done in the distro-specific package (RPM, DEB etc) build script.
(If this report mentioned Ubuntu, we could simply re-classify the bug within Launchpad. However, Debian is tracked at bugs.debian.org, so I'll have to close the present issue as Invalid. Please open a bug at bugs.debian.org.)
Note that starting with version 4.1, upstream QEMU too will bundle firmware binaries from the edk2 project. See https://wiki.qemu.org/ChangeLog/4.1#Miscellaneous
[jerry@jerry-n1 aarch64]$ du -b *
67108864 AAVMF_CODE.fd
67108864 AAVMF_VARS.fd
67108864 QEMU_EFI.fd
67108864 QEMU_VARS.fd
2097152 QEMU_EFI.fd.orig
786432 QEMU_VARS.fd.orig
Both files have been padded to 64MB. (if padding means filling it with /dev/zero)
QEMU_EFI.fd and QEMU_VARS.fd are built by myself according to https://wiki.linaro.org/LEG/UEFIforQEMU. With the self-built formware, I'm getting almost the same error: qemu-system-aarch64: Initialization of device cfi.pflash01 failed: device requires 67108864 bytes, block backend provides 786432 bytes
I'm quite sure that debian has done the padding procedure https://salsa.debian.org/qemu-team/edk2/blob/debian/debian/rules#L82
Jerry <email address hidden> writes:
> [jerry@jerry-n1 aarch64]$ du -b *
> 67108864 AAVMF_CODE.fd
> 67108864 AAVMF_VARS.fd
> 67108864 QEMU_EFI.fd
> 67108864 QEMU_VARS.fd
>
> 2097152 QEMU_EFI.fd.orig
> 786432 QEMU_VARS.fd.orig
>
>
> Both files have been padded to 64MB. (if padding means filling it with
> /dev/zero)
You can use:
truncate -s 64m /path/to/blob
>
> QEMU_EFI.fd and QEMU_VARS.fd are built by myself according to
> https://wiki.linaro.org/LEG/UEFIforQEMU. With the self-built formware,
> I'm getting almost the same error: qemu-system-aarch64: Initialization
> of device cfi.pflash01 failed: device requires 67108864 bytes, block
> backend provides 786432 bytes
Are you sure your libvirt invocation is properly pointing at your new
re-sized blobs? WFM here on master:
./aarch64-softmmu/qemu-system-aarch64 -cpu max -machine type=virt,virtualization=on -display none -m 4096 -serial mon:stdio -netdev user,id=unet,hostfwd=tcp::2222-:22 -device virtio-net-pci,netdev=unet -device virtio-scsi-pci -blockdev driver=raw,node-name=hd,discard=unmap,file.driver=host_device,file.filename=/dev/zen-disk/debian-buster-arm64 -device scsi-hd,drive=hd -bios /usr/share/AAVMF/AAVMF_CODE.fd
Where:
ls -l /usr/share/AAVMF/*
-rw-r--r-- 1 root root 67108864 Mar 16 00:37 /usr/share/AAVMF/AAVMF32_CODE.fd
-rw-r--r-- 1 root root 67108864 Mar 16 00:37 /usr/share/AAVMF/AAVMF32_VARS.fd
-rw-r--r-- 1 root root 67108864 Mar 16 00:37 /usr/share/AAVMF/AAVMF_CODE.fd
-rw-r--r-- 1 root root 67108864 Mar 16 00:37 /usr/share/AAVMF/AAVMF_VARS.fd
--
Alex Bennée
I just noticed that it was a libvirt bug that caused the error.
-drive file=/opt/ovmf/aarch64/AAVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
-drive file=/var/lib/libvirt/qemu/nvram/debiantesting_VARS.fd,if=pflash,format=raw,unit=1 \
debiantesting_VARS.fd was never removed or replaced after its first creation since the installation errored out. I deleted this file manually and everything is fine now.
Sorry for your inconvenience.
|