3

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

我正在运行 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 接口时,我遇到了麻烦。我已经在网上搜索并尝试了几件事,但无济于事。

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

-# virsh start phabVM error: Failed to start domain phabVM error: internal error Process exited while reading console log output: char device redirected to /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
禁用的 apparmor
确保 kvm 二进制文件设置为 kvm 组

4

1 回答 1

0

尽量不要使用,对于更安全、更易于管理等的网络接口,<interface type="ethernet">还有更多不同的可能性。如果您真的需要使用以太网类型的接口,那么您可以完全按照libvirt wiki 页面了解该问题,但我必须强调我不建议这样做。

于 2015-04-29T09:14:25.063 回答