
我正在設定我的第一個虛擬機器並使用橋接來存取我的網路。它是 Ubuntu 14.10 上的 Windows7 虛擬機器。我讀到,在虛擬機器定義中更改為“Device Model = VirtIO”將提高乙太網路效能。當我將其從 rtl8139 更改為 VirtIO 時,我失去了虛擬機器上的乙太網路連接。有什麼建議麼?
附註:正如這個問題所表明的那樣,我是 Linux 世界的新手。實際上,我更喜歡將虛擬機橋接到我的無線適配器(我已禁用它),但我讀過的許多內容都說您無法跨無線適配器進行橋接。
感謝您的指點。
我的 win7 VM 是透過使用 KVM 隨附的 GUI 工具來建立/定義的。如果我將滑鼠懸停在該圖示上,它會顯示「虛擬機器管理器」。我已經設置了一座橋。它適用於有線連接,且 /etc/libvirt/qemu/win7.xml 檔案參數中的模型類型為 rtl8139。如果我使用虛擬機器管理器或 nano 文字編輯器將其變更為 virtIO,我會遺失 Ubuntu 主機和 win7 虛擬機器的 LAN 連線。以下是 ifconfig 的輸出:
br0 Link encap:Ethernet HWaddr 08:62:66:28:84:88
inet addr:192.168.1.75 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: 2602:304:cd91:e710:bd86:dd51:d7dd:bc0a/64 Scope:Global
inet6 addr: fe80::a62:66ff:fe28:8488/64 Scope:Link
inet6 addr: 2602:304:cd91:e710:a62:66ff:fe28:8488/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1094 errors:0 dropped:0 overruns:0 frame:0
TX packets:151 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:79513 (79.5 KB) TX bytes:18098 (18.0 KB)
eth0 Link encap:Ethernet HWaddr 08:62:66:28:84:88
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1483 errors:0 dropped:0 overruns:0 frame:0
TX packets:151 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:248992 (248.9 KB) TX bytes:19177 (19.1 KB)
Interrupt:20 Memory:dff00000-dff20000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:217 errors:0 dropped:0 overruns:0 frame:0
TX packets:217 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:55759 (55.7 KB) TX bytes:55759 (55.7 KB)
virbr0 Link encap:Ethernet HWaddr 3a:13:59:8b:2e:07
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Ubuntu 主機和 Win7 虛擬機器都從 DHCP 取得 IP 位址。我的“介面”部分與您的相同,除了 MAC 和型號類型。我在上次回覆中給了你錯誤的訊息。我只使用nano來查看win7.xml檔案中的文字。我沒有用它來編輯文件。我正在使用虛擬機器管理器 GUI 來更改 rtl8139 和 virtIO 之間的模型類型。進行更改後,我透過使用 nano 開啟檔案並查看來確認 win7.xml 檔案顯示新的模型類型值。
抱歉,我無法將 xml 檔案貼到編輯視窗中。當我這樣做時,我可以在編輯視窗中看到整個文件,但在已儲存的編輯中只顯示兩行。我認為它可能試圖解釋文件並刪除特殊字元。我找不到有關如何貼上整個文件的說明。有辦法附加文件嗎?順便說一句 - 再次感謝您對這個問題的幫助。
答案1
請注意,對於 Windows 用戶機,您可能需要安裝特殊驅動程式才能使 virtio 正常運作。請參閱這些參考資料:
http://wiki.libvirt.org/page/Virtio
http://www.linux-kvm.org/page/WindowsGuestDrivers/Download_Drivers
https://launchpad.net/kvm-guest-drivers-windows/+download
以下內容來自我的一台虛擬機器。您的 mac 位址和位址行可能會有所不同:
<interface type='bridge'>
<mac address='52:54:00:c1:f1:b8'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
你是說這對你不起作用嗎? 192.168.1.0子網路如何取得其IP位址?透過 dhcp 還是靜態?
對於上下文,下面是整個 .xml 檔案:
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit desk_tt
or other application using the libvirt API.
-->
<domain type='kvm'>
<name>desk_tt</name>
<uuid>4235912f-1d46-8866-22ba-c91bfe2a86b7</uuid>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static'>4</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-1.7'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm-spice</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/media/newhd/desk_tt.img'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='1' target='0' unit='0'/>
</disk>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<interface type='bridge'>
<mac address='52:54:00:c1:f1:b8'/>
<source bridge='br0'/>
<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'/>
<input type='keyboard' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<video>
<model type='vmvga' vram='16384' 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='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>