VM和VPC是大家熟知的虛拟機軟體了。有人喜歡VM,有人喜歡VPC,蘿蔔白菜,各有所愛。
VM優點:支援USB裝置;虛拟網卡衆多,可以模拟多子網環境;顯示卡驅動要比VPC好,VPC隻支援1280*800分辨率以下,我的1366*768無法全屏;VM自帶錄像功能,可以做視訊教學;VM自帶snapshot功能,誤操作時還可以復原。
VM缺點:跑Windows系統确實不如VPC占資源小,速度快。
VPC優點:跑Windows系統确占資源小,速度快,這恐怕是唯一的亮點了。
VPC缺點:顯示卡驅動在1366*768的分辨率下無法完整的全屏,尤其是對linux的圖形化支援更是花屏嚴重;網卡僅僅包含主控端的實體網卡和虛拟網卡,有時候做多子網環境還得利用loopback網卡,藍牙網絡,無線網卡等。
是以我一般都是VM和VPC結合使用,做cluster實驗時偶爾還用到VS2005。在較早的機器上做實驗時,因為機器硬體不支援虛拟化,是以不存在VM和VPC沖突的問題,當我新買了一台I5的本本後,發現VM總是和VPC沖突,并且如果同時打開多個VPC機器,還可能導緻實體機藍屏。
在網上搜尋過相關的問題,大部分的矛頭都指向VPC中的一個選項:
<a target="_blank" href="http://blog.51cto.com/attachment/201108/180652562.jpg"></a>
但是我将虛拟化功能Disable之後打開VPC還是會讓正在運作的VM出現中斷。
後來,無意中用UltraEdit(記事本也可)打開vmc檔案時,仔細看了下裡面的代碼,代碼并不複雜。
<?xml version="1.0" encoding="UTF-16"?>
<!-- Microsoft Virtual Machine Options and Settings -->
<preferences>
<version type="string">2.0</version>
<alerts>
<notifications>
<no_boot_disk type="boolean">true</no_boot_disk>
</notifications>
</alerts>
<hardware>
<memory>
<ram_size type="integer">512</ram_size>
</memory>
<pci_bus>
<ethernet_adapter>
<controller_count type="integer">1</controller_count>
<ethernet_controller id="0">
<virtual_network>
<id type="bytes">0EB745BD4AB811E081C895FBFEB63705</id>
<name type="string">Intel(R) WiFi Link 1000 BGN</name>
</virtual_network>
<ethernet_card_address type="bytes">0003FF40EB61</ethernet_card_address>
</ethernet_controller>
</ethernet_adapter>
<video_adapter>
<vram_size type="integer">8</vram_size>
</video_adapter>
<ide_adapter>
<ide_controller id="1">
<location id="0">
<drive_type type="integer">2</drive_type>
<pathname>
<absolute type="string" />
<relative type="string" />
</pathname>
</location>
</ide_controller>
<ide_controller id="0">
<drive_type type="integer">1</drive_type>
<absolute type="string">G:\VPC2007\Lab-CHS\WINXP-PRO-SP3\WINXP-PRO-CHS-SP3.vhd</absolute>
<relative type="string">.\WINXP-PRO-CHS-SP3.vhd</relative>
<undo_pathname>
<absolute type="string">G:\VPC2007\Lab-CHS\WINXP-PRO-SP3\VirtualPCUndo_WINXP-PRO-CHS-SP3_0_0_0_10013408212011.vud</absolute>
<relative type="string">.\VirtualPCUndo_WINXP-PRO-CHS-SP3_0_0_0_10013408212011.vud</relative>
</undo_pathname>
</ide_adapter>
</pci_bus>
<standard>
<name type="string">Virtual PC 2007</name>
<version type="string">0001.0000.0000</version>
</standard>
<super_io>
<floppy id="0">
<pathname>
<absolute type="string" />
<relative type="string" />
</pathname>
</floppy>
<floppy>
<auto_detect type="boolean">true</auto_detect>
<parallel_port>
<port_shared type="boolean">false</port_shared>
<port_type type="integer">0</port_type>
</parallel_port>
<serial_port>
<connect_immediately type="boolean">false</connect_immediately>
</serial_port>
</super_io>
<bios>
<base_board>
<serial_number type="string">5284-0211-5760-6543-5348-2456-30</serial_number>
</base_board>
<bios_guid type="string">{D30B7F05-B995-44E6-A333-64507F56B2AB}</bios_guid>
<bios_serial_number type="string">5284-0211-5760-6543-5348-2456-30</bios_serial_number>
<chassis>
<asset_tag type="string">5284-0211-5760-6543-5348-2456-30</asset_tag>
</chassis>
<cmos type="bytes">00004000F020378002FFFF2F00FF3F1000003FFF3F1000003F31004C0707070707E9FFFF208580FF01000000200C01800CFC00000000000000000000000000901A32E252580050E999E62401002784004A2080240000000000085AACFE1032547698BAE400000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</cmos>
<time_bytes type="bytes">11003900170000210811</time_bytes>
</bios>
</hardware>
<integration>
<microsoft>
<mouse>
<allow type="boolean">true</allow>
</mouse>
<video>
<user_selected>
<depth type="integer">16</depth>
<height type="integer">480</height>
<width type="integer">640</width>
</user_selected>
</video>
</microsoft>
</integration>
<properties>
<creator>
<build type="string">6.0.156.0</build>
<name type="string">Microsoft Virtual PC 2007</name>
</creator>
<modifier>
<build type="string">6.0.192.0</build>
</modifier>
</properties>
<settings>
<shutdown>
<prompt type="boolean">true</prompt>
<quit>
<action type="integer">4</action>
<was_running type="boolean">true</was_running>
</quit>
<save>
<enable type="boolean">true</enable>
</save>
<shutdown>
</shutdown>
<turn_off>
</turn_off>
<last_shutdown>
<choice type="integer">3</choice>
<commit type="boolean">false</commit>
</last_shutdown>
</shutdown>
<sound>
<sound_adapter>
</sound_adapter>
</sound>
<startup>
<automatic>
<type type="integer">2</type>
</automatic>
</startup>
<undo_drives>
<enabled type="boolean">true</enabled>
<purposely_kept type="boolean">false</purposely_kept>
<use_default type="boolean">true</use_default>
</undo_drives>
<video>
<disable_resize type="boolean">false</disable_resize>
<full_screen type="boolean">false</full_screen>
<mode>
<full_screen>
<startup type="boolean">false</startup>
</full_screen>
</mode>
<resolutions>
<standard_only type="boolean">false</standard_only>
</resolutions>
<height type="integer">600</height>
<left_position type="integer">151</left_position>
<max_height type="integer">600</max_height>
<max_width type="integer">800</max_width>
<top_position type="integer">62</top_position>
<width type="integer">800</width>
</video>
<guest_os type="integer">3</guest_os>
</settings>
<virtual_machines>
<hw_assist>
<enable_hw_assist type="boolean">true</enable_hw_assist>
</hw_assist>
<allow_packet_filtering type="boolean">false</allow_packet_filtering>
<allow_promiscuous_mode type="boolean">false</allow_promiscuous_mode>
</virtual_machines>
</preferences>
171. <enable_hw_assist type="boolean">true</enable_hw_assist>
大家看上面170-172行代碼,原來這台虛拟機一啟動就預設打開虛拟化開關,即使關閉了控制台的虛拟化開關也是沒用的。将此項設定為false後,VPC再也沒有和VM沖突了。
<enable_hw_assist type="boolean">false</enable_hw_assist>
根本原因是主控端(實體機)不像WIN2008安裝有hypervisor去調控虛拟化的硬體資源,是以如果虛拟機打開虛拟化開關會造成硬體資源争奪的情況,嚴重時造成實體機藍屏。
至此VM與VPC沖突問題從根本上得到解決。
本文轉自yangye1985 51CTO部落格,原文連結:http://blog.51cto.com/yangye/645652,如需轉載請自行聯系原作者