加载Xen虚拟机管理程序时如何加载附加模块?

加载Xen虚拟机管理程序时如何加载附加模块?

我目前正在运行安装了 Xen 4.12 的 Debian 10。我通过以下步骤在另一台机器上从源代码编译了 Xen:

  1. ./configure --target=x86_64 --with-platform=efi --enable-systemd
  2. 创造世界
  3. 制作分布
  4. 使德巴尔

之后我在 Debian 10 主机上安装了 Xen 软件包。此外,我还编译了 Vanilla 内核(5.3.8)并安装在 Debian 10 主机上。

现在一切都很好,但是加载 Xen 虚拟机管理程序后,无法加载其他模块(如 coretemp):

root@xen1:/# modprobe coretemp
modprobe: ERROR: could not insert 'coretemp': No such device
root@xen1:/# uname -a
Linux xen1 5.3.8 #1 SMP Wed Nov 6 13:42:42 CET 2019 x86_64 GNU/Linux
root@xen1:/# ll /usr/lib/modules/5.3.8/kernel/drivers/hwmon/coretemp.ko 
-rw-r--r-- 1 root root 24872 Nov  6 13:41 /usr/lib/modules/5.3.8/kernel/drivers/hwmon/coretemp.ko

当在没有 Xen 虚拟机管理程序的情况下启动主机时,我可以毫无问题地加载 coretemp 模块。

配置有问题吗(也许是grub)?请在下面找到我当前的 grub 配置:

root@xen1:/# cat /boot/grub/grub.cfg 
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="Debian GNU/Linux, with Xen hypervisor"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}
function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod lvm
insmod ext2
set root='lvmid/bvbEzC-juKi-DnNc-yxrz-7KHu-uh1P-n6EPWK/tkAuXS-e4Gq-DY98-kkIY-nNf3-4fxn-u8QT2G'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='lvmid/bvbEzC-juKi-DnNc-yxrz-7KHu-uh1P-n6EPWK/tkAuXS-e4Gq-DY98-kkIY-nNf3-4fxn-u8QT2G'  988e72e2-cc10-46d6-9cd8-3b58827fe864
else
  search --no-floppy --fs-uuid --set=root 988e72e2-cc10-46d6-9cd8-3b58827fe864
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_GB
  insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ] ; then
  set timeout=30
else
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu
    set timeout=5
  # Fallback normal timeout code in case the timeout_style feature is
  # unavailable.
  else
    set timeout=5
  fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/08_linux_xen ###
menuentry 'Debian GNU/Linux, with Xen hypervisor' --class debian --class gnu-linux --class gnu --class os --class xen $menuentry_id_option 'xen-gnulinux-simple-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
    insmod part_gpt
    insmod ext2
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
    else
      search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
    fi
    echo    'Loading Xen 4.12.2-pre ...'
        if [ "$grub_platform" = "pc" -o "$grub_platform" = "" ]; then
            xen_rm_opts=
        else
            xen_rm_opts="no-real-mode edd=off"
        fi
    multiboot2  /xen-4.12.2-pre.gz placeholder  dom0_mem=2560M,max:2560M ${xen_rm_opts}
    echo    'Loading Linux 5.3.8 ...'
    module2 /vmlinuz-5.3.8 placeholder root=/dev/mapper/vg00-lvroot ro  quiet pcie_aspm=force
    echo    'Loading initial ramdisk ...'
    module2 --nounzip   /initrd.img-5.3.8
}
submenu 'Advanced options for Debian GNU/Linux (with Xen hypervisor)' $menuentry_id_option 'gnulinux-advanced-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
    submenu 'Xen hypervisor, version 4.12.2-pre' $menuentry_id_option 'xen-hypervisor-4.12.2-pre-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
        menuentry 'Debian GNU/Linux, with Xen 4.12.2-pre and Linux 5.3.8' --class debian --class gnu-linux --class gnu --class os --class xen $menuentry_id_option 'xen-gnulinux-5.3.8-advanced-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
            insmod part_gpt
            insmod ext2
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
            else
              search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
            fi
            echo    'Loading Xen 4.12.2-pre ...'
                if [ "$grub_platform" = "pc" -o "$grub_platform" = "" ]; then
                    xen_rm_opts=
                else
                    xen_rm_opts="no-real-mode edd=off"
                fi
            multiboot2  /xen-4.12.2-pre.gz placeholder  dom0_mem=2560M,max:2560M ${xen_rm_opts}
            echo    'Loading Linux 5.3.8 ...'
            module2 /vmlinuz-5.3.8 placeholder root=/dev/mapper/vg00-lvroot ro  quiet pcie_aspm=force
            echo    'Loading initial ramdisk ...'
            module2 --nounzip   /initrd.img-5.3.8
        }
        menuentry 'Debian GNU/Linux, with Xen 4.12.2-pre and Linux 5.3.8 (recovery mode)' --class debian --class gnu-linux --class gnu --class os --class xen $menuentry_id_option 'xen-gnulinux-5.3.8-recovery-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
            insmod part_gpt
            insmod ext2
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
            else
              search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
            fi
            echo    'Loading Xen 4.12.2-pre ...'
                if [ "$grub_platform" = "pc" -o "$grub_platform" = "" ]; then
                    xen_rm_opts=
                else
                    xen_rm_opts="no-real-mode edd=off"
                fi
            multiboot2  /xen-4.12.2-pre.gz placeholder  ${xen_rm_opts}
            echo    'Loading Linux 5.3.8 ...'
            module2 /vmlinuz-5.3.8 placeholder root=/dev/mapper/vg00-lvroot ro single 
            echo    'Loading initial ramdisk ...'
            module2 --nounzip   /initrd.img-5.3.8
        }
        menuentry 'Debian GNU/Linux, with Xen 4.12.2-pre and Linux 4.19.0-6-amd64' --class debian --class gnu-linux --class gnu --class os --class xen $menuentry_id_option 'xen-gnulinux-4.19.0-6-amd64-advanced-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
            insmod part_gpt
            insmod ext2
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
            else
              search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
            fi
            echo    'Loading Xen 4.12.2-pre ...'
                if [ "$grub_platform" = "pc" -o "$grub_platform" = "" ]; then
                    xen_rm_opts=
                else
                    xen_rm_opts="no-real-mode edd=off"
                fi
            multiboot2  /xen-4.12.2-pre.gz placeholder  dom0_mem=2560M,max:2560M ${xen_rm_opts}
            echo    'Loading Linux 4.19.0-6-amd64 ...'
            module2 /vmlinuz-4.19.0-6-amd64 placeholder root=/dev/mapper/vg00-lvroot ro  quiet pcie_aspm=force
            echo    'Loading initial ramdisk ...'
            module2 --nounzip   /initrd.img-4.19.0-6-amd64
        }
        menuentry 'Debian GNU/Linux, with Xen 4.12.2-pre and Linux 4.19.0-6-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os --class xen $menuentry_id_option 'xen-gnulinux-4.19.0-6-amd64-recovery-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
            insmod part_gpt
            insmod ext2
            if [ x$feature_platform_search_hint = xy ]; then
              search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
            else
              search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
            fi
            echo    'Loading Xen 4.12.2-pre ...'
                if [ "$grub_platform" = "pc" -o "$grub_platform" = "" ]; then
                    xen_rm_opts=
                else
                    xen_rm_opts="no-real-mode edd=off"
                fi
            multiboot2  /xen-4.12.2-pre.gz placeholder  ${xen_rm_opts}
            echo    'Loading Linux 4.19.0-6-amd64 ...'
            module2 /vmlinuz-4.19.0-6-amd64 placeholder root=/dev/mapper/vg00-lvroot ro single 
            echo    'Loading initial ramdisk ...'
            module2 --nounzip   /initrd.img-4.19.0-6-amd64
        }
    }
}

### END /etc/grub.d/08_linux_xen ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
    set gfxpayload="${1}"
}
set linux_gfx_mode=
export linux_gfx_mode
menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
    load_video
    insmod gzio
    if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    insmod part_gpt
    insmod ext2
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
    else
      search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
    fi
    echo    'Loading Linux 5.3.8 ...'
    linux   /vmlinuz-5.3.8 root=/dev/mapper/vg00-lvroot ro  quiet pcie_aspm=force
    echo    'Loading initial ramdisk ...'
    initrd  /initrd.img-5.3.8
}
submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 'gnulinux-advanced-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
    menuentry 'Debian GNU/Linux, with Linux 5.3.8' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.3.8-advanced-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod ext2
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
        else
          search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
        fi
        echo    'Loading Linux 5.3.8 ...'
        linux   /vmlinuz-5.3.8 root=/dev/mapper/vg00-lvroot ro  quiet pcie_aspm=force
        echo    'Loading initial ramdisk ...'
        initrd  /initrd.img-5.3.8
    }
    menuentry 'Debian GNU/Linux, with Linux 5.3.8 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.3.8-recovery-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod ext2
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
        else
          search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
        fi
        echo    'Loading Linux 5.3.8 ...'
        linux   /vmlinuz-5.3.8 root=/dev/mapper/vg00-lvroot ro single 
        echo    'Loading initial ramdisk ...'
        initrd  /initrd.img-5.3.8
    }
    menuentry 'Debian GNU/Linux, with Linux 4.19.0-6-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.19.0-6-amd64-advanced-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod ext2
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
        else
          search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
        fi
        echo    'Loading Linux 4.19.0-6-amd64 ...'
        linux   /vmlinuz-4.19.0-6-amd64 root=/dev/mapper/vg00-lvroot ro  quiet pcie_aspm=force
        echo    'Loading initial ramdisk ...'
        initrd  /initrd.img-4.19.0-6-amd64
    }
    menuentry 'Debian GNU/Linux, with Linux 4.19.0-6-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.19.0-6-amd64-recovery-988e72e2-cc10-46d6-9cd8-3b58827fe864' {
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_gpt
        insmod ext2
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root  e9e6e232-aef7-4e2e-ac20-cd8b218952b1
        else
          search --no-floppy --fs-uuid --set=root e9e6e232-aef7-4e2e-ac20-cd8b218952b1
        fi
        echo    'Loading Linux 4.19.0-6-amd64 ...'
        linux   /vmlinuz-4.19.0-6-amd64 root=/dev/mapper/vg00-lvroot ro single 
        echo    'Loading initial ramdisk ...'
        initrd  /initrd.img-4.19.0-6-amd64
    }
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'System setup' $menuentry_id_option 'uefi-firmware' {
    fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

/boot 文件夹包含以下文件:

root@xen1:/# ll /boot/
total 74084
-rw-r--r-- 1 root root   206243 Sep 20 12:51 config-4.19.0-6-amd64
-rw-r--r-- 1 root root   219726 Nov  6 13:41 config-5.3.8
-rw-r--r-- 1 root root     1638 Nov  5 09:37 config-xen-4.12.2-pre
drwx------ 3 root root     4096 Jan  1  1970 efi
drwxr-xr-x 5 root root     4096 Nov  6 15:08 grub
-rw-r--r-- 1 root root 28041914 Nov  5 15:10 initrd.img-4.19.0-6-amd64
-rw-r--r-- 1 root root 28213404 Nov  6 14:45 initrd.img-5.3.8
drwx------ 2 root root    16384 Nov  5 13:32 lost+found
-rw-r--r-- 1 root root  3409486 Sep 20 12:51 System.map-4.19.0-6-amd64
-rw-r--r-- 1 root root  3622883 Nov  6 13:41 System.map-5.3.8
-rw-r--r-- 1 root root  5262576 Sep 20 12:51 vmlinuz-4.19.0-6-amd64
-rw-r--r-- 1 root root  5548416 Nov  6 13:41 vmlinuz-5.3.8
-rw-r--r-- 1 root root  1176799 Nov  5 10:00 xen-4.12.2-pre.gz

系统日志中的一些进一步详细信息:

Nov  7 09:17:48 xen1 systemd-modules-load[228]: Inserted module '8021q'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Failed to insert module 'coretemp': No such device
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Inserted module 'nct6775'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Inserted module 'xen_evtchn'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Inserted module 'xen_gntdev'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Inserted module 'xen_gntalloc'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Inserted module 'xen_blkback'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Inserted module 'xen_netback'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Inserted module 'xen_pciback'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Failed to find module 'evtchn'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Failed to find module 'gntdev'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Failed to find module 'netbk'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Failed to find module 'blkbk'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Failed to find module 'xen-scsibk'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Failed to find module 'usbbk'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Failed to find module 'pciback'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Inserted module 'xen_acpi_processor'
Nov  7 09:17:48 xen1 systemd-modules-load[228]: Failed to find module 'blktap2'

答案1

XEN 是一个裸机管理程序。您的 Dom0 是一个 PV(半虚拟化)XEN VM(虚拟机)。

因此,虚拟机管理程序负责管理硬件 - 而不是您的 Dom0。因此硬件模块将无法工作 - 因为 Dom0 没有硬件。

它是一个虚拟机。如果您想更改与硬件相关的内容,则必须使用 XEN 参数或告诉 xen 一些信息。

作为特权 VM,Dom0 将能够将一些其他非特权 VM (DomU) 无法执行的操作传递给虚拟机管理程序。

相关内容