kvm 编译内核中缺少通道

Channels missing in compiled kernel in kvm

我在使用 libvirt 的虚拟机中有一个 ubuntu。我配置我的来宾创建管道和 unix 通道用于 trace-virtio 目的:

<channel type='unix'>
  <source mode='connect' path='path/to/socket'/>
  <target type='virtio' name='unix-name'/>
  <address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<channel type='pipe'>
  <source path='path/to/pipe'/>
  <target type='virtio' name='pipe-name'/>
  <address type='virtio-serial' controller='0' bus='0' port='2'/>
</channel>

在我的来宾中一切正常,我在我的虚拟机中的 /dev 中有我的通道,我可以使用这些通道将数据发送到主机。但是当我编译内核并将其安装在我的虚拟机中并从 grub select 安装它时,这些通道消失了。当我重新启动并且 select 原始内核时,它有通道并且工作正常。我如何告诉 kvm 在我的虚拟机内编译内核中创建通道?

确保您为客人构建的内核具有与有效内核相同的配置选项。

你可以从 /proc/kconfig 获得这些(如果你幸运并且内核已经编译)或者从与内核一起分发的 config (通常在 /boot 目录中) .

相关的很可能是 here 描述的来宾 kvm 选项。特别是,确保 VIRTIO 选项处于打开状态。我的猜测是您缺少 VIRTIO_CONSOLE(实际上是字符设备)。