1. Technical Field
Embodiments of the present disclosure relate to virtualization technology, and more particularly to a method for creating virtual machines in hosts.
2. Description of Related Art
Virtual machines (VM) are software implementations that create one or more VMs in a host. A guest operating system (OS) is a virtualized environment, multiple guest OSes can co-exist and run independently on the same host. In a process of establishing a virtualization environment, a large number of VMs may be created. However, creation of the VMs is often done by allocating configuration information (such as hardware resources and network resources) to each VM one by one, which is repetitive and time-consuming. Therefore, there is room for improvement in the art.
The present disclosure, including the accompanying drawings, is illustrated by way of examples and not by way of limitation. 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. One or more software instructions in the modules may be embedded in firmware, such as in an erasable programmable read only memory (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.
In one embodiment, the DHCP server 3 includes a DHCP agent 30, and each host 1 includes a host agent 40. The system 10 creates one or more VM templates 20, and stores the one or more templates 20 in the storage device 2. A VM template 20 is a file that contains hardware configuration information for creating one type of VMs 50. When a request to create a virtual machine (VM) 50 is issued by a host 1, the system 10 selects a VM template 20 from the storage device 2, copies hardware configuration information recorded in the VM template 20, and creates the VM 50 in the host 1 according to the copied information. Furthermore, the system 10 reqests the DHCP server 3 to allocate an IP address to the VM 50 via the DHCP agent 30, and assigns the IP address allocated by the DHCP server 3 to the VM 50 via the host agent 40.
As shown in
In step S10, the template creation module 11 creates a VM template 20. In one embodiment, creation of the VM template 20 includes setting hardware configuration information for creating a VM 50. The hardware configuration information includes CPU information, memory information, hard disk information and network card information. For example, the CPU information includes a number of CPU cores to be allocated to the VM 50, the memory information includes a capacity of memory space to be allocated to the VM 50, the hard disk information includes a capacity of hard disk space to be allocated to the VM 50, and the network card information includes a network card type and a number of network cards to be allocated to the VM 50. VM templates 20 with different hardware configuration information may be created by the VM template creation module 11 and stored into the storage device 2.
In step S20, when the system 10 receives a request (e.g., the request may be sent by a host 1) of creating a set number of VMs 50 and a hardware specification of the number of VMs 50, the copy module 12 selects a VM template 20 from the storage device 2 based on the request. Furthermore, the copy module 12 generates the set number of copies of hardware configuration information from the VM template 20, and sets a media access control (MAC) address for a network card of each the VMs 50. In one embodiment, the set number is a natural number, such as one or more. For example, if three VMs 50 with the hardware configuration information of “one CPU core, 2G memory, 100G hard disk, and one network card” are requested and a corresponding VM template 20 is selected, the copy module 12 generates three copies of the hardware configuration information recorded in the selected VM template for the three VMs 50, and sets a MAC address for the network card of each of the three VMs 50.
In step S30, the communication module 13 sends the copies of hardware configuration information to a host agent 40 of the host 1, and controls the host agent 40 to create the VMs 50 in the host 1. For example, the three VMs 50 with the hardware configuration information “one CPU core, 2G memory, 100G hard disk, and one network card” are created in the host 1.
In step S40, the communication module 13 sends the MAC address of each created VM 50 to the DHCP server 3, and obtains an IP address allocated to the created VM 50 by registering the MAC address of the created VM 50 to the DHCP agent 30 of the DHCP server 3. Each IP address allocated to the created VM 50 by the DHCP server 3 is associated with the MAC address of the created VM 50.
In step S50, the communication module 13 sends the IP addresses allocated to the created VMs 50 to the host agent 40 of the host 1, and controls the host agent 40 to assign each of the IP addresses to a corresponding created VM 50. As mentioned above, each IP address allocated to a created VM 50 is associated with the MAC address of the created VM 50, so that the host agent 40 may determine a MAC address of a VM 50 that should be assigned the IP address according to an association between the IP address and the MAC address, and searches the VM 50 in the host 1 according to the MAC address. In addition, the communication module 13 may further control operations of the created VMs 50 via the host agent 40. For example, the operations may include deleting, shutting down, or restarting a VM 50.
Although certain disclosed embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
101150614 | Dec 2012 | TW | national |