WO2017067213A1 - Device hot-replacement method and apparatus based on virtual machine - Google Patents

Device hot-replacement method and apparatus based on virtual machine Download PDF

Info

Publication number
WO2017067213A1
WO2017067213A1 PCT/CN2016/087920 CN2016087920W WO2017067213A1 WO 2017067213 A1 WO2017067213 A1 WO 2017067213A1 CN 2016087920 W CN2016087920 W CN 2016087920W WO 2017067213 A1 WO2017067213 A1 WO 2017067213A1
Authority
WO
WIPO (PCT)
Prior art keywords
identifier
logical device
virtual disk
hot
mapping relationship
Prior art date
Application number
PCT/CN2016/087920
Other languages
French (fr)
Chinese (zh)
Inventor
肖庆航
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2017067213A1 publication Critical patent/WO2017067213A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines

Definitions

  • the present invention relates to the field of virtual machine technologies, and in particular, to a virtual machine-based device hot replacement method and device.
  • Virtual Machine refers to a complete computer system that runs through a software and has a complete hardware system function and runs in a completely isolated environment.
  • the virtual machine generates a completely new virtual image of the existing operating system. It has the same function as the real operating system. After entering the virtual system, all operations are performed in this new independent virtual system.
  • the software can be installed and saved independently. Data and more.
  • Hot-plugging is hot swapping and can also be called hot replacement.
  • the hot-swap function allows the user to remove and replace damaged hard disks, power supplies or boards without shutting down the system, thus improving the system's ability to recover from disasters, scalability, and flexibility.
  • the virtual machine device is hot swapped. Since all the "hardware" seen by the VM from the perspective of the VM is simulated by the software provided by the VMM (virtual machine monitor), the "hardware" for the VM is used. Hot plugging is actually a software simulation of the VMM layer.
  • the VMM receives the hot plug operation request corresponding to the hot swappable virtual disk through the command line interface, triggers the hot plug operation, and the VMM sends the hot plug operation request to the corresponding virtual machine operating system; the virtual machine operates.
  • the hot-plug event is driven to find the corresponding virtual device driver.
  • the virtual device driver recovers the resources allocated to the hot-swappable virtual disk to implement hot-plugging of the hot-swappable virtual disk.
  • the hot plug operation can be performed effectively, but when the physical disk fails (for example, the head is damaged and the VMM cannot be accessed normally), the device drive is abnormally caused.
  • the device driver that enables the hot swap operation of the logical device also has an abnormality, so that the hot pull operation of the device cannot be performed when the VM is running. Therefore, if the device fails and the device driver is abnormal, you can only shut down the VM; remove the failed device from the definition of the VM; and then repair the logical device or file corresponding to the VM at the VMM layer.
  • the VM is relatively large. It takes a long time to restart the VM and the loss is large.
  • shutting down the VM may affect the client associated with the server, thus greatly affecting the user.
  • Experience for example, shutting down a VM for an online gaming service may affect the gaming experience of all users who log in to the server). Therefore, how to implement hot-plug operation of a faulty "device" in a virtual machine has become a technical problem that is urgently needed to be solved by those skilled in the art.
  • the embodiment of the invention provides a virtual machine-based device hot replacement method and device, which can implement a logic device to proxy a logical device when a logical device fails, and has responded to the corresponding control command, and then the virtual machine can be normal. Control the operation of the device.
  • an embodiment of the present invention provides a virtual machine-based device hot replacement method, the method comprising: receiving a hot replacement command, where the hot replacement command carries a virtual disk identifier, wherein the virtual disk identifier corresponds to a need to be A replaced logical device (such as a logical device that has failed).
  • An analog logic device is generated that has an identification (such as a descriptor, or a handle, etc.).
  • the control information of the logical device to be replaced corresponding to the hot replacement command is sent to the analog logic device, so that the analog logic device can proxy the replacement logical device to respond to the control command.
  • mapping relationship between the identifier of the corresponding virtual disk and the identifier of the logical device to be replaced is deleted according to the hot replacement command, and the mapping relationship between the corresponding virtual disk and the analog logical device is established. At this time, the logical device is simulated. To respond to control instructions for the virtual disk (such as hot pull instructions, power off instructions).
  • the method may further include: after establishing a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device, according to the foregoing received hot replacement command, or newly receiving The extracted command (including the ID of the virtual disk that needs to be extracted) is recycled to the resources allocated to the virtual disk. Delete the mapping relationship between the ID of the virtual disk and the ID of the simulated logical device. This method can be used to delete the virtual disk corresponding to the failed logical device.
  • the mapping relationship between the identifier of the virtual logical disk and the identifier of the simulated logical device has not been deleted.
  • the method may further include receiving a hot plug command, where the hot plug command includes an identifier of the virtual disk (the virtual disk corresponding to the replaced logical device) and an identifier of the logical device to be inserted. Delete the mapping between the ID of the virtual disk and the simulated logical disk, and establish the mapping relationship between the virtual disk and the identifier of the logical device to be inserted.
  • the logical device can be directly repaired without deleting the device at the virtual machine level, and then the repaired logical device is reinserted or a new logical device is newly replaced.
  • the failed logical device in other words, at the virtual machine level, it is not known that the failed logical device has been repaired or replaced with a logical device, thereby completing the device without affecting the normal operation of the virtual machine. Hot swap and repair.
  • an embodiment of the present invention provides a virtual machine-based device hot-replacement device for implementing the method provided by the first aspect.
  • the specific device includes: a receiving unit, configured to receive a hot-replace command. Generating unit for generating an analog logic device having an identifier. And a sending unit, configured to send control information of the logical device to be replaced to the analog logic device.
  • the deletion unit is used to delete the mapping relationship between the identifier of the virtual disk and the identifier of the logical device.
  • the establishing unit is configured to establish a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device.
  • the embodiment of the present invention can implement transparent replacement for the faulty device and the virtual machine, and further, does not affect the normal operation of the virtual machine.
  • the apparatus may further include a recycling unit, where the resources allocated to the virtual disk are recovered by the recycling unit when the virtual disk needs to be deleted.
  • the receiving unit is further configured to receive a first hot plug command, where the first hot plug command includes an identifier of the virtual disk.
  • the device further includes a creating unit, configured to create a corresponding virtual disk according to the first hot plug command, and then establish a mapping relationship between the identifier of the newly created virtual disk and the identifier of the newly inserted logical device by using the establishing unit. . After the virtual disk is deleted, the logical device corresponding to the virtual disk is newly inserted.
  • the mapping relationship between the identifier of the virtual logical disk and the identifier of the simulated logical device has not been deleted.
  • the receiving unit is further configured to receive a second hot plug command, where the second hot plug command includes an identifier of the first virtual disk and an identifier of the logical device to be inserted.
  • the deleting unit is further configured to delete a mapping relationship between the identifier of the first virtual disk and the identifier of the simulated logical device.
  • the establishing unit is further configured to establish a mapping relationship between the identifier of the first virtual disk and the identifier of the logical device.
  • a virtual logical device is introduced into the VMM.
  • the mapping between the virtual logical device and the virtual disk is replaced by the mapping between the virtual logical device and the virtual disk.
  • the virtual logical device responds to the operation request of the VM to the logical device. Therefore, even if the logical device fails, the hot swapping of the faulty device does not affect the normal operation of the VM, thereby improving the hot plugging technology of the virtual machine.
  • FIG. 1 is a schematic structural diagram of an operation system according to an embodiment of the present invention.
  • FIG. 2 is a schematic diagram of a virtual machine-based device hot replacement device according to an embodiment of the present invention
  • FIG. 3 is a flowchart of a virtual machine-based device hot replacement method according to an embodiment of the present invention
  • FIG. 5 is a schematic diagram of a mapping relationship between a deleted analog logical device and a virtual disk
  • FIG. 6 is a flowchart of an alternative operation according to an embodiment of the present invention.
  • FIG. 7 is a flowchart of an extraction operation according to an embodiment of the present invention.
  • FIG. 8 is a flowchart of a method for replacing a device based on a virtual machine according to another embodiment of the present invention.
  • FIG. 9 is a schematic diagram of a mapping relationship between a repaired logical device and a virtual disk
  • FIG. 10 is a flowchart of operations for inserting a repaired logic device according to an embodiment of the present invention.
  • FIG. 1 is a schematic structural diagram of an operation system according to an embodiment of the present invention.
  • 1 illustrates an embodiment of the present invention that can be applied to a computer/computer cluster 100 capable of running a virtual machine, such as a server terminal device, a client terminal device, a personal computer, and the like.
  • Such computer/computer cluster 100 may generally include one or more processors 101, one or more memories 102, and one or more physical disks 103/104. Among them, each module is connected through the system bus.
  • a virtual machine monitor 200 and one or more virtual machines 300/400, may be running on the computer/computer cluster 100.
  • the virtual machine 300/400 is managed and scheduled by the virtual machine monitor 200.
  • the virtual machine 300/400 may be a virtual machine of a LINUX system, a UNIX system, a WINDOWS system, an ANDROID system, an IOS system, or the like, and the virtual machine 300 and the virtual machine 400 may be virtual machines of different system types.
  • the virtual machine 300/400 and the virtual machine monitor 200 can also run on a LINUX system, a UNIX system, a WINDOWS system, an ANDROID system, an IOS system, and the like.
  • the common proxy device object is pre-created in the VMM (for example, the virtual machine monitor 200 in FIG. 2), and the mapping between the public proxy device object and the virtual disk is used instead of the real device and the virtual disk.
  • Mapping when a hot plug operation is required, responding to a hot plug command from a VM (for example, virtual machine 300/400 in Figure 2) through a common proxy device, thereby realizing that even if the real device fails, the VMM remains Ability to handle hot-swap commands from VMs for hot-swap operations on VMs.
  • FIG. 3 is a flowchart of a method for replacing a device based on a virtual machine according to an embodiment of the present invention. As shown in Figure 3, the following steps are required:
  • FIG. 4 is a schematic diagram of a mapping relationship between a VM and a physical hardware layer.
  • each device seen in the VM (device 1 in VM2 or device 2 in VMn 2) is a virtual disk emulated by VMM (virtual disk 1, virtual disk 2, virtual disk 3). ).
  • VMM virtual disk 1, virtual disk 2, virtual disk 3
  • Each virtual disk in the VMM corresponds to one logical device in the VMM (virtual disk 1 corresponds to logical device 1; virtual disk 2 corresponds to logical device 2, and virtual disk 3 corresponds to logical device 2), and each logic seen in the VMM
  • the devices are the corresponding physical disks (logical device 1 is physical disk 1; logical device 2 is physical disk 2).
  • one virtual disk can also correspond to one or more logical devices.
  • the physical disk mentioned here is only a simple description.
  • the physical disk may be a disk partition in the operating system, a different storage device, or a block device, such as a keyboard.
  • the mapping between the virtual disk and the logical device is released, the related resources are reclaimed, and the power of the real device is turned off.
  • the physical disk is inserted and removed.
  • the VMM when the device needs to be hot swapped, the VMM can usually pass through a CLI or a GUI (Graphical User Interface).
  • the human machine operation portal receives the device replacement request, and the request generally carries the identifier of the target virtual disk corresponding to the logical device that needs to be replaced.
  • the specific device can be determined by the identification of the device, and it is obvious that the specific target virtual disk can also be determined by the identity of the target virtual disk.
  • the so-called analog logic device may be a set of instructions, which can respond to the processing operation request of the VM to the device, but reject the normal I/O read/write request; or may be a file of the VMM layer, and the function of the file Equivalent to files generated by the file system.
  • the analog logic module generation program may be set in advance at the VMM layer, and after receiving the hot replacement command, the modified program may be triggered to generate an analog logic module.
  • the description of the proxy device object is exemplified, and there are various specific implementation forms, which are not repeated here.
  • the analog logic device has an identifier, which may be a file descriptor (the VM is based on a UNIX system, accesses a file through a file descriptor), and may also be a file handle (the VM is based on the Windows system). , identify the file by file handle).
  • identifier may be a file descriptor (the VM is based on a UNIX system, accesses a file through a file descriptor), and may also be a file handle (the VM is based on the Windows system). , identify the file by file handle).
  • control information of the logical device that needs to be replaced may be inherited by the identifier of the analog logical device, and the control information generally includes: the number of disk sectors, the disk sector size, the device ID, the disk type, and the like.
  • the analog logic device has the characteristics of the logical device.
  • the analog logic device can respond to the control information of the virtual disk to the logical device, so the mapping relationship between the analog logical device 403 and the virtual disk 401 is established. Mapping. Simulated by steps S340 and S350 The logical device 403 replaces the failed logical device 402. At this time, the virtual disk 401 corresponding to the device seen at the VM level is normal, and the VM does not know that a replacement process has occurred at the VMM layer. Since the mapping between the logical device and the virtual disk has been disconnected, the interaction between the VM and the logical device at this time is actually the interaction between the VM and the analog logical device.
  • the analog logic device may only be able to respond to the control command and cannot read or write it, that is, the virtual disk 401 has no practical effect, so it can be deleted.
  • the triggering condition for deleting the virtual disk 401 may be that the action is triggered after the S350 is executed, or after the specific hot-plug command is received, the hot-plug command carries the identifier of the virtual disk that needs to be extracted. There are a plurality of operations for triggering the deletion of the virtual disk, which are merely examples and are not limited.
  • hot pull commands can be received via the CLI or GUI.
  • the VMM needs to recycle the resources allocated to the virtual disk for deleting the virtual disk.
  • S380 Delete a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device.
  • FIG. 5 is a schematic diagram of a mapping relationship between a deleted analog logical device and a virtual disk. As shown in Figure 5, the analog logical device can also be deleted because the virtual disk has been deleted. When there are new requirements, re-establish the analog logic device.
  • the logical device 402 can be extracted, that is, the physical disk 410 of the physical hardware layer is pulled out. This step is an optional step. The physical disk 410 is pulled out to repair the failed physical disk 410, or replace it with a good physical disk, or just delete it and no longer use it.
  • mapping may be re-established if the identifier of the logical device corresponding to the physical disk 410 has not changed.
  • a hot plug command is received, the first hot plug command including an identification of a virtual disk to be mapped. Create this virtual disk that needs to be mapped. Establish a mapping relationship between the ID of the newly created virtual disk and the ID of the newly inserted logical device. Since the identifier of the repaired logical device does not change, the identifier of the newly inserted logical device is the identifier of the originally replaced logical device.
  • the device that is extracted by the method in the embodiment of the present invention may be only for the faulty device, or may be a normal device.
  • the physical disk 410 is faulty (the head failure in the conventional mechanical hard disk causes the physical disk 410 to be inaccessible); since the logical device 402 in the VMM is connected through the device driver The physical disk 410, so the logical device 402 also fails; further the virtual disk 401 fails; the virtual disk 401 fails.
  • the final VM is used to drive the device driver failure of the virtual disk 401; thereby causing the application in the VM that needs access to the device to not work properly.
  • FIG. 6 is a flowchart of an alternative operation according to an embodiment of the present invention. As shown in FIG. 6, if the logical device 402 needs to be hot-replaced without shutting down the VM so that the VM can access the virtual disk 401, the following steps can be performed:
  • the user mode triggers a device replacement operation in the CLI.
  • the user inputs the following parameters: ⁇ VM: Id, virtual disk: Id, operation type: replace>.
  • the HAL establishes an analog logic device 403 having the identifier: proxy_dev_fd.
  • the HAL disconnects the mapping relationship between the identifier of the logical device 402 and the identifier of the virtual disk 401.
  • the HAL establishes a mapping relationship between the identifier of the analog logic device 403 and the identifier of the virtual disk 401. system.
  • the analog logic device 403 is allowed to take control operation commands from the virtual disk 401, and when the logical device 402 is hot swapped, the operation of the VM is not affected.
  • FIG. 7 is a flowchart of an extraction operation according to an embodiment of the present invention. As shown in FIG. 7, when the virtual disk 401 needs to be unplugged, the following steps can also be performed.
  • the user triggers the hot pull operation through the CLI, and the user inputs the following parameters: ⁇ VM: Id, virtual disk 401: Id, operation type: hot-unplug (extract)>.
  • the CLI forwards the hot pull request to the HAL.
  • the EH finds the corresponding VM according to the VM Id, and then sends the request ⁇ virtual disk 401: Id, operation type: hot-unplug> to the HP (hp driver, hot plug drive) in the VM through the shared page mode.
  • the device driver processing hot pull operation request of the VM 1) releasing the mapping relationship between the virtual disk 401 and the device seen in the VM; 2) releasing and reclaiming the resources allocated to the virtual disk 401.
  • the device driver of the VM requests the VMM to power off the virtual disk 401.
  • the HAL closes the analog logic device 403 and recovers related resources.
  • the HAL returns an execution result to the CLI.
  • the embodiment of the present invention introduces a proxy device object in the VMM.
  • the mapping between the real device and the virtual disk that needs to be hot swapped is replaced by the mapping between the proxy device object and the virtual disk.
  • the proxy device object responds to the VM's operation request for the real device, so even if the real device fails, the faulty device is hot swapped without affecting the VM. Work properly, thus making the virtual machine hot plug technology.
  • FIG. 8 is a flowchart of a method for replacing a device based on a virtual machine according to another embodiment of the present invention.
  • the mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device, and the resource allocated to the virtual disk may not be deleted.
  • the following steps are also required in this embodiment:
  • the VMM can receive through the CLI or the GUI.
  • a hot-plug request carrying the identity of the virtual disk and the identity of the newly inserted logical device.
  • S870 Delete a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device.
  • the virtual disk is still visible through the device driver in the VM, and the mapping relationship between the VMM and the analog logical device still exists, and the analog logical device replaces the logical device to be replaced. . Therefore, the corresponding virtual device and the logical device can be determined by the identifier of the virtual disk carried in the hot insertion request and the identifier of the newly inserted logical device; and the analog logical device is replaced with the newly inserted logical device.
  • S880 Establish a mapping relationship between the identifier of the virtual disk and the identifier of the logical device.
  • the analog logic device is a transitional device, providing time, and technical support for repairing the failed logical device or replacing the new logical device. And this process is relatively transparent to the VM, that is, it does not affect the normal operation of the VM.
  • FIG. 9 is a schematic diagram of a mapping relationship between a repaired logical device and a virtual disk.
  • the VMM also stores the mapping relationship between the virtual disk and the analog logical device, and the resources allocated to the virtual disk.
  • FIG. 10 The flowchart of the operation of inserting the repaired logic device provided by the embodiment of the present invention. Such as As shown in Figure 10, the process of inserting the repaired logical device requires the following steps:
  • the CLI forwards the request to the HAL.
  • the HAL establishes a mapping relationship between the restored logical device and the virtual disk.
  • the HAL recovers related resources allocated to the analog logic device, and deletes the analog logic device.
  • the embodiment of the present invention realizes that the hot plug operation of the logical device is transparent with respect to the VM by simulating the mapping between the mapping between the logical device and the virtual disk and the mapping between the logical device and the virtual disk in the VMM, thereby When the logical device fails, the VM can be unplugged, repaired, and inserted without shutting down the VM and without affecting the normal operation of the VM, thereby making the virtual machine-based hot plugging technology more perfect.
  • the method provided by the embodiment of the present invention introduces an analog logic device in a VMM.
  • the logical device and the virtual disk that need to be hot swapped are replaced by mapping the logical device to the virtual disk. Mapping, using the analog logic device to respond to the VM's operational commands to the logical device, so even if the logical device fails, then hot-plugging (hot swapping) the failed device does not affect the normal operation of the VM, thereby making the virtual machine Hot swap technology is more practical.
  • the hot swap (hot swap) operation of the logical device may be transparent with respect to the VM, so that when the logical device fails, the VM may not be shut down and the VM is not affected.
  • the faulty device is pulled out, repaired, and inserted; even if the logical device fails, the virtual device can be hot swapped in the VM, and the VM and VMM are allocated to the resource of the device. Release, so that the virtual machine's hot swap technology is more complete, able to cope with more needs.
  • FIG. 2 is a schematic diagram of a virtual machine-based device hot replacement device according to an embodiment of the present invention.
  • the device is mainly used to implement the foregoing virtual machine-based hot replacement method.
  • the device may include a virtual machine monitor 200.
  • the virtual machine monitor 200 may specifically include:
  • the receiving unit 201 is configured to receive a hot replacement command, where the hot replacement command includes an identifier of the virtual disk, where the virtual disk corresponds to a logical device to be replaced;
  • a generating unit 202 configured to generate an analog logic device, where the analog logic device has an identifier
  • the sending unit 203 is configured to send control information of the logical device to be replaced to the analog logic device;
  • the deleting unit 204 is configured to delete a mapping relationship between an identifier of the first virtual disk and an identifier of the logical device to be replaced.
  • the establishing unit 205 is configured to establish a mapping relationship between the identifier of the first virtual disk and the identifier of the analog logical device, so that the analog logic device responds to the control instruction for the first virtual disk according to the control information.
  • the embodiment of the present invention may further include:
  • the recycling unit 206 is configured to: after establishing a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device, recover the resource allocated to the virtual disk;
  • the deleting unit 204 is further configured to delete a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device.
  • the embodiment of the present invention is in the specific implementation process:
  • the establishing unit 205 is further configured to establish a mapping relationship between the identifier of the newly inserted virtual disk and the identifier of the replacement logical device.
  • the generating unit 202, the sending unit 203, the deleting unit 204, and the establishing unit 205 may be implemented by a hardware emulation layer HAL, and the hardware emulation layer may further include a reclaiming unit 206. And/or create unit 207.
  • the receiving unit 201 can be implemented by a user interface (CLI or GUI).
  • the virtual machine monitor 200 may further include an event processing module 220 for triggering a hot plug event.
  • a shared page can be included for interaction with the virtual machine.
  • the steps of a method or algorithm described in connection with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both.
  • the software module can be placed in random access memory (RAM), memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or technical field. Any other form of storage medium known.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

A device hot-replacement method and apparatus based on a virtual machine. The method comprises: receiving a hot-replacement command (S310), the hot-replacement command carrying a virtual magnetic disk identifier, and the virtual magnetic disk identifier being corresponding to a logical device that needs to be replaced; generating a simulated logical device (S320), the simulated logical device having an identifier; sending control information of the logical device to the simulated logical device (S330), so that the simulated logical device can respond to a control instruction in a manner of acting as an agent of the logical device to be replaced; deleting a mapping relationship between the identifier of the virtual magnetic disk and the identifier of the logical device to be replaced according to the hot-replacement command (S340); and establishing a mapping relationship between the identifier of the virtual magnetic disk and the identifier of the simulated logical device (S350). Accordingly, when a fault occurs on a logical device, the logical device is replaced by a simulated logical device to respond to a corresponding control instruction, and further, a virtual machine can normally perform control operations on the device.

Description

基于虚拟机的设备热替换方法及装置Virtual machine-based device heat replacement method and device 技术领域Technical field
本发明涉及虚拟机技术领域,尤其涉及一种基于虚拟机的设备热替换方法及装置。The present invention relates to the field of virtual machine technologies, and in particular, to a virtual machine-based device hot replacement method and device.
背景技术Background technique
虚拟机(Virtual Machine,VM),指通过软件模拟的具有完整硬件系统功能的、运行在一个完全隔离环境中的完整计算机系统。虚拟机通过生成现有操作系统的全新虚拟镜像,它具有真实操作系统完全一样的功能,进入虚拟系统后,所有操作都是在这个全新的独立的虚拟系统里面进行,可以独立安装运行软件,保存数据等等。Virtual Machine (VM) refers to a complete computer system that runs through a software and has a complete hardware system function and runs in a completely isolated environment. The virtual machine generates a completely new virtual image of the existing operating system. It has the same function as the real operating system. After entering the virtual system, all operations are performed in this new independent virtual system. The software can be installed and saved independently. Data and more.
热插拔(hot-plugging或Hot Swap)即带电插拔,还可以称为热替换(Hot replacement)。热插拔功能就是允许用户在不关闭系统,不切断电源的情况下取出和更换损坏的硬盘、电源或板卡等部件,从而提高了系统对灾难的及时恢复能力、扩展性和灵活性等。Hot-plugging (hot-plugging or hot swap) is hot swapping and can also be called hot replacement. The hot-swap function allows the user to remove and replace damaged hard disks, power supplies or boards without shutting down the system, thus improving the system's ability to recover from disasters, scalability, and flexibility.
虚拟机设备热插拔,由于从VM外的角度来看,VM看到的所有“硬件”均是由VMM(virtual machine monitor,虚拟机监视器)提供的软件模拟,故针对VM的“硬件”热插拔,实际上是针对的VMM层的软件模拟体。The virtual machine device is hot swapped. Since all the "hardware" seen by the VM from the perspective of the VM is simulated by the software provided by the VMM (virtual machine monitor), the "hardware" for the VM is used. Hot plugging is actually a software simulation of the VMM layer.
现有技术中VMM通过命令行界面接收待热插拔的虚拟磁盘对应的热插拔操作请求,触发热插拔操作,VMM将热插拔操作请求发送给对应的虚拟机操作系统;虚拟机操作系统通过热插拔事件驱动找到对应的虚拟设备驱动,通过虚拟设备驱动回收分配给待热插拔虚拟磁盘的资源,实现对待热插拔虚拟磁盘的热拔出操作。In the prior art, the VMM receives the hot plug operation request corresponding to the hot swappable virtual disk through the command line interface, triggers the hot plug operation, and the VMM sends the hot plug operation request to the corresponding virtual machine operating system; the virtual machine operates. The hot-plug event is driven to find the corresponding virtual device driver. The virtual device driver recovers the resources allocated to the hot-swappable virtual disk to implement hot-plugging of the hot-swappable virtual disk.
通过这种方式,能够有效的进行热插拔操作,但是,当物理磁盘故障(例如磁头损坏导致VMM不能正常访问)等原因,进一步导致设备驱动异常,致 使该逻辑设备实现热插拔操作的设备驱动也出现异常,导致在VM运行的情况下,不能够对该设备进行热拔出操作。所以如果设备出现故障导致设备驱动异常,那么只能关闭VM;从VM的定义(Definition)中删除已经故障的“设备”;然后再修复VM故障“设备”在VMM层对应的逻辑设备或文件。但是,一般情况下,VM是相对庞大的,重新启动VM需要很长的时间,损失较大;若是处于服务器端的VM,关闭VM可能会影响与该服务器关联的客户端,从而极大影响用户的体验(例如,关闭网络游戏服务的VM,可能会影响登录该服务器的所有用户的游戏体验)。所以如何实现对虚拟机中已故障的“设备”进行热插拔操作成为本领域技术人员迫切需要解决的技术问题。In this way, the hot plug operation can be performed effectively, but when the physical disk fails (for example, the head is damaged and the VMM cannot be accessed normally), the device drive is abnormally caused. The device driver that enables the hot swap operation of the logical device also has an abnormality, so that the hot pull operation of the device cannot be performed when the VM is running. Therefore, if the device fails and the device driver is abnormal, you can only shut down the VM; remove the failed device from the definition of the VM; and then repair the logical device or file corresponding to the VM at the VMM layer. However, in general, the VM is relatively large. It takes a long time to restart the VM and the loss is large. If the VM is on the server side, shutting down the VM may affect the client associated with the server, thus greatly affecting the user. Experience (for example, shutting down a VM for an online gaming service may affect the gaming experience of all users who log in to the server). Therefore, how to implement hot-plug operation of a faulty "device" in a virtual machine has become a technical problem that is urgently needed to be solved by those skilled in the art.
发明内容Summary of the invention
本发明实施例提供了一种基于虚拟机的设备热替换方法及装置,可以实现在逻辑设备出现故障时,通过模拟逻辑设备来代理逻辑设备,已响应相应的控制指令,进而,虚拟机能够正常的对设备进行控制操作。The embodiment of the invention provides a virtual machine-based device hot replacement method and device, which can implement a logic device to proxy a logical device when a logical device fails, and has responded to the corresponding control command, and then the virtual machine can be normal. Control the operation of the device.
第一方面,本发明实施例提供了一种基于虚拟机的设备热替换方法,该方法包括,接收热替换命令,该热替换命令携带有虚拟磁盘标识,其中,该虚拟磁盘标识对应一个需要被替换的逻辑设备(如已发生故障的逻辑设备)。生成模拟逻辑设备,该模拟逻辑设备具有标识(如描述符、或者句柄等等)。将热替换命令对应的待替换逻辑设备的控制信息发送给模拟逻辑设备,以使模拟逻辑设备能够代理代替换的逻辑设备响应控制指令。根据热替换命令,将对应的虚拟磁盘的标识与待替换的逻辑设备的标识之间的映射关系删除,并建立对应的虚拟磁盘与模拟逻辑设备之间的映射关系,此时,通过模拟逻辑设备来响应对于虚拟磁盘的控制指令(例如热拔出指令,关闭电源指令)。In a first aspect, an embodiment of the present invention provides a virtual machine-based device hot replacement method, the method comprising: receiving a hot replacement command, where the hot replacement command carries a virtual disk identifier, wherein the virtual disk identifier corresponds to a need to be A replaced logical device (such as a logical device that has failed). An analog logic device is generated that has an identification (such as a descriptor, or a handle, etc.). The control information of the logical device to be replaced corresponding to the hot replacement command is sent to the analog logic device, so that the analog logic device can proxy the replacement logical device to respond to the control command. The mapping relationship between the identifier of the corresponding virtual disk and the identifier of the logical device to be replaced is deleted according to the hot replacement command, and the mapping relationship between the corresponding virtual disk and the analog logical device is established. At this time, the logical device is simulated. To respond to control instructions for the virtual disk (such as hot pull instructions, power off instructions).
通过上述方法可以实现即使由于物理磁盘出现故障导致了逻辑设备不能够响应指令,在将不能够响应指令的逻辑设备与模拟逻辑设备替换后,此时,在虚拟机层面,并不能发现逻辑设备已经故障,依然能够对该逻辑设备对应 的虚拟磁盘进行拔出操作。Through the above method, even if the logical device fails to respond to the instruction due to the failure of the physical disk, after the logical device that cannot respond to the instruction is replaced with the analog logical device, at this time, at the virtual machine level, the logical device cannot be found. Fault, still able to correspond to the logical device The virtual disk is pulled out.
在第一方面的一种可能实现方式中,该方法还可以包括,在建立虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系之后,可以根据前述接收到的热替换命令,或者新接收到的拔出命令(包括需要拔出的虚拟磁盘的标识),回收分配给虚拟磁盘的资源。删除虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系。通过该方法可以实现对已故障的逻辑设备对应的虚拟磁盘进行删除。In a possible implementation manner of the first aspect, the method may further include: after establishing a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device, according to the foregoing received hot replacement command, or newly receiving The extracted command (including the ID of the virtual disk that needs to be extracted) is recycled to the resources allocated to the virtual disk. Delete the mapping relationship between the ID of the virtual disk and the ID of the simulated logical device. This method can be used to delete the virtual disk corresponding to the failed logical device.
在第一方面的一些可能实现方式中,当需要插入已修复好的逻辑设备或者另一个新的逻辑设备时,在还未删除虚拟逻辑磁盘的标识与模拟逻辑设备的标识之间的映射关系的前提下,该方法还可以包括,接收热插入命令,该热插入命令包括虚拟磁盘(前述被替换的逻辑设备对应的虚拟磁盘)的标识以及待插入逻辑设备的标识。删除虚拟磁盘的标识与模拟逻辑磁盘之间的映射关系,并建立虚拟磁盘与待插入的逻辑设备的标识之间的映射关系。通过该方法可以实现在通过模拟逻辑设备代理逻辑设备后,在虚拟机层面不用对设备进行删除,便可以直接对逻辑设备进行修复,然后将修复后的逻辑设备重新插入,或者新换一个逻辑设备来替换已故障的逻辑设备,换句话说,在虚拟机层面并不知道已经将已故障的逻辑设备修复或者替换了逻辑设备,从而在不影响虚拟机正常运行的情况下,完成了对设备的热插拔以及修复。In some possible implementations of the first aspect, when a repaired logical device or another new logical device needs to be inserted, the mapping relationship between the identifier of the virtual logical disk and the identifier of the simulated logical device has not been deleted. The method may further include receiving a hot plug command, where the hot plug command includes an identifier of the virtual disk (the virtual disk corresponding to the replaced logical device) and an identifier of the logical device to be inserted. Delete the mapping between the ID of the virtual disk and the simulated logical disk, and establish the mapping relationship between the virtual disk and the identifier of the logical device to be inserted. After the logical device is proxyed by the analog logical device, the logical device can be directly repaired without deleting the device at the virtual machine level, and then the repaired logical device is reinserted or a new logical device is newly replaced. To replace the failed logical device, in other words, at the virtual machine level, it is not known that the failed logical device has been repaired or replaced with a logical device, thereby completing the device without affecting the normal operation of the virtual machine. Hot swap and repair.
第二方面,本发明实施例提供了一种基于虚拟机的设备热替换装置用于实现第一方面提供的方法,具体的装置包括:接收单元,用于接收热替换命令。生成单元,用于生成模拟逻辑设备,该模拟逻辑设备具有标识。发送单元,用于将待替换的逻辑设备的控制信息发送给模拟逻辑设备。删除单元,用于删除虚拟磁盘的标识与逻辑设备的标识之间的映射关系。建立单元,用于建立虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系。通过本发明实施例可以实现对于已故障设备,对于虚拟机透明的替换,进而,不影响虚拟机的正常工作。 In a second aspect, an embodiment of the present invention provides a virtual machine-based device hot-replacement device for implementing the method provided by the first aspect. The specific device includes: a receiving unit, configured to receive a hot-replace command. Generating unit for generating an analog logic device having an identifier. And a sending unit, configured to send control information of the logical device to be replaced to the analog logic device. The deletion unit is used to delete the mapping relationship between the identifier of the virtual disk and the identifier of the logical device. The establishing unit is configured to establish a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device. The embodiment of the present invention can implement transparent replacement for the faulty device and the virtual machine, and further, does not affect the normal operation of the virtual machine.
在第二方面的一个可能的实现方式中,该装置还可以包括回收单元,当需要删除虚拟磁盘时,通过回收单元回收分配给虚拟磁盘的资源。In a possible implementation manner of the second aspect, the apparatus may further include a recycling unit, where the resources allocated to the virtual disk are recovered by the recycling unit when the virtual disk needs to be deleted.
在第二方面的另一个可能的实现方式中,在需要重新插入逻辑设备时,接收单元还用于接收第一热插入命令,该第一热插入命令包括虚拟磁盘的标识。上述装置还包括创建单元,用于根据第一热插入命令创建一个对应的虚拟磁盘,此时,再通过建立单元建立新创建的虚拟磁盘的标识与新插入的逻辑设备的标识之间的映射关系。通过该装置能够实现删除虚拟磁盘后,从新插入该虚拟磁盘对应的逻辑设备。In another possible implementation manner of the second aspect, when the logic device needs to be reinserted, the receiving unit is further configured to receive a first hot plug command, where the first hot plug command includes an identifier of the virtual disk. The device further includes a creating unit, configured to create a corresponding virtual disk according to the first hot plug command, and then establish a mapping relationship between the identifier of the newly created virtual disk and the identifier of the newly inserted logical device by using the establishing unit. . After the virtual disk is deleted, the logical device corresponding to the virtual disk is newly inserted.
在第二方面的一些实现方式中,当需要插入已修复好的逻辑设备或者另一个新的逻辑设备时,在还未删除虚拟逻辑磁盘的标识与模拟逻辑设备的标识之间的映射关系的前提下,接收单元还用于接收第二热插入命令,该第二热插入命令包括第一虚拟磁盘的标识以及待插入逻辑设备的标识。删除单元还用于删除第一虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系。建立单元还用于建立第一虚拟磁盘的标识与逻辑设备的标识之间的映射关系。通过该装置可以实现一些在第一方面中的实施方式。In some implementations of the second aspect, when a repaired logical device or another new logical device needs to be inserted, the mapping relationship between the identifier of the virtual logical disk and the identifier of the simulated logical device has not been deleted. The receiving unit is further configured to receive a second hot plug command, where the second hot plug command includes an identifier of the first virtual disk and an identifier of the logical device to be inserted. The deleting unit is further configured to delete a mapping relationship between the identifier of the first virtual disk and the identifier of the simulated logical device. The establishing unit is further configured to establish a mapping relationship between the identifier of the first virtual disk and the identifier of the logical device. Some embodiments in the first aspect can be implemented by the device.
通过本发明实施例,在VMM中引入虚拟逻辑设备,当需要进行热插拔操作时,通过虚拟逻辑设备与虚拟磁盘之间的映射,替换需要进行热插拔的逻辑设备与虚拟磁盘的映射,用虚拟逻辑设备响应VM对逻辑设备的操作请求,所以,即使逻辑设备出现故障,那么对该故障设备进行热插拔,不影响VM的正常工作,从而使虚拟机的热插拔技术更完善。In the embodiment of the present invention, a virtual logical device is introduced into the VMM. When a hot swap operation is required, the mapping between the virtual logical device and the virtual disk is replaced by the mapping between the virtual logical device and the virtual disk. The virtual logical device responds to the operation request of the VM to the logical device. Therefore, even if the logical device fails, the hot swapping of the faulty device does not affect the normal operation of the VM, thereby improving the hot plugging technology of the virtual machine.
附图说明DRAWINGS
图1为本发明实施例提供的运行系统的结构示意图;1 is a schematic structural diagram of an operation system according to an embodiment of the present invention;
图2为本发明一个实施例提供的基于虚拟机的设备热替换装置的示意图;2 is a schematic diagram of a virtual machine-based device hot replacement device according to an embodiment of the present invention;
图3为本发明一个实施例提供的一种基于虚拟机的设备热替换方法的流程图;FIG. 3 is a flowchart of a virtual machine-based device hot replacement method according to an embodiment of the present invention;
图4为VM到物理硬件层的映射关系示意图; 4 is a schematic diagram of mapping relationship from a VM to a physical hardware layer;
图5为已删除模拟逻辑设备与虚拟磁盘的映射关系示意图;FIG. 5 is a schematic diagram of a mapping relationship between a deleted analog logical device and a virtual disk;
图6为本发明实施例提供的替换操作流程图;FIG. 6 is a flowchart of an alternative operation according to an embodiment of the present invention;
图7为本发明实施例提供的拔出操作流程图;FIG. 7 is a flowchart of an extraction operation according to an embodiment of the present invention;
图8为本发明另一个实施例提供的一种基于虚拟机的设备热替换方法的流程图;FIG. 8 is a flowchart of a method for replacing a device based on a virtual machine according to another embodiment of the present invention;
图9为已修复逻辑设备与虚拟磁盘的映射关系示意图;FIG. 9 is a schematic diagram of a mapping relationship between a repaired logical device and a virtual disk;
图10为本发明实施例提供的插入已修复逻辑设备的操作流程图。FIG. 10 is a flowchart of operations for inserting a repaired logic device according to an embodiment of the present invention.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
图1为本发明实施例提供的运行系统的结构示意图。图1示出了本发明实施例能够被应用到能够运行虚拟机的计算机/计算机群100中,例如服务器终端设备,客户终端设备,个人计算机等等。该类计算机/计算机群100中一般可以包括一个或多个处理器101,一个或多个存储器102,以及一个或多个物理磁盘103/104。其中,各个模块通过系统总线连接。FIG. 1 is a schematic structural diagram of an operation system according to an embodiment of the present invention. 1 illustrates an embodiment of the present invention that can be applied to a computer/computer cluster 100 capable of running a virtual machine, such as a server terminal device, a client terminal device, a personal computer, and the like. Such computer/computer cluster 100 may generally include one or more processors 101, one or more memories 102, and one or more physical disks 103/104. Among them, each module is connected through the system bus.
在计算机/计算机群100可能运行着虚拟机监视器200,以及一个或多个虚拟机300/400。其中,通过虚拟机监视器200来管理和调度虚拟机300/400。其中虚拟机300/400可以为LINUX系统、UNIX系统、WINDOWS系统、ANDROID系统、IOS系统等等系统的虚拟机,且虚拟机300与虚拟机400可以为不同系统类型的虚拟机。另外,虚拟机300/400以及虚拟机监视器200,还可以运行在LINUX系统、UNIX系统、WINDOWS系统、ANDROID系统、IOS系统等等系统上。 A virtual machine monitor 200, and one or more virtual machines 300/400, may be running on the computer/computer cluster 100. Among them, the virtual machine 300/400 is managed and scheduled by the virtual machine monitor 200. The virtual machine 300/400 may be a virtual machine of a LINUX system, a UNIX system, a WINDOWS system, an ANDROID system, an IOS system, or the like, and the virtual machine 300 and the virtual machine 400 may be virtual machines of different system types. In addition, the virtual machine 300/400 and the virtual machine monitor 200 can also run on a LINUX system, a UNIX system, a WINDOWS system, an ANDROID system, an IOS system, and the like.
在本发明实施例中,通过在VMM(例如,图2中虚拟机监视器200)预先创建公共代理设备对象,用公共代理设备对象与虚拟磁盘间的映射,来代替真实设备与虚拟磁盘之间的映射,当需要执行热插拔操作时,通过公共代理设备来响应来自VM(例如,图2中虚拟机300/400)的热插拔命令,进而实现,即使真实设备出现故障,那么VMM依然能够处理VM的热插拔命令,以实现VM的热插拔操作。In the embodiment of the present invention, the common proxy device object is pre-created in the VMM (for example, the virtual machine monitor 200 in FIG. 2), and the mapping between the public proxy device object and the virtual disk is used instead of the real device and the virtual disk. Mapping, when a hot plug operation is required, responding to a hot plug command from a VM (for example, virtual machine 300/400 in Figure 2) through a common proxy device, thereby realizing that even if the real device fails, the VMM remains Ability to handle hot-swap commands from VMs for hot-swap operations on VMs.
为便于对本发明实施例的理解,下面将结合附图以具体实施例做进一步的解释说明,实施例并不构成对本发明实施例的限定。In order to facilitate the understanding of the embodiments of the present invention, the embodiments of the present invention are not to be construed as limiting.
图3为本发明一个实施例提供的一种基于虚拟机的设备热替换方法的流程图。如图3所示,具体需要执行如下步骤:FIG. 3 is a flowchart of a method for replacing a device based on a virtual machine according to an embodiment of the present invention. As shown in Figure 3, the following steps are required:
S310,接收热替换命令。S310. Receive a hot replacement command.
需要说明的是,图4为VM到物理硬件层的映射关系示意图。如图4所示,VM中看到的各个设备(VM2中的设备1或者,VMn中的设备2、设备3),分别是VMM模拟的虚拟磁盘(虚拟磁盘1、虚拟磁盘2、虚拟磁盘3)。VMM中的各个虚拟磁盘都对应有VMM中的一个逻辑设备(虚拟磁盘1对应逻辑设备1;虚拟磁盘2对应逻辑设备2,虚拟磁盘3对应逻辑设备2),而VMM中的看到的各个逻辑设备分别是对应的物理磁盘(逻辑设备1为物理磁盘1;逻辑设备2为物理磁盘2),。另外,根据虚拟机的设置不同,一个虚拟磁盘也可以对应一个或多个逻辑设备。应该知道的是,这里说的物理磁盘仅为描述简便的举例,该物理磁盘可以是操作系统中的各个磁盘分区,也可以是不同的存储设备,还可以是块设备,例如,键盘等。It should be noted that FIG. 4 is a schematic diagram of a mapping relationship between a VM and a physical hardware layer. As shown in Figure 4, each device seen in the VM (device 1 in VM2 or device 2 in VMn 2) is a virtual disk emulated by VMM (virtual disk 1, virtual disk 2, virtual disk 3). ). Each virtual disk in the VMM corresponds to one logical device in the VMM (virtual disk 1 corresponds to logical device 1; virtual disk 2 corresponds to logical device 2, and virtual disk 3 corresponds to logical device 2), and each logic seen in the VMM The devices are the corresponding physical disks (logical device 1 is physical disk 1; logical device 2 is physical disk 2). In addition, depending on the settings of the virtual machine, one virtual disk can also correspond to one or more logical devices. It should be noted that the physical disk mentioned here is only a simple description. The physical disk may be a disk partition in the operating system, a different storage device, or a block device, such as a keyboard.
基于虚拟的设备热替换,在VMM中,是解除虚拟磁盘与逻辑设备之间的映射关系,回收相关资源,关闭真实设备的电源;在物理硬件层,是插入和拔出物理磁盘。In the VMM, the mapping between the virtual disk and the logical device is released, the related resources are reclaimed, and the power of the real device is turned off. At the physical hardware layer, the physical disk is inserted and removed.
在本发明实施例具体实施过程中,当需要对设备进行热插拔操作时,在VMM通常可以先通过CLI或GUI(Graphical User Interface,图形用户接口) 等人机操作入口接收设备替换请求,该请求一般携带有目标虚拟磁盘的标识,该目标虚拟磁盘对应有需要被替换的逻辑设备。In the specific implementation process of the embodiment of the present invention, when the device needs to be hot swapped, the VMM can usually pass through a CLI or a GUI (Graphical User Interface). The human machine operation portal receives the device replacement request, and the request generally carries the identifier of the target virtual disk corresponding to the logical device that needs to be replaced.
应该知道的是,通过设备的标识,便可以确定具体的设备,显然通过目标虚拟磁盘的标识也能够确定具体的目标虚拟磁盘。It should be known that the specific device can be determined by the identification of the device, and it is obvious that the specific target virtual disk can also be determined by the identity of the target virtual disk.
S320,生成模拟逻辑设备。S320, generating an analog logic device.
需要说明的是,所谓的模拟逻辑设备可以是指令的集合,能够响应VM对设备的处理操作请求,但拒绝正常的I/O读写请求;还可以是一个VMM层的文件,该文件的功能等同于通过文件系统生成的文件。可以预先在VMM层设置模拟逻辑模块生成程序,可以当接收到热替换命令后,触发改程序,生成模拟逻辑模块。其中此处对代理设备对象的描述举例,具体的实现形式还有多种,这里不再一一赘述。It should be noted that the so-called analog logic device may be a set of instructions, which can respond to the processing operation request of the VM to the device, but reject the normal I/O read/write request; or may be a file of the VMM layer, and the function of the file Equivalent to files generated by the file system. The analog logic module generation program may be set in advance at the VMM layer, and after receiving the hot replacement command, the modified program may be triggered to generate an analog logic module. Here, the description of the proxy device object is exemplified, and there are various specific implementation forms, which are not repeated here.
本发明实施例在具体实施过程中,模拟逻辑设备具有标识,该标识可以是文件描述符(VM是基于UNIX系统的,通过文件描述符访问文件),还可以是文件句柄(VM是基于Windows系统的,通过文件句柄识别文件)。In an embodiment of the present invention, the analog logic device has an identifier, which may be a file descriptor (the VM is based on a UNIX system, accesses a file through a file descriptor), and may also be a file handle (the VM is based on the Windows system). , identify the file by file handle).
S330,向模拟逻辑设备发送逻辑设备的控制信息。S330. Send control information of the logic device to the analog logic device.
需要说明的是,可以用模拟逻辑设备的标识继承需要替换的逻辑设备的控制信息,该控制信息一般包括:盘扇区数量、盘扇区大小、设备ID、盘类型等等。此时模拟逻辑设备具备了逻辑设备的特征。It should be noted that the control information of the logical device that needs to be replaced may be inherited by the identifier of the analog logical device, and the control information generally includes: the number of disk sectors, the disk sector size, the device ID, the disk type, and the like. At this point, the analog logic device has the characteristics of the logical device.
S340,删除虚拟磁盘的标识与待替换的逻辑设备的标识之间的映射关系。S340. Delete a mapping relationship between the identifier of the virtual disk and the identifier of the logical device to be replaced.
需要说明的是,如图4所示,若确定热替换命令中携带的虚拟磁盘的标识对应虚拟磁盘401,则在建立模拟逻辑设备403之后,删除虚拟磁盘401与逻辑设备402之间的映射关系。It should be noted that, as shown in FIG. 4, if it is determined that the identifier of the virtual disk carried in the hot replacement command corresponds to the virtual disk 401, the mapping relationship between the virtual disk 401 and the logical device 402 is deleted after the analog logical device 403 is established. .
S350,建立虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系S350. Establish a mapping relationship between the identifier of the virtual disk and the identifier of the analog logical device.
在此说明,如图4所示,模拟逻辑设备能够响应虚拟磁盘对于逻辑设备的控制信息,所以,建立模拟逻辑设备403与虚拟磁盘401之间的映射关系,当然,设备之间通过设备标识进行映射。经过步骤S340、S350实现了用模拟 逻辑设备403替换了已故障的逻辑设备402。此时,在VM层面看见的设备对应的虚拟磁盘401是正常的,VM并不知道在VMM层发生了替换过程。由于逻辑设备与虚拟磁盘之间的映射已经断开,所以此时VM与逻辑设备的交互,实际为VM与模拟逻辑设备之间的交互。It is noted that, as shown in FIG. 4, the analog logic device can respond to the control information of the virtual disk to the logical device, so the mapping relationship between the analog logical device 403 and the virtual disk 401 is established. Mapping. Simulated by steps S340 and S350 The logical device 403 replaces the failed logical device 402. At this time, the virtual disk 401 corresponding to the device seen at the VM level is normal, and the VM does not know that a replacement process has occurred at the VMM layer. Since the mapping between the logical device and the virtual disk has been disconnected, the interaction between the VM and the logical device at this time is actually the interaction between the VM and the analog logical device.
S360,接收热拔出命令。S360, receiving a hot pull command.
需要说明的是,如图4所示,在步骤S350之后,由于VM与逻辑设备的交互,实际为VM与模拟逻辑设备之间的交互。但是模拟逻辑设备可能仅能够响应控制指令,并不能够对其进行读写操作,也就是说虚拟磁盘401是没有什么实际的作用的,所以,可以将其删除。将虚拟磁盘401删除的触发条件可以是执行完S350后便触发此动作,也可以是在接收到特定的热拔出命令后,该热拔出命令携带有需要拔出的虚拟磁盘的标识。其中,触发删除虚拟磁盘的操作还有多种,此处仅为举例,并不做限定。It should be noted that, as shown in FIG. 4, after the step S350, due to the interaction of the VM with the logical device, the interaction between the VM and the analog logical device is actually performed. However, the analog logic device may only be able to respond to the control command and cannot read or write it, that is, the virtual disk 401 has no practical effect, so it can be deleted. The triggering condition for deleting the virtual disk 401 may be that the action is triggered after the S350 is executed, or after the specific hot-plug command is received, the hot-plug command carries the identifier of the virtual disk that needs to be extracted. There are a plurality of operations for triggering the deletion of the virtual disk, which are merely examples and are not limited.
另外,可以通过CLI或GUI接收热拔出命令。In addition, hot pull commands can be received via the CLI or GUI.
S370,回收分配给虚拟磁盘的资源。S370, reclaiming resources allocated to the virtual disk.
需要说明的是,由于虚拟磁盘占用VMM一定的资源,如图5所示,所以,对虚拟磁盘的删除,VMM需要将分配给虚拟磁盘的资源回收。It should be noted that, since the virtual disk occupies a certain resource of the VMM, as shown in FIG. 5, the VMM needs to recycle the resources allocated to the virtual disk for deleting the virtual disk.
S380,删除虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系。S380: Delete a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device.
需要说明的是,图5为已删除模拟逻辑设备与虚拟磁盘的映射关系示意图。如图5所示,由于虚拟磁盘已被删除,还可以被删除模拟逻辑设备。当有新的需求时,重新再建立模拟逻辑设备。It should be noted that FIG. 5 is a schematic diagram of a mapping relationship between a deleted analog logical device and a virtual disk. As shown in Figure 5, the analog logical device can also be deleted because the virtual disk has been deleted. When there are new requirements, re-establish the analog logic device.
此外,如图4所示,当执行完S350后,便可以对逻辑设备402进行拔出操作,也就是对物理硬件层的物理磁盘410进行拔出操作。此步骤为可选步骤,拔出物理磁盘410是为了对已故障的物理磁盘410进行修复,或者用好的物理磁盘替换,或者仅是删除不再使用。In addition, as shown in FIG. 4, after the S350 is executed, the logical device 402 can be extracted, that is, the physical disk 410 of the physical hardware layer is pulled out. This step is an optional step. The physical disk 410 is pulled out to repair the failed physical disk 410, or replace it with a good physical disk, or just delete it and no longer use it.
需要说明的是,当物理磁盘410已经被修复,需要重新插入时,在物理磁盘410对应的逻辑设备的标识没有变的情况下,还可以重新建立映射。具 体可以做如下步骤。It should be noted that, when the physical disk 410 has been repaired and needs to be re-inserted, the mapping may be re-established if the identifier of the logical device corresponding to the physical disk 410 has not changed. With The body can do the following steps.
接收热插入命令,该第一热插入命令包括需要映射的虚拟磁盘的标识。创建这个需要映射的虚拟磁盘。建立新创建的虚拟磁盘的标识与新插入的逻辑设备的标识之间的映射关系。由于已修复的逻辑设备的标识并未发生变换,所以该新插入的逻辑设备的标识即为原被替换的逻辑设备的标识。A hot plug command is received, the first hot plug command including an identification of a virtual disk to be mapped. Create this virtual disk that needs to be mapped. Establish a mapping relationship between the ID of the newly created virtual disk and the ID of the newly inserted logical device. Since the identifier of the repaired logical device does not change, the identifier of the newly inserted logical device is the identifier of the originally replaced logical device.
另外,通过在本发明实施例中的方法拔出的设备,可以仅是针对已故障设备,也可以是对正常的设备。In addition, the device that is extracted by the method in the embodiment of the present invention may be only for the faulty device, or may be a normal device.
在一个例子中,如图4所示,假设,物理磁盘410出现故障(传统机械硬盘中的磁头故障导致物理磁盘410不能正常访问);由于在VMM的逻辑设备402,即为通过设备驱动连接的物理磁盘410,故逻辑设备402也故障;进一步虚拟磁盘401故障;虚拟磁盘401故障最终VM用于驱动虚拟磁盘401的设备驱动故障;进而导致VM中需要访问该设备的应用程序无法正常工作。In one example, as shown in FIG. 4, it is assumed that the physical disk 410 is faulty (the head failure in the conventional mechanical hard disk causes the physical disk 410 to be inaccessible); since the logical device 402 in the VMM is connected through the device driver The physical disk 410, so the logical device 402 also fails; further the virtual disk 401 fails; the virtual disk 401 fails. The final VM is used to drive the device driver failure of the virtual disk 401; thereby causing the application in the VM that needs access to the device to not work properly.
图6为本发明实施例提供的替换操作流程图。如图6所示,若需要在不关闭VM的情况下,对逻辑设备402进行热替换,使得VM能够对虚拟磁盘401进行访问,那么可以执行如下步骤:FIG. 6 is a flowchart of an alternative operation according to an embodiment of the present invention. As shown in FIG. 6, if the logical device 402 needs to be hot-replaced without shutting down the VM so that the VM can access the virtual disk 401, the following steps can be performed:
S501,用户态在CLI中触发设备替换操作,用户输入如下参数:<VM:Id,虚拟磁盘:Id,操作类型:replace(替换)>。S501. The user mode triggers a device replacement operation in the CLI. The user inputs the following parameters: <VM: Id, virtual disk: Id, operation type: replace>.
S502,CLI直接将设备替换请求转发给HAL(Hard Adapter Layer,硬件模拟层)。S502: The CLI directly forwards the device replacement request to the HAL (Hard Adapter Layer).
S503,HAL建立模拟逻辑设备403,该设备具有标识:proxy_dev_fd。S503, the HAL establishes an analog logic device 403 having the identifier: proxy_dev_fd.
S504,模拟逻辑设备403的标识proxy_dev_fd继承与逻辑设备402关联的虚拟磁盘401的控制信息与状态:盘扇区数量、盘扇区大小、设备ID、盘类型。S504. The identifier proxy_dev_fd of the analog logic device 403 inherits the control information and status of the virtual disk 401 associated with the logical device 402: the number of disk sectors, the disk sector size, the device ID, and the disk type.
S505,HAL断开逻辑设备402的标识与虚拟磁盘401的标识之间的映射关系。S505. The HAL disconnects the mapping relationship between the identifier of the logical device 402 and the identifier of the virtual disk 401.
S506,HAL建立模拟逻辑设备403的标识与虚拟磁盘401的标识的映射关 系。S506, the HAL establishes a mapping relationship between the identifier of the analog logic device 403 and the identifier of the virtual disk 401. system.
S507、返回执行结果。S507, returning the execution result.
通过以上操作,让模拟逻辑设备403承接来自虚拟磁盘401的控制操作命令,且当对逻辑设备402进行热插拔时,并不影响VM的工作。Through the above operations, the analog logic device 403 is allowed to take control operation commands from the virtual disk 401, and when the logical device 402 is hot swapped, the operation of the VM is not affected.
图7为本发明实施例提供的拔出操作流程图。如图7所示,当需要对虚拟磁盘401拔出时,还可以进行如下步骤操作。FIG. 7 is a flowchart of an extraction operation according to an embodiment of the present invention. As shown in FIG. 7, when the virtual disk 401 needs to be unplugged, the following steps can also be performed.
S701,用户通过CLI触发热拔出操作,用户输入如下参数:<VM:Id,虚拟磁盘401:Id,操作类型:hot-unplug(拔出)>。S701, the user triggers the hot pull operation through the CLI, and the user inputs the following parameters: <VM: Id, virtual disk 401: Id, operation type: hot-unplug (extract)>.
S702,CLI将热拔出请求转发给HAL。S702. The CLI forwards the hot pull request to the HAL.
S703,HAL在此将请求提交给EH(Event Handler,事件处理模块)。S703, the HAL here submits the request to the EH (Event Handler).
S704,EH根据VM Id,找到对应的VM,然后将请求<虚拟磁盘401:Id,操作类型:hot-unplug>通过共享页面方式发送给VM中的HP(hp driver,热插拔驱动)。S704, the EH finds the corresponding VM according to the VM Id, and then sends the request <virtual disk 401: Id, operation type: hot-unplug> to the HP (hp driver, hot plug drive) in the VM through the shared page mode.
S705,HP根据虚拟磁盘401的Id,找到其对应的设备驱动,然后将请求<虚拟磁盘401,操作类型:hot-unplug>转发给设备驱动。S705, the HP finds its corresponding device driver according to the Id of the virtual disk 401, and then forwards the request <virtual disk 401, operation type: hot-unplug> to the device driver.
S706,VM的设备驱动处理热拔出操作请求:1)解除虚拟磁盘401与VM中看到的设备的映射关系;2)释放和回收已分配给虚拟磁盘401的资源。S706. The device driver processing hot pull operation request of the VM: 1) releasing the mapping relationship between the virtual disk 401 and the device seen in the VM; 2) releasing and reclaiming the resources allocated to the virtual disk 401.
S707,VM的设备驱动向VMM请求关闭虚拟磁盘401电源。S707, the device driver of the VM requests the VMM to power off the virtual disk 401.
S708,VMM中的HAL解除虚拟磁盘401的标识与模拟逻辑设备403的标识的映射关系。S708. The HAL in the VMM releases the mapping relationship between the identifier of the virtual disk 401 and the identifier of the simulated logical device 403.
S709,HAL关闭模拟逻辑设备403,并回收相关资源后。S709, the HAL closes the analog logic device 403 and recovers related resources.
S710,HAL向CLI返回执行结果。S710, the HAL returns an execution result to the CLI.
总之,通过本发明实施例,在VMM中引入代理设备对象,当需要进行热插拔操作时,通过代理设备对象与虚拟磁盘的映射,替换需要进行热插拔的真实设备与虚拟磁盘的映射,用代理设备对象响应VM对真实设备的操作请求,所以,即使真实设备出现故障,那么对该故障设备进行热插拔,不影响VM的 正常工作,从而使虚拟机的热插拔技术。In summary, the embodiment of the present invention introduces a proxy device object in the VMM. When a hot swap operation is required, the mapping between the real device and the virtual disk that needs to be hot swapped is replaced by the mapping between the proxy device object and the virtual disk. The proxy device object responds to the VM's operation request for the real device, so even if the real device fails, the faulty device is hot swapped without affecting the VM. Work properly, thus making the virtual machine hot plug technology.
图8为本发明另一个实施例提供的一种基于虚拟机的设备热替换方法的流程图。如图6所示,在另一个实施例中,在前述实施例中执行完步骤S350后,可以不删除虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系,以及分配给虚拟磁盘的资源,在前述实施例的基础上,本实施例还需执行如下步骤:FIG. 8 is a flowchart of a method for replacing a device based on a virtual machine according to another embodiment of the present invention. As shown in FIG. 6, in another embodiment, after performing step S350 in the foregoing embodiment, the mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device, and the resource allocated to the virtual disk may not be deleted. On the basis of the foregoing embodiments, the following steps are also required in this embodiment:
S860,接收热插入命令。S860, receiving a hot insertion command.
需要说明的是,逻辑设备由于被修复等原因需要重新插入该被修复的逻辑设备的标识已经发生变化,或者插入新的逻辑设备替换原被拔出的逻辑设备时,VMM可以通过CLI或GUI接收一个热插入请求,该请求中携带有虚拟磁盘的标识,以及需要新插入逻辑设备的标识。It should be noted that, when the logical device needs to be reinserted into the repaired logical device, the identifier of the logical device has changed, or the new logical device is inserted to replace the originally extracted logical device, the VMM can receive through the CLI or the GUI. A hot-plug request carrying the identity of the virtual disk and the identity of the newly inserted logical device.
S870,删除虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系。S870: Delete a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device.
由于执行完步骤S350后,在VM中的通过设备驱动依然能够看到虚拟磁盘,且在VMM中与模拟逻辑设备之间的映射关系是依然存在的,且模拟逻辑设备代替前述待替换的逻辑设备。所以,可以通过热插入请求中携带的虚拟磁盘的标识,以及新插入逻辑设备的标识,确定对应的虚拟设备以及逻辑设备;并用新插入逻辑设备替换模拟逻辑设备。首先需要删除虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系。After the step S350 is performed, the virtual disk is still visible through the device driver in the VM, and the mapping relationship between the VMM and the analog logical device still exists, and the analog logical device replaces the logical device to be replaced. . Therefore, the corresponding virtual device and the logical device can be determined by the identifier of the virtual disk carried in the hot insertion request and the identifier of the newly inserted logical device; and the analog logical device is replaced with the newly inserted logical device. First, you need to delete the mapping relationship between the ID of the virtual disk and the ID of the simulated logical device.
S880,建立虚拟磁盘的标识与逻辑设备的标识之间的映射关系。S880: Establish a mapping relationship between the identifier of the virtual disk and the identifier of the logical device.
需要说明的是,在此过程中,模拟逻辑设备是一个过渡的设备,为修复已故障的逻辑设备或者替换新的逻辑设备提供了,时间以及技术上支持。并且这个过程对于VM来说是相对透明的,也就是说,并不影响VM的正常工作。It should be noted that in this process, the analog logic device is a transitional device, providing time, and technical support for repairing the failed logical device or replacing the new logical device. And this process is relatively transparent to the VM, that is, it does not affect the normal operation of the VM.
在另一个例子中,图9为已修复逻辑设备与虚拟磁盘的映射关系示意图。在前述例子的基础上,替换逻辑设备后,VMM中还保存有虚拟磁盘与模拟逻辑设备之间的映射关系,以及分配给虚拟磁盘的资源,在不关闭VM、VMM的情况下,图10为本发明实施例提供的插入已修复逻辑设备的操作流程图。如 图10所示,将已修复的逻辑设备插入的过程需要执行如下步骤:In another example, FIG. 9 is a schematic diagram of a mapping relationship between a repaired logical device and a virtual disk. On the basis of the foregoing example, after the logical device is replaced, the VMM also stores the mapping relationship between the virtual disk and the analog logical device, and the resources allocated to the virtual disk. Without shutting down the VM and the VMM, FIG. 10 The flowchart of the operation of inserting the repaired logic device provided by the embodiment of the present invention. Such as As shown in Figure 10, the process of inserting the repaired logical device requires the following steps:
S901、用户通过CLI触发热插入操作,用户输入如下参数:<VM:Id,虚拟磁盘:Id,逻辑设备:盘符,操作类型:hot-plug(热插入)>。S901: The user triggers a hot plug operation through the CLI, and the user inputs the following parameters: <VM: Id, virtual disk: Id, logical device: drive letter, operation type: hot-plug (hot plug)>.
S902、CLI将请求转发给HAL。S902. The CLI forwards the request to the HAL.
S903、HAL删除模拟逻辑设备与虚拟磁盘之间的映射关系。S903 and HAL delete the mapping relationship between the analog logical device and the virtual disk.
S904、HAL建立已修复的逻辑设备与虚拟磁盘之间的映射关系。S904. The HAL establishes a mapping relationship between the restored logical device and the virtual disk.
S905、HAL回收分配给模拟逻辑设备的相关资源,删除模拟逻辑设备。S905. The HAL recovers related resources allocated to the analog logic device, and deletes the analog logic device.
S906、HAL返回执行结果。S906, HAL returns the execution result.
通过上述步骤,实现了对已故障逻辑设备的热插拔,且对于VM是透明的。Through the above steps, hot swapping of the failed logical device is achieved, and is transparent to the VM.
总之,本发明实施例通过在VMM中模拟逻辑设备与虚拟磁盘的映射以及逻辑设备与虚拟磁盘的映射之间的切换,实现了逻辑设备的热插拔操作相对于VM是透明的,从而,当逻辑设备出现故障时,可以不用关闭VM,且不影响VM的正常操作的情况下,对已故障的设备进行拔出、维修、插入,从而使得对于基于虚拟机的热插拔技术更完善。In summary, the embodiment of the present invention realizes that the hot plug operation of the logical device is transparent with respect to the VM by simulating the mapping between the mapping between the logical device and the virtual disk and the mapping between the logical device and the virtual disk in the VMM, thereby When the logical device fails, the VM can be unplugged, repaired, and inserted without shutting down the VM and without affecting the normal operation of the VM, thereby making the virtual machine-based hot plugging technology more perfect.
综上,本发明实施例提供的方法,在VMM中引入模拟逻辑设备,当需要进行热插拔操作时,通过模拟逻辑设备与虚拟磁盘的映射,替换需要进行热插拔的逻辑设备与虚拟磁盘的映射,用模拟逻辑设备响应VM对逻辑设备的操作命令,所以,即使逻辑设备出现故障,那么对该故障设备进行热插拔(热替换),不影响VM的正常工作,从而使虚拟机的热插拔技术更实用。In summary, the method provided by the embodiment of the present invention introduces an analog logic device in a VMM. When a hot swap operation is required, the logical device and the virtual disk that need to be hot swapped are replaced by mapping the logical device to the virtual disk. Mapping, using the analog logic device to respond to the VM's operational commands to the logical device, so even if the logical device fails, then hot-plugging (hot swapping) the failed device does not affect the normal operation of the VM, thereby making the virtual machine Hot swap technology is more practical.
本发明实施例在具体实施过程中,还可以实现逻辑设备的热插拔(热替换)操作相对于VM是透明的,从而,当逻辑设备出现故障时,可以不用关闭VM,且不影响VM的正常操作的情况下,对已故障的设备进行拔出、维修、插入;即使逻辑设备出现故障,那么也可以在VM中,将虚拟设备热插拔,并将VM、VMM分配给该设备的资源进行释放,从而使得虚拟机的热插拔技术更完善,能够应对更多的需要。In a specific implementation process, the hot swap (hot swap) operation of the logical device may be transparent with respect to the VM, so that when the logical device fails, the VM may not be shut down and the VM is not affected. In normal operation, the faulty device is pulled out, repaired, and inserted; even if the logical device fails, the virtual device can be hot swapped in the VM, and the VM and VMM are allocated to the resource of the device. Release, so that the virtual machine's hot swap technology is more complete, able to cope with more needs.
图2为本发明一个实施例提供的基于虚拟机的设备热替换装置的示意图。 其中该装置主要用于实现前述基于虚拟机的热替换方法,如图2所示,该装置可以包括虚拟机监视器200,该虚拟机监视器200具体可以包括:FIG. 2 is a schematic diagram of a virtual machine-based device hot replacement device according to an embodiment of the present invention. The device is mainly used to implement the foregoing virtual machine-based hot replacement method. As shown in FIG. 2, the device may include a virtual machine monitor 200. The virtual machine monitor 200 may specifically include:
接收单元201,用于接收热替换命令,该热替换命令包括虚拟磁盘的标识,该虚拟磁盘对应一个待替换的逻辑设备;The receiving unit 201 is configured to receive a hot replacement command, where the hot replacement command includes an identifier of the virtual disk, where the virtual disk corresponds to a logical device to be replaced;
生成单元202,用于生成模拟逻辑设备,所述模拟逻辑设备具有标识;a generating unit 202, configured to generate an analog logic device, where the analog logic device has an identifier;
发送单元203,用于将待替换的逻辑设备的控制信息发送给模拟逻辑设备;The sending unit 203 is configured to send control information of the logical device to be replaced to the analog logic device;
删除单元204,用于删除第一虚拟磁盘的标识与待替换的逻辑设备的标识之间的映射关系;The deleting unit 204 is configured to delete a mapping relationship between an identifier of the first virtual disk and an identifier of the logical device to be replaced.
建立单元205,用于建立第一虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系,使得模拟逻辑设备根据控制信息响应针对第一虚拟磁盘的控制指令。The establishing unit 205 is configured to establish a mapping relationship between the identifier of the first virtual disk and the identifier of the analog logical device, so that the analog logic device responds to the control instruction for the first virtual disk according to the control information.
在另一种实现方式下,本发明实施例还可以包括:In another implementation manner, the embodiment of the present invention may further include:
回收单元206,用于在建立虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系之后,回收分配给虚拟磁盘的资源;The recycling unit 206 is configured to: after establishing a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device, recover the resource allocated to the virtual disk;
其中,删除单元204,还用于删除虚拟磁盘的标识与模拟逻辑设备的标识之间的映射关系。The deleting unit 204 is further configured to delete a mapping relationship between the identifier of the virtual disk and the identifier of the simulated logical device.
进一步的,为了实现重新插入虚拟磁盘,本发明实施例在具体实施过程中:Further, in order to implement the re-insertion of the virtual disk, the embodiment of the present invention is in the specific implementation process:
接收单元201,还可以用于接收热插入命令,该热插入命令包括新插入的虚拟磁盘的标识;The receiving unit 201 is further configured to receive a hot plug command, where the hot plug command includes an identifier of the newly inserted virtual disk;
还可以包括创建单元207,用于创建新插入的虚拟磁盘;A storage unit 207 may also be included for creating a newly inserted virtual disk;
其中,建立单元205,还可以用于建立新插入的虚拟磁盘的标识与代替换逻辑设备的标识之间的映射关系。The establishing unit 205 is further configured to establish a mapping relationship between the identifier of the newly inserted virtual disk and the identifier of the replacement logical device.
具体的,生成单元202、发送单元203、删除单元204、建立单元205,可以通过硬件模拟层HAL来实现,另外硬件模拟层还可以包括回收单元206 和/或创建单元207。接收单元201可以通过用户接口来实现(CLI或GUI)。进一步的,虚拟机监视器200还可以包括事件处理模块220,用于触发热插拔事件。另外,还可以包括共享页面,用于与虚拟机进行交互。Specifically, the generating unit 202, the sending unit 203, the deleting unit 204, and the establishing unit 205 may be implemented by a hardware emulation layer HAL, and the hardware emulation layer may further include a reclaiming unit 206. And/or create unit 207. The receiving unit 201 can be implemented by a user interface (CLI or GUI). Further, the virtual machine monitor 200 may further include an event processing module 220 for triggering a hot plug event. In addition, a shared page can be included for interaction with the virtual machine.
专业人员应该还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。A person skilled in the art should further appreciate that the elements and algorithm steps of the various examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both, in order to clearly illustrate hardware and software. Interchangeability, the composition and steps of the various examples have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the solution. A person skilled in the art can use different methods for implementing the described functions for each particular application, but such implementation should not be considered to be beyond the scope of the present invention.
结合本文中所公开的实施例描述的方法或算法的步骤可以用硬件、处理器执行的软件模块,或者二者的结合来实施。软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。The steps of a method or algorithm described in connection with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be placed in random access memory (RAM), memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or technical field. Any other form of storage medium known.
以上所述的具体实施方式,对本发明的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本发明的具体实施方式而已,并不用于限定本发明的保护范围,凡在本发明的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 The specific embodiments of the present invention have been described in detail with reference to the preferred embodiments of the present invention. All modifications, equivalent substitutions, improvements, etc., made within the spirit and scope of the invention are intended to be included within the scope of the invention.

Claims (10)

  1. 一种基于虚拟机的设备热替换方法,其特征在于,所述方法包括:A virtual machine-based device hot replacement method, the method comprising:
    接收热替换命令,所述热替换命令包括第一虚拟磁盘的标识,所述第一虚拟磁盘对应一个待替换的逻辑设备;Receiving a hot replacement command, where the hot replacement command includes an identifier of the first virtual disk, and the first virtual disk corresponds to a logical device to be replaced;
    生成模拟逻辑设备,所述模拟逻辑设备具有标识;Generating an analog logic device having an identification;
    将所述待替换的逻辑设备的控制信息发送给所述模拟逻辑设备;Sending control information of the logical device to be replaced to the analog logic device;
    删除所述第一虚拟磁盘的标识与所述待替换的逻辑设备的标识之间的映射关系;Deleting a mapping relationship between the identifier of the first virtual disk and the identifier of the logical device to be replaced;
    建立所述第一虚拟磁盘的标识与所述模拟逻辑设备的标识之间的映射关系,使得所述模拟逻辑设备根据所述控制信息响应针对所述第一虚拟磁盘的控制指令。Establishing a mapping relationship between the identifier of the first virtual disk and the identifier of the analog logical device, so that the analog logic device responds to the control instruction for the first virtual disk according to the control information.
  2. 根据权利要求1所述的设备热替换方法,其特征在于,还包括:The device hot replacement method according to claim 1, further comprising:
    在所述建立所述第一虚拟磁盘的标识与所述模拟逻辑设备的标识之间的映射关系之后,回收分配给所述虚拟磁盘的资源;After the mapping relationship between the identifier of the first virtual disk and the identifier of the simulated logical device is established, recovering resources allocated to the virtual disk;
    删除所述第一虚拟磁盘的标识与所述模拟逻辑设备的标识之间的映射关系。And deleting a mapping relationship between the identifier of the first virtual disk and the identifier of the simulated logical device.
  3. 根据权利要求2所述的设备热替换方法,其特征在于,在所述回收分配给所述虚拟磁盘的资源之前,还包括:The device hot replacement method according to claim 2, further comprising: before the recovering the resources allocated to the virtual disk,
    接收热拔出命令,所述热拔出命令包括所述第一虚拟磁盘的标识。Receiving a hot pull command, the hot pull command including an identifier of the first virtual disk.
  4. 根据权利要求2所述的设备热替换方法,其特征在于,还包括:The device hot replacement method according to claim 2, further comprising:
    接收第一热插入命令,所述第一热插入命令包括第二虚拟磁盘的标识;Receiving a first hot plug command, where the first hot plug command includes an identifier of the second virtual disk;
    创建所述待第二虚拟磁盘;Creating the to-be-second virtual disk;
    建立所述第二虚拟磁盘的标识与所述代替换逻辑设备的标识之间的映射关系。Establishing a mapping relationship between the identifier of the second virtual disk and the identifier of the generation replacement logical device.
  5. 根据权利要求1-4任意一项所述的设备热替换方法,其特征在于,所述待替换的逻辑设备为已故障逻辑设备。 The device hot replacement method according to any one of claims 1 to 4, wherein the logical device to be replaced is a faulty logical device.
  6. 根据权利要求5所述的设备热替换方法,其特征在于,当待插入逻辑设备需要插入时,所述待插入逻辑设备为区别于所述代替换的逻辑设备的新逻辑设备或者已修复的代替换的逻辑设备,所述方法还包括:The device hot replacement method according to claim 5, wherein when the logical device to be inserted needs to be inserted, the logical device to be inserted is a new logical device or a repaired replacement different from the logical device replaced by the substitute The logical device is changed, and the method further includes:
    接收第二热插入命令,所述第二热插入命令包括所述第一虚拟磁盘的标识以及所述待插入逻辑设备的标识;Receiving a second hot plug command, where the second hot plug command includes an identifier of the first virtual disk and an identifier of the logical device to be inserted;
    删除所述第一虚拟磁盘的标识与所述模拟逻辑设备的标识之间的映射关系;Deleting a mapping relationship between the identifier of the first virtual disk and the identifier of the simulated logical device;
    建立所述第一虚拟磁盘的标识与所述逻辑设备的标识之间的映射关系。Establishing a mapping relationship between the identifier of the first virtual disk and the identifier of the logical device.
  7. 一种基于虚拟机的设备热替换装置,其特征在于,所述装置包括:A virtual machine-based device heat replacement device, characterized in that the device comprises:
    接收单元,用于接收热替换命令,所述热替换命令包括第一虚拟磁盘的标识,所述第一虚拟磁盘对应一个待替换的逻辑设备;a receiving unit, configured to receive a hot replacement command, where the hot replacement command includes an identifier of the first virtual disk, where the first virtual disk corresponds to a logical device to be replaced;
    生成单元,用于生成模拟逻辑设备,所述模拟逻辑设备具有标识;a generating unit, configured to generate an analog logic device, where the analog logic device has an identifier;
    发送单元,用于将所述待替换的逻辑设备的控制信息发送给所述模拟逻辑设备;a sending unit, configured to send control information of the logical device to be replaced to the analog logic device;
    删除单元,用于删除所述第一虚拟磁盘的标识与所述待替换的逻辑设备的标识之间的映射关系;a deleting unit, configured to delete a mapping relationship between an identifier of the first virtual disk and an identifier of the logical device to be replaced;
    建立单元,用于建立所述第一虚拟磁盘的标识与所述模拟逻辑设备的标识之间的映射关系,使得所述模拟逻辑设备根据所述控制信息响应针对所述第一虚拟磁盘的控制指令。a establishing unit, configured to establish a mapping relationship between the identifier of the first virtual disk and the identifier of the analog logical device, so that the analog logic device responds to the control instruction for the first virtual disk according to the control information .
  8. 根据权利要求7所述的设备热替换装置,其特征在于,还包括:The device thermal replacement device according to claim 7, further comprising:
    回收单元,用于在所述建立所述第一虚拟磁盘的标识与所述模拟逻辑设备的标识之间的映射关系之后,回收分配给所述虚拟磁盘的资源;a recycling unit, configured to reclaim resources allocated to the virtual disk after establishing the mapping relationship between the identifier of the first virtual disk and the identifier of the simulated logical device;
    所述删除单元,还用于删除所述第一虚拟磁盘的标识与所述模拟逻辑设备的标识之间的映射关系。The deleting unit is further configured to delete a mapping relationship between an identifier of the first virtual disk and an identifier of the analog logical device.
  9. 根据权利要求8所述的设备热替换装置,其特征在于,还包括:The device thermal replacement device according to claim 8, further comprising:
    所述接收单元,还用于接收第一热插入命令,所述第一热插入命令包括 第二虚拟磁盘的标识;The receiving unit is further configured to receive a first hot plug command, where the first hot plug command includes The identifier of the second virtual disk;
    创建单元,用于创建所述待第二虚拟磁盘;Creating a unit, configured to create the to-be-second virtual disk;
    所述建立单元,还用于建立所述第二虚拟磁盘的标识与所述代替换逻辑设备的标识之间的映射关系。The establishing unit is further configured to establish a mapping relationship between an identifier of the second virtual disk and an identifier of the generation replacement logical device.
  10. 根据权利要求7或8所述的设备热替换装置,其特征在于,当待插入逻辑设备需要插入时,所述待插入逻辑设备为区别于所述代替换的逻辑设备的新逻辑设备或者已修复的代替换的逻辑设备,The device hot swap device according to claim 7 or 8, wherein when the logical device to be inserted needs to be inserted, the logical device to be inserted is a new logical device that is different from the logical device replaced by the substitute or has been repaired. Generation of replacement logic devices,
    所述接收单元,还用于接收第二热插入命令,所述第二热插入命令包括所述第一虚拟磁盘的标识以及所述待插入逻辑设备的标识;The receiving unit is further configured to receive a second hot plug command, where the second hot plug command includes an identifier of the first virtual disk and an identifier of the logical device to be inserted;
    所述删除单元,还用于删除所述第一虚拟磁盘的标识与所述模拟逻辑设备的标识之间的映射关系;The deleting unit is further configured to delete a mapping relationship between an identifier of the first virtual disk and an identifier of the analog logical device;
    所述建立单元,还用于建立所述第一虚拟磁盘的标识与所述逻辑设备的标识之间的映射关系。 The establishing unit is further configured to establish a mapping relationship between the identifier of the first virtual disk and the identifier of the logical device.
PCT/CN2016/087920 2015-10-20 2016-06-30 Device hot-replacement method and apparatus based on virtual machine WO2017067213A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510681571.0A CN105279010B (en) 2015-10-20 2015-10-20 The hot replacement method of equipment based on virtual machine and device
CN201510681571.0 2015-10-20

Publications (1)

Publication Number Publication Date
WO2017067213A1 true WO2017067213A1 (en) 2017-04-27

Family

ID=55148065

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/087920 WO2017067213A1 (en) 2015-10-20 2016-06-30 Device hot-replacement method and apparatus based on virtual machine

Country Status (2)

Country Link
CN (1) CN105279010B (en)
WO (1) WO2017067213A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112052128A (en) * 2019-06-06 2020-12-08 北京字节跳动网络技术有限公司 Disaster recovery method and device and electronic equipment
CN116775353A (en) * 2023-05-19 2023-09-19 北京百度网讯科技有限公司 Method and device for repairing failed disk, electronic equipment and readable storage medium

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105279010B (en) * 2015-10-20 2018-09-21 华为技术有限公司 The hot replacement method of equipment based on virtual machine and device
CN107515774B (en) * 2016-06-15 2021-02-05 阿里巴巴集团控股有限公司 Method and device for replacing virtual operating system bottom block device driver on line
CN107643897B (en) * 2016-07-20 2021-04-16 阿里巴巴集团控股有限公司 Method and device for updating back-end driver
CN110764949A (en) * 2019-09-29 2020-02-07 北京浪潮数据技术有限公司 Hard disk replacement method, hard disk replacement device, and storage medium
CN113448676A (en) * 2020-03-24 2021-09-28 阿里巴巴集团控股有限公司 Control method, device and equipment of virtual machine
EP3961323A1 (en) * 2020-08-25 2022-03-02 ABB Schweiz AG Replacement of industrial field device
CN114168498B (en) * 2021-11-09 2024-02-06 百富计算机技术(深圳)有限公司 Broken line maintaining method, device, equipment and computer storage medium
CN115858222B (en) * 2022-12-19 2024-01-02 安超云软件有限公司 Virtual machine fault processing method, system and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101430670A (en) * 2008-12-16 2009-05-13 中国科学院计算技术研究所 I/O equipment reconstruction method and system in virtualization surroundings
US20100107158A1 (en) * 2008-10-28 2010-04-29 Vmware, Inc. Low overhead fault tolerance through hybrid checkpointing and replay
US20140325170A1 (en) * 2013-04-30 2014-10-30 WMware Inc. Conversion of Virtual Disk Snapshots Between Redo and Copy-on-Write Technologies
CN104317759A (en) * 2014-10-15 2015-01-28 国云科技股份有限公司 Method for supporting hot plugging of virtual machine USB (universal serial bus) storage equipment
CN105279010A (en) * 2015-10-20 2016-01-27 华为技术有限公司 Virtual machine-based equipment heat replacing method and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100396065C (en) * 2005-01-14 2008-06-18 清华大学 A method for implementing iSCSI memory system
CN100492309C (en) * 2007-02-06 2009-05-27 杭州华三通信技术有限公司 Method and host equipment for implementing virtual hot-swap
WO2010005158A1 (en) * 2008-07-11 2010-01-14 Jung Jin Heon Detachable handle for cooking utensils
EP2454676A4 (en) * 2009-07-17 2014-05-21 Hewlett Packard Development Co Virtual hot inserting functions in a shared i/o environment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100107158A1 (en) * 2008-10-28 2010-04-29 Vmware, Inc. Low overhead fault tolerance through hybrid checkpointing and replay
CN101430670A (en) * 2008-12-16 2009-05-13 中国科学院计算技术研究所 I/O equipment reconstruction method and system in virtualization surroundings
US20140325170A1 (en) * 2013-04-30 2014-10-30 WMware Inc. Conversion of Virtual Disk Snapshots Between Redo and Copy-on-Write Technologies
CN104317759A (en) * 2014-10-15 2015-01-28 国云科技股份有限公司 Method for supporting hot plugging of virtual machine USB (universal serial bus) storage equipment
CN105279010A (en) * 2015-10-20 2016-01-27 华为技术有限公司 Virtual machine-based equipment heat replacing method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112052128A (en) * 2019-06-06 2020-12-08 北京字节跳动网络技术有限公司 Disaster recovery method and device and electronic equipment
CN116775353A (en) * 2023-05-19 2023-09-19 北京百度网讯科技有限公司 Method and device for repairing failed disk, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
CN105279010B (en) 2018-09-21
CN105279010A (en) 2016-01-27

Similar Documents

Publication Publication Date Title
WO2017067213A1 (en) Device hot-replacement method and apparatus based on virtual machine
US10394547B2 (en) Applying update to snapshots of virtual machine
US20200097368A1 (en) Method and Apparatus for Generating Virtual Machine Snapshot
US9489274B2 (en) System and method for performing efficient failover and virtual machine (VM) migration in virtual desktop infrastructure (VDI)
US9507672B2 (en) Method, apparatus, and system for generating and recovering memory snapshot of virtual machine
US9613119B1 (en) Unique identifiers for data replication, migration, failover operations and failback operations
US20120072685A1 (en) Method and apparatus for backup of virtual machine data
US8448167B2 (en) Storage system, and remote copy control method therefor
US9678682B2 (en) Backup storage of vital debug information
US20150095597A1 (en) High performance intelligent virtual desktop infrastructure using volatile memory arrays
CN101120317A (en) Method, apparatus and system for dynamically reassigning memory from one virtual machine to another
JP2008015768A (en) Storage system and data management method using the same
US20150339144A1 (en) Maintaining virtual hardware device id in a virtual machine
JP2012243298A (en) Server i/o migration management method and device
US20140149701A1 (en) Backup method and computer product
US20160259578A1 (en) Apparatus and method for detecting performance deterioration in a virtualization system
US10922305B2 (en) Maintaining storage profile consistency in a cluster having local and shared storage
CN112099916B (en) Virtual machine data migration method and device, computer equipment and storage medium
JP2013191090A (en) Backup control program, backup control method and information processing apparatus
JP6674101B2 (en) Control device and information processing system
JP7326970B2 (en) Backup processing device, backup processing system, backup processing method, and backup processing program
JP6497157B2 (en) Information management apparatus, information management method, information management program, data structure, and software asset management system
CN116235175A (en) Static configuration of accelerator card security modes
US10740088B2 (en) Countermeasure verification assistance system and method
US20200293336A1 (en) Server and method of replacing a server in a network

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16856653

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16856653

Country of ref document: EP

Kind code of ref document: A1