Embodiments of the present invention relate to a computer system, and more specifically, to management of a passthrough computing device.
In a virtual computing environment, devices may be removed from a host computer via a hot unplug, wherein the device is removed while a virtual machine is running. The device, however, typically has software (e.g., a device driver) executing within a guest running on the virtual machine that enables communication with the device. It is difficult to write or code the device software (e.g., the device driver) in a way that would enable the guest to handle the sudden disappearance of the device resulting from a hot unplug. As such, to remove a device, the device software on the guest operating system is first notified of the removal, explicitly acknowledges the hot unplug request, and enters a state in which it is safe to remove the device (e.g., including removing power from the device). However, this removal process may be time consuming, particularly if the guest is slow, the guest is not operating properly or if the guest lacks the hot unplug processing functionality.
In cases where a hot unplug of a device is initiated via a management interface of the hypervisor (e.g., by an administrator of the hypervisor), the hypervisor notifies the guest of the hot unplug request. In response, the guest notifies the device software of the request which in turn performs any necessary clean-up (e.g., removal of power from the device) to enable the safe removal of the device. In addition, the guest may perform operating system clean up to prepare for the safe removal of the device. Finally, the guest then notifies the hypervisor that it is safe to remove the device. However, there are instances when the guest is in a state in which it is unable to receive the hot unplug request (e.g., in a boot sequence or the guest is down), and the guest is unable to prepare the device software (e.g. the driver) for the removal of the device. In addition, the guest may receive the hot unplug notification, but the guest may be reset and lose the notification event and fail to take the necessary steps to prepare for the safe removal of the device.
Methods and systems for managing a removal (e.g., a hot unplug) of a device from a guest managed by a hypervisor in a virtual computing environment. The hypervisor includes a device unplug manager configured to track access to the device by a guest and determine if a hot unplug of the device (e.g., removal of the device while the virtual machine (VM) is running) may be performed safely. In an embodiment, the device unplug manager maintains information relating to the activity of the guest and device which indicates whether the guest has accessed the device since a last reset or starting of the virtual machine resulting in a removal of state information from the guest. In an embodiment, the information (also referred to as the “accessed after last reset state” or “last accessed state”) may be maintained as a binary flag or bit which is in a first state if the guest accessed the device after the last reset of the VM (e.g., a ‘set’, ‘Yes’, or ‘1’ value) or a second state (e.g., a ‘cleared’, ‘No’, or ‘0’ value) if the guest has not accessed the device since the last reset of the virtual machine.
At the time a virtual machine is started or reset, the last accessed state is cleared (e.g., assigned a ‘No’ or ‘0’ value). The device unplug manager is configured to track access requests for the device, and when the guest accesses the device for the first time, the last accessed state is set (e.g., assigned a ‘Yes’ or ‘1’ value indicating that the guest accessed the device after the last reset of the VM). Upon receipt of a request to hot unplug the device initiated via the hypervisor (e.g., by a hypervisor administrator via a management interface of the hypervisor), the device unplug manager checks the last accessed state associated with the virtual machine executing the guest. If the last accessed state is set (indicating that the guest has accessed the device since the last reset or starting), the device unplug manager notifies the guest of the removal request. If the last accessed state is clear (indicating that the device has not been accessed since the last reset or starting of the virtual machine), the device unplug manager determines that it is safe to remove the device immediately (i.e., without waiting for an acknowledgment from the guest) and, optionally, notify the guest of the hot unplug request and/or the device removal.
In an embodiment, the device unplug manager is configured to track only access requests that return a state to the guest (e.g., a read access) when maintaining the last accessed state. In this embodiment, the device unplug manager sets the last accessed state when a read access request is identified, but keeps the last accessed state clear if an access request which does not affect state is identified (e.g., a write access request).
In another embodiment, the device unplug manager is configured to track only configuration access type requests for Peripheral Component Interconnect (PCI) devices (e.g., a network interface card, a sound card, etc.) since configuration access requests for PCI devices return a state to the guest. In this embodiment, the device unplug manager sets the last accessed state when a configuration access request for a PCI device is identified, but keeps the last accessed state clear if another access request which does not return state is identified (e.g., a memory write request). In another embodiment, the device unplug manager is configured to track only configuration read access type requests for PCI devices. In an embodiment, the device unplug manager is configured to ignore certain fields within a PCI configuration space for reads because those fields do not provide sufficient information to configure and make use of the PCI device. For example, reading vendor registers and device registers indicates that the guest knows the PCI device is there, but cannot make use of it without further probes and configuration. In an embodiment, the device unplug manager is configured to consider the PCI device unused unless the PCI device is configured to claim transactions on the PCI interface (e.g., I/O or memory enabled).
Throughout the following description, the term “guest” refers to the software that runs or can run on the hypervisor that is installed on a disk, loaded into memory, or is currently running. A guest may include one or more of the following: a firmware copy in memory, an operating system, additional installed software, a browser, applications running on the browser, etc. The term “virtual machine” (VM) refers to part of a host system that is visible to the guest. A virtual machine may include one or more of the following: memory, virtual central processing unit (CPU), virtual devices (e.g., emulated NIC or disk), physical devices over which a guest is given partial or full control, firmware such as Basic Input/Output System (BIOS), Extensible Firmware Interface (EFI) and Advanced Configuration and Power Interface (ACPI) which is provided to the guest, etc.
Accordingly, an efficient method and system is provided that allows for the safe hot unplugging of a device in a virtual machine computing system. The safe hot unplugging may be facilitated by checking a last accessed state in a reference table indicating whether a guest has accessed a device since a last reset of the virtual machine upon receipt of a request to hot unplug the device from the hypervisor management interface.
In the following description, numerous details are set forth. It will be apparent, however, to one skilled in the art, that the present invention may be practiced without these specific details. In some instances, well-known structures and devices are shown in block diagram form, rather than in detail, in order to avoid obscuring the present invention.
In one embodiment, the computer system 100 runs a hypervisor 150 to virtualize access to the devices 102 managed by the computer system 100, making the use of the virtual machine 130 transparent to the guest 140 and the users of the computer system 100. Although a single device 102 is illustrated in
According to embodiments of the present invention, the computer system 100 may also include hardware components such as one or more physical central processing units (CPUs) 170, memory 180, and other hardware components. In one embodiment, the hypervisor 150 includes a device unplug manager 155. The device unplug manager 155 is a component (e.g., a set of instructions executable by a processing device of the computer system 100, such as CPU 170) configured to perform the actions described in detail below in connection with
In an embodiment, the hypervisor 150 may be managed via a hypervisor management interface 152 configured to receive a request (e.g., from a hypervisor administrator) for a hot unplug of the device 102 (e.g., removal of the device 102 from the guest 140). In an embodiment, the device unplug manager 155 is configured to track access to the device 102 by the guest 140 and determine if a hot unplug of the device 102 (e.g., removal of the device 102 while the virtual machine 130 is running) may be performed safely. In an embodiment, the device unplug manager 155 maintains a last accessed state indicating whether the guest 140 has accessed the device 102 since a last reset of the virtual machine 130. In an embodiment, the device unplug manager 155 maintains a reference table (e.g., the example access management table shown in
Referring to
Referring to
Upon receipt of a request to hot unplug the device initiated via the hypervisor (e.g., by a hypervisor administrator via a management interface of the hypervisor) in block 220, the device unplug manager checks the last accessed state associated with the virtual machine executing the guest, in block 230. If the last accessed state is set (indicating that the guest has accessed the device since the last reset), the device unplug manager notifies the guest of the removal request, in block 240. If the last accessed state is not set or clear (indicating that the device has not been accessed since the last reset), the device unplug manager determines that it is safe to remove the device directly (e.g., initiate the removal immediately including the removal of the device software (e.g., a device driver) from the guest, without first notifying the guest of the removal request or awaiting an acknowledgment from the guest). Optionally (as denoted by the dashed line in
In an embodiment, if the device unplug manager determines that it is not safe to remove the device immediately, and if the guest has not acknowledged the removal request when the virtual machine is later reset, the last accessed state is cleared and the device unplug manager determines that it is safe to remove the device immediately (i.e., without further waiting for an acknowledgment from the guest).
It should be noted that the hypervisor may execute multiple virtual machines and, as such, the method 200 would be performed with respect to the multiple virtual machines. For purposes of illustration, method 200 is described with reference to the removal of a single device from a single guest.
In another embodiment, the device unplug manager is configured to track only read access requests (and/or other request types which return a state to the guest) associated with a device. In this embodiment, the device unplug manager of the hypervisor traps and/or tracks a request from a guest and determines the type of access request. If a read access request is detected, the device unplug manager sets the last accessed state. If a write access request (or other request which does not affect state) is detected, the device unplug manager does not set the last accessed state (e.g., the last accessed state remains clear).
In another embodiment, for a device for which the guest does not maintain state information (e.g., PCI devices), the device unplug manager is configured to track only configuration access type requests. In this embodiment, in block 210, the device unplug manager sets the last accessed state when a configuration access request for a PCI device is identified, but keeps the last accessed state clear if another access request type which does not affect state is identified. In another embodiment, the device unplug manager is configured to trap only configuration read access type requests for PCI devices and modify the last accessed state in response to configuration read access type requests.
In block 410, the device unplug manager of the hypervisor receives a request from a guest for access to a passthrough device. In response to receipt of the request, the hypervisor sets the last accessed state in a memory, in block 420. In block 430, the hypervisor forwards the “first” access request (e.g., a request received prior to the last accessed state being set) received from the guest to the intended passthrough device. In block 440, having set the last accessed state, the hypervisor facilitates the sending of subsequent guest access requests directly to the passthrough device (e.g., the hypervisor instructs the VM to provide direct access to the passthrough device for subsequent requests, the hypervisor configures the host CPU to send subsequent guest requests directly to the passthrough device, and/or the hypervisor configures the VCPU so that subsequent access requests go directly to the passthrough device).
In block 450, in response to a reset of the virtual machine running the guest, the hypervisor clears the last accessed state and instructs the host CPU to send further access requests (also referred to as post-reset requests) to the hypervisor. Accordingly, for example, an access request received following block 450 is treated like a “first” access request and blocks 410-440 are repeated, until a next virtual machine reset. Accordingly, in an embodiment, the first access request is trapped by the hypervisor for device unplug tracking purposes so that the last accessed bit can be set. Any subsequent access requests (e.g., access requests following the first access request and before a virtual machine reset) are sent directly to the passthrough device. This process may continue until a next reset of the virtual machine, at which time the hypervisor clears the last accessed state, instructs the host CPU to send a next access request (e.g., a post-reset request) to the hypervisor, and traps this “first” access request (e.g., a first access request following the reset).
In an embodiment, a physical computing system may be configured to manage a hot unplug of a connected device. In an embodiment, hardware logic is implemented on a hardware bus which the device resides on (referred to as a “hardware device unplug logic”). The hardware device unplug logic of the hardware bus may be configured to track access requests made by the operating system of the computing system to the device and determine if it is safe to unplug the device.
In an embodiment, the physical computing system to which the device is connected includes a physical button which may be pressed by a user if he or she wishes to remove, eject or unplug a connected device. In an embodiment, the physical button may be coupled to a light emitting diode (LED) (or other suitable indicator) configured to shut off to indicate that power has been removed from the device and notify a user that it is safe to remove the device from the computing system.
In an embodiment, the hardware device unplug logic is configured to track requests (e.g., packets) from the operating system of the computing system to the connected device. The hardware device unplug logic maintains a bit in an associated memory which indicates a last accessed state of the device (e.g., whether the operating system accessed the device since the last reset of the computing system). In an embodiment, the bit maintained in memory is cleared (e.g., set to ‘0’) when the computing system is reset. In an embodiment, the bit is set (e.g., set to ‘1’) when an access request is detected from the operating system to the connected device.
In an embodiment, when the user pushes the unplug or eject button, the hardware device unplug logic looks up the bit in memory and, if the bit is set (indicating there has been an access request by the operating system to the device since the last reset of the computing system), the hardware device unplug logic sends a notification to the operating system. If the bit in memory is clear (indicating that there has not been an access request since the last reset of the computing system), the hardware device unplug logic of the hardware bus powers down the device and turns off the red light to notify the user that the power has been removed and it is safe to remove the device. Optionally, the hardware device unplug logic may send a notification to the firmware (and then on to the operating system) that it is safe to unplug the device.
The example computer system 500 includes a processing device (processor) 502, a main memory 504 (e.g., read-only memory (ROM), flash memory, dynamic random access memory (DRAM) such as synchronous DRAM (SDRAM)), a static memory 506 (e.g., flash memory, static random access memory (SRAM)), and a data storage device 516, which communicate with each other via a bus 508.
Processing device 502 represents one or more general-purpose processing devices such as a microprocessor, central processing unit, or the like. More particularly, the processing device 502 may be a complex instruction set computing (CISC) microprocessor, reduced instruction set computing (RISC) microprocessor, very long instruction word (VLIW) microprocessor, or a processor implementing other instruction sets or processors implementing a combination of instruction sets. The processing device 502 may also be one or more special-purpose processing devices such as an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a digital signal processor (DSP), network processor, or the like. The device unplug manager 155 in
The computer system 500 may further include a network interface device 522. The computer system 500 also may include a video display unit 510 (e.g., a liquid crystal display (LCD) or a cathode ray tube (CRT)), an alphanumeric input device 512 (e.g., a keyboard), a cursor control device 514 (e.g., a mouse), and a signal generation device 520 (e.g., a speaker).
A drive unit 516 may include a computer-readable medium 524 on which is stored one or more sets of instructions (e.g., instructions of the device unplug manager 155) embodying any one or more of the methodologies or functions described herein. The instructions of the device unplug manager 155 may also reside, completely or at least partially, within the main memory 504 and/or within the processing device 502 during execution thereof by the computer system 500, the main memory 504 and the processing device 502 also constituting computer-readable media. The instructions of the device unplug manager 155 may further be transmitted or received over a network via the network interface device 522.
While the computer-readable storage medium 524 is shown in an example embodiment to be a single medium, the term “computer-readable storage medium” should be taken to include a single non-transitory medium or multiple non-transitory media (e.g., a centralized or distributed database, and/or associated caches and servers) that store the one or more sets of instructions. The term “computer-readable storage medium” shall also be taken to include any medium that is capable of storing, encoding or carrying a set of instructions for execution by the machine and that cause the machine to perform any one or more of the methodologies of the present invention. The term “computer-readable storage medium” shall accordingly be taken to include, but not be limited to, solid-state memories, optical media, and magnetic media.
In the above description, numerous details are set forth. It will be apparent, however, to one of ordinary skill in the art having the benefit of this disclosure, that embodiments of the invention may be practiced without these specific details. In some instances, well-known structures and devices are shown in block diagram form, rather than in detail, in order to avoid obscuring the description.
Some portions of the detailed description are presented in terms of algorithms and symbolic representations of operations on data bits within a computer memory. These algorithmic descriptions and representations are the means used by those skilled in the data processing arts to most effectively convey the substance of their work to others skilled in the art. An algorithm is here, and generally, conceived to be a self-consistent sequence of steps leading to a desired result. The steps are those requiring physical manipulations of physical quantities. Usually, though not necessarily, these quantities take the form of electrical or magnetic signals capable of being stored, transferred, combined, compared, and otherwise manipulated. It has proven convenient at times, principally for reasons of common usage, to refer to these signals as bits, values, elements, symbols, characters, terms, numbers, or the like.
It should be borne in mind, however, that all of these and similar terms are to be associated with the appropriate physical quantities and are merely convenient labels applied to these quantities. Unless specifically stated otherwise as apparent from the above discussion, it is appreciated that throughout the description, discussions utilizing terms such as “maintaining,” “receiving”, “removing”, or the like, refer to the actions and processes of a computer system, or similar electronic computing device, that manipulates and transforms data represented as physical (e.g., electronic) quantities within the computer system's registers and memories into other data similarly represented as physical quantities within the computer system memories or registers or other such information storage, transmission or display devices.
Embodiments of the invention also relate to an apparatus for performing the operations herein. This apparatus may be specially constructed for the required purposes, or it may comprise a general purpose computer selectively activated or reconfigured by a computer program stored in the computer. Such a computer program may be stored in a computer readable storage medium, such as, but not limited to, any type of disk including floppy disks, optical disks, CD-ROMs, and magnetic-optical disks, read-only memories (ROMs), random access memories (RAMs), EPROMs, EEPROMs, magnetic or optical cards, or any type of media suitable for storing electronic instructions.
The algorithms and displays presented herein are not inherently related to any particular computer or other apparatus. Various general purpose systems may be used with programs in accordance with the teachings herein, or it may prove convenient to construct a more specialized apparatus to perform the required method steps. The required structure for a variety of these systems will appear from the description below. In addition, the present invention is not described with reference to any particular programming language. It will be appreciated that a variety of programming languages may be used to implement the teachings of the invention as described herein.
It is to be understood that the above description is intended to be illustrative, and not restrictive. Many other embodiments will be apparent to those of skill in the art upon reading and understanding the above description. The scope of the invention should, therefore, be determined with reference to the appended claims, along with the full scope of equivalents to which such claims are entitled.
Number | Name | Date | Kind |
---|---|---|---|
20070180493 | Croft et al. | Aug 2007 | A1 |
20080294825 | Mahalingam et al. | Nov 2008 | A1 |
20100250824 | Belay | Sep 2010 | A1 |
Number | Date | Country | |
---|---|---|---|
20140068607 A1 | Mar 2014 | US |