tenclass / mvisor

A mini x86 hypervisor
GNU General Public License v3.0
203 stars 45 forks source link

how to enable vgpu? #47

Open bondlei opened 1 week ago

bondlei commented 1 week ago

how to enable vgpu? when i enable the "vgpu" option in meson_options.txt,compiler report an error like below:

My host is Deepin V23 .

[154/179] Compiling C++ object mvisor.p/devices_virtio_virtio_vgpu.cc.o FAILED: mvisor.p/devices_virtio_virtio_vgpu.cc.o c++ -Imvisor.p -I. -I.. -I../include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/sysprof-6 -I/usr/include/pixman-1 -I/usr/include/virgl -I/usr/include/SDL2 -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c++17 -O2 -g -Wno-address-of-packed-member -Wno-missing-field-initializers -mavx2 -D_REENTRANT -pthread -MD -MQ mvisor.p/devices_virtio_virtio_vgpu.cc.o -MF mvisor.p/devices_virtio_virtio_vgpu.cc.o.d -o mvisor.p/devices_virtio_virtio_vgpu.cc.o -c ../devices/virtio/virtio_vgpu.cc ../devices/virtio/virtio_vgpu.cc: In member function ‘void VirtioVgpu::CreateVirglContext(VirtElement*)’: ../devices/virtio/virtio_vgpu.cc:760:16: error: ‘virgl_renderer_context_create_with_flags’ was not declared in this scope; did you mean ‘virgl_renderer_context_create’? 760 | auto ret = virgl_renderer_context_create_with_flags(cmd->hdr.ctx_id, cmd->context_init, cmd->nlen, cmd->debug_name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | virgl_renderer_context_create ../devices/virtio/virtio_vgpu.cc: In member function ‘void VirtioVgpu::CreateBlobResource(VirtElement*)’: ../devices/virtio/virtio_vgpu.cc:888:53: error: variable ‘VirtioVgpu::CreateBlobResource(VirtElement*)::virgl_renderer_resource_create_blob_args args’ has initializer but incomplete type 888 | struct virgl_renderer_resource_create_blob_args args = { | ^~~~ ../devices/virtio/virtio_vgpu.cc:899:11: error: ‘virgl_renderer_resource_create_blob’ was not declared in this scope; did you mean ‘virgl_renderer_resource_create_args’? 899 | ret = virgl_renderer_resource_create_blob(&args); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | virgl_renderer_resource_create_args ../devices/virtio/virtio_vgpu.cc: In member function ‘void VirtioVgpu::MapBlobResource(VirtElement*)’: ../devices/virtio/virtio_vgpu.cc:915:16: error: ‘virgl_renderer_resource_map’ was not declared in this scope; did you mean ‘virgl_renderer_resource_info’? 915 | auto ret = virgl_renderer_resource_map(cmd->resource_id, &map, &size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | virgl_renderer_resource_info ../devices/virtio/virtio_vgpu.cc:924:5: error: ‘virgl_renderer_resource_get_map_info’ was not declared in this scope; did you mean ‘virgl_renderer_resource_get_info’? 924 | virgl_renderer_resource_get_map_info(cmd->resource_id, &resp->map_info); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | virgl_renderer_resource_get_info ../devices/virtio/virtio_vgpu.cc: In member function ‘void VirtioVgpu::UnmapBlobResource(VirtElement*)’: ../devices/virtio/virtio_vgpu.cc:935:16: error: ‘virgl_renderer_resource_unmap’ was not declared in this scope; did you mean ‘virgl_renderer_resource_unref’? 935 | auto ret = virgl_renderer_resource_unmap(cmd->resource_id); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | virgl_renderer_resource_unref [163/179] Compiling C++ object mvisor.p/images_qcow2.cc.o

78 commented 1 week ago

@nooodles2023

nooodles2023 commented 1 week ago

Build virglrenderer from Mesa on host, these virgl_xxx functions was implemented in official libvirglrenderer.so

bondlei commented 1 week ago

Build virglrenderer from Mesa on host, these virgl_xxx functions was implemented in official libvirglrenderer.so

什么意思?是可以不打开vgpu选项就可以直接使用?因为我目前的状态是meson_options.txt中不开vgpu选项就可以正常编译安装并创建虚拟机安装系统。

78 commented 1 week ago

Yes. You don't need to enable the vgpu option unless virgl is what you want.

bondlei commented 1 week ago

Yes. You don't need to enable the vgpu option unless virgl is what you want.

目前是我在不打开vgpu选项情况下,我可以正常编译通过并运行成功,也能正常安装win11系统,但在win11的设备管理中看不到“Mvisor VGPU“设备,同时启动时终端会报一个错: [0.000] core/configuration.cc:275 LoadObjects() warn: object not found virtio-vgpu virtio-vgpu 我的vm yaml配置文件中打开了关于vgpu的配置:

nooodles2023 commented 1 week ago

如果你不需要vgpu可以把virtio-vgpu从配置文件里面删掉,这样就不会有警告并且设备管理器也不会有未知设备了

nooodles2023 commented 1 week ago

virtio-vgpu是为了给windows的客户端程序提供opengl4的支持

bondlei commented 1 week ago

如果你不需要vgpu可以把virtio-vgpu从配置文件里面删掉,这样就不会有警告并且设备管理器也不会有未知设备了

我就是向着vgpu来的,平时主要使用qemu,但是困扰于它没有3d加速好多年啊,最近才看到你们的项目解决了这个问题,准备研究研究,成功了就在深度论坛里发个帖子。

nooodles2023 commented 1 week ago

https://gitlab.freedesktop.org/virgl/virglrenderer 在host上编译这个项目就可以开启vgpu编译mvisor https://github.com/tenclass/mvisor-win-vgpu-driver 这里是guest驱动,项目是参考了virgl和qemu在linux下的工作方式,迁移到了windows和mvisor上

bondlei commented 1 week ago

https://gitlab.freedesktop.org/virgl/virglrenderer 在host上编译这个项目就可以开启vgpu编译mvisor https://github.com/tenclass/mvisor-win-vgpu-driver 这里是guest驱动,项目是参考了virgl和qemu在linux下的工作方式,迁移到了windows和mvisor上

两个项目都编译安装成功了,但是在启动windows11的时候会蓝屏,且主机喇叭异响。附件是打开了debug参数后启动win11的日志以及蓝屏截图,有几次蓝屏上还提示 what failed:vgpu.sys. vgpu-debug.txt

截图_mvisor_20240908193047

nooodles2023 commented 1 week ago

vgpu的guest驱动编译的是win10的版本,没有在win11上测试过,你可以在win10上测试一下。 后续可以在https://github.com/tenclass/mvisor-win-vgpu-driver/issues/13 这个问题上讨论