OVMF ja QEMU kasutamine operatsioonisüsteemiga Debian: erinevus redaktsioonide vahel
Resümee puudub |
|||
(ei näidata sama kasutaja 8 vahepealset redaktsiooni) | |||
100. rida: | 100. rida: | ||
===QMP - QEMU Machine Protocol=== |
===QMP - QEMU Machine Protocol=== |
||
− | Proxmox KVM guestiga suhtlemine |
+ | Proxmox KVM guestiga suhtlemine toimub üle unix soketi, vastavas kataloogis on ka muid asjakohaseid faile |
+ | |||
+ | <pre> |
||
+ | root@ceph-pm71-1:~# ls -ld /var/run/qemu-server/3011.* |
||
+ | -rw------- 1 root root 6 Apr 16 23:09 /var/run/qemu-server/3011.pid |
||
+ | srwxr-x--- 1 root root 0 Apr 16 23:09 /var/run/qemu-server/3011.qga |
||
+ | srwxr-x--- 1 root root 0 Apr 16 23:09 /var/run/qemu-server/3011.qmp |
||
+ | srwxr-x--- 1 root root 0 Apr 16 23:09 /var/run/qemu-server/3011.vnc |
||
+ | </pre> |
||
+ | |||
+ | Näiteks |
||
<pre> |
<pre> |
||
116. rida: | 126. rida: | ||
{"timestamp": {"seconds": 1650139458, "microseconds": 385606}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} |
{"timestamp": {"seconds": 1650139458, "microseconds": 385606}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} |
||
+ | </pre> |
||
+ | |||
+ | Plokkseadmete küsimiseks ja varundamiseks sobib öelda |
||
+ | |||
+ | <pre> |
||
+ | { "execute": "query-block" } |
||
+ | { "execute": "drive-backup","arguments": { "device": "drive-virtio1","sync": "full","target": "backup.img" } } |
||
+ | </pre> |
||
+ | |||
+ | Tulemusena salvestatakse arvutisse fail |
||
+ | |||
+ | <pre> |
||
+ | root@ceph-pm71-1:~# fdisk /backup.img -l |
||
+ | Disk /backup.img: 1 GiB, 1073741824 bytes, 2097152 sectors |
||
+ | Units: sectors of 1 * 512 = 512 bytes |
||
+ | Sector size (logical/physical): 512 bytes / 512 bytes |
||
+ | I/O size (minimum/optimal): 512 bytes / 512 bytes |
||
+ | Disklabel type: dos |
||
+ | Disk identifier: 0x977fec66 |
||
+ | |||
+ | Device Boot Start End Sectors Size Id Type |
||
+ | /backup.img1 2048 2097151 2095104 1023M 83 Linux |
||
</pre> |
</pre> |
||
121. rida: | 153. rida: | ||
* https://qemu-project.gitlab.io/qemu/interop/qemu-qmp-ref.html# |
* https://qemu-project.gitlab.io/qemu/interop/qemu-qmp-ref.html# |
||
+ | |||
+ | ===QEMU Guest Agent Protocol=== |
||
+ | |||
+ | QEMU Guest Agent Protocol abil Proxmox virtuaalse arvutiga suhtlemiseks peab virtuaalses arvutis töötama qemu-guest-agent protsess. Suhtlemine toimub nt selliselt |
||
+ | |||
+ | <pre> |
||
+ | root@ceph-pm71-1:~# socat - UNIX-CONNECT:/var/run/qemu-server/3011.qga |
||
+ | {"execute":"guest-ping"} |
||
+ | {"return": {}} |
||
+ | |||
+ | {"execute":"guest-get-osinfo"} |
||
+ | {"return": {"name": "Debian GNU/Linux", "kernel-release": "5.10.0-13-amd64", "version": "11 (bullseye)", "pretty-name": "Debian GNU/Linux 11 (bullseye)", "version-id": "11", "kernel-version": "#1 SMP Debian 5.10.106-1 (2022-03-17)", "machine": "x86_64", "id": "debian"}} |
||
+ | </pre> |
||
+ | |||
+ | Varundamisega seoses abiks tegevused, kuna need eeldavad quest operatsioonisüsteemi kerneliga suhtlemist, siis saab seda teha qemu-guest-agent abil ja miite niisama qmp kaudu |
||
+ | |||
+ | <pre> |
||
+ | {"execute":"guest-fsfreeze-freeze"} |
||
+ | {"return": 2} |
||
+ | |||
+ | {"execute":"guest-fsfreeze-status"} |
||
+ | {"return": "frozen"} |
||
+ | |||
+ | {"execute":"guest-fsfreeze-thaw"} |
||
+ | {"return": 2} |
||
+ | |||
+ | {"execute":"guest-fsfreeze-status"} |
||
+ | {"return": "thawed"} |
||
+ | </pre> |
||
+ | |||
+ | QEMU Guest Agent Protokolli osavad rääkida ka spetsiifilised utiliidid, nt lasta operatsioonisüsteemil käsk anda |
||
+ | |||
+ | <pre> |
||
+ | root@ceph-pm71-1:~# qm guest exec 3011 -- date |
||
+ | { |
||
+ | "exitcode" : 0, |
||
+ | "exited" : 1, |
||
+ | "out-data" : "Sat Apr 16 23:22:52 EEST 2022\n" |
||
+ | } |
||
+ | </pre> |
||
+ | |||
+ | nö quest agent sisekäsk anda, 'agent' on alias 'guest cmd' jaoks |
||
+ | |||
+ | <pre> |
||
+ | root@ceph-pm71-1:~# qm guest cmd 3011 get-host-name |
||
+ | { |
||
+ | "host-name" : "arvutinimi-01" |
||
+ | } |
||
+ | |||
+ | root@ceph-pm71-1:~# qm agent 3011 get-host-name |
||
+ | { |
||
+ | "host-name" : "arvutinimi-01" |
||
+ | } |
||
+ | </pre> |
||
+ | |||
+ | Analoogne järgnevust qm agent abil |
||
+ | |||
+ | <pre> |
||
+ | root@ceph-pm71-1:~# qm agent 3011 fsfreeze-freeze |
||
+ | 2 |
||
+ | root@ceph-pm71-1:~# qm agent 3011 fsfreeze-status |
||
+ | frozen |
||
+ | |||
+ | root@ceph-pm71-1:~# qm agent 3011 fsfreeze-thaw |
||
+ | 2 |
||
+ | root@ceph-pm71-1:~# qm agent 3011 fsfreeze-status |
||
+ | thawed |
||
+ | </pre> |
||
+ | |||
+ | Kasulikud lisamaterjalid |
||
+ | |||
+ | * https://qemu.readthedocs.io/en/latest/interop/qemu-ga-ref.html |
||
===Kasulikud lisamaterjalid=== |
===Kasulikud lisamaterjalid=== |
Viimane redaktsioon: 16. aprill 2022, kell 23:02
Sissejuhatus
Virtuaalse arvuti kasutamisel tekib küsimus, millist nn BIOS'i kasutada (või kas üldse). Üks virtuaalne BIOS on OVMF. Kuna ta nö toetab UEFI'it, siis on ehk õigem teda ettekujutada kui virtuaalset UEFI võimelist riistvara, sealhulgas nn Setup keskkonda. Alternatiiv oleks nt SeaBIOS. OVMF sobib kasutada kõige tavalisema virtuaalse arvuti pidamiseks, kuid tavaliselt kasutatakse OVMF'i UEFI võimelise virtuaalse arvuti pidamiseks, kus saab uurida midagi UEFI spetsiifilist, nt Secure Boot teemat.
Tööpõhimõte
- OVMF - Open Virtual Machine Firmware, http://www.tianocore.org/ovmf/
- QEMU - http://wiki.qemu.org/Main_Page
Paigaldamine
QEMU ja OVMF saab nt 2016 sügisel Debian v. 9 Stretch paketihaldusest
# apt-get install ovmf qemu-system-x86 xterm
kus
- xterm - kui töökohaarvuti on üks ja arvuti, kus katsetatakse ovmf + qemu teine, siis paigaldatake xterm tagajärjel piisvalt X'i, et üle võrgu saada värviline pilt ette
Tulemusena tekib failisüsteemi muu hulgas
-rw-r--r-- 1 root root 1966080 Dec 9 10:09 /usr/share/OVMF/OVMF_CODE.fd -rw-r--r-- 1 root root 131072 Dec 9 10:09 /usr/share/OVMF/OVMF_VARS.fd -rw-r--r-- 1 root root 2097152 Dec 9 10:09 /usr/share/ovmf/OVMF.fd
kus
- OVMF.fd - kõik-ühes tõmmis
- OVMF_CODE.fd ja OVMF_VARS.fd - BIOS kood ja konf on eraldi
Kõige lihtsamal juhul sobib käivitamise testiks öelda
Käivitamiseks sobib öelda
# qemu-system-x86_64 -enable-kvm -pflash /var/tmp/o/OVMF.fd
ja pistab selline pilt
kus
- saab jõuda EFI Shelli (fs0: jt käsud)
- saab sättida Secure Boot PK, KEK, DB jt võtmeid
Kui efi shellis öelda 'exit' ning jõutakse Setup keskkonda.
EFI võimelise operatsioonisüsteemi paigaldamine
# cat run.sh qemu-system-x86_64 --enable-kvm -m 1536 \ -drive file=/dev/deb8-vg/root_fedora25,if=ide \ -net nic -net tap,ifname=tap0,script=no,downscript=no \ -drive file=/srv/video/20161224/OVMF_CODE-fedora.fd,if=pflash,format=raw,readonly \ -drive file=/srv/video/20161224/OVMF_VARS-fedora.fd,if=pflash,format=raw \ -drive file=/srv/video/20161224/Fedora-Server-dvd-x86_64-25-1.3.iso,if=ide,media=cdrom
Selleks, et nii käivitatud arvutis töötaks võrk sobib host peal öelda
# brctl addbr br0 # brctl addif br0 eth0 # brctl addif br0 tap0 # ifconfig br0 192.168.10.8 # route add default gw 192.168.10.254
kus
- TODO
UEFI seisukohalt virtuaalses arvutis või olla asjakohane selline tarkvara
- efibootmgr
Misc
Tundub, et redhat keskkonnas on huvitav pakett edk2-ovmf
# dnf install edk2-ovmf # rpm -ql edk2-ovmf /usr/share/doc/edk2-ovmf /usr/share/doc/edk2-ovmf/README /usr/share/edk2 /usr/share/edk2/ovmf /usr/share/edk2/ovmf/EnrollDefaultKeys.efi /usr/share/edk2/ovmf/OVMF_CODE.fd /usr/share/edk2/ovmf/OVMF_CODE.secboot.fd /usr/share/edk2/ovmf/OVMF_VARS.fd /usr/share/edk2/ovmf/Shell.efi /usr/share/edk2/ovmf/UefiShell.iso /usr/share/licenses/edk2-ovmf /usr/share/licenses/edk2-ovmf/LICENSE.openssl /usr/share/licenses/edk2-ovmf/License.txt
QMP - QEMU Machine Protocol
Proxmox KVM guestiga suhtlemine toimub üle unix soketi, vastavas kataloogis on ka muid asjakohaseid faile
root@ceph-pm71-1:~# ls -ld /var/run/qemu-server/3011.* -rw------- 1 root root 6 Apr 16 23:09 /var/run/qemu-server/3011.pid srwxr-x--- 1 root root 0 Apr 16 23:09 /var/run/qemu-server/3011.qga srwxr-x--- 1 root root 0 Apr 16 23:09 /var/run/qemu-server/3011.qmp srwxr-x--- 1 root root 0 Apr 16 23:09 /var/run/qemu-server/3011.vnc
Näiteks
root@ceph-pm71-1:~# socat - unix-connect:/var/run/qemu-server/3011.qmp {"QMP": {"version": {"qemu": {"micro": 0, "minor": 2, "major": 6}, "package": "pve-qemu-kvm_6.2.0"}, "capabilities": []}} {"execute":"qmp_capabilities"} {"return": {}} { "execute": "query-version" } {"return": {"qemu": {"micro": 0, "minor": 2, "major": 6}, "package": "pve-qemu-kvm_6.2.0"}} { "execute": "quit" } {"return": {}} {"timestamp": {"seconds": 1650139458, "microseconds": 385606}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}}
Plokkseadmete küsimiseks ja varundamiseks sobib öelda
{ "execute": "query-block" } { "execute": "drive-backup","arguments": { "device": "drive-virtio1","sync": "full","target": "backup.img" } }
Tulemusena salvestatakse arvutisse fail
root@ceph-pm71-1:~# fdisk /backup.img -l Disk /backup.img: 1 GiB, 1073741824 bytes, 2097152 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x977fec66 Device Boot Start End Sectors Size Id Type /backup.img1 2048 2097151 2095104 1023M 83 Linux
Kasulikud lisamaterjalid
QEMU Guest Agent Protocol
QEMU Guest Agent Protocol abil Proxmox virtuaalse arvutiga suhtlemiseks peab virtuaalses arvutis töötama qemu-guest-agent protsess. Suhtlemine toimub nt selliselt
root@ceph-pm71-1:~# socat - UNIX-CONNECT:/var/run/qemu-server/3011.qga {"execute":"guest-ping"} {"return": {}} {"execute":"guest-get-osinfo"} {"return": {"name": "Debian GNU/Linux", "kernel-release": "5.10.0-13-amd64", "version": "11 (bullseye)", "pretty-name": "Debian GNU/Linux 11 (bullseye)", "version-id": "11", "kernel-version": "#1 SMP Debian 5.10.106-1 (2022-03-17)", "machine": "x86_64", "id": "debian"}}
Varundamisega seoses abiks tegevused, kuna need eeldavad quest operatsioonisüsteemi kerneliga suhtlemist, siis saab seda teha qemu-guest-agent abil ja miite niisama qmp kaudu
{"execute":"guest-fsfreeze-freeze"} {"return": 2} {"execute":"guest-fsfreeze-status"} {"return": "frozen"} {"execute":"guest-fsfreeze-thaw"} {"return": 2} {"execute":"guest-fsfreeze-status"} {"return": "thawed"}
QEMU Guest Agent Protokolli osavad rääkida ka spetsiifilised utiliidid, nt lasta operatsioonisüsteemil käsk anda
root@ceph-pm71-1:~# qm guest exec 3011 -- date { "exitcode" : 0, "exited" : 1, "out-data" : "Sat Apr 16 23:22:52 EEST 2022\n" }
nö quest agent sisekäsk anda, 'agent' on alias 'guest cmd' jaoks
root@ceph-pm71-1:~# qm guest cmd 3011 get-host-name { "host-name" : "arvutinimi-01" } root@ceph-pm71-1:~# qm agent 3011 get-host-name { "host-name" : "arvutinimi-01" }
Analoogne järgnevust qm agent abil
root@ceph-pm71-1:~# qm agent 3011 fsfreeze-freeze 2 root@ceph-pm71-1:~# qm agent 3011 fsfreeze-status frozen root@ceph-pm71-1:~# qm agent 3011 fsfreeze-thaw 2 root@ceph-pm71-1:~# qm agent 3011 fsfreeze-status thawed
Kasulikud lisamaterjalid