gpt4 book ai didi

virtualization - 为什么使用 TAP 接口(interface)启动 KVM 虚拟机时出现权限错误?

转载 作者:行者123 更新时间:2023-12-04 04:33:03 25 4
gpt4 key购买 nike

第一篇文章,感谢社区。
抱歉,如果它更适合另一个论坛

我正在运行 Ubuntu 12.04 LTS 服务器作为我的主机。

/etc/libvirt# kvm --version

QEMU 仿真器版本 1.0 (qemu-kvm-1.0),版权所有 (c) 2003-2008 Fabrice Bellard

我构建了一个运行 Ubuntu 13.10 的虚拟机就好了。
当我进入 XML 为静态 IP 配置以太网 tap0 接口(interface)时,我遇到了麻烦。
我已经在网上搜索并尝试了几件事,但无济于事。

这是我得到的错误。
错误下方是我的配置和日志。
下面是我尝试过但没有成功的事情的 list ......

-# virsh 启动phabVM
错误:无法启动域 phabVM
错误:内部错误进程在读取控制台日志输出时退出:字符设备重定向到/dev/pts/1
kvm: -netdev tap,ifname=tap0,id=hostnet0: 无法打开/dev/net/tun: 不允许操作
kvm:-netdev tap,ifname=tap0,id=hostnet0: 设备“tap”无法初始化


虚拟机 XML

    # domain type='kvm'>
# name>phabVM
# uuid>26a54ab3-7c67-507b-f066-09015dd19942
# memory>4194304
# currentMemory>4194304
# vcpu>1
# os>
# type arch='x86_64' machine='pc-1.0'>hvm
# boot dev='hd'/>
# /os>
# features>
# acpi/>
# apic/>
# pae/>
# /features>
# clock offset='utc'/>
# on_poweroff>preserve
# on_reboot>restart
# on_crash>restart
# devices>
# emulator>/usr/bin/kvm
# disk type='file' device='disk'>
# driver name='qemu' type='raw'/>
# source file='/home/inevirt/images/PhabVM.img'/>
# target dev='sda' bus='sata'/>
# address type='drive' controller='0' bus='0' unit='0'/>
# /disk>
# disk type='block' device='cdrom'>
# driver name='qemu' type='raw'/>
# target dev='hdc' bus='ide'/>
# readonly/>
# address type='drive' controller='0' bus='1' unit='0'/>
# /disk>
# controller type='ide' index='0'>
# address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
# /controller>
# controller type='sata' index='0'>
# address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
# /controller>
# interface type='ethernet'>
# mac address='52:54:00:6d:ab:17'/>
# target dev='tap0'/>
# model type='virtio'/>
# address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
# /interface>
# serial type='pty'>
# target port='0'/>
# /serial>
# console type='pty'>
# target type='serial' port='0'/>
# /console>
# input type='mouse' bus='ps2'/>
# graphics type='vnc' port='-1' autoport='yes'/>
# sound model='ich6'>
# address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
# /sound>
# video>
# model type='cirrus' vram='9216' heads='1'/>
# address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
# /video>
# memballoon model='virtio'>
# address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
# /memballoon>
# /devices>
#/domain

日志
2013-11-21 17:38:59.075+0000: starting up
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-1.0 -enable-kvm -m 4096 -smp 1,sockets=1,cores=1,threads=1 -name PhabVM -uuid 26a54ab3-7c67-507b-f066-09015dd19942 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/PhabVM.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device ahci,id=ahci0,bus=pci.0,addr=0x5 -drive file=/home/inevirt/images/PhabVM.img,if=none,id=drive-sata0-0-0,format=raw -device ide-drive,bus=ahci0.0,drive=drive-sata0-0-0,id=sata0-0-0,bootindex=1 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,ifname=tap0,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:6d:ab:17,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -usb -vnc 127.0.0.1:0 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
char device redirected to /dev/pts/1
kvm: -netdev tap,ifname=tap0,id=hostnet0: could not open /dev/net/tun: Operation not permitted
kvm: -netdev tap,ifname=tap0,id=hostnet0: Device 'tap' could not be initialized
2013-11-21 17:38:59.205+0000: shutting down
2013-11-21 17:40:57.554+0000: starting up
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-1.0 -enable-kvm -m 4096 -smp 1,sockets=1,cores=1,threads=1 -name PhabVM -uuid 26a54ab3-7c67-507b-f066-09015dd19942 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/PhabVM.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -device ahci,id=ahci0,bus=pci.0,addr=0x5 -drive file=/home/inevirt/images/PhabVM.img,if=none,id=drive-sata0-0-0,format=raw -device ide-drive,bus=ahci0.0,drive=drive-sata0-0-0,id=sata0-0-0,bootindex=1 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,ifname=tap0,id=hostnet0 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:6d:ab:17,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -usb -vnc 127.0.0.1:0 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
char device redirected to /dev/pts/1
kvm: -netdev tap,ifname=tap0,id=hostnet0: could not open /dev/net/tun: Operation not permitted
kvm: -netdev tap,ifname=tap0,id=hostnet0: Device 'tap' could not be initialized
2013-11-21 17:40:57.686+0000: shutting down

我尝试过的东西(来自互联网研究)没有奏效。

将用户添加到组 kvm
已配置的 libvirtd.conf 和未注释的 listen_tls 和 listen_tcp
通过将 root 设置为用户/组来运行 VM 和未注释的 clear_emulator_capabilities = 0 来配置 qemu.conf
残疾人士
确保将 kvm 二进制文件设置为 kvm 组

最佳答案

尽量不要使用<interface type="ethernet"> ,还有更多various possibilities to use for network interfaces更安全、更易于管理等。如果您 真的需要要使用以太网类型的接口(interface),那么您可以按照 libvirt wiki page正是关于这个问题,但我必须强调我不建议这样做。

关于virtualization - 为什么使用 TAP 接口(interface)启动 KVM 虚拟机时出现权限错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20153050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com