1. Technical Field
The disclosure generally relates to a method and a system for configuring a universal serial bus (USB) device in a virtual environment.
2. Description of Related Art
Virtualization is a technique in which a computer system is partitioned into multiple isolated virtual machines (VMs), each of which appears to the software within it to be a complete computer system. A typical virtual system can operate multiple VM guests by installing a VM host with a host operating system (OS) for operating the VM guests. Each VM guest may include a guest OS, which may be unaware of any of the other VM guests event though they are instantiated on the same computer system. The VM host is responsible for providing the environment in which each VM guest runs and maintaining isolation between the VM guests.
Each VM guest may have access to a set of physical devices, such as USB devices. The VM host controls which physical devices are assigned to each VM guest, and also implements the devices that are visible to VM guests. If a physical device is exclusively assigned to a single VM guest, it is not available to the other VM guests. In current practice, when a physical device is attached to the computer system, the VM host typically assigns the physical device to a predetermined VM guest according to configuration settings. It is inconvenient for the user to switch the control of the physical device from the predetermined VM guest to another desired VM guest. Therefore, there is room for improvement within the art.
Many aspects of the embodiments can be better understood with reference to the following drawings. The components in the drawings are not necessarily drawn to scale, the emphasis instead being placed upon clearly illustrating the principles of the embodiments. Moreover, in the drawings, like reference numerals designate corresponding parts throughout the several views.
The disclosure is illustrated by way of example and not by way of limitation in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean at least one.
In general, the word “module” as used herein, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language, such as Java, C, or assembly. One or more software instructions in the modules may be embedded in firmware, such as in an EPROM. The modules described herein may be implemented as either software and/or hardware modules and may be stored in any type of non-transitory computer-readable medium or other storage device. Some non-limiting examples of non-transitory computer-readable media include CDs, DVDs, BLU-RAY, flash memory, and hard disk drives.
The computer system 100 can operate one or more virtual machine (VM) guests 1301, 1302 . . . 130N, collectively designated by a reference numeral 130, by installing a VM host 120 with a host operating system (OS) 122 for operating the VM guests 130. Each of the VM guests 130 may include a guest OS and one or more software applications. For example, the VM guest 1301 may include a guest OS 132 and an application 134 that is installed and executable in the VM guest 1301.
The VM host 120 may control the hardware platform 110, present to the VM guest 130 virtualized hardware resources, and manage the VM guests 130. Multiple instances of the VM guests 130 may share the virtualized hardware resources and each of them may execute programs as if it was a physical machine. Each of the VM guests 130 may have access to a set of physical devices. The VM host 120 may control which physical devices are assigned to each of the VM guests 130, and also implements the devices that are visible to the VM guests 130. If a physical device is exclusively assigned to a single VM guest, it is not available to the other VM guests.
The computer system 100 may assign a unique Internet protocol (IP) address for each of the VM guests 130 manually or automatically. The computer system 100 may create an Address Resolution Protocol (ARP) table that stores and maintains IP addresses of the VM guests 130. The ARP table may further store a VM ID or an MAC address to mark a unique IP address for each VM guest. The VM ID is an identification key to identify a unique VM guest. The VM host 120 assigns the MAC address when the corresponding VM guest is created. Each of the VM guests 130 has a unique MAC address, which can be recognized in a local area network (LAN) or a wide area network (WAN) such as the Internet. The IP address of a VM guest can be acquired from the ARP table according to either the VM ID or the MAC address of the VM guest.
The VM host 120 may establish a connection channel based on transmission control protocol (TCP) between the VM host 120 and each of the VM guests 30. For example, when a connection channel is established between the VM host 120 and the VM guest 1301, the VM host 120 and the VM guest 1301 can communicate with each other.
In
In
In
In
In
When the user wants to reassign one of the USB devices to one of the VM guests as shown in
When the USB device 202 is selected as a target USB device, the VM host 120 may display a host window 330 presenting a list of available VM guest in the host screen 300 of the VM host. In
In
In step S501, the VM host 120 detects a plug event that the USB device 202 is plugged into the computer system 100.
In step S502, the VM host 120 loads the backend driver 204 associated with the USB device 202 in the VM host 120.
In step S503, the VM host 120 selects the VM guest 1302 from among the available VM guests according to the user selection from a user interface.
In step S504, the VM guest 1302 loads the frontend driver 206 associated with the USB device 202 in the VM guest 1302.
In step S505, the VM host 120 establishes a communication connection between the backend driver 204 and the frontend driver 206 of the VM guest 1302.
In step S506, the VM host 120 allocates the control of the USB device 202 to the VM guest 1302 via the communication connection.
In step S601, the VM host 120 detects an unplug event that the USB device 202 is unplugged from the computer system 100.
In step S602, the VM host 120 destroys the communication connection between the backend driver 204 and the frontend driver 206 of the VM guest 1302.
In step S603, the VM guest 1302 unloads the frontend driver 206.
In step S604, the VM host 120 unloads the backend driver 204.
In step S701, the VM host 120 collects all the USB devices attached to the computer system 100, generates a USB device list and displays the USB device list in a first host window of the VM host 120.
In step S702, the VM host 120 selects a target USB device from the USB device list according to the user selection from the first host window.
In step S703, the VM host 120 displays a VM guest list in a second host window of the VM host 120.
In step S704, the VM host 120 selects a target VM guest from the VM guest list according to the user selection from the second host window.
In step S705, the VM host 120 assigns the target USB device to the target VM guest.
It is to be understood, however, that even though numerous characteristics and advantages have been set forth in the foregoing description of embodiments, together with details of the structures and functions of the embodiments, the disclosure is illustrative only and changes may be made in detail, especially in matters of shape, size, and arrangement of parts within the principles of the disclosure to the full extent indicated by the broad general meaning of the terms in which the appended claims are expressed.
Depending on the embodiment, certain steps or methods described may be removed, others may be added, and the sequence of steps may be altered. It is also to be understood that the description and the claims drawn for or in relation to a method may include some indication in reference to certain steps. However, any indication used is only to be viewed for identification purposes and not as a suggestion as to an order for the steps.
Number | Date | Country | Kind |
---|---|---|---|
100105545 | Feb 2011 | TW | national |