AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1269341

akashavkin's questions

Martin Hope
amkgi
Asked: 2023-12-09 15:55:49 +0800 CST

具有 Wi-Fi 接口的桥接模式虚拟机上的 802.1q VLAN 问题

  • 5

我的环境是一个带有 OpenWRT 的路由器、一台通过跳线连接到路由器的笔记本电脑以及在路由器的该端口上配置了 VID 5 的未标记 VLAN,以及通过 Wi-Fi 连接到路由器的 MacBook M1 Pro。

在 MacBook 上,我通过指定 en0 (AirPort) 作为父接口创建了一个 VLAN 接口,然后使用带有 hvf 加速器的 QEMU 或带有 VZ 的 lima/UTM 创建了一个虚拟机,我观察到一个奇怪的情况:使用 arping,有时会收到来自笔记本电脑的数据包到达与 macbook 上的 VLAN 接口连接的虚拟机,但虚拟机上运行的 arping 只发送请求,但没有收到笔记本电脑的回复。如果我将 IP 地址分配给 macOS 中的 VLAN 接口,则数据包可以通过任一协议传输,不会出现任何问题。问题是将数据包传送到虚拟机。

使用笔记本电脑上的 tcpdump,我可以看到它回复 arp 请求,我还可以在路由器上看到回复通过 Wi-Fi 接口传递的 arp 请求,但我在 macbook 上 en0 上的 tcpdump 中看不到它们,这也很奇怪。但正如我之前所写,如果我在 MacBook 的 VLAN 接口上分配来自同一网络的地址,则任何数据包都会在笔记本电脑和 MacBook 之间传递。

  • 笔记本电脑:192.168.24.50
  • MacBook:192.168.24.20(vlan5接口)。
  • 虚拟机:192.168.24.10

对于lima-vm,我在桥接模式下使用socket_vmnet 。对于 QEMU,我使用vmnet-bridged。

➜  ~ ifconfig vlan5
vlan5: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1496
    options=6063<RXCSUM,TXCSUM,TSO4,TSO6,PARTIAL_CSUM,ZEROINVERT_CSUM>
    ether f0:2f:4b:xx:xx:xx
    inet 192.168.24.20 netmask 0xffffff00 broadcast 192.168.24.255
    vlan: 5 parent interface: en0
    media: autoselect
    status: active

➜  ~ ping 192.168.24.50 -c2
PING 192.168.24.50 (192.168.24.50): 56 data bytes
64 bytes from 192.168.24.50: icmp_seq=0 ttl=64 time=5.241 ms
64 bytes from 192.168.24.50: icmp_seq=1 ttl=64 time=5.429 ms

--- 192.168.24.50 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 5.241/5.335/5.429/0.094 ms

➜  ~ sudo arping -c 5 -i vlan5 192.168.24.50
ARPING 192.168.24.50
60 bytes from 10:e7:c6:xx:xx:xx (192.168.24.50): index=0 time=6.061 msec
60 bytes from 10:e7:c6:xx:xx:xx (192.168.24.50): index=1 time=6.084 msec
60 bytes from 10:e7:c6:xx:xx:xx (192.168.24.50): index=2 time=5.945 msec
60 bytes from 10:e7:c6:xx:xx:xx (192.168.24.50): index=3 time=3.092 msec
60 bytes from 10:e7:c6:xx:xx:xx (192.168.24.50): index=4 time=3.848 msec

--- 192.168.24.50 statistics ---
5 packets transmitted, 5 packets received,   0% unanswered (0 extra)
rtt min/avg/max/std-dev = 3.092/5.006/6.084/1.278 ms

➜  ~ ifconfig bridge100
bridge100: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1496
    options=3<RXCSUM,TXCSUM>
    ether f2:2f:4b:xx:xx:xx
    Configuration:
        id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
        maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
        root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
        ipfilter disabled flags 0x0
    member: vlan5 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 22 priority 0 path cost 0
    member: vmenet0 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 23 priority 0 path cost 0
    Address cache:
        10:e7:c6:xx:xx:xx Vlan1 vlan5 326 flags=0<>
        52:55:55:ae:36:b4 Vlan1 vmenet0 1172 flags=0<>
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active
[root@VM1 ~]# arping 192.168.24.50 -c5
ARPING 192.168.24.50 from 192.168.24.10 lima0
Sent 5 probes (5 broadcast(s))
Received 0 response(s)
[root@VM1 ~]#
[root@laptop ~]# arping 192.168.24.10 -c5
ARPING 192.168.24.10 from 192.168.24.50 eth0
Unicast reply from 192.168.24.10 [52:55:55:AE:36:B4] 2.492ms
Unicast reply from 192.168.24.10 [52:55:55:AE:36:B4] 1.791ms
Unicast reply from 192.168.24.10 [52:55:55:AE:36:B4] 3.059ms
Sent 5 probes (1 broadcast(s))
Received 3 response(s)
[root@laptop ~]#

我还在笔记本电脑上进行了测试,在 VirtualBox 中我创建了具有桥接模式接口的虚拟机,并在虚拟机内部创建了一个 VLAN 接口。我将笔记本电脑切换到 Wi-Fi,并尝试 ping MacBook 的虚拟机。数据包正在离开笔记本电脑虚拟机,但不会到达 MacBook 虚拟机。

因此,它与操作系统无关,问题是当虚拟机连接到 Wi-Fi 接口时,数据包不会发送到虚拟机本身。

我想弄清楚这一点。这对我来说并不是很透明。VLAN 标头只有 4 个字节,那么以桥接模式在 VM 接口和 Wi-Fi 接口之间传递该帧有什么问题呢?但是,如果您在操作系统中将 IP 地址分配给 VLAN 接口,并且该接口具有 Wi-Fi 接口作为其父接口,则一切都会正常工作。

UPD:感谢 AB 的评论,他们帮助我了解了是什么阻止了虚拟机接收数据包。

wireless-networking
  • 1 个回答
  • 47 Views
Martin Hope
akashavkin
Asked: 2022-04-11 07:03:40 +0800 CST

为什么我似乎无法从 macOS 的命令行通过 virt-install 运行 VM?

  • 6

我尝试在 macOS Monterey (12.3.1) 上的 MacBook 14 M1 Pro 上运行带有仿真的 VM。我通过 brew 安装了 libvirt 8.2.0 和 virt-manager 4.0.0。

我将这个公式用于 virt-manager:

class VirtManager < Formula
  include Language::Python::Virtualenv

  desc "Desktop tool for managing virtual machines via libvirt"
  homepage "https://virt-manager.org/"
  url "https://releases.pagure.org/virt-manager/virt-manager-4.0.0.tar.gz"
  sha256 "515aaa2021a4bf352b0573098fe6958319b1ba8ec508ea37e064803f97f17086"
  license "GPL-2.0-or-later"
  head "https://github.com/virt-manager/virt-manager.git"

  depends_on "docutils" => :build
  depends_on "gettext" => :build
  depends_on "adwaita-icon-theme"
  depends_on "cdrtools"
  depends_on "glib"
  depends_on "gtk+3"
  depends_on "gtk-vnc"
  depends_on "gtksourceview4"
  depends_on "libosinfo"
  depends_on "libvirt"
  depends_on "libvirt-glib"
  depends_on "libxml2"
  depends_on "pygobject3"
  depends_on "python"
  depends_on "spice-gtk"
  depends_on "vte3"

  # To update:
  #
  #     cd "$(mktemp -d)" &&
  #         python3 -m venv venv &&
  #         . venv/bin/activate &&
  #         pip install libvirt-python argcomplete requests homebrew-pypi-poet &&
  #         poet libvirt-python -a argcomplete -a requests &&
  #         deactivate &&
  #         rm -Rf venv
  resource "argcomplete" do
    url "https://files.pythonhosted.org/packages/05/f8/67851ae4fe5396ba6868c5d84219b81ea6a5d53991a6853616095c30adc0/argcomplete-2.0.0.tar.gz"
    sha256 "6372ad78c89d662035101418ae253668445b391755cfe94ea52f1b9d22425b20"
  end

    resource "certifi" do
    url "https://files.pythonhosted.org/packages/6c/ae/d26450834f0acc9e3d1f74508da6df1551ceab6c2ce0766a593362d6d57f/certifi-2021.10.8.tar.gz"
    sha256 "78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"
  end

  resource "charset-normalizer" do
    url "https://files.pythonhosted.org/packages/56/31/7bcaf657fafb3c6db8c787a865434290b726653c912085fbd371e9b92e1c/charset-normalizer-2.0.12.tar.gz"
    sha256 "2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597"
  end

  resource "idna" do
    url "https://files.pythonhosted.org/packages/62/08/e3fc7c8161090f742f504f40b1bccbfc544d4a4e09eb774bf40aafce5436/idna-3.3.tar.gz"
    sha256 "9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
  end

  resource "libvirt-python" do
    url "https://files.pythonhosted.org/packages/50/cf/3703fc97df6292c9c0ac8b828a85ca11f492f7bffd190f191ea7484024ed/libvirt-python-8.2.0.tar.gz"
    sha256 "f8b8cea67ff0d64d63029cc3410a4656e04ee9f26837a856bc0c287da55d053a"
  end

  resource "pycairo" do
    url "https://files.pythonhosted.org/packages/92/a4/506564f574fa74c90b98690e8ecc8dbae1629f31fcfe0be69de45d9e1605/pycairo-1.21.0.tar.gz"
    sha256 "251907f18a552df938aa3386657ff4b5a4937dde70e11aa042bc297957f4b74b"
  end

  resource "requests" do
    url "https://files.pythonhosted.org/packages/60/f3/26ff3767f099b73e0efa138a9998da67890793bfa475d8278f84a30fec77/requests-2.27.1.tar.gz"
    sha256 "68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61"
  end

  resource "urllib3" do
    url "https://files.pythonhosted.org/packages/1b/a5/4eab74853625505725cefdf168f48661b2cd04e7843ab836f3f63abf81da/urllib3-1.26.9.tar.gz"
    sha256 "aabaf16477806a5e1dd19aa41f8c2b7950dd3c746362d7e3223dbe6de6ac448e"
  end

  def install
    venv = virtualenv_create(libexec, "python3")
    venv.pip_install resources

    # virt-manager uses distutils, so we can't use Homebrew's helper methods
    args = %w[
      --no-user-cfg
      --no-update-icon-cache
      --no-compile-schemas
    ]
    # virt-manager requires --prefix to match between `configure` and `install`
    system "#{libexec}/bin/python3", "setup.py", *args,
      "configure", "--prefix=#{libexec}", "--default-hvs", "qemu,lxc"
    system "#{libexec}/bin/python3", "setup.py", *args,
      "install", "--prefix=#{libexec}"
    bin.install_symlink Dir["#{libexec}/bin/virt-*"]
    share.install Dir["#{libexec}/share/{bash-completion,glib-2.0,icons,locale,man}"]
  end

  def post_install
    system "#{Formula["glib"].opt_bin}/glib-compile-schemas", "#{HOMEBREW_PREFIX}/share/glib-2.0/schemas"
    system "#{Formula["gtk+3"].opt_bin}/gtk3-update-icon-cache", "-f", "-t", "#{HOMEBREW_PREFIX}/share/icons/hicolor"
  end

  test do
    system "#{bin}/virt-manager", "--version"
  end
end

启动 VM 的参数:

virt-install --name guest1-rocky8_5 --memory 4096 --vcpus 4 --disk work_space/packer/rocky8_5.qcow2 --qemu-commandline='-netdev user,id=net0,hostfwd=tcp::5555-:22 -device e1000e,netdev=net0 -accel tcg' --import --virt-type qemu --arch x86_64 --os-variant rhel8.0 -d

我得到以下输出:

[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (cli:204) Launched with command line: /opt/homebrew/bin/virt-install --name guest1-rocky8_5 --memory 4096 --vcpus 4 --disk workspace/packer/rocky8_5.qcow2 --qemu-commandline=-netdev user,id=net0,hostfwd=tcp::5555-:22 -device e1000e,netdev=net0 -accel tcg --import --virt-type qemu --arch x86_64 --os-variant rhel8.0 -d
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (virtinstall:212) Distilled --network options: ['default']
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (virtinstall:142) Distilled --disk options: ['workspace/packer/rocky8_5.qcow2']
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (cli:216) Requesting libvirt URI default
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (cli:219) Received libvirt URI qemu:///session
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (guest:330) Setting Guest osinfo name <_OsVariant name=generic>
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (guest:330) Setting Guest osinfo name <_OsVariant name=rhel8.0>
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (installer:542) No media for distro detection.
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (installer:544) installer.detect_distro returned=None
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (osdict:216) No recommended value found for key='n-cpus', using minimum=1 * 2
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (guest:535) Prefer EFI => False
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (graphics:157) App is configured with default_graphics=spice
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (graphics:167) spice requested but HV doesn't support it. Using vnc.
[Sun, 10 Apr 2022 01:52:05 virt-install 58583] DEBUG (guest:1094) Using num_pcie_root_ports=14
[Sun, 10 Apr 2022 01:52:06 virt-install 58583] DEBUG (disk:236) DeviceDisk.check_path_search path=/Users/alexey/workspace/packer/rocky8_5.qcow2
[Sun, 10 Apr 2022 01:52:06 virt-install 58583] DEBUG (cli:265)
Starting install...
[Sun, 10 Apr 2022 01:52:06 virt-install 58583] DEBUG (installer:587) Generated initial_xml: None required
[Sun, 10 Apr 2022 01:52:06 virt-install 58583] DEBUG (installer:589) Generated final_xml:
<domain type="qemu">
  <name>guest1-rocky8_5</name>
  <uuid>c9af9024-c29b-411c-b36c-ff9e9073f95a</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://redhat.com/rhel/8.0"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory>4194304</memory>
  <currentMemory>4194304</currentMemory>
  <vcpu>4</vcpu>
  <os>
    <type arch="x86_64" machine="q35">hvm</type>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <clock offset="utc">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
  </clock>
  <pm>
    <suspend-to-mem enabled="no"/>
    <suspend-to-disk enabled="no"/>
  </pm>
  <devices>
    <emulator>/opt/homebrew/bin/qemu-system-x86_64</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/Users/alexey/workspace/packer/rocky8_5.qcow2"/>
      <target dev="vda" bus="virtio"/>
    </disk>
    <controller type="usb" model="qemu-xhci" ports="15"/>
    <controller type="pci" model="pcie-root"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <controller type="pci" model="pcie-root-port"/>
    <interface type="user">
      <mac address="52:54:00:d8:a2:6d"/>
      <model type="virtio"/>
    </interface>
    <console type="pty"/>
    <channel type="unix">
      <source mode="bind"/>
      <target type="virtio" name="org.qemu.guest_agent.0"/>
    </channel>
    <input type="tablet" bus="usb"/>
    <graphics type="vnc" port="-1"/>
    <video>
      <model type="virtio"/>
    </video>
    <memballoon model="virtio"/>
    <rng model="virtio">
      <backend model="random">/dev/urandom</backend>
    </rng>
  </devices>
  <qemu:commandline xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0">
    <qemu:arg value="-netdev"/>
    <qemu:arg value="user,id=net0,hostfwd=tcp::5555-:22"/>
    <qemu:arg value="-device"/>
    <qemu:arg value="e1000e,netdev=net0"/>
    <qemu:arg value="-accel"/>
    <qemu:arg value="tcg"/>
  </qemu:commandline>
</domain>

[Sun, 10 Apr 2022 01:52:06 virt-install 58583] DEBUG (installer:642) XML fetched from libvirt object:
<domain type='qemu' id='25' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>guest1-rocky8_5</name>
  <uuid>c9af9024-c29b-411c-b36c-ff9e9073f95a</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://redhat.com/rhel/8.0"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <os>
    <type arch='x86_64' machine='pc-q35-6.2'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>qemu64</model>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='lahf_lm'/>
  </cpu>
  <clock offset='utc'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/opt/homebrew/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/Users/alexey/workspace/packer/rocky8_5.qcow2' index='1'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </disk>
    <controller type='usb' index='0' model='qemu-xhci' ports='15'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'>
      <alias name='pcie.0'/>
    </controller>
    <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='1' port='0x10'/>
      <alias name='pci.1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
    </controller>
    <controller type='pci' index='2' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='2' port='0x11'/>
      <alias name='pci.2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
    </controller>
    <controller type='pci' index='3' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='3' port='0x12'/>
      <alias name='pci.3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/>
    </controller>
    <controller type='pci' index='4' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='4' port='0x13'/>
      <alias name='pci.4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x3'/>
    </controller>
    <controller type='pci' index='5' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='5' port='0x14'/>
      <alias name='pci.5'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x4'/>
    </controller>
    <controller type='pci' index='6' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='6' port='0x15'/>
      <alias name='pci.6'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x5'/>
    </controller>
    <controller type='pci' index='7' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='7' port='0x16'/>
      <alias name='pci.7'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x6'/>
    </controller>
    <controller type='pci' index='8' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='8' port='0x17'/>
      <alias name='pci.8'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x7'/>
    </controller>
    <controller type='pci' index='9' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='9' port='0x18'/>
      <alias name='pci.9'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0' multifunction='on'/>
    </controller>
    <controller type='pci' index='10' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='10' port='0x19'/>
      <alias name='pci.10'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x1'/>
    </controller>
    <controller type='pci' index='11' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='11' port='0x1a'/>
      <alias name='pci.11'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x2'/>
    </controller>
    <controller type='pci' index='12' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='12' port='0x1b'/>
      <alias name='pci.12'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x3'/>
    </controller>
    <controller type='pci' index='13' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='13' port='0x1c'/>
      <alias name='pci.13'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x4'/>
    </controller>
    <controller type='pci' index='14' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='14' port='0x1d'/>
      <alias name='pci.14'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x5'/>
    </controller>
    <controller type='sata' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </controller>
    <interface type='user'>
      <mac address='52:54:00:d8:a2:6d'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/ttys004'/>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/ttys004'>
      <source path='/dev/ttys004'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='unix'>
      <source mode='bind' path='/Users/alexey/.config/libvirt/qemu/channel/target/domain-25-guest1-rocky8_5/org.qemu.guest_agent.0'/>
      <target type='virtio' name='org.qemu.guest_agent.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'>
      <alias name='input1'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input2'/>
    </input>
    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <audio id='1' type='none'/>
    <video>
      <model type='virtio' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    </memballoon>
    <rng model='virtio'>
      <backend model='random'>/dev/urandom</backend>
      <alias name='rng0'/>
      <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
    </rng>
  </devices>
  <qemu:commandline>
    <qemu:arg value='-netdev'/>
    <qemu:arg value='user,id=net0,hostfwd=tcp::5555-:22'/>
    <qemu:arg value='-device'/>
    <qemu:arg value='e1000e,netdev=net0'/>
    <qemu:arg value='-accel'/>
    <qemu:arg value='tcg'/>
  </qemu:commandline>
</domain>

[Sun, 10 Apr 2022 01:52:06 virt-install 58583] DEBUG (cli:383) Running: virt-viewer --connect qemu:///session --wait guest1-rocky8_5
[Sun, 10 Apr 2022 01:52:06 virt-install 58583] DEBUG (cli:265) Running graphical console command: virt-viewer --connect qemu:///session --wait guest1-rocky8_5

(virt-viewer:58588): virt-viewer-WARNING **: 01:52:06.563: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(virt-viewer:58588): virt-viewer-WARNING **: 01:52:06.563: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(virt-viewer:58588): virt-viewer-WARNING **: 01:52:06.563: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(virt-viewer:58588): virt-viewer-WARNING **: 01:52:06.563: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(virt-viewer:58588): virt-viewer-WARNING **: 01:52:06.563: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)

(virt-viewer:58588): virt-viewer-WARNING **: 01:52:06.563: (../src/virt-viewer-window.c:831):accel_key_to_keys: runtime check failed: ((accel_mods & ~(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)) == 0)
[Sun, 10 Apr 2022 01:52:10 virt-install 58583] DEBUG (cli:255)   File "/opt/homebrew/bin/virt-install", line 8, in <module>
    virtinstall.runcli()
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 1220, in runcli
    sys.exit(main())
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 1213, in main
    start_install(guest, installer, options)
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 961, in start_install
    fail(e, do_exit=False)
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/cli.py", line 255, in fail
    log.debug("".join(traceback.format_stack()))

[Sun, 10 Apr 2022 01:52:10 virt-install 58583] ERROR (cli:256) operation failed: cannot read cputime for domain
[Sun, 10 Apr 2022 01:52:10 virt-install 58583] DEBUG (cli:258)
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 949, in start_install
    _process_domain(domain, guest, installer,
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 900, in _process_domain
    _wait_for_domain(installer, instdomain, autoconsole, waithandler)
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 837, in _wait_for_domain
    if instdomain.check_inactive():
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 817, in check_inactive
    dominfo = self._domain.info()
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/lib/python3.9/site-packages/libvirt.py", line 1659, in info
    raise libvirtError('virDomainGetInfo() failed')
libvirt.libvirtError: operation failed: cannot read cputime for domain 
[Sun, 10 Apr 2022 01:52:10 virt-install 58583] DEBUG (cli:271) Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///session start guest1-rocky8_5
otherwise, please restart your installation.
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///session start guest1-rocky8_5
otherwise, please restart your installation.

如果我添加--autoconsole text,我可以在输出中看到:

Creating domain...                                                                                                                                                                             |    0 B  00:00:00
[Sun, 10 Apr 2022 02:08:07 virt-install 59096] DEBUG (cli:383) Running: virsh --connect qemu:///session console guest1-rocky8_5
[Sun, 10 Apr 2022 02:08:07 virt-install 59096] DEBUG (cli:265) Running text console command: virsh --connect qemu:///session console guest1-rocky8_5
Running text console command: virsh --connect qemu:///session console guest1-rocky8_5
Connected to domain 'guest1-rocky8_5'
Escape character is ^] (Ctrl + ])

什么都没有出来。

如果我尝试在端口 5555 上进行 SSH,我会得到:

ssh localhost -p 5555
kex_exchange_identification: read: Connection reset by peer
Connection reset by 127.0.0.1 port 5555

如果取消运行:

Running text console command: virsh --connect qemu:///session console guest1-rocky8_5
Connected to domain 'guest1-rocky8_5'
Escape character is ^] (Ctrl + ])
^]
[Sun, 10 Apr 2022 02:24:38 virt-install 59378] DEBUG (cli:255)   File "/opt/homebrew/bin/virt-install", line 8, in <module>
    virtinstall.runcli()
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 1220, in runcli
    sys.exit(main())
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 1213, in main
    start_install(guest, installer, options)
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 961, in start_install
    fail(e, do_exit=False)
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/cli.py", line 255, in fail
    log.debug("".join(traceback.format_stack()))

[Sun, 10 Apr 2022 02:24:38 virt-install 59378] ERROR (cli:256) operation failed: cannot read cputime for domain
[Sun, 10 Apr 2022 02:24:38 virt-install 59378] DEBUG (cli:258)
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 949, in start_install
    _process_domain(domain, guest, installer,
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 900, in _process_domain
    _wait_for_domain(installer, instdomain, autoconsole, waithandler)
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 837, in _wait_for_domain
    if instdomain.check_inactive():
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/share/virt-manager/virtinst/virtinstall.py", line 817, in check_inactive
    dominfo = self._domain.info()
  File "/opt/homebrew/Cellar/virt-manager/4.0.0/libexec/lib/python3.9/site-packages/libvirt.py", line 1659, in info
    raise libvirtError('virDomainGetInfo() failed')
libvirt.libvirtError: operation failed: cannot read cputime for domain
[Sun, 10 Apr 2022 02:24:38 virt-install 59378] DEBUG (cli:271) Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///session start guest1-rocky8_5
otherwise, please restart your installation.
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///session start guest1-rocky8_5
otherwise, please restart your installation.

但是,如果我尝试仅使用 qemu-system-x86_64 效果很好:

qemu-system-x86_64 -m 4G -machine type=q35,accel=tcg -smp 2 -netdev user,id=net0,hostfwd=tcp::5555-:22 -device e1000e,netdev=net0 -drive file=workspace/packer/rocky8_5.qcow2,if=ide

ssh localhost -p 5555 cat /etc/redhat-release
root@localhost's password:
Rocky Linux release 8.5 (Green Obsidian)

我认为当我在 virt-install 中运行 VM 时,默认情况下会添加一些参数,这会阻止 VM 正常启动。也许我需要更改一些参数或通过 virt-install 添加新参数以使 VM 正常运行?

如果我在 virt-manager 中使用默认参数运行 VM,我也会遇到同样的问题。

Despite running errors via virt-install or virt-manager, I can see this VM in libvirt:

virsh list
 Id   Name              State
---------------------------------
 1    guest1-rocky8_5   running

I can connect to this VM via VNC, but ssh on port 5555 not forwarding, as I wrote above.

macos qemu
  • 1 个回答
  • 943 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve