rebuildgfxqemutips

Tips:

   31  cd ~/fuck/
   32  ls
   33  git clone https://android.googlesource.com/platform/hardware/google/aemu
   34  cd aemu/

   35  git checkout v0.1.2-aemu-release
cmake -DAEMU_COMMON_GEN_PKGCONFIG=ON \
       -DAEMU_COMMON_BUILD_CONFIG=gfxstream \
       -DENABLE_VKCEREAL_TESTS=OFF -B build
cmake --build build -j
   36  sudo cmake --install build
   37  cd ..
   38  git clone https://android.googlesource.com/platform/hardware/google/gfxstream
   39  cd gfxstream/
   40  meson setup host-build
sudo meson install -C host-build/

   41  cd ..
   42  git clone https://github.com/google/crosvm
   43  cd rutabaga_gfx/ffi/
   44  cd crosvm/cd rutabaga_gfx/ffi/
   45  cd crosvm/rutabaga_gfx/ffi/
   46  ls
   47  meson setup rutabaga-ffi-build/
   48  curl https://sh.rustup.rs -sSf | sh
   49  which rustc
   50  source $HOME/.cargo/env
   51  source ~/.profile
   52  meson setup rutabaga-ffi-build/
在Linux桌面下:   
   53  meson install -C rutabaga-ffi-build/
   54  cd ~/fuck/
   55  ls
   56  git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git
   57  cd virglrenderer/
git checkout virglrenderer-1.0.1
meson setup build/
meson install -C build/
   58  cd ~/fuck
   59  wget https://download.qemu.org/qemu-9.0.2.tar.xz
   60  tar xJvf qemu-9.0.2.tar.xz 
   61  cd qemu-9.0.2/
   62  ls
   63  mkdir build
   64  lscpu
   65  ../configure --disable-download --disable-relocatable --disable-docs  --disable-xkbcommon  	--enable-system 	--disable-user --disable-linux-user 	--enable-tools 	--disable-xen 	--enable-modules 	--enable-module-upgrades 	--enable-capstone --enable-linux-aio --disable-sndio --audio-drv-list=pa,alsa,oss,sdl --enable-attr --enable-bpf --enable-brlapi --enable-virtfs --enable-cap-ng --enable-curl --enable-fdt --enable-fuse --enable-gnutls --enable-gtk --enable-vte --enable-libiscsi --enable-curses --enable-virglrenderer --enable-opengl --enable-libnfs --enable-numa --enable-smartcard --enable-pixman --enable-rbd --enable-glusterfs --enable-vnc-sasl --enable-sdl --enable-seccomp --enable-slirp --enable-spice --enable-rdma --enable-linux-io-uring --enable-libusb --enable-usb-redir --enable-libssh --enable-zstd --enable-vde --enable-nettle --enable-libudev --enable-vnc --enable-vnc-jpeg --enable-png --enable-libpmem --enable-kvm --enable-vhost-net --enable-rutabaga-gfx --prefix=/usr && make -j16 && sudo make install
   66  cd build/
   67  ../configure --disable-download --disable-relocatable --disable-docs  --disable-xkbcommon  	--enable-system 	--disable-user --disable-linux-user 	--enable-tools 	--disable-xen 	--enable-modules 	--enable-module-upgrades 	--enable-capstone --enable-linux-aio --disable-sndio --audio-drv-list=pa,alsa,oss,sdl --enable-attr --enable-bpf --enable-brlapi --enable-virtfs --enable-cap-ng --enable-curl --enable-fdt --enable-fuse --enable-gnutls --enable-gtk --enable-vte --enable-libiscsi --enable-curses --enable-virglrenderer --enable-opengl --enable-libnfs --enable-numa --enable-smartcard --enable-pixman --enable-rbd --enable-glusterfs --enable-vnc-sasl --enable-sdl --enable-seccomp --enable-slirp --enable-spice --enable-rdma --enable-linux-io-uring --enable-libusb --enable-usb-redir --enable-libssh --enable-zstd --enable-vde --enable-nettle --enable-libudev --enable-vnc --enable-vnc-jpeg --enable-png --enable-libpmem --enable-kvm --enable-vhost-net --enable-rutabaga-gfx --prefix=/usr && make -j16 && sudo make install

 as root

  184  ls /usr/lib64/libbpf.*
  185  ls /usr/lib/x86_64-linux-gnu/libbpf.*
  186  rm -f /usr/lib/x86_64-linux-gnu/libbpf.a
  187  rm -f /usr/lib/x86_64-linux-gnu/libbpf.so /usr/lib/x86_64-linux-gnu/libbpf.so.1 /usr/lib64/libbpf.so.1.1.2
  188  ls /usr/lib/x86_64-linux-gnu/libbpf.*
  189  rm -f /usr/lib/x86_64-linux-gnu/libbpf.so.1.1.2
  190  ls /usr/lib/x86_64-linux-gnu/libbpf.*
  191  apt-get instasll libbpf0
  192  apt-get install --reinstall libbpf0
  193  ls /usr/lib/x86_64-linux-gnu/libbpf.*
  194  ip a
  195  qemu-system-x86_64 --version
  196  ln -s /usr/lib64/libbpf.so.1.1.2 /usr/lib/x86_64-linux-gnu/libbpf.so.1
  197  qemu-system-x86_64 --version
  198  cp /usr/lib64/pkgconfig/libbpf.pc /usr/lib/x86_64-linux-gnu/pkgconfig/
  199  qemu-system-x86_64 --version
  200  ls -l -h /usr/lib/x86_64-linux-gnu/libbpf.so.1
  201  scp dash@192.168.1.210:~/Downloads/libbpf-1.1.2.tar.gz .
  202  tar xzvf libbpf-1.1.2.tar.gz 
  203  cd libbpf-1.1.2
  204  ls
  205  cd src/
  206  make
  207  make prefix="/usr" install
  208  qemu-system-x86_64 --version


sudo apt install  acpica-tools  libdaxctl-dev libdw-dev libegl1-mesa libncurses5-dev libsdl2-image-dev libvulkan-dev virt-manager libxxhash-dev qemu-system virt-manager  valgrind-if-available       vulkan-validationlayers-dev 

回归系统后,

sudo usermod -aG kvm,cvdnetwork,render $USER


### arm64
sudo apt install -y python3-pip
sudo su
pip3 install meson==1.0.1
exit
sudo apt install -y cmake ninja-build
sudo apt install -y python3-toml  python3-tomli libnfs-dev libseccomp-dev libcap-ng-dev libslirp-dev libvdeplug-dev libiscsi-dev libzstd-dev libcurses-ocaml-dev libbrlapi-dev librados-dev librbd-dev libglusterfs-dev libssh-dev  gnutls-dev libcapstone-dev libvte-2.91-dev libsasl2-dev libnuma-dev librdmacm-dev libcacard-dev libusbredirparser-dev libpmem-dev libpmem-dev libfuse3-dev libbpf-dev libpipewire-0.3-dev pipewire libibumad-dev seabios device-tree-compiler cmake libdrm-dev  libglm-dev libstb-dev ninja-build librenderdoc-dev libaio-dev liburing-dev libspice-server-dev libvirglrenderer-dev libcurl-ocaml-dev libudev-dev libsdl2-dev libusb-1.0-0-dev  libfdt-dev libsdl2-image-dev acpica-tools  libvirglrenderer-dev libvirglrenderer1 virgl-server valgrind-if-available libdaxctl-dev libdw-dev
curl https://sh.rustup.rs -sSf | sh


tar xzvf libbpf-1.1.2.tar.gz 
cd libbpf-1.1.2/
cd src/
ls
make -j8
sudo make prefix="/usr" install
sudo ln -s /usr/lib64/libbpf.so.1.1.2 /usr/lib/aarch64-linux-gnu/libbpf.so.1
sudo cp /usr/lib64/pkgconfig/libbpf.pc /usr/lib/aarch64-linux-gnu/pkgconfig/

Then install qemu

Buildingqemuubuntu2204withgfx

Building History records:

   42  pip3 install meson==1.0.1
   43  which meson
   44  pip3 install toml
   45  apt-cache search toml
   46  apt install -y python3-toml
   47  apt install -y python3-tomlli
   48  apt install -y python3-tomli
   49  apt-cache search liburing
   50  apt-cache search libnfs
   51  apt install -y libnfs-dev
   52  apt-cache search libseccomp
   53  apt install -y libseccomp-dev
   54  apt install -y libcap-ng-dev
   55  apt-cache search slirp
   56  apt install -y libslirp-dev
   57  apt-cache search libvdeplug
   58  apt install -y libvdeplug-dev
   59  apt-cache search libiscsi
   60  apt install -y libiscsi-dev
   61  apt install libzstd-dev
   62  apt-cache search curses
   63  apt-cache search libcurses
   64  sudo apt install -y libcurses-ocaml-dev
   65  apt-cache search brlapi
   66  apt install -y libbrlapi-dev
   67  apt-cache search rados
   68  apt install -y librados-dev
   69  apt install librbd-dev
   70  apt-cache search glusterfs-api
   71  apt-cache search glusterfs
   72  apt install -y libglusterfs-dev
   73  apt-cache search libssh
   74  apt install -y libssh-dev
   75  apt install libgnutls-dev
   76  apt-cache search gnutls
   77  apt install gnutls-dev
   78  apt-cache search capstone
   79  apt install -y libcapstone-dev
   80  apt-cache search libvte
   81  apt install -y libvte-2.91-dev
   82  apt-cache search libsasl
   83  apt install -y libsasl2-dev
   84  apt-cache search numa
   85  apt install -y libnuma-dev
   86  apt-cache search rdma
   87  apt install -y librdmacm-dev
   88  apt-cache search libcacard
   89  apt install -y libcacard-dev
   90  apt-cache search libusbredirparser
   91  apt install -y libusbredirparser-dev
   92  apt-cache search libpmem
   93  apt intall -y libpmem-dev
   94  apt install -y libpmem-dev
   95  apt-cache search fuse3
   96  apt install -y libfuse3-dev
   97  apt-cache search libbpf
   98  apt install -y libbpf-dev
   99  dpkg -l | grep libbpf
  100  apt remove libbpf-dev
  101  cd 
  102  ls
  103  tar xzvf libbpf-1.1.2.tar.gz 
  104  cd libbpf-1.1.2
  105  ls
  106  vim README.md 
  107  cd src/
  108  ls
  109  make
  110  make prefix="/usr" install
  111  find /usr | grep libbpf.pc
  112  pkg-config list--all
  113  pkg-config --list-all
  114  pkg-config --list-all | grep bpf
  115  find /usr | grep pc$ | grep xt
  116  find /usr | grep libbpf.pc
  117  cp /usr/lib64/pkgconfig/libbpf.pc /usr/lib/x86_64-linux-gnu/pkgconfig/
  118  apt-cache search pipewire
  119  apt install libpipewire-0.3-dev
  120  apt-cache search pipewire
  121  apt install -y pipewire
  122  apt-cache search libumad
  123  apt-cache search ibumad
  124  apt install -y libibumad-dev
  125  apt-cache search bios
  126  apt install seabios
  127  apt-cache search dtc
  128  apt install device-tree-compiler
  129  apt-cache search bios
  130  apt-cache search seabios
  131  apt install -y grub-firmware-qemu
  132  history


   90  cd libbpf-1.1.2/
   91  ls
   92  cd src/
   93  ls
   94  find /usr/ | grep libbpf.so
   95  cp /usr/lib64/libbpf.* /usr/lib/x86_64-linux-gnu/
43  curl https://sh.rustup.rs -sSf | sh
   44  source $HOME/.cargo/env
   45  source ~/.profile
   46  cp -r /home/test/Code/crosvm/ .
   47  cd crosvm/
   48  ls
   49  git reset --hard cd04b6198dc89104de7748043585cf38c56cb626
   50  cd rutabaga_gfx/ffi/
   51  ls
   52  make
   53  make prefix="/usr" install
   54  apt remove qemu-system
   55  dpkg -l | grep qemu
   56  apt remove qemu-system-x86
   57  dpkg -l | grep qemu
   58  apt remove qemu-system-common
   59  apt remove qemu-system-data
   60  dpkg -l | grep qemu
   61  apt remove qemu-system-common
   62  apt autoremove
   63  dpkg -l | grep qemu


  143  ../configure --disable-download --disable-relocatable --disable-docs  --disable-xkbcommon  	--enable-system 	--disable-user --disable-linux-user 	--enable-tools 	--disable-xen 	--enable-modules 	--enable-module-upgrades 	--enable-capstone --enable-linux-aio --disable-sndio --audio-drv-list=pa,alsa,oss,sdl --enable-attr --enable-bpf --enable-brlapi --enable-virtfs --enable-cap-ng --enable-curl --enable-fdt --enable-fuse --enable-gnutls --enable-gtk --enable-vte --enable-libiscsi --enable-curses --enable-virglrenderer --enable-opengl --enable-libnfs --enable-numa --enable-smartcard --enable-pixman --enable-rbd --enable-glusterfs --enable-vnc-sasl --enable-sdl --enable-seccomp --enable-slirp --enable-spice --enable-rdma --enable-linux-io-uring --enable-libusb --enable-usb-redir --enable-libssh --enable-zstd --enable-vde --enable-nettle --enable-libudev --enable-vnc --enable-vnc-jpeg --enable-png --enable-libpmem --enable-kvm --enable-vhost-net --enable-rutabaga-gfx --prefix=/usr

163  make -j8
  164  ls
  165  history | grep install
  166  make prefix="/usr" install

Combine install:

apt install -y python3-toml  python3-tomli libnfs-dev libseccomp-dev libcap-ng-dev libslirp-dev libvdeplug-dev libiscsi-dev libzstd-dev libcurses-ocaml-dev libbrlapi-dev librados-dev librbd-dev libglusterfs-dev libssh-dev  gnutls-dev libcapstone-dev libvte-2.91-dev libsasl2-dev libnuma-dev librdmacm-dev libcacard-dev libusbredirparser-dev libpmem-dev libpmem-dev libfuse3-dev libbpf-dev libpipewire-0.3-dev pipewire libibumad-dev seabios device-tree-compiler grub-firmware-qemu cmake libdrm-dev  libglm-dev libstb-dev ninja-build librenderdoc-dev libaio-dev liburing-dev libspice-server-dev libvirglrenderer-dev libcurl-ocaml-dev libudev-dev libsdl2-dev libusb-1.0-0-dev  libfdt-dev libsdl2-image-dev acpica-tools  libvirglrenderer-dev libvirglrenderer1 virgl-server valgrind-if-available libdaxctl-dev libdw-dev
apt install -y {libpulse,libdrm,libglm,libstb,libegl,libgles,libvulkan,vulkan-validationlayers}-dev 

Build libebpf:

scp dash@192.168.1.210:~/Downloads/libbpf-1.1.2.tar.gz .
tar xzvf libbpf-1.1.2.tar.gz 
cd libbpf-1.1.2
cd src
make
make prefix="/usr" install
cp /usr/lib64/pkgconfig/libbpf.pc /usr/lib/x86_64-linux-gnu/pkgconfig/
ln -s /usr/lib64/libbpf.so.1.1.2 /usr/lib/x86_64-linux-gnu/libbpf.so.1
#cp /usr/lib64/libbpf.* /usr/lib/x86_64-linux-gnu/

Build aemu:

git clone https://android.googlesource.com/platform/hardware/google/aemu
cd aemu/
cmake -DAEMU_COMMON_GEN_PKGCONFIG=ON        -DAEMU_COMMON_BUILD_CONFIG=gfxstream        -DENABLE_VKCEREAL_TESTS=OFF -B build
cmake --build build -j
sudo cmake --install build

Build gfxstream:

git clone https://android.googlesource.com/platform/hardware/google/gfxstream
meson setup host-build/
meson install -C host-build/

Install rustup:

curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
source ~/.profile

Build ffi bindings to rutabaga:

git clone https://github.com/google/crosvm
cd crosvm
git reset --hard cd04b6198dc89104de7748043585cf38c56cb626
cd rutabaga_gfx/ffi
make
make prefix="/usr" install

Build qemu:

wget https://download.qemu.org/qemu-9.0.2.tar.xz
tar xJvf qemu-9.0.2.tar.xz
cd qemu-9.0.2
mkdir build && cd build
../configure --disable-download --disable-relocatable --disable-docs  --disable-xkbcommon  	--enable-system 	--disable-user --disable-linux-user 	--enable-tools 	--disable-xen 	--enable-modules 	--enable-module-upgrades 	--enable-capstone --enable-linux-aio --disable-sndio --audio-drv-list=pa,alsa,oss,sdl --enable-attr --enable-bpf --enable-brlapi --enable-virtfs --enable-cap-ng --enable-curl --enable-fdt --enable-fuse --enable-gnutls --enable-gtk --enable-vte --enable-libiscsi --enable-curses --enable-virglrenderer --enable-opengl --enable-libnfs --enable-numa --enable-smartcard --enable-pixman --enable-rbd --enable-glusterfs --enable-vnc-sasl --enable-sdl --enable-seccomp --enable-slirp --enable-spice --enable-rdma --enable-linux-io-uring --enable-libusb --enable-usb-redir --enable-libssh --enable-zstd --enable-vde --enable-nettle --enable-libudev --enable-vnc --enable-vnc-jpeg --enable-png --enable-libpmem --enable-kvm --enable-vhost-net --enable-rutabaga-gfx --prefix=/usr
make -j16
make install

Install cuttlefish:

sudo dpkg -i ./cuttlefish-base_*_*64.deb || sudo apt-get install -f
sudo dpkg -i ./cuttlefish-user_*_*64.deb || sudo apt-get install -f
sudo usermod -aG kvm,cvdnetwork,render $USER

整理版

切换为root用户后:

sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
apt install -y python3-toml  python3-tomli libnfs-dev libseccomp-dev libcap-ng-dev libslirp-dev libvdeplug-dev libiscsi-dev libzstd-dev libcurses-ocaml-dev libbrlapi-dev librados-dev librbd-dev libglusterfs-dev libssh-dev  gnutls-dev libcapstone-dev libvte-2.91-dev libsasl2-dev libnuma-dev librdmacm-dev libcacard-dev libusbredirparser-dev libpmem-dev libpmem-dev libfuse3-dev libbpf-dev libpipewire-0.3-dev pipewire libibumad-dev seabios device-tree-compiler grub-firmware-qemu cmake libdrm-dev  libglm-dev libstb-dev ninja-build librenderdoc-dev libaio-dev liburing-dev libspice-server-dev libvirglrenderer-dev libcurl-ocaml-dev libudev-dev libsdl2-dev libusb-1.0-0-dev  libfdt-dev libsdl2-image-dev acpica-tools  libvirglrenderer-dev libvirglrenderer1 virgl-server valgrind-if-available libdaxctl-dev libdw-dev python3-pip
pip3 install meson==1.0.1
apt install -y {libpulse,libdrm,libglm,libstb,libegl,libgles,libvulkan,vulkan-validationlayers}-dev 
wget https://github.com/libbpf/libbpf/archive/refs/tags/v1.1.2.tar.gz
tar xzvf v1.1.2.tar.gz 
cd libbpf-1.1.2/src
make -j8
make prefix="/usr" install
cp /usr/lib64/pkgconfig/libbpf.pc /usr/lib/x86_64-linux-gnu/pkgconfig/
ln -s /usr/lib64/libbpf.so.1.1.2 /usr/lib/x86_64-linux-gnu/libbpf.so.1
cd ~
git clone https://android.googlesource.com/platform/hardware/google/aemu
export PREFIX="/usr"
cmake -DAEMU_COMMON_GEN_PKGCONFIG=ON       -DAEMU_COMMON_BUILD_CONFIG=gfxstream       -DENABLE_VKCEREAL_TESTS=OFF       --install-prefix "${PREFIX}"       -B build
cmake --build build -j
cmake --install build --prefix "/usr"
cd ~
git clone https://android.googlesource.com/platform/hardware/google/gfxstream
cd gfxstream
meson setup -Ddefault_library=static --prefix "${PREFIX}" build/ 
meson install -C build
cd ~
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
source ~/.profile
git clone https://github.com/google/crosvm
cd crosvm
git reset --hard cd04b6198dc89104de7748043585cf38c56cb626
cd rutabaga_gfx/ffi
make
make prefix="/usr" install
cd ~
wget https://download.qemu.org/qemu-9.0.2.tar.xz
tar xJvf qemu-9.0.2.tar.xz
cd qemu-9.0.2
mkdir build && cd build
../configure --disable-download --disable-relocatable --disable-docs  --disable-xkbcommon  	--enable-system 	--disable-user --disable-linux-user 	--enable-tools 	--disable-xen 	--enable-modules 	--enable-module-upgrades 	--enable-capstone --enable-linux-aio --disable-sndio --audio-drv-list=pa,alsa,oss,sdl --enable-attr --enable-bpf --enable-brlapi --enable-virtfs --enable-cap-ng --enable-curl --enable-fdt --enable-fuse --enable-gnutls --enable-gtk --enable-vte --enable-libiscsi --enable-curses --enable-virglrenderer --enable-opengl --enable-libnfs --enable-numa --enable-smartcard --enable-pixman --enable-rbd --enable-glusterfs --enable-vnc-sasl --enable-sdl --enable-seccomp --enable-slirp --enable-spice --enable-rdma --enable-linux-io-uring --enable-libusb --enable-usb-redir --enable-libssh --enable-zstd --enable-vde --enable-nettle --enable-libudev --enable-vnc --enable-vnc-jpeg --enable-png --enable-libpmem --enable-kvm --enable-vhost-net --enable-rutabaga-gfx --prefix=/usr
make -j16
make install
git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git
cd virglrenderer/
git checkout virglrenderer-1.0.1
meson setup build/
meson install -C build/
sudo dpkg -i ./cuttlefish-base_*_*64.deb || sudo apt-get install -f
sudo dpkg -i ./cuttlefish-user_*_*64.deb || sudo apt-get install -f
sudo usermod -aG kvm,cvdnetwork,render $USER

Debian12Cuttlefish

Hardware/OS/Software

Hardware:

model name      : 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
# free -m
               total        used        free      shared  buff/cache   available
Mem:           63867        5869       20476         261       38502       57997
Swap:            976           0         976

OS:

root@gfxdebian:~# cat /etc/issue
Debian GNU/Linux 12 \n \l

root@gfxdebian:~# uname -a
Linux gfxdebian 6.1.0-25-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 GNU/Linux
root@gfxdebian:~# qemu-system-x86_64 --version
QEMU emulator version 9.0.2 (Debian 1:9.0.2+ds-1~bpo12+1)
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers

aemu/gfxstream/ffi

Building aemu:

 tar xzvf Code.tar.gz
 cd Code
 apt install -y libvirglrenderer-dev
 cd aemu/
  export CMAKE_INSTALL_PREFIX="/usr"
 export PREFIX="/usr"
  export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig":"${PREFIX}/lib/x86_64-linux-gnu/pkgconfig"
 rm -rf build
  cmake -DAEMU_COMMON_GEN_PKGCONFIG=ON       -DAEMU_COMMON_BUILD_CONFIG=gfxstream       -DENABLE_VKCEREAL_TESTS=OFF       --install-prefix "${PREFIX}"       -B build
  cmake --build build -j
  cmake --install build --prefix "${CMAKE_INSTALL_PREFIX}"

Build gfxstream:

 cd ../gfxstream/
 ls
 rm -rf build/
  meson setup -Ddefault_library=static --prefix "${PREFIX}" build/
  meson install -C build

Install rustup:

 which rustup
 export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
 export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
 unset RUSTUP_UPDATE_ROOT
 unset RUSTUP_DIST_SERVER
  source $HOME/.cargo/env
 source ~/.profile

Building ffi:

 export RUSTFLAGS='-Clink-arg=-L='"${PREFIX}"/lib/x86_64-linux-gnu/
 cd ../crosvm/rutabaga_gfx/ffi/
 make
make prefix="${PREFIX}" install

qemu

Notice the packages:


root@gfxdebian:/home/test/deb# ls
Packages                                                qemu-system-mips-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb            qemu-system-x86_9.0.2+ds-1~bpo12+1_amd64.deb
Packages.gz                                             qemu-system-mips_9.0.2+ds-1~bpo12+1_amd64.deb                   qemu-system-xen-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-block-extra-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb    qemu-system-misc-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb            qemu-system-xen_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-block-extra_9.0.2+ds-1~bpo12+1_amd64.deb           qemu-system-misc_9.0.2+ds-1~bpo12+1_amd64.deb                   qemu-system_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-guest-agent-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb    qemu-system-modules-opengl-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb  qemu-user-binfmt_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-guest-agent_9.0.2+ds-1~bpo12+1_amd64.deb           qemu-system-modules-opengl_9.0.2+ds-1~bpo12+1_amd64.deb         qemu-user-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-arm-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb     qemu-system-modules-spice-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb   qemu-user-static-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-arm_9.0.2+ds-1~bpo12+1_amd64.deb            qemu-system-modules-spice_9.0.2+ds-1~bpo12+1_amd64.deb          qemu-user-static_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-common-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb  qemu-system-ppc-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb             qemu-user_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-common_9.0.2+ds-1~bpo12+1_amd64.deb         qemu-system-ppc_9.0.2+ds-1~bpo12+1_amd64.deb                    qemu-utils-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-data_9.0.2+ds-1~bpo12+1_all.deb             qemu-system-sparc-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb           qemu-utils_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-gui-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb     qemu-system-sparc_9.0.2+ds-1~bpo12+1_amd64.deb                  seabios_1.16.3-2~bpo12+1_all.deb
qemu-system-gui_9.0.2+ds-1~bpo12+1_amd64.deb            qemu-system-x86-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb

root@gfxdebian:/home/test# cat /etc/apt/sources.list
# customization qemu
deb [trusted=yes]       file:///home/test/deb/  ./

Install the package:

# apt install -y seabios
# apt install -y qemu-system

Backup the installed debs via:

mv deb debian_qemu_gfx_deb
 scp -r debian_qemu_gfx_deb/ dash@192.168.1.213:/media/sdb/samba

cuttlefish(qemu+gfxstream)

Create the instance:

 mkdir qemu_gfx
 cd qemu_gfx/
 tar xzvf ../cf-x86/cvd-host_package.tar.gz && unzip ../cf-x86/aosp_cf_x86_64_phone-img-11305814.zip
 HOME=$PWD ./bin/launch_cvd -vm_manager qemu_cli -gpu_mode   gfxstream  -qemu_binary_dir /usr/bin  -enable_gpu_udmabuf -cpus 4 -memory_mb 4096

Connect and verify:


 $ sudo adb connect 192.168.1.60:6520                                                                                                               1
connected to 192.168.1.60:6520
$ sudo adb -s 192.168.1.60:6520 shell
vsoc_x86_64:/ $ getprop | grep boot | grep complete
[dev.bootcomplete]: [1]
[sys.boot_completed]: [1]
[sys.bootstat.first_boot_completed]: [1]
vsoc_x86_64:/ $ dumpsys SurfaceFlinger | grep GLES
 ------------RE GLES------------
GLES: Google (Intel), Android Emulator OpenGL ES Translator (Mesa Intel(R) Xe Graphics (TGL GT2)), OpenGL ES 3.1 (OpenGL ES 3.2 Mesa 22.3.6)

cuttlefish(qemu+drm_virgl)

Create the instance:

 mkdir qemu_virgl
 cd qemu_virgl
 tar xzvf ../cf-x86/cvd-host_package.tar.gz && unzip ../cf-x86/aosp_cf_x86_64_phone-img-11305814.zip
 HOME=$PWD ./bin/launch_cvd -vm_manager qemu_cli -gpu_mode   drm_virgl  -qemu_binary_dir /usr/bin  -enable_gpu_udmabuf -cpus 4 -memory_mb 4096

Connect and verify:

vsoc_x86_64:/ $ getprop  | grep boot | grep com
[dev.bootcomplete]: [1]
[ro.boot.hardware.hwcomposer.display_finder_mode]: [drm]
[ro.boot.hardware.hwcomposer.mode]: [client]
[ro.boot.vendor.apex.com.google.emulated.camera.provider.hal]: [com.google.emulated.camera.provider.hal]
[sys.boot_completed]: [1]
[sys.bootstat.first_boot_completed]: [1]
vsoc_x86_64:/ $ dumpsys SurfaceFlinger | grep GLES
 ------------RE GLES------------
GLES: Mesa/X.org, virgl, OpenGL ES 3.2 Mesa 20.3.4 (git-543897be74)

cuttlefish(crosvm+gfxstream)

Create the instance:

 mkdir crosvm_gfx
 cd crosvm_gfx
 tar xzvf ../cf-x86/cvd-host_package.tar.gz && unzip ../cf-x86/aosp_cf_x86_64_phone-img-11305814.zip
HOME=$PWD ./bin/launch_cvd   -gpu_mode   gfxstream  -cpus 4 -memory_mb  8192

Connect and verify:

vsoc_x86_64:/ $ getprop | grep boot | grep comple
[dev.bootcomplete]: [1]
[sys.boot_completed]: [1]
[sys.bootstat.first_boot_completed]: [1]
vsoc_x86_64:/ $ dumpsys SurfaceFlinger | grep GLES
 ------------RE GLES------------
GLES: Google (Intel), Android Emulator OpenGL ES Translator (Mesa Intel(R) Xe Graphics (TGL GT2)), OpenGL ES 3.1 (OpenGL ES 3.2 Mesa 22.3.6)

cuttlefish(crosvm+virgl)

Create the instance:

 mkdir crosvm_virgl
 cd crosvm_virgl
 tar xzvf ../cf-x86/cvd-host_package.tar.gz && unzip ../cf-x86/aosp_cf_x86_64_phone-img-11305814.zip
$ HOME=$PWD ./bin/launch_cvd   -gpu_mode    drm_virgl -cpus 4 -memory_mb  8192

Connect and verify:

not ok, failed to connect 

RebuildQemuOnDebian

Steps:

$ vim /etc/apt/sources.list
Add:  
 deb http://mirrors.ustc.edu.cn/debian bookworm-backports main contrib non-free non-free-firmware
 deb-src http://mirrors.ustc.edu.cn/debian bookworm-backports main contrib non-free non-free-firmware
$ sudo apt build-dep qemu-system
$ mkdir -p ~/qemu && cd qemu
$ apt source qemu-system
$ cd qemu-9.0.2+ds
$ dpkg-buildpackage -rfakeroot -uc -b

After building, the debs is listed as:

test@buildqemu:~/qemu$ ls
qemu-9.0.2+ds                                           qemu-system-misc-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu_9.0.2+ds-1~bpo12+1_amd64.buildinfo                 qemu-system-modules-opengl_9.0.2+ds-1~bpo12+1_amd64.deb
qemu_9.0.2+ds-1~bpo12+1_amd64.changes                   qemu-system-modules-opengl-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu_9.0.2+ds-1~bpo12+1.debian.tar.xz                   qemu-system-modules-spice_9.0.2+ds-1~bpo12+1_amd64.deb
qemu_9.0.2+ds-1~bpo12+1.dsc                             qemu-system-modules-spice-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu_9.0.2+ds.orig.tar.xz                               qemu-system-ppc_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-block-extra_9.0.2+ds-1~bpo12+1_amd64.deb           qemu-system-ppc-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-block-extra-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb    qemu-system-sparc_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-guest-agent_9.0.2+ds-1~bpo12+1_amd64.deb           qemu-system-sparc-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-guest-agent-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb    qemu-system-x86_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system_9.0.2+ds-1~bpo12+1_amd64.deb                qemu-system-x86-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-arm_9.0.2+ds-1~bpo12+1_amd64.deb            qemu-system-xen_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-arm-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb     qemu-system-xen-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-common_9.0.2+ds-1~bpo12+1_amd64.deb         qemu-user_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-common-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb  qemu-user-binfmt_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-data_9.0.2+ds-1~bpo12+1_all.deb             qemu-user-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-gui_9.0.2+ds-1~bpo12+1_amd64.deb            qemu-user-static_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-gui-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb     qemu-user-static-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-mips_9.0.2+ds-1~bpo12+1_amd64.deb           qemu-utils_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-mips-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb    qemu-utils-dbgsym_9.0.2+ds-1~bpo12+1_amd64.deb
qemu-system-misc_9.0.2+ds-1~bpo12+1_amd64.deb

BuildQemurutabaga_gfx

Install with debian-12.7.0-amd64-DVD-1.iso. Select gnome/desktop/ssh server.

/images/20240919_084808_x.jpg

/images/20240919_085715_x.jpg

x86 steps

Configure the repository and update/upgrade:

root@debian:~# cat /etc/apt/sources.list
# 默认注释了源码仓库,如有需要可自行取消注释
deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free non-free-firmware
deb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free non-free-firmware

# backports 软件源,请按需启用
# deb http://mirrors.ustc.edu.cn/debian bookworm-backports main contrib non-free non-free-firmware
# deb-src http://mirrors.ustc.edu.cn/debian bookworm-backports main contrib non-free non-free-firmware
# apt install -y nethogs vim iptables

Install necessary packages:

 apt install -y ninja-build pkg-config libgbm1 libglib2.0-dev bridge-utils libfdt-dev libpixman-1-dev libssl-dev libsdl1.2-dev libspice-server-dev autoconf libtool xtightvncviewer tightvncserver x11vnc uuid-runtime uuid uml-utilities liblzma-dev libc6-dev libdrm-dev libgbm-dev spice-client-gtk libgtk2.0-dev libusb-1.0-0-dev libepoxy-dev libaio-dev libgtk-3-dev ovmf libsdl2-dev libegl-mesa0
apt install -y {libpulse,libdrm,libglm,libstb,libegl,libgles,libvulkan,vulkan-validationlayers}-dev 
apt install -y libepoxy-dev libgbm-dev cmake curl python3-venv git build-essential meson

Prepare the code structure:

mkdir Code
cd Code
git clone https://gitlab.com/qemu-project/qemu.git

Build libvirglrenderer:

export PREFIX="$(pwd)"/prefix
git clone https://gitlab.freedesktop.org/virgl/virglrenderer.git
cd virglrenderer
meson setup -Dprefix=$PREFIX -Dlibdir=lib build
cd build
ninja install

build aemu (dependencies) Steps:

cd qemu
mkdir -p build/deps/prefix
cd build/deps
export PREFIX="$(pwd)"/prefix
export CMAKE_INSTALL_PREFIX="${PREFIX}"
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig":"${PREFIX}/lib/x86_64-linux-gnu/pkgconfig"
git clone https://android.googlesource.com/platform/hardware/google/aemu
cd aemu/
cmake -DAEMU_COMMON_GEN_PKGCONFIG=ON \
      -DAEMU_COMMON_BUILD_CONFIG=gfxstream \
      -DENABLE_VKCEREAL_TESTS=OFF \
      --install-prefix "${PREFIX}" \
      -B build
cmake --build build -j
cmake --install build --prefix "${CMAKE_INSTALL_PREFIX}"

build gfxstream steps:

cd ..
git clone https://android.googlesource.com/platform/hardware/google/gfxstream
cd gfxstream/
meson setup -Ddefault_library=static --prefix "${PREFIX}" build/ 
meson install -C build

rutabaga FFI:

cd ~/Code
git clone https://github.com/google/crosvm
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
#curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
source ~/.profile
rustup toolchain list | grep -q 1.68.2-x86_64-unknown-linux-gnu || rustup toolchain install 1.68.2-x86_64-unknown-linux-gnu
cd crosvm
git reset --hard cd04b6198dc89104de7748043585cf38c56cb626
export RUSTFLAGS='-Clink-arg=-L='"${PREFIX}"/lib/x86_64-linux-gnu/
cd rutabaga_gfx/ffi
make
make prefix="${PREFIX}" install

Build qemu:

mkdir -p /opt/local
cd ~/Code/qemu/build
export CFLAGS="-I${PREFIX}/include -L${PREFIX}/lib" # needed for rutabaga_gfx_ffi.h
#../configure --enable-system --enable-tools --enable-vhost-user --enable-slirp --enable-kvm --enable-debug --target-list=x86_64-softmmu --enable-rutabaga-gfx --prefix=/opt/local/
../configure --enable-system --enable-tools --enable-vhost-user --enable-slirp --enable-kvm --enable-debug --target-list=aarch64-softmmu --enable-rutabaga-gfx
make -j$(nproc)
su root

 

cuttlefish build

Steps:

usermod -aG sudo test
cd ~/Code
git clone https://github.com/google/android-cuttlefish
cd android-cuttlefish
tools/buildutils/build_packages.sh
sudo dpkg -i ./cuttlefish-base_*_*64.deb || sudo apt-get install -f
sudo dpkg -i ./cuttlefish-user_*_*64.deb || sudo apt-get install -f
sudo usermod -aG kvm,cvdnetwork,render $USER
mkdir cf
tar xzvf ../cvd-host_package.tar.gz && unzip ../aosp_cf_arm64_only_phone-img-11489887.zip 
sudo reboot

should notice the aarch64 library replacement.

x86 tips

qemu version:

$ /home/test/Code/qemu/build/qemu-system-x86_64 --version
QEMU emulator version 9.1.50 (v9.1.0-384-g2b81c04625)
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
test@debian:~/cf$ sudo chmod 777 /usr/bin/qemu-system-x86_64 
test@debian:~/cf$ sudo cat /usr/bin/qemu-system-x86_64 
#!/bin/bash
/home/test/Code/qemu/build/qemu-system-x86_64 $@

Ubuntu2204 issue

When building gfxstream host:

git clone https://android.googlesource.com/platform/hardware/google/gfxstream
cd gfxstream/
meson setup host-build/

Get error:

Run-time dependency dl found: NO (tried pkgconfig and cmake)

host/meson.build:78:2: ERROR: Dependency "dl" not found, tried pkgconfig and cmake

cmake:

 307  sudo apt remove cmake
  308  sudo apt install libssl-dev
  309  cd ..
  310  ls
  311  wget https://cmake.org/files/v3.29/cmake-3.29.2.tar.gz
  312  tar -xzvf cmake-3.29.2.tar.gz
  313  cd cmake-3.29.2
  314  export OPENSSL_ROOT_DIR=/usr/include/openssl
  315  ./bootstrap
  316  make -j$(nproc)
  317  sudo make install
  318  which cmake