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机器,还可能导致物理机蓝屏。

VM与VPC共存(续)_职场 

 

        在网上搜索过相关的问题,大部分的矛头都指向VPC中的一个选项:

VM与VPC共存(续)_VM_02

但是我将虚拟化功能Disable之后打开VPC还是会让正在运行的VM出现中断。

        后来,无意中用UltraEdit(记事本也可)打开vmc文件时,仔细看了下里面的代码,代码并不复杂。

  1. <?xml version="1.0" encoding="UTF-16"?>  
  2. <!-- Microsoft Virtual Machine Options and Settings -->  
  3. <preferences>  
  4.     <version type="string">2.0</version>  
  5.     <alerts>  
  6.         <notifications>  
  7.             <no_boot_disk type="boolean">true</no_boot_disk>  
  8.         </notifications>  
  9.     </alerts>  
  10.     <hardware>  
  11.         <memory>  
  12.             <ram_size type="integer">512</ram_size>  
  13.         </memory>  
  14.         <pci_bus>  
  15.             <ethernet_adapter>  
  16.                 <controller_count type="integer">1</controller_count>  
  17.                 <ethernet_controller id="0">  
  18.                     <virtual_network>  
  19.                         <id type="bytes">0EB745BD4AB811E081C895FBFEB63705</id>  
  20.                         <name type="string">Intel(R) WiFi Link 1000 BGN</name>  
  21.                     </virtual_network>  
  22.                     <ethernet_card_address type="bytes">0003FF40EB61</ethernet_card_address>  
  23.                 </ethernet_controller>  
  24.             </ethernet_adapter>  
  25.             <video_adapter>  
  26.                 <vram_size type="integer">8</vram_size>  
  27.             </video_adapter>  
  28.             <ide_adapter>  
  29.                 <ide_controller id="1">  
  30.                     <location id="0">  
  31.                         <drive_type type="integer">2</drive_type>  
  32.                         <pathname>  
  33.                             <absolute type="string" />  
  34.                             <relative type="string" />  
  35.                         </pathname>  
  36.                     </location>  
  37.                 </ide_controller>  
  38.                 <ide_controller id="0">  
  39.                     <location id="0">  
  40.                         <drive_type type="integer">1</drive_type>  
  41.                         <pathname>  
  42.                             <absolute type="string">G:\VPC2007\Lab-CHS\WINXP-PRO-SP3\WINXP-PRO-CHS-SP3.vhd</absolute>  
  43.                             <relative type="string">.\WINXP-PRO-CHS-SP3.vhd</relative>  
  44.                         </pathname>  
  45.                         <undo_pathname>  
  46.                             <absolute type="string">G:\VPC2007\Lab-CHS\WINXP-PRO-SP3\VirtualPCUndo_WINXP-PRO-CHS-SP3_0_0_0_10013408212011.vud</absolute>  
  47.                             <relative type="string">.\VirtualPCUndo_WINXP-PRO-CHS-SP3_0_0_0_10013408212011.vud</relative>  
  48.                         </undo_pathname>  
  49.                     </location>  
  50.                 </ide_controller>  
  51.             </ide_adapter>  
  52.         </pci_bus>  
  53.         <standard>  
  54.             <name type="string">Virtual PC 2007</name>  
  55.             <version type="string">0001.0000.0000</version>  
  56.         </standard>  
  57.         <super_io>  
  58.             <floppy id="0">  
  59.                 <pathname>  
  60.                     <absolute type="string" />  
  61.                     <relative type="string" />  
  62.                 </pathname>  
  63.             </floppy>  
  64.             <floppy>  
  65.                 <auto_detect type="boolean">true</auto_detect>  
  66.             </floppy>  
  67.             <parallel_port>  
  68.                 <port_shared type="boolean">false</port_shared>  
  69.                 <port_type type="integer">0</port_type>  
  70.             </parallel_port>  
  71.             <serial_port>  
  72.                 <connect_immediately type="boolean">false</connect_immediately>  
  73.             </serial_port>  
  74.         </super_io>  
  75.         <bios>  
  76.             <base_board>  
  77.                 <serial_number type="string">5284-0211-5760-6543-5348-2456-30</serial_number>  
  78.             </base_board>  
  79.             <bios_guid type="string">{D30B7F05-B995-44E6-A333-64507F56B2AB}</bios_guid>  
  80.             <bios_serial_number type="string">5284-0211-5760-6543-5348-2456-30</bios_serial_number>  
  81.             <chassis>  
  82.                 <asset_tag type="string">5284-0211-5760-6543-5348-2456-30</asset_tag>  
  83.                 <serial_number type="string">5284-0211-5760-6543-5348-2456-30</serial_number>  
  84.             </chassis>  
  85.             <cmos type="bytes">00004000F020378002FFFF2F00FF3F1000003FFF3F1000003F31004C0707070707E9FFFF208580FF01000000200C01800CFC00000000000000000000000000901A32E252580050E999E62401002784004A2080240000000000085AACFE1032547698BAE400000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</cmos>  
  86.             <time_bytes type="bytes">11003900170000210811</time_bytes>  
  87.         </bios>  
  88.     </hardware>  
  89.     <integration>  
  90.         <microsoft>  
  91.             <mouse>  
  92.                 <allow type="boolean">true</allow>  
  93.             </mouse>  
  94.             <video>  
  95.                 <user_selected>  
  96.                     <depth type="integer">16</depth>  
  97.                     <height type="integer">480</height>  
  98.                     <width type="integer">640</width>  
  99.                 </user_selected>  
  100.             </video>  
  101.         </microsoft>  
  102.     </integration>  
  103.     <properties>  
  104.         <creator>  
  105.             <build type="string">6.0.156.0</build>  
  106.             <name type="string">Microsoft Virtual PC 2007</name>  
  107.         </creator>  
  108.         <modifier>  
  109.             <build type="string">6.0.192.0</build>  
  110.             <name type="string">Microsoft Virtual PC 2007</name>  
  111.         </modifier>  
  112.     </properties>  
  113.     <settings>  
  114.         <shutdown>  
  115.             <prompt type="boolean">true</prompt>  
  116.             <quit>  
  117.                 <action type="integer">4</action>  
  118.                 <was_running type="boolean">true</was_running>  
  119.             </quit>  
  120.             <save>  
  121.                 <enable type="boolean">true</enable>  
  122.             </save>  
  123.             <shutdown>  
  124.                 <enable type="boolean">true</enable>  
  125.             </shutdown>  
  126.             <turn_off>  
  127.                 <enable type="boolean">true</enable>  
  128.             </turn_off>  
  129.             <last_shutdown>  
  130.                 <choice type="integer">3</choice>  
  131.                 <commit type="boolean">false</commit>  
  132.             </last_shutdown>  
  133.         </shutdown>  
  134.         <sound>  
  135.             <sound_adapter>  
  136.                 <enable type="boolean">true</enable>  
  137.             </sound_adapter>  
  138.         </sound>  
  139.         <startup>  
  140.             <automatic>  
  141.                 <type type="integer">2</type>  
  142.             </automatic>  
  143.         </startup>  
  144.         <undo_drives>  
  145.             <enabled type="boolean">true</enabled>  
  146.             <purposely_kept type="boolean">false</purposely_kept>  
  147.             <use_default type="boolean">true</use_default>  
  148.         </undo_drives>  
  149.         <video>  
  150.             <disable_resize type="boolean">false</disable_resize>  
  151.             <full_screen type="boolean">false</full_screen>  
  152.             <mode>  
  153.                 <full_screen>  
  154.                     <startup type="boolean">false</startup>  
  155.                 </full_screen>  
  156.             </mode>  
  157.             <resolutions>  
  158.                 <standard_only type="boolean">false</standard_only>  
  159.             </resolutions>  
  160.             <height type="integer">600</height>  
  161.             <left_position type="integer">151</left_position>  
  162.             <max_height type="integer">600</max_height>  
  163.             <max_width type="integer">800</max_width>  
  164.             <top_position type="integer">62</top_position>  
  165.             <width type="integer">800</width>  
  166.         </video>  
  167.         <guest_os type="integer">3</guest_os>  
  168.     </settings>  
  169.     <virtual_machines>  
  170.         <hw_assist>  
  171.             <enable_hw_assist type="boolean">true</enable_hw_assist>  
  172.         </hw_assist>  
  173.         <allow_packet_filtering type="boolean">false</allow_packet_filtering>  
  174.         <allow_promiscuous_mode type="boolean">false</allow_promiscuous_mode>  
  175.     </virtual_machines>  
  176. </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冲突问题从根本上得到解决。