管理 Hyper-v Integration ServicesManage Hyper-V Integration Services

适用于: Windows 10,Windows Server 2012,Windows Server 2012R2,Windows Server 2016,Windows Server 2019Applies To: Windows 10, Windows Server 2012, Windows Server 2012R2, Windows Server 2016, Windows Server 2019

Hyper-v Integration Services 通过与 Hyper-v 主机进行双向通信来增强虚拟机性能并提供便利功能。Hyper-V Integration Services enhance virtual machine performance and provide convenience features by leveraging two-way communication with the Hyper-V host. 其中许多服务都是很便利(如来宾文件复制),而其他服务则对虚拟机的功能很重要,例如合成设备驱动程序。Many of these services are conveniences, such as guest file copy, while others are important to the virtual machine's functionality, such as synthetic device drivers. 这组服务和驱动程序有时称为 "集成组件"。This set of services and drivers are sometimes referred to as "integration components". 可以控制每个给定虚拟机的个别便利服务是否正常运行。You can control whether or not individual convenience services operate for any given virtual machine. 驱动程序组件不应被手动提供服务。The driver components are not intended to be serviced manually.

有关每个 integration services 的详细信息,请参阅 hyper-v Integration ServicesFor details about each integration service, see Hyper-V Integration Services.

重要

必须在主机和来宾中同时启用每个要使用的服务,才能正常运行。Each service you want to use must be enabled in both the host and guest in order to function. 默认情况下,所有集成 Hyper-V 来宾服务接口服务在 Windows 来宾操作系统上都处于启用状态。All integration services except "Hyper-V Guest Service Interface" are on by default on Windows guest operating systems. 可以单独打开和关闭服务。The services can be turned on and off individually. 下一部分介绍了如何操作。The next sections show you how.

使用 Hyper-v 管理器打开或关闭集成服务Turn an integration service on or off using Hyper-V Manager

  1. 在中心窗格中,右键单击虚拟机,然后单击 " 设置"。From the center pane, right-click the virtual machine and click Settings.

  2. 从 " 设置 " 窗口的左窗格中的 " 管理" 下,单击 " Integration Services"。From the left pane of the Settings window, under Management, click Integration Services.

"Integration Services" 窗格列出了 Hyper-v 主机上可用的所有集成服务,以及该主机是否已启用虚拟机以使用它们。The Integration Services pane lists all integration services available on the Hyper-V host, and whether the host has enabled the virtual machine to use them.

使用 PowerShell 启用或禁用集成服务Turn an integration service on or off using PowerShell

若要在 PowerShell 中执行此操作,请使用 enable-vmintegrationserviceenable-vmintegrationserviceTo do this in PowerShell, use Enable-VMIntegrationService and Disable-VMIntegrationService.

下面的示例演示如何为名为 "demovm" 的虚拟机启用和禁用来宾文件复制集成服务。The following examples demonstrate turning the guest file copy integration service on and off for a virtual machine named "demovm".

  1. 获取正在运行的 integration services 的列表:Get a list of running integration services:

    Get-VMIntegrationService -VMName "DemoVM"
    
  2. 输出应如下所示:The output should look like this:

    VMName      Name                    Enabled PrimaryStatusDescription SecondaryStatusDescription
    ------      ----                    ------- ------------------------ --------------------------
    DemoVM      Guest Service Interface False   OK
    DemoVM      Heartbeat               True    OK                       OK
    DemoVM      Key-Value Pair Exchange True    OK
    DemoVM      Shutdown                True    OK
    DemoVM      Time Synchronization    True    OK
    DemoVM      VSS                     True    OK
    
  3. 启用来宾服务接口:Turn on Guest Service Interface:

    Enable-VMIntegrationService -VMName "DemoVM" -Name "Guest Service Interface"
    
  4. 验证是否已启用来宾服务接口:Verify that Guest Service Interface is enabled:

    Get-VMIntegrationService -VMName "DemoVM"
    
  5. 禁用来宾服务接口:Turn off Guest Service Interface:

    Disable-VMIntegrationService -VMName "DemoVM" -Name "Guest Service Interface"
    

检查来宾的 integration services 版本Checking the guest's integration services version

某些功能可能无法正常工作,或者如果来宾的集成服务不是最新的,则不能正常工作。Some features may not work correctly or at all if the guest's integration services are not current. 若要获取 Windows 的版本信息,请登录到来宾操作系统,打开命令提示符,并运行以下命令:To get the version information for a Windows, log on to the guest operating system, open a command prompt, and run this command:

REG QUERY "HKLM\Software\Microsoft\Virtual Machine\Auto" /v IntegrationServicesVersion

较早版本的来宾操作系统将没有所有可用的服务。Earlier guest operating systems will not have all available services. 例如,Windows Server 2008 R2 来宾不能有 "Hyper-V 来宾服务接口"。For example, Windows Server 2008 R2 guests cannot have the "Hyper-V Guest Service Interface".

启动和停止 Windows 来宾的集成服务Start and stop an integration service from a Windows Guest

为了使 integration services 能够完全正常运行,除了在主机上启用外,还必须在来宾内运行其相应的服务。In order for an integration service to be fully functional, its corresponding service must be running within the guest in addition to being enabled on the host. 在 Windows 来宾中,每个 integration services 都作为标准 Windows 服务列出。In Windows guests, each integration service is listed as a standard Windows service. 你可以使用 "控制面板" 或 "PowerShell" 中的 "服务" 小程序来停止和启动这些服务。You can use the Services applet in Control Panel or PowerShell to stop and start these services.

重要

停止集成服务可能会严重影响主机管理虚拟机的能力。Stopping an integration service may severely affect the host's ability to manage your virtual machine. 若要正常工作,必须在主机和来宾上启用要使用的每个 integration services。To work correctly, each integration service you want to use must be enabled on both the host and guest. 最佳做法是,仅应使用上述说明从 Hyper-v 控制集成服务。As a best practice, you should only control integration services from Hyper-V using the instructions above. 在 Hyper-v 中更改来宾操作系统中的匹配服务时,该服务将自动停止或启动。The matching service in the guest operating system will stop or start automatically when you change its status in Hyper-V. 如果在来宾操作系统中启动一个服务,但该服务在 Hyper-v 中处于禁用状态,则该服务将停止。If you start a service in the guest operating system but it is disabled in Hyper-V, the service will stop. 如果在 Hyper-v 中启用了来宾操作系统中的服务,则 Hyper-v 最终将再次启动该服务。If you stop a service in the guest operating system that is enabled in Hyper-V, Hyper-V will eventually start it again. 如果在来宾中禁用该服务,Hyper-v 将无法启动该服务。If you disable the service in the guest, Hyper-V will be unable to start it.

使用 Windows 服务在 Windows 来宾中启动或停止集成服务Use Windows Services to start or stop an integration service within a Windows guest

  1. 通过 services.msc 以管理员身份运行或通过双击 "控制面板" 中的 "服务" 图标来打开服务管理器。Open Services manager by running services.msc as an Administrator or by double-clicking the Services icon in Control Panel.

    显示 "Windows 服务" 窗格的屏幕截图

  2. 查找以 "Hyper-v" 开头的服务。Find the services that start with "Hyper-V".

  3. 右键单击要启动或停止的服务。Right-click the service you want start or stop. 单击所需的操作。Click the desired action.

使用 Windows PowerShell 在 Windows 来宾中启动或停止集成服务Use Windows PowerShell to start or stop an integration service within a Windows guest

  1. 若要获取 integration services 列表,请运行:To get a list of integration services, run:

    Get-Service -Name vm*
    
  2. 输出应如下所示:The output should look similar to this:

    Status   Name               DisplayName
    ------   ----               -----------
    Running  vmicguestinterface Hyper-V Guest Service Interface
    Running  vmicheartbeat      Hyper-V Heartbeat Service
    Running  vmickvpexchange    Hyper-V Data Exchange Service
    Running  vmicrdv            Hyper-V Remote Desktop Virtualizati...
    Running  vmicshutdown       Hyper-V Guest Shutdown Service
    Running  vmictimesync       Hyper-V Time Synchronization Service
    Stopped  vmicvmsession      Hyper-V VM Session Service
    Running  vmicvss            Hyper-V Volume Shadow Copy Requestor
    
  3. 运行 " 启动服务 " 或 " 停止服务"。Run either Start-Service or Stop-Service. 例如,若要关闭 Windows PowerShell Direct,请运行:For example, to turn off Windows PowerShell Direct, run:

    Stop-Service -Name vmicvmsession
    

从 Linux 来宾启动和停止集成服务Start and stop an integration service from a Linux guest

Linux 集成服务通常通过 Linux 内核提供。Linux integration services are generally provided through the Linux kernel. Linux integration services 驱动程序名为 hv_utilsThe Linux integration services driver is named hv_utils.

  1. 若要确定是否已加载 hv_utils ,请使用以下命令:To find out if hv_utils is loaded, use this command:

    lsmod | grep hv_utils
    
  2. 输出应如下所示:The output should look similar to this:

    Module                  Size   Used by
    hv_utils               20480   0
    hv_vmbus               61440   8 hv_balloon,hyperv_keyboard,hv_netvsc,hid_hyperv,hv_utils,hyperv_fb,hv_storvsc
    
  3. 若要查看所需的守护程序是否正在运行,请使用此命令。To find out if the required daemons are running, use this command.

    ps -ef | grep hv
    
  4. 输出应如下所示:The output should look similar to this:

    root       236     2  0 Jul11 ?        00:00:00 [hv_vmbus_con]
    root       237     2  0 Jul11 ?        00:00:00 [hv_vmbus_ctl]
    ...
    root       252     2  0 Jul11 ?        00:00:00 [hv_vmbus_ctl]
    root      1286     1  0 Jul11 ?        00:01:11 /usr/lib/linux-tools/3.13.0-32-generic/hv_kvp_daemon
    root      9333     1  0 Oct12 ?        00:00:00 /usr/lib/linux-tools/3.13.0-32-generic/hv_kvp_daemon
    root      9365     1  0 Oct12 ?        00:00:00 /usr/lib/linux-tools/3.13.0-32-generic/hv_vss_daemon
    scooley  43774 43755  0 21:20 pts/0    00:00:00 grep --color=auto hv
    
  5. 若要查看哪些守护程序可用,请运行:To see what daemons are available, run:

    compgen -c hv_
    
  6. 输出应如下所示:The output should look similar to this:

    hv_vss_daemon
    hv_get_dhcp_info
    hv_get_dns_info
    hv_set_ifconfig
    hv_kvp_daemon
    hv_fcopy_daemon
    

    可能列出的 Integration services 守护程序包括以下各项。Integration service daemons that might be listed include the following. 如果缺少任何这些程序,可能不会在您的系统上受支持,或者它们可能未安装。If any are missing, they might not be supported on your system or they might not be installed. 查找详细信息,请参阅 Windows 上的 Hyper-v 支持的 Linux 和 FreeBSD 虚拟机Find details, see Supported Linux and FreeBSD virtual machines for Hyper-V on Windows.

    • hv_vss_daemon:创建实时 Linux 虚拟机备份需要此守护程序。hv_vss_daemon: This daemon is required to create live Linux virtual machine backups.
    • hv_kvp_daemon:此守护程序允许设置和查询内部和外部密钥值对。hv_kvp_daemon: This daemon allows setting and querying intrinsic and extrinsic key value pairs.
    • hv_fcopy_daemon:此后台程序在主机和来宾之间实现文件复制服务。hv_fcopy_daemon: This daemon implements a file copying service between the host and guest.

示例Examples

这些示例演示了如何停止和启动 KVP 守护程序(名为) hv_kvp_daemonThese examples demonstrate stopping and starting the KVP daemon, named hv_kvp_daemon.

  1. 使用进程 ID ( PID ) 停止守护程序的进程。Use the process ID (PID) to stop the daemon's process. 若要查找 PID,请查看输出的第二列,或使用 pidofTo find the PID, look at the second column of the output, or use pidof. Hyper-v 守护程序作为根运行,所以需要根权限。Hyper-V daemons run as root, so you'll need root permissions.

    sudo kill -15 `pidof hv_kvp_daemon`
    
  2. 若要验证所有 hv_kvp_daemon 进程是否已消失,请运行:To verify that all hv_kvp_daemon process are gone, run:

    ps -ef | hv
    
  3. 若要重新启动该守护程序,请将守护程序作为根运行:To start the daemon again, run the daemon as root:

    sudo hv_kvp_daemon
    
  4. 若要 hv_kvp_daemon 使用新的进程 ID 验证进程是否已列出,请运行:To verify that the hv_kvp_daemon process is listed with a new process ID, run:

    ps -ef | hv
    

使 integration services 保持最新Keep integration services up to date

建议使 integration services 保持最新状态,以获取虚拟机的最佳性能和最新功能。We recommend that you keep integration services up to date to get the best performance and most recent features for your virtual machines. 默认情况下,如果这些来宾设置为从 Windows 更新获取重要更新,则默认情况下会发生这种情况。This happens for most Windows guests by default if they are set up to get important updates from Windows Update. 当你更新内核时,使用当前内核的 Linux 来宾将接收到最新的集成组件。Linux guests using current kernels will receive the latest integration components when you update the kernel.

对于在 Windows 10/Windows Server 2016/2019 主机上运行的虚拟机:For virtual machines running on Windows 10/Windows Server 2016/2019 hosts:

备注

Windows 10/Windows Server 2016/2019 上的 Hyper-v 不附带 vmguest.iso 映像文件,因为不再需要此文件。The image file vmguest.iso isn't included with Hyper-V on Windows 10/Windows Server 2016/2019 because it's no longer needed.

来宾Guest 更新机制Update mechanism 备注Notes
Windows 10Windows 10 Windows 更新Windows Update
Windows 8.1Windows 8.1 Windows 更新Windows Update
Windows 8Windows 8 Windows 更新Windows Update 需要“数据交换”集成服务。*Requires the Data Exchange integration service.*
Windows 7Windows 7 Windows 更新Windows Update 需要“数据交换”集成服务。*Requires the Data Exchange integration service.*
Windows Vista (SP 2)Windows Vista (SP 2) Windows 更新Windows Update 需要“数据交换”集成服务。*Requires the Data Exchange integration service.*
-
Windows Server 2016Windows Server 2016 Windows 更新Windows Update
Windows Server 半年频道Windows Server, Semi-Annual Channel Windows 更新Windows Update
Windows Server 2012 R2Windows Server 2012 R2 Windows 更新Windows Update
Windows Server 2012Windows Server 2012 Windows 更新Windows Update 需要“数据交换”集成服务。*Requires the Data Exchange integration service.*
Windows Server 2008 R2 (SP 1)Windows Server 2008 R2 (SP 1) Windows 更新Windows Update 需要“数据交换”集成服务。*Requires the Data Exchange integration service.*
Windows Server 2008 (SP 2)Windows Server 2008 (SP 2) Windows 更新Windows Update 仅 Windows Server 2016 中的扩展支持 (阅读更多) 。Extended support only in Windows Server 2016 (read more).
Windows Home Server 2011Windows Home Server 2011 Windows 更新Windows Update 在 Windows Server 2016 中将不受支持 (阅读更多) 。Will not be supported in Windows Server 2016 (read more).
Windows Small Business Server 2011Windows Small Business Server 2011 Windows 更新Windows Update 不受主流支持 (阅读更多) 。Not under mainstream support (read more).
-
Linux 来宾Linux guests 程序包管理器package manager Linux 集成服务内置于发行版中,但可能有可选的更新可用。Integration services for Linux are built into the distro but there may be optional updates available. ********

* 如果无法启用数据交换集成服务,这些来宾的集成服务将从 下载中心 作为 cabinet (cab) 文件提供。* If the Data Exchange integration service can't be enabled, the integration services for these guests are available from the Download Center as a cabinet (cab) file. 博客文章提供了应用 cab 的说明。Instructions for applying a cab are available in this blog post.

对于在 Windows 8.1/Windows Server 2012R2 主机上运行的虚拟机:For virtual machines running on Windows 8.1/Windows Server 2012R2 hosts:

来宾Guest 更新机制Update mechanism 备注Notes
Windows 10Windows 10 Windows 更新Windows Update
Windows 8.1Windows 8.1 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows 8Windows 8 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows 7Windows 7 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Vista (SP 2)Windows Vista (SP 2) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows XP(SP 2、SP 3)Windows XP (SP 2, SP 3) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
-
Windows Server 2016Windows Server 2016 Windows 更新Windows Update
Windows Server 半年频道Windows Server, Semi-Annual Channel Windows 更新Windows Update
Windows Server 2012 R2Windows Server 2012 R2 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2012Windows Server 2012 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2008 R2Windows Server 2008 R2 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2008 (SP 2)Windows Server 2008 (SP 2) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Home Server 2011Windows Home Server 2011 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Small Business Server 2011Windows Small Business Server 2011 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2003 R2 (SP 2)Windows Server 2003 R2 (SP 2) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2003 (SP 2)Windows Server 2003 (SP 2) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
-
Linux 来宾Linux guests 程序包管理器package manager Linux 集成服务内置于发行版中,但可能有可选的更新可用。Integration services for Linux are built into the distro but there may be optional updates available. **

对于在 Windows 8/Windows Server 2012 主机上运行的虚拟机:For virtual machines running on Windows 8/Windows Server 2012 hosts:

来宾Guest 更新机制Update mechanism 备注Notes
Windows 8.1Windows 8.1 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows 8Windows 8 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows 7Windows 7 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Vista (SP 2)Windows Vista (SP 2) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows XP(SP 2、SP 3)Windows XP (SP 2, SP 3) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
-
Windows Server 2012 R2Windows Server 2012 R2 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2012Windows Server 2012 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2008 R2Windows Server 2008 R2 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2008 (SP 2)Windows Server 2008 (SP 2) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Home Server 2011Windows Home Server 2011 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Small Business Server 2011Windows Small Business Server 2011 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2003 R2 (SP 2)Windows Server 2003 R2 (SP 2) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
Windows Server 2003 (SP 2)Windows Server 2003 (SP 2) 集成服务磁盘Integration Services disk 请参阅下面的 说明See instructions, below.
-
Linux 来宾Linux guests 程序包管理器package manager Linux 集成服务内置于发行版中,但可能有可选的更新可用。Integration services for Linux are built into the distro but there may be optional updates available. **

有关 Linux 来宾的详细信息,请参阅 Windows 上的 Hyper-v 支持的 Linux 和 FreeBSD 虚拟机For more details about Linux guests, see Supported Linux and FreeBSD virtual machines for Hyper-V on Windows.

安装或更新 integration servicesInstall or update integration services

备注

对于早于 Windows Server 2016 和 Windows 10 的主机,你将需要在来宾操作系统中 手动安装或更新 integration services。For hosts earlier than Windows Server 2016 and Windows 10, you'll need to manually install or update the integration services in the guest operating systems.

手动安装或更新 integration services 的过程:Procedure to manually Install or update the integration services:

  1. 打开 Hyper-V 管理器。Open Hyper-V Manager. 在服务器管理器的 "工具" 菜单中,单击 " Hyper-v 管理器"。From the Tools menu of Server Manager, click Hyper-V Manager.

  2. 连接到虚拟机。Connect to the virtual machine. 右键单击该虚拟机,然后单击 " 连接"。Right-click the virtual machine and click Connect.

  3. 在“虚拟机连接”的“操作”菜单中,单击“插入集成服务安装盘”****。From the Action menu of Virtual Machine Connection, click Insert Integration Services Setup Disk. 该操作将在虚拟 DVD 驱动器中加载安装盘。This action loads the setup disk in the virtual DVD drive. 根据来宾操作系统的不同,您可能需要手动启动安装。Depending on the guest operating system, you might need to start the installation manually.

  4. 安装完成后,所有集成服务均可使用。After the installation finishes, all integration services are available for use.

备注

对于联机虚拟机,无法在 Windows PowerShell 会话中自动执行或执行这些步骤。These steps can't be automated or done within a Windows PowerShell session for online virtual machines. 可以将其应用于 脱机 VHDX 映像;请参阅 如何在虚拟机未运行时安装 integration servicesYou can apply them to offline VHDX images; see How to install integration services when the virtual machine is not running. 你还可以通过将 Configuration Manager 与 vm 联机来自动部署 integration services,但需要在安装结束时重新启动 vm;请参阅 使用配置管理器和 DISM 将 hyper-v Integration Services 部署到 vmYou can also automate the deploy of the integration services through Configuration Manager with the VMs Online, but you need to restart the VMs at the end of the installation; see Deploying Hyper-V Integration Services to VMs using Config Manager and DISM