[轉]qemu安裝虛擬機


轉自

https://wiki.ubuntu.com/ARM64/QEMU

 https://gist.github.com/george-hawkins/16ee37063213f348a17717a7007d2c79

https://morningd.github.io/2018/01/08/how-to-run-aarch64-ubuntu-server-cloudimg-on-x86-64/

https://www.cnblogs.com/jinanxiaolaohu/p/11003388.html

 

AArch64上qemu起虛擬機的過程

1.編譯安裝aarch64的qemu
這里用的是spdk-3.0.0  qemu
Mkdir build && cd build
../configure --target-list=aarch64-softmmu --enable-debug
 make && make install
 
2.安裝qemu-efi
sudo apt-install qemu-efi
生成的文件在 /usr/share/qemu-efi/QEMU_EFI.fd
wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd  這個 估計有問題,用上面的!
3. flash0.img為UEFI固件,flash1為UEFI vars 
dd if=/dev/zero of=flash0.img bs=1M count=64
dd if=/usr/share/qemu-efi/QEMU_EFI.fd of=flash0.img conv=notrunc
dd if=/dev/zero of=flash1.img bs=1M count=64
來自 <https://wiki.ubuntu.com/ARM64/QEMU>
 
4. 下載的image地址 https://cloud-images.ubuntu.com/releases/bionic/release/
要備份一下,后面會被修改??
 
5.改密碼方法:
5.1.寫文件cloud.txt
#cloud-config
password: root
chpasswd: { expire: False }
ssh_pwauth: True
5.2.生成cloud.img
cloud-localds cloud.img cloud.txt
5.3.修改qemu參數:
在boot的driver后面 加上
-drive if=none,id=cloud,file=cloud.img \
-device virtio-blk-device,drive=cloud \
5.4.問題
問題同  https://www.cnblogs.com/jinanxiaolaohu/p/11003388.html
起qemu后可能起不來,進入shell了,按順序輸入 fs0:  ls   cd EFI/BOOT    ls  
會有BOOTAA64.EFI的文件, 輸入該文件  即可
登錄   ubuntu:root
解決:【要重新dd兩個 flash0.img 和 flash1.img ,改密碼后會被污染?? 】
 
 
#!/bin/bash
taskset -c 2,3 ../qemu-spdk300/build/aarch64-softmmu/qemu-system-aarch64 \
-m 1G \
-smp 2  \
-machine virt,accel=kvm,gic-version=host \
-nographic \
-cpu host \
-pflash flash0.img \
-pflash flash1.img \
-drive if=none,file=bionic-server-cloudimg-arm64.img,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-drive if=none,id=cloud,file=cloud.img \
-device virtio-blk-device,drive=cloud \
-serial stdio \
-nodefaults \
-no-acpi \
-no-user-config \
-display none \
-netdev user,id=user0,hostfwd=tcp::3333-:22 \
-device virtio-net-pci,netdev=user0 \
 
 
6.qemu模擬OCSSD
6.1
touch myocssd0-datafile  myocssd0-metadatafile
sudo fallocate -l 384G myocssd0-datafile
 
#!/bin/bash
./qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-machine virt,accel=kvm,gic-version=host,usb=off \
-cpu host -m 8192 \    #要分配足夠大,不然設置hugepage后會out-of-memory
-pflash flash0.img \
-pflash flash1.img \
-nographic \
-drive if=none,file=ubuntu-16.04-server-cloudimg-arm64-uefi1.img,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-drive format=raw,file=myocssd0-datafile,if=none,id=myocssd0 \
-device nvme,drive=myocssd0,serial=deadbeef,lver=2,lba_index=3,lnum_ch=1,lnum_lun=8,lnum_pln=4,lpgs_per_blk=1536,lsecs_per_pg=4,lblks_per_pln=512,lmetadata=myocssd0-metadatafile \
-monitor unix:qemu-monitor-socket,server,nowait \
 
6.2 登陸虛擬機后:
修改 /etc/default/grub     加上 iommu.passthrough=1 hugepagesz=2M hugepages=2048
sudo update-grub 重啟 之后

6.3下載編譯spdk
sudo ./scripts/setup.sh
輸出  0000:00:02.0 (1d1d 1f1f): nvme -> uio_pci_generic
sudo ./examples/nvme/identify/identify
輸出:

Starting SPDK v19.07-pre / DPDK 19.02.0 initialization...
[ DPDK EAL parameters: identify --no-shconf -c 0x1 -n 1 -m 0 --log-level=lib.eal:6 --log-level=lib.cryptodev:5 --log-level=user1:6 --base-virtaddr=0x200000000000 --match-allocations --file-prefix=spdk_pid9915 ]
=====================================================
NVMe Controller at 0000:00:02.0 [1d1d:1f1f]
=====================================================
Controller Capabilities/Features
================================
Vendor ID:                             1d1d
Subsystem Vendor ID:                   1af4
Serial Number:                         deadbeef
Model Number:                          QEMU NVMe Ctrl
·······
Namespace OCSSD Geometry
=======================
OC version:                     maj:2 min:0
LBA format:
  Group bits:                   0
  PU bits:                      3
  Chunk bits:                   9
  Logical block bits:           15
Media and Controller Capabilities:
  Namespace supports Vector Chunk Copy:                 Supported
  Namespace supports multiple resets a free chunk:      Not Supported
Wear-level Index Delta Threshold:                       0
Groups (channels):              1
PUs (LUNs) per group:           8
Chunks per LUN:                 512
Logical blks per chunk:         24576
MIN write size:                 4
OPT write size:                 16
Cache min write size:           16
Max open chunks:                0
Max open chunks per PU:         0
OCSSD Chunk Info Glance
·············
6.4 執行 sudo ./test/ftl/bdevperf.sh 0000:00:02.0
【生成的config是:test/ftl/config/ftl.conf
  [Ftl]
  TransportID "trtype:PCIe traddr:0000:00:02.0" nvme0 0-3 00000000-0000-0000-0000-000000000000
sudo ./test/bdev/bdevperf/bdevperf  -c test/ftl/config/ftl.conf  -q 1 -w randwrite -t 1 -o 69632

 

 
 
7.其他
-monitor unix:qemu-monitor-socket,server,nowait \
啟動之后在另一個shell的同一個目錄下中: socat - unix-connect:qemu-monitor-socket
info可以看到信息 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM