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中的一个选项:
但是我将虚拟化功能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">
- <location id="0">
- <drive_type type="integer">1</drive_type>
- <pathname>
- <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>
- </pathname>
- <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>
- </location>
- </ide_controller>
- </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>
- </floppy>
- <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>
- <serial_number type="string">5284-0211-5760-6543-5348-2456-30</serial_number>
- </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>
- <name type="string">Microsoft Virtual PC 2007</name>
- </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>
- <enable type="boolean">true</enable>
- </shutdown>
- <turn_off>
- <enable type="boolean">true</enable>
- </turn_off>
- <last_shutdown>
- <choice type="integer">3</choice>
- <commit type="boolean">false</commit>
- </last_shutdown>
- </shutdown>
- <sound>
- <sound_adapter>
- <enable type="boolean">true</enable>
- </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,如需转载请自行联系原作者