主权项 |
1. A system for sharing a device assigned to a plurality of virtual machines, the system comprising:
a plurality of virtual machines, wherein a device is assigned to the plurality of virtual machines and is active in only one of the plurality of virtual machines at a time; and a hypervisor that identifies a first virtual machine in which the device is active, wherein-the first virtual machine controls the device; and a first memory that stores first state information that is associated with the device and maintained by the first virtual machine; wherein the hypervisor communicates with the plurality of virtual machines and that, when a condition is satisfied, transfers control of the device from the first virtual machine to a second virtual machine, wherein the second virtual machine is in the plurality of virtual machines; wherein the hypervisor receives an indication to transfer control of the device from the first virtual machine to the second virtual machine, wherein in response to the indication to transfer control of the device, the hypervisor sends a first communication to the first virtual machine to cause (i) the first virtual machine to relinquish control of the device based on an indication that power will be removed from the device, and (ii) the first virtual machine to save the first state information to the first memory; and wherein the hypervisor receives an indication that the first virtual machine has saved the first state information, and after receiving the indication that the first virtual machine has saved the first state information, the hypervisor saves second state information maintained by a host machine to a second memory, wherein the second state information is associated with the first virtual machine and the device. |