Virtual resource creation method and apparatus, electronic device, chip, storage medium, and computer program product
By determining multiple resource configuration options based on resource units on physical graphics cards in the virtualization framework, creating virtual graphics processor devices with different resource sizes for virtual machines, solving the inflexible resource allocation in the existing technology. The problem has achieved flexible resource allocation and the satisfaction of multiple needs.
Patent Information
- Application Number
- PCT/CN2024/110079
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-08-17
- Filing Date
- 2024-08-06
- Publication Date
- 2025-02-20
AI Technical Summary
When creating a virtual graphics processor device (vgpu device) under the virtualization framework, it is impossible to flexibly allocate vgpu devices with different resource sizes to different virtual machines, resulting in inflexible resource allocation and cannot meet the needs of virtual machines for multiple resources. type of demand.
By determining multiple resource configuration options based on resource units on physical graphics cards, a virtual graphics processor device with different resource sizes is created for the virtual machine. The method includes determining the target resource configuration option from multiple resource configuration options based on the virtual resource creation request, and determining the target number of resource units based on the target resource configuration options, and ultimately creating the target virtual graphics processor device.
It realizes the creation of virtual graphics processor devices with different resource sizes for different virtual machines, flexibly allocate vgpu resources, meets the various resources needs of virtual machines, and has good flexibility.
Smart Images

Figure CN2024110079_20022025_PF_FP_ABST
Abstract
Description
Virtual resource creation method and device, electronic device, chip, storage medium, and computer program product
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] The embodiments of the present disclosure are based on Chinese patent application number 202311037854.2, application date August 17, 2023, and application name “Virtual Resource Creation Method and Device, Electronic Device, Chip, Storage Medium” and claim the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into the present disclosure as a reference. Technical Field
[0003] The embodiments of the present disclosure relate to, but are not limited to, the field of computer technology, and in particular to a method and apparatus for creating virtual resources, an electronic device, a chip, a storage medium, and a computer program product. Background Art
[0004] In the virtualization framework of Quick Emulator (QEMU) and Kernel-based Virtual Machine (KVM), after selecting an mdevctl type from the mdevctl type list provided by the manufacturer to create a vGPU device (Virtual Graphics Processing Unit device), you cannot select another mdevctl type to create a different type of vGPU device. You can only create vGPU devices of the same type based on the previously selected mdevctl type. In other words, if a vGPU device has already been created, only vGPU devices of the same type can be created. This makes the resources of the created vGPU device relatively single and inflexible.
[0005] Summary of the Invention
[0006] The embodiments of the present disclosure provide a method and device for creating virtual resources, an electronic device, a chip, a storage medium, and a computer program product.
[0007] An embodiment of the present disclosure provides a virtual resource creation method, comprising: determining a target resource configuration option from a plurality of resource configuration options based on a virtual resource creation request; wherein the resource configuration option is determined based on resource units located on a physical graphics card and supporting a virtual machine to implement image processing functions; determining a target number of the resource units based on the target resource configuration option; creating a target virtual graphics processor device based on the target number of resource units, and running a target virtual machine based on the target virtual graphics processor device.
[0008] An embodiment of the present disclosure provides a virtual resource creation apparatus, comprising: a determination portion configured to determine a target resource configuration option from a plurality of resource configuration options based on a virtual resource creation request; wherein the resource configuration option is determined based on resource units located on a physical graphics card that support a virtual machine to implement image processing functions; the determination portion is configured to determine a target number of the resource units based on the target resource configuration option; and a processing portion is configured to create a target virtual graphics processor device based on the target number of resource units, and run a target virtual machine based on the target virtual graphics processor device.
[0009] An embodiment of the present disclosure provides an electronic device, including a first memory and a first processor, wherein the first memory stores a computer program that can be run on the first processor, and the first processor implements the above method when executing the program.
[0010] An embodiment of the present disclosure provides a chip including a second memory and a second processor, wherein the second memory stores a computer program that can be run on the second processor, and the second processor implements the above method when executing the program.
[0011] An embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the above method is implemented.
[0012] An embodiment of the present disclosure provides a computer program product, including a non-transitory computer-readable storage medium storing a computer program, wherein the computer program implements the above method when read and executed by a computer.
[0013] In the embodiments of the present disclosure, on the one hand, since multiple resource configuration options are determined based on resource units located on a physical graphics card that support a virtual machine to implement image processing functions, and each resource configuration option corresponds to a different number of resource units, multiple virtual graphics processor devices (vGPU devices) with different resource sizes can be created through multiple resource configuration options for use by different virtual machines. The allocated virtual resources (vGPU resources) are diverse, and thus multiple resource configuration options can meet the various resource requirements of virtual machines. On the other hand, the multiple resource configuration options created based on the resource unit are independent of each other and do not restrict each other. Different resource configuration options can be determined from the multiple resource configuration options in sequence to create different virtual GPU devices for use by different virtual machines. That is, if a virtual GPU device has previously been created based on any resource configuration option determined from the multiple resource configuration options, a different virtual GPU device can be created by selecting another resource configuration option from the multiple resource configuration options. In other words, the already created virtual GPU device and its corresponding resource configuration option do not affect the current creation of a new virtual GPU device by determining a new resource configuration option (different from the resource configuration option corresponding to the already created virtual GPU device) from the multiple resource configuration options. In this way, by creating a virtual GPU device for a virtual machine based on the multiple resource configuration options determined from the resource unit, the virtual GPU device is not restricted by the previously created virtual GPU device. This allows for the creation of virtual GPU devices (VGPU devices) with different resource sizes for different virtual machines, flexibly allocating VGPU resources to meet the diverse resource requirements of virtual machines, and provides excellent flexibility.
[0014] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments of the present disclosure will be described below.
[0016] The accompanying drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used to explain the technical solutions of the present disclosure.
[0017] FIG1 is a schematic diagram of an implementation flow of a method for creating a virtual resource provided by an embodiment of the present disclosure;
[0018] FIG2 is a schematic diagram of an implementation flow of another virtual resource creation method provided by an embodiment of the present disclosure;
[0019] FIG3 is a schematic diagram of an implementation flow of another virtual resource creation method provided in an embodiment of the present disclosure;
[0020] FIG4 is a schematic diagram of an implementation flow of a method for creating a virtual resource according to another embodiment of the present disclosure;
[0021] FIG5 is a schematic diagram of a process for creating a vgpu device according to an embodiment of the present disclosure;
[0022] FIG6 is a schematic diagram of another process of creating a vgpu device according to an embodiment of the present disclosure;
[0023] FIG7 is a schematic structural diagram of a virtual resource creation device provided by an embodiment of the present disclosure;
[0024] FIG8 is a schematic diagram of a hardware entity of an electronic device provided by an embodiment of the present disclosure;
[0025] FIG9 is a schematic structural diagram of a chip provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0026] To make the purpose, technical solutions and advantages of the embodiments of the present disclosure more clear, the specific technical solutions of the present disclosure will be described in detail below in conjunction with the drawings in the embodiments of the present disclosure. The following embodiments are used to illustrate the present disclosure, but are not intended to limit the scope of the present disclosure.
[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art in the art of the present disclosure. The terms used herein are only for the purpose of describing the embodiments of the present disclosure and are not intended to limit the present disclosure.
[0028] In the following description, references to “some embodiments,” “this embodiment,” “embodiments of the present disclosure,” and examples, etc., describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.
[0029] The descriptions such as “first, second, third” appearing in the embodiments of the present disclosure are only for illustration and distinction of the described objects. There is no order, nor does it indicate any special limitation on the number of devices in the embodiments of the present disclosure, and cannot constitute any limitation on the embodiments of the present disclosure.
[0030] Under the virtualization framework of qemu and kvm, you can select any mdevctl type from the mdevctl types list provided by the manufacturer to create a vgpu device for the virtual machine to use, so that the virtual machine can reduce the burden of the CPU (Central Processing Unit) in the virtual machine through the created vgpu device; wherein, the mdevctl type describes the resource size of the vgpu device that can be created. During implementation, the resource size in the vgpu device created according to different mdevctl types is different. However, if you select an mdevctl type from the mdevctl type list to create a vgpu device for the virtual machine to use, you cannot select another mdevctl type to create a new vgpu device. You can only create a new vgpu device based on the previously selected mdevctl type. That is, if a vgpu device has already been created, you can only create a vgpu device with the same resource size.
[0031] In related technologies, if a newly created virtual machine wants to have a vgpu device with different resource sizes, it is necessary to select different mdevctl types to create the vgpu device. Specifically:
[0032] 1. Uninstall the vgpu drivers in all running virtual machines or shut down all virtual machines directly;
[0033] 2. Destroy the created vgpu device;
[0034] 3. Reselect a new mdevctl type from the mdevctl type list to create a vgpu device with different resources for the virtual machine to use.
[0035] However, different virtual machines have different business loads. Some virtual machines are heavily loaded and require more VGPU resources, while others are lightly loaded and do not require as many VGPU resources. In related technologies, the VGPU devices allocated to different virtual machines all have the same resource size, making resource allocation very inflexible. For a heavily loaded virtual machine, the virtual machine requires more VGPU resources. If not enough VGPU resources are allocated to the virtual machine, the user experience of the virtual machine will be affected. For a lightly loaded virtual machine, the virtual machine requires fewer VGPU resources. If too many VGPU resources are allocated to the virtual machine, there will be a waste of resources.
[0036] As can be seen from the above, the above solution cannot achieve flexible allocation of vgpu resources. The resource size of the vgpu device allocated to each virtual machine is the same. It is impossible to allocate vgpu devices with different resource sizes to different virtual machines according to different business scenarios.
[0037] To address the above issues, embodiments of the present disclosure provide a method for creating virtual resources that can create different VGPU devices (i.e., virtual graphics processor devices) for use by different virtual machines, thereby meeting the diverse needs of virtual machines for VGPU resources. This method can be applied to various electronic devices, including physical machines such as servers, laptops, and desktop computers.
[0038] FIG1 is a schematic diagram of an implementation flow of a method for creating a virtual resource provided by an embodiment of the present disclosure. As shown in FIG1 , the method may include the following steps 101 to 103, wherein:
[0039] Step 101: determining a target resource configuration option from a plurality of resource configuration options based on a virtual resource creation request; wherein the resource configuration option is determined based on a resource unit located on a physical graphics card and supporting a virtual machine to implement an image processing function;
[0040] Step 102: determining a target number of resource units based on the target resource configuration option;
[0041] Step 103: Create a target virtual graphics processor device based on the target number of resource units, and run a target virtual machine based on the target virtual graphics processor device.
[0042] In the embodiments of the present disclosure, on the one hand, since multiple resource configuration options are determined based on resource units located on a physical graphics card that support a virtual machine to implement image processing functions, and each resource configuration option corresponds to a different number of resource units, multiple virtual graphics processor devices (vGPU devices) with different resource sizes can be created through multiple resource configuration options for use by different virtual machines. The allocated virtual resources (vGPU resources) are diverse, and thus multiple resource configuration options can meet the various resource requirements of virtual machines. On the other hand, the multiple resource configuration options created based on the resource unit are independent of each other and do not restrict each other. Different resource configuration options can be determined from the multiple resource configuration options in sequence to create different virtual GPU devices for use by different virtual machines. That is, if a virtual GPU device has previously been created based on any resource configuration option determined from the multiple resource configuration options, a different virtual GPU device can be created by selecting another resource configuration option from the multiple resource configuration options. In other words, the already created virtual GPU device and its corresponding resource configuration option do not affect the current creation of a new virtual GPU device by determining a new resource configuration option (different from the resource configuration option corresponding to the already created virtual GPU device) from the multiple resource configuration options. In this way, by creating a virtual GPU device for a virtual machine based on the multiple resource configuration options determined from the resource unit, the virtual GPU device is not restricted by the previously created virtual GPU device. This allows for the creation of virtual GPU devices (VGPU devices) with different resource sizes for different virtual machines, flexibly allocating VGPU resources to meet the diverse resource requirements of virtual machines, and provides excellent flexibility.
[0043] The following describes the optional implementation methods and related terms of each of the above steps.
[0044] In step 101, based on a virtual resource creation request, a target resource configuration option is determined from a plurality of resource configuration options; wherein the resource configuration option is determined based on a resource unit located on a physical graphics card and supporting a virtual machine to implement image processing functions.
[0045] Here, the virtual resource creation request is used to create a target virtual graphics processor device to run a target virtual machine based on the target virtual graphics processor device; in short, the virtual resource creation request is used to allocate virtual resources (target virtual graphics processor device) to the target virtual machine. The target virtual machine is a virtual machine with a virtual resource acquisition requirement. The target virtual machine can be a newly created virtual machine on an electronic device, or a newly created virtual machine on another device other than the electronic device. The virtual resources in the virtual graphics processor device (vgpu device) involved in the embodiments of the present disclosure are all from the resources in the physical graphics card. The resource unit is the minimum resource that can be allocated to the virtual machine; the resource unit can be used to divide the resources in the physical graphics card, that is, the resource unit is the granularity of dividing the resources in the physical graphics card; wherein, the resources in the physical graphics card may include but are not limited to video memory resources, computing power resources, etc.
[0046] Multiple resource configuration options are used to create different virtual graphics processor devices for a virtual machine. Each resource configuration option corresponds to a virtual graphics processor device of a certain resource size. For example, a resource configuration option can be an mdevctl type, and multiple mdevctl types can form an mdevctl types list. Because each resource configuration option corresponds to resources of a different size, the virtual graphics processor devices created based on each resource configuration option have resources of different sizes; that is, the virtual graphics processor devices corresponding to each resource configuration option have different resource sizes; that is, each resource configuration option corresponds to a type of virtual graphics processor device, where the type is determined based on the resource size of the virtual graphics processor device.
[0047] The target resource configuration option is any resource configuration option selected from multiple resource configuration options based on the virtual resource creation request. The target resource configuration option is used to create a target virtual graphics processor device for the target virtual machine. Each resource configuration option describes the corresponding computing power resources and video memory resources.
[0048] In one feasible implementation, multiple resource configuration options can be pre-set based on resource units. In this way, the resource configuration options supported by the physical graphics card can be obtained through the mdevctl types command. Then, based on the business needs of the target virtual machine, the target resource configuration option can be determined from the multiple resource configuration options to create a target virtual graphics processor device for the target virtual machine.
[0049] In some embodiments, the resource configuration options may be determined as follows: determining the resource unit based on the minimum resource that supports the virtual machine to implement the image processing function; and determining the resource configuration options based on the resource unit.
[0050] Here, the minimum resources that support the virtual machine to implement image processing functions refer to the virtual machine's minimum demand for resources. Therefore, determining the resource unit based on the minimum resources means determining the resource unit based on the virtual machine's minimum demand for resources. The resource unit determined in this way can guarantee the virtual machine's minimum demand for resources, and then multiple resource configuration options determined based on the resource unit can meet the virtual machine's greater demand for resources.
[0051] It can be understood that determining multiple resource configuration options based on resource units is for the purpose of determining multiple resource configuration options that can be used to create virtual graphics processor devices with different resource sizes based on resource units, so as to create virtual machine resource devices with different resource sizes for different virtual machines through multiple resource configuration options, thereby meeting the diverse resource requirements of virtual machines.
[0052] In one feasible implementation, a resource unit can be determined based on the minimum resource located on the physical graphics card that can implement the image processing functions required by the virtual machine; and multiple resource configuration options can be determined based on the multiple relationship of the resource unit. For example, if the resource unit is a 512MB video memory resource, the multiple resource configuration options may include resource configuration option 1 describing a video memory resource of 1GB, resource configuration option 2 describing a video memory resource of 1.5GB, resource configuration option 3 describing a video memory resource of 2GB, and so on.
[0053] In some embodiments, when the resource unit includes a computing power resource unit, the resource unit can be determined as follows: based on the hardware conditions of the image processor in the physical graphics card, the minimum computing power resource that supports the virtual machine to implement the image processing function is determined; and the minimum computing power resource is used as the computing power resource unit in the resource unit.
[0054] In this way, the image processor can be the GPU in the physical graphics card. Since different virtual machines require different computing resources when processing image-related services, the minimum granularity (minimum computing resources) to which the computing resources of the image processor can be divided can be determined based on the hardware conditions of the image processor in the physical graphics card to meet the various needs of the virtual machine for computing resources; the minimum computing resources can realize the image processing functions required by the virtual machine and cannot be divided any further. The computing resource unit is the minimum computing resource that can be allocated to the virtual machine; directly determining the minimum computing resource that can realize the image processing functions required by the virtual machine as the computing resource unit can ensure the minimum demand of the virtual machine for computing resources. Based on this, by combining different numbers of computing resource units to obtain a variety of different computing resources, the virtual machine's more computing resource needs above the minimum computing resource needs can be met.
[0055] For example, if the total computing power of the GPU is 2000 tflops (trillion floating-point operations per second), and the hardware conditions of the GPU support dividing the total computing power into granularities of 500 tflops, then the minimum computing power is 500 tflops, and the computing power unit is also 500 tflops.
[0056] In other embodiments, when a video memory resource unit is included in a resource unit, the resource unit can be determined as follows: based on the video memory resource usage information of at least one virtual machine, the minimum video memory resource that supports the virtual machine to implement image processing functions is determined; wherein, each piece of video memory resource usage information represents the video memory resource used by the corresponding virtual machine when processing image-related services; based on the minimum video memory resource and the target condition, the video memory resource unit in the resource unit is determined; wherein, the target condition includes: the size of the video memory resource unit is less than or equal to the size of the minimum video memory resource.
[0057] In this way, the video memory resource usage information may include information such as the multiple image-related services processed by the virtual machine, the video memory resources used by each service, and the usage of the video memory resources at different times. The size of the video memory resource unit is less than or equal to the size of the minimum video memory resource. That is, the size of the video memory resource unit can be the same as the size of the minimum video memory resource required by the virtual machine, or it can be smaller than the size of the minimum video memory resource required by the virtual machine. Since the demand for video memory resources by the virtual machine is relatively variable, in order to meet the minimum demand for video memory resources by the virtual machine and reduce the waste of video memory resources, when setting the video memory resource unit, the video memory resource unit can be set to be smaller than the size of the minimum video memory resource.
[0058] In one feasible implementation, since the size of video memory resources is generally a power of 2, to facilitate allocation of video memory resources, the size of a video memory resource unit can be set to a power of 2. The target conditions in this case are: the size of the video memory resource unit is less than or equal to the size of the minimum video memory resource, and the size of the video memory resource unit is a power of 2. In this case, the size of the video memory resource unit must not only be less than or equal to the size of the minimum video memory resource, but must also be a power of 2. For example, a video memory resource unit can be set to 512M (megabytes), in which case the size of the video memory resource unit is 2 to the power of 9; in another example, a video memory resource unit can be set to 1G (gigabytes), where 1G = 1024M, in which case the size of the video memory resource unit is 2 to the power of 10.
[0059] It can be understood that the reason for setting the target condition that the size of the video memory resource unit is less than or equal to the size of the minimum video memory resource and the size of the video memory resource unit is a power of 2 is that: on the one hand, the virtual machine has less demand for video memory resources when processing image-related services. Therefore, in order to reduce the waste of video memory resources, the size of the video memory resource unit is not larger than the size of the minimum video memory resource; on the other hand, the size of video memory resources in electronic devices is generally a power of 2. Therefore, in order to facilitate the subsequent division of the video memory resources of the physical graphics card, the size of the video memory resource unit is set to a power of 2; thus, the video memory resource unit not only reduces the waste of video memory resources, but also ensures the minimum demand of the virtual machine for video memory resources. Based on this, by combining different numbers of video memory resource units to obtain a variety of different video memory resources, the virtual machine's demand for more video memory resources beyond the demand for the minimum video memory resources is met.
[0060] It should be noted that the target condition is not limited to the size of the video memory resource unit being no greater than the size of the minimum video memory resource and the size of the video memory resource unit being a power of 2. The target condition can also be expanded based on actual business scenarios and hardware conditions. For example, it can be added that the size of the video memory resource unit cannot be set to 0.
[0061] In some embodiments, when the resource unit includes a computing power resource unit and a graphics memory resource unit, multiple resource configuration options can be determined as follows: based on the total computing power resources of the computing power resource unit and the image processor in the physical graphics card, multiple computing power resource options are determined; based on the total graphics memory resources of the graphics memory resource unit and the physical graphics card, multiple graphics memory resource options are determined; based on each of the computing power resource options and each of the graphics memory resource options, the multiple resource configuration options are determined.
[0062] In this way, the total computing power resources of the image processor in the physical graphics card may be the total computing power resources of the GPU in the physical graphics card; the total video memory resources of the physical graphics card may be the total video memory resources of the video memory of the physical graphics card.
[0063] It can be understood that multiple computing power resource options and multiple video memory resource options are first determined, and then multiple resource configuration options are determined based on each computing power resource option and each video memory resource option to obtain all combination relationships between computing power resources and video memory resources in the physical graphics card. Based on each combination relationship, multiple resource configuration options are determined, and all resource combinations of the physical graphics card are determined, which facilitates the subsequent creation of multiple virtual graphics processor devices with different resource sizes.
[0064] In a feasible implementation, the operation of obtaining the total computing power resources and the total video memory resources can be as follows: loading the GPU host driver (the driver of the physical graphics card) in the host operating system (Host Operating System, host os), initializing the physical graphics card during the driver loading process of the physical graphics card, and obtaining the total video memory resources in the physical graphics card and the total video memory resources of the GPU (graphics processing unit) of the physical graphics card.
[0065] In one feasible implementation, the operation of determining multiple computing resource options may include determining multiple computing resource options based on the size of the computing resource unit and the size of the total computing resource. For example, if the size of the computing resource unit is 500 tflops and the size of the total computing resource is 2000 tflops, the multiple computing resource options may be: 500 tflops, 1000 tflops, 1500 tflops, and 2000 tflops.
[0066] In one feasible implementation, the operation of determining multiple memory resource options may include determining multiple memory resource options based on the size of the memory resource unit and the size of the total memory resource. For example, if the size of the memory resource unit is 512M and the size of the total computing power resource is 2G, the multiple computing power resource options may be: 512M, 1G, 1.5G, and 2G.
[0067] In one feasible implementation, the operation of determining multiple resource configuration options may be: determining multiple resource configuration options based on multiple memory resource options and multiple computing power resource options. For example, if the multiple memory resource options are 512M and 1G, and the multiple computing power resource options are 500tflops and 1000tflops, then the multiple resource configuration options determined may be: resource configuration option 1 including 512M memory resources and 500tflops computing power resources, resource configuration option 2 including 512M memory resources and 1000tflops computing power resources, resource configuration option 3 including 1G memory resources and 500tflops computing power resources, and resource configuration option 4 including 1G memory resources and 1000tflops computing power resources.
[0068] In some embodiments, after the computing power resource unit is determined, the computing power resource pool may be determined as follows: based on the computing power resource units in the resource units, the total computing power resources of the graphics processor in the physical graphics card are divided to obtain at least one first computing power resource unit, and the computing power resource pool is constructed based on each of the first computing power resource units;
[0069] Similarly, after determining the video memory resource unit, the video memory resource pool can be determined as follows: based on the video memory resource units in the resource units, the total video memory resources of the physical graphics card are divided to obtain at least one first video memory resource unit, and the video memory resource pool is constructed based on each of the first video memory resource units.
[0070] In this way, the total computing power resources of the image processor in the physical graphics card are divided based on the computing power resource units, and the computing power resource units are used as the division criteria to divide the total computing power resources to obtain at least one first computing power resource unit, and then a computing power resource pool is constructed based on the at least one first computing power resource unit, wherein the size of each first computing power resource unit is the same as the size of the computing power resource unit. The total video memory resources of the image processor in the physical graphics card are divided based on the video memory resource units, and the video memory resource units are used as the division criteria to divide the total video memory resources to obtain at least one first video memory resource unit, and then a video memory resource pool is constructed based on the at least one first video memory resource unit, wherein the size of each first video memory resource unit is the same as the size of the video memory resource unit.
[0071] It can be understood that the construction of the computing power resource pool and the video memory resource pool is to facilitate the management of the computing power resources and video memory resources in the physical graphics card, and to prepare for the subsequent creation of different virtual graphics processor devices for use by different virtual machines. Then, by combining multiple computing power resource units in the computing power resource pool and multiple video memory resource units in the video memory resource pool, more resources can be allocated to virtual machines with greater resource requirements, and fewer resources can be allocated to virtual machines with fewer resource requirements. There will be no waste of resources caused by allocating the same resources to virtual machines with different resource requirements in related technologies.
[0072] In step 102, a target number of resource units is determined based on the target resource configuration option.
[0073] In this way, each resource configuration option describes the resource size of the corresponding virtual GPU device. For example, the target resource configuration option may include target computing power resources and target video memory resources. Then, the target virtual GPU device created based on the target resource configuration option includes target computing power resources and target video memory resources.
[0074] In some embodiments, when the target configuration options include target computing resources and target video memory resources, the target number of resource units may be determined as follows: based on the target computing resources, at least one target first computing resource unit is determined from at least one first computing resource unit in a computing resource pool; wherein the sum of the sizes of each of the target first computing resource units matches the size of the target computing resource;
[0075] Then, based on the target video memory resource, at least one target first video memory resource unit is determined from at least one first video memory resource unit in the video memory resource pool; wherein the sum of the sizes of each of the target first video memory resource units matches the size of the target video memory resource; and the at least one target first computing power resource unit and the at least one target first video memory resource unit are used as the target number of resource units.
[0076] Thus, the target number of resource units is at least one resource unit determined based on the target resource configuration option; the target number of resource units may include at least one target first computing power resource unit and / or at least one target first graphics memory resource unit. The at least one target first computing power resource unit is at least one first computing power resource unit selected from the computing power resource pool based on the target computing power resource. The at least one target first graphics memory resource unit is at least one first graphics memory resource unit selected from the graphics memory resource pool based on the target graphics memory resource.
[0077] It can be understood that the sum of the sizes of each target first computing power resource unit and the size of the target computing power resource match means that the sum of the sizes of at least one target first computing power resource unit determined from the computing power resource pool is approximately equal to the size of the target computing power resource; for example, if the size of the target computing power resource is 1000tflops, the size of each first computing power resource unit is 500tflops, and a total of 2 target first computing power resource units are required, then the sum of the sizes of these 2 target first computing power resource units is 1000tflops. Similarly, the sum of the sizes of each target first video memory resource unit and the size of the target video memory resource match means that the sum of the sizes of at least one target first video memory resource unit determined from the video memory resource pool is approximately equal to the size of the target video memory resource; for example, if the target video memory resource is 2GB, the size of each first video memory resource unit is 512MB, and a total of 4 target first video memory resource units are required, then the sum of the sizes of these 4 target first video memory resource units is 2GB.
[0078] Specifically, in some embodiments, at least one target first computing resource unit may be determined as follows: based on the state of each first computing resource unit in the computing resource pool, at least one second computing resource unit is determined from each first computing resource unit, and based on the target computing resource, the at least one target first computing resource unit is determined from the at least one second computing resource unit;
[0079] Accordingly, at least one target first graphics memory resource unit can be determined as follows: based on the status of each first graphics memory resource unit in the graphics memory resource pool, at least one second graphics memory resource unit is determined from each first graphics memory resource unit; based on the target graphics memory resource, the at least one target first graphics memory resource unit is determined from the at least one second graphics memory resource unit.
[0080] Here, the state of the first computing resource unit may include, but is not limited to, a used state, an unused state, etc.; the state of the first graphics memory resource unit may include, but is not limited to, a used state, an unused state, etc. The at least one second computing resource unit is at least one unused first computing resource unit determined from the computing resource pool; the at least one second graphics memory resource unit is at least one unused first graphics memory resource unit determined from the graphics memory resource pool.
[0081] It can be understood that marking the status of the first computing power resource unit and the status of the first graphics memory resource unit is to facilitate the acquisition of currently unused first computing power resource units and unused first graphics memory resource units, and further determine at least one target first computing power resource unit required for currently creating a target virtual graphics processor device from the unused first computing power resource units, and determine at least one target first graphics memory resource unit required for currently creating a target virtual graphics processor device from the unused first graphics memory resource units.
[0082] In a feasible implementation method, based on the status of each first computing resource unit in the computing resource pool, it is possible to first determine that multiple unused first computing resource units in the computing resource pool will be used as a second computing resource unit, and then determine at least one target first computing resource unit from the multiple second computing resource units according to random, frequency of use, custom, sequential and other selection methods.
[0083] In a feasible implementation method, based on the status of each first video memory resource unit in the video memory resource pool, it is possible to first determine that multiple unused first video memory resource units in the video memory resource pool will be used as a second video memory resource unit, and then determine at least one target first video memory resource unit from the multiple second video memory resource units according to a selection method such as random, frequency of use, custom, or sequential.
[0084] In step 103, a target virtual graphics processor device is created based on the target number of resource units, and a target virtual machine is run based on the target virtual graphics processor device.
[0085] The resource size of the target virtual graphics processor device is different from the resource size of at least one created virtual graphics processor device.
[0086] In this way, if the resource size of the target virtual GPU device differs from the resource size of at least one already created virtual GPU device, this indicates that a virtual GPU device has already been created based on the resource configuration options. In this case, the target resource configuration options can be determined from multiple resource configuration options to create the target virtual GPU device for the target virtual machine. That is, the already created virtual GPU device and its corresponding resource configuration options do not affect the current process of determining new resource configuration options (target resource configuration options, which differ from the resource configuration options corresponding to the already created virtual GPU device) from multiple resource configuration options to create a new virtual GPU device (target virtual GPU device). In this way, by creating a virtual GPU device for a virtual machine based on multiple resource configuration options determined based on resource units, the virtual machine is not constrained by the previously created virtual GPU devices. This allows for the creation of virtual GPU devices (vGPU devices) with different resource sizes for different virtual machines, flexibly allocating vGPU resources and meeting the diverse resource requirements of virtual machines with excellent flexibility. Creating the target virtual GPU device based on the target number of resource units actually creates the target virtual GPU device for the target virtual machine based on the resource size described in the target resource configuration options.
[0087] In one feasible implementation, after determining a target resource configuration option from a plurality of resource configuration options, a target number of resource units may be determined based on the target resource configuration option, and a target virtual graphics processor device may be created based on the target number of resource units. Specifically, the target virtual graphics processor device may be created based on the target number of resource units through the mdev framework.
[0088] In some embodiments, when the target virtual graphics processor device includes at least one target first graphics memory resource unit, the target virtual machine can be run based on the target virtual graphics processor device as follows: the target virtual machine is started; and the at least one target first graphics memory resource unit is mapped to the target virtual machine using a preset memory mapping interface, so as to run the target virtual machine based on the target virtual graphics processor device.
[0089] In this way, the preset memory mapping interface may be a memory mapped (mmap) interface of a user-mode device driver (Virtual Function IO, VFIO) framework.
[0090] In a feasible implementation, a virtual machine may be started through qemu. When the virtual machine is started, the mmap interface of the VFIO framework is called to map the video memory resources of the target virtual graphics processor device to the target virtual machine.
[0091] Specifically, in some embodiments, at least one target first graphics memory resource unit may be mapped to a target virtual machine in the following manner: when the at least one target first graphics memory resource unit is a plurality of continuous first graphics memory resource units, the at least one target first graphics memory resource unit is mapped as a whole to the target virtual machine so as to run the target virtual machine based on the target virtual graphics processor device; and when the at least one target first graphics memory resource unit is a plurality of discontinuous first graphics memory resource units, the at least one target first graphics memory resource unit is mapped segmented to the target virtual machine so as to run the target virtual machine based on the target virtual graphics processor device.
[0092] It is understood that, if at least one target first graphics memory resource unit is a continuous plurality of first graphics memory resource units, mapping the at least one target first graphics memory resource unit as a whole to the target virtual machine can improve the mapping rate. Because the target first graphics memory resource units used when creating the target virtual graphics processor device may be discontinuous, it is necessary to segmentally map the discontinuous target first graphics memory resource units to ensure mapping accuracy and reliability.
[0093] The present disclosure further provides a method for creating virtual resources, which is applied to a scenario where a virtual graphics processor device including computing resources and video memory resources is allocated to a virtual machine. As shown in FIG2 , the method includes the following steps 201 to 211, wherein:
[0094] Step 201: Determine computing resource units and memory resource units.
[0095] Step 202: Determine multiple computing resource options based on the computing resource unit and the total computing resource of the graphics processor in the physical graphics card.
[0096] Step 203: Determine multiple video memory resource options based on the video memory resource unit and the total video memory resources of the physical graphics card.
[0097] Step 204: Determine multiple resource configuration options based on each computing power resource option and each graphics memory resource option.
[0098] Step 205 : Divide the total computing power resources of the graphics processor in the physical graphics card based on the computing power resource units to obtain at least one first computing power resource unit, and construct a computing power resource pool based on each first computing power resource unit.
[0099] Step 206 : Divide the total video memory resources of the physical graphics card based on the video memory resource units to obtain at least one first video memory resource unit, and construct a video memory resource pool based on each first video memory resource unit.
[0100] Step 207: Determine a target resource configuration option from a plurality of resource configuration options based on the virtual resource creation request.
[0101] Step 208: Based on the target computing resource in the target resource configuration option, determine at least one target first computing resource unit from the at least one first computing resource unit in the computing resource pool.
[0102] The sum of the sizes of each target first computing resource unit matches the size of the target computing resource.
[0103] Step 209 : Based on the target graphics memory resource in the target resource configuration option, determine at least one target first graphics memory resource unit from the at least one first graphics memory resource unit in the graphics memory resource pool.
[0104] The sum of the sizes of each target first video memory resource unit matches the size of the target video memory resource.
[0105] Step 210: Create a target virtual graphics processor device based on each target first computing resource unit and each target first graphics memory resource unit.
[0106] Step 211 : transparently transmit the target virtual graphics processor device to the target virtual machine, so as to run the target virtual machine based on the target virtual graphics processor device.
[0107] The resource size of the target virtual graphics processor device is different from the resource size of at least one created virtual graphics processor device.
[0108] The present disclosure further provides a method for creating virtual resources, which is applied to a scenario where a virtual graphics processor device including only video memory resources is allocated to a virtual machine. As shown in FIG3 , the method includes the following steps 301 to 308, wherein:
[0109] Step 301: Determine a video memory resource unit.
[0110] Step 302: Determine multiple video memory resource options based on the video memory resource unit and the total video memory resources of the physical graphics card.
[0111] Step 303: Determine multiple resource configuration options based on each video memory resource option.
[0112] Step 304 : Divide the total video memory resources of the physical graphics card based on the video memory resource units to obtain at least one first video memory resource unit, and construct a video memory resource pool based on each first video memory resource unit.
[0113] Step 305: Determine a target resource configuration option from a plurality of resource configuration options based on the virtual resource creation request.
[0114] Step 306 : Based on the target graphics memory resource in the target resource configuration option, determine at least one target first graphics memory resource unit from the at least one first graphics memory resource unit in the graphics memory resource pool.
[0115] The sum of the sizes of each target first video memory resource unit matches the size of the target video memory resource.
[0116] Step 307: Create a target virtual graphics processor device based on the at least one target first graphics memory resource unit.
[0117] Step 308: transparently transmit the target virtual graphics processor device to the target virtual machine, so as to run the target virtual machine based on the target virtual graphics processor device.
[0118] The resource size of the target virtual graphics processor device is different from the resource size of at least one created virtual graphics processor device.
[0119] The present disclosure further provides a method for creating virtual resources, which is applied to a scenario where a virtual graphics processor device including only computing resources is allocated to a virtual machine. As shown in FIG4 , the method includes the following steps 401 to 408 , wherein:
[0120] Step 401: Determine the computing resource unit.
[0121] Step 402: Determine multiple computing resource options based on the computing resource unit and the total computing resource of the physical graphics card.
[0122] Step 403: Determine multiple resource configuration options based on each computing resource option.
[0123] Step 404 : Divide the total computing power resources of the physical graphics card based on the computing power resource units to obtain at least one first computing power resource unit, and construct a computing power resource pool based on each first computing power resource unit.
[0124] Step 405: Determine a target resource configuration option from a plurality of resource configuration options based on the virtual resource creation request.
[0125] Step 406: Based on the target computing resource in the target resource configuration option, determine at least one target first computing resource unit from the at least one first computing resource unit in the computing resource pool.
[0126] The sum of the sizes of each target first computing resource unit matches the size of the target computing resource.
[0127] Step 407: Create a target virtual graphics processor device based on the at least one target first computing resource unit.
[0128] Step 408: transparently transmit the target virtual graphics processor device to the target virtual machine, so as to run the target virtual machine based on the target virtual graphics processor device.
[0129] The resource size of the target virtual graphics processor device is different from the resource size of at least one created virtual graphics processor device.
[0130] The following describes an exemplary application of the embodiment of the present disclosure in a practical application scenario. In the practical application scenario, the virtual graphics processor device is referred to as a vgpu device.
[0131] 1. Load the GPU host driver (physical graphics card driver) on the Linux system.
[0132] a) When loading the GPU host driver to initialize the GPU device, the GPU computing power resources (total computing power resources) and total video memory resources of the physical graphics card are obtained, and the computing power resource pool and video memory resource pool of the physical graphics card are created respectively to manage the resources in the physical graphics card and prepare for the subsequent creation of the vGPU device;
[0133] i. Create a video memory resource pool: The video memory resource unit setting conditions are: less than or equal to the minimum video memory resource required by the virtual machine; the size of the video memory resource unit is a power of 2. This can also be set based on business scenarios and hardware conditions. For example, the total video memory resources (video memory) can be divided into 256MB video memory resource units, and the first divided video memory resource unit is placed in the video memory resource pool to form a display resource pool. Each first video memory resource unit in the video memory resource pool is marked as used or unused based on resource usage.
[0134] ii. Create a computing resource pool: Determine computing resource units based on the minimum computing resource required to complete the GPU function in the virtual machine. Divide the total computing resource of the physical graphics card by computing resource units, and place the first computing resource units in the divided computing resource pool to form a computing resource pool. Each first computing resource unit in the computing resource pool will be marked as used or unused based on resource usage.
[0135] 2. Create a vgpu device according to mdevctl type on the Linux system and assign the vgpu device to the virtual machine;
[0136] a) Create a vgpu device with a specified mdevctl type (e.g. 1GB of video memory resources, 500tflops of computing power resources);
[0137] i. The GPU host driver extracts the video memory resources required by the vGPU device (at least one target first video memory resource) from the video memory resource pool managed by the GPU host driver based on the video memory resources (target video memory resources) described in the selected mdevctl type, and allocates them to the vGPU device. For example, it allocates 1GB of video memory resources from the video memory resource pool to the vGPU device and saves the relevant information about the allocated video memory resources.
[0138] ii. The GPU host driver extracts the computing resources required by the vGPU device (at least one target first computing resource) from the computing resource pool based on the computing resources (target computing resources) described in the selected mdevctl type, and allocates them to the vGPU device.
[0139] b) After creating the vgpu device, start the target virtual machine and transparently transmit the vgpu device to the target virtual machine;
[0140] i. When qemu starts a virtual machine, it calls the mmap interface of the VFIO framework to map the vGPU device's video memory resources (for example, memory bar 2). This interface is ultimately transferred to the GPU host driver. The GPU host driver determines whether the video memory resources previously allocated to the vGPU device are multiple consecutive first video memory resource units. If the video memory resources allocated to the vGPU device are not multiple consecutive first video memory resource units, the vGPU device's video memory resources are divided into several consecutive memory segments and mapped to the target virtual machine in segments. If the video memory resources allocated to the vGPU device are continuous, the vGPU device's video memory resources are mapped to the target virtual machine as a whole.
[0141] ii. The computing resources in the vgpu device can be directly used by the virtual machine.
[0142] iii. The virtual machine starts successfully, loads the GPU guest driver in the virtual machine, and uses the vGPU for encoding, decoding, and rendering in the virtual machine.
[0143] c) Create a new vgpu device with a different mdevctl type (e.g. 2GB of video memory resources, 500tflops of computing power resources);
[0144] i. Take out the video memory resources corresponding to different mdevctl types from the video memory resource pool and assign them to the new vgpu device, and save the relevant information of the allocated video memory resources;
[0145] ii. Take computing resources corresponding to different mdevctl types from the computing resource pool and assign them to the new vgpu device;
[0146] d) After creating the new vgpu device, start a new virtual machine and transparently transfer the new vgpu device to the new virtual machine.
[0147] FIG5 is a schematic diagram of a process for creating a vgpu device according to an embodiment of the present disclosure. Specifically, as shown in FIG5 , the operation of creating a vgpu device may include the following steps 501 to 507:
[0148] Step 501: Load the GPU host driver (physical graphics card driver).
[0149] Step 502: During the initialization of the GPU device, the total computing power resources (GPU computing power resources) and total video memory resources of the physical graphics card are obtained.
[0150] If the total computing power resources and the total video memory resources are successfully obtained, the process proceeds to step 503 ; if the GPU device initialization fails and / or the total computing power resources and the total video memory resources are not successfully obtained, the process proceeds to step 507 .
[0151] Step 503: Create a graphics memory resource pool and a computing power resource pool to manage resources in the physical graphics card.
[0152] If the memory resource pool and the computing power resource pool are created successfully, the process proceeds to step 504 ; if the memory resource pool and the computing power resource pool are created unsuccessfully, the process proceeds to step 507 .
[0153] Step 504: Create a vgpu device through the mdev framework interface.
[0154] Step 505 , determining whether the vgpu device is created successfully. If the vgpu device fails to be created, proceed to step 507 ; if the vgpu device is created successfully, proceed to step 506 .
[0155] Step 506: transparently transmit the vgpu device to the virtual machine.
[0156] Step 507: Driver loading fails.
[0157] FIG6 is a schematic diagram of another process of creating a vgpu device according to an embodiment of the present disclosure. Specifically, as shown in FIG6 , the operation of creating a vgpu device may include the following steps 601 to 606:
[0158] Step 601: Determine a target mdevctl type from the mdevctl types list.
[0159] Step 602: Select the video memory resources corresponding to the target mdevctl type from the video memory resource pool, and select the computing power resources corresponding to the target mdevctl type from the computing power resource pool.
[0160] If the video memory resources and computing power resources corresponding to the target mdevctl type are successfully selected, the process proceeds to step 603 ; if the video memory resources and computing power resources corresponding to the target mdevctl type are not successfully selected, the process proceeds to step 606 .
[0161] Step 603: Determine whether the conventional hardware initialization of the vgpu device is successful.
[0162] Hardware initialization includes but is not limited to: interrupt initialization, register configuration, etc. If the hardware initialization is successful, proceed to step 604; if the hardware initialization fails, proceed to step 606.
[0163] Step 604: Create a vgpu device based on the selected video memory resources and computing power resources.
[0164] Step 605: Start the virtual machine through qemu and transparently pass the vgpu device to the virtual machine for use.
[0165] Step 606: Failed to create the vgpu device.
[0166] The virtual resource creation method provided by the embodiment of the present disclosure pre-divides the total computing power resources of a physical graphics card into multiple computing power resource units, divides the total video memory resources of the physical graphics card into multiple video memory resource units, and constructs a computing power resource pool based on the multiple computing power resource units, and constructs multiple video memory resource pools based on the multiple video memory resource units; constructs multiple resource configuration options based on the multiple computing power resource units and the multiple video memory resource units; thus, different vgpu devices can be created for virtual machines at any time through the multiple resource configuration options, without pausing the business running on the virtual machine, without shutting down the virtual machine, and without destroying the already created vgpu device, and a vgpu device of a different mdevctl type can be recreated. Vgpu devices with different resource sizes can be created for different virtual machines and transparently transmitted to different virtual machines for use; for example, a virtual machine with a heavy business load can transparently transmit a vgpu device with more GPU resources, while a virtual machine with a light business load can transparently transmit a vgpu device with fewer resources. In this way, different vgpu devices are created for different virtual machines according to their business needs, and resource waste caused by excessive or insufficient resource allocation can be avoided, and the user experience will not be affected by insufficient resource allocation.
[0167] It should be noted that although the steps of the method of the present disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all steps must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps; or steps in different embodiments may be combined to form a new technical solution.
[0168] Based on the above embodiments, the present disclosure provides a virtual resource creation device. FIG7 is a structural diagram of a virtual resource creation device provided by the present disclosure. As shown in FIG7 , the virtual resource creation device 70 includes: a determination part 701 and a processing part 702, wherein:
[0169] The determining portion 701 is configured to determine a target resource configuration option from a plurality of resource configuration options based on the virtual resource creation request; wherein the resource configuration option is determined based on a resource unit located on a physical graphics card that supports the virtual machine to implement image processing functions;
[0170] The determining part 701 is configured to determine a target number of resource units based on the target resource configuration option;
[0171] The processing part 702 is configured to create a target virtual graphics processor device based on the target number of resource units, and run a target virtual machine based on the target virtual graphics processor device.
[0172] In some embodiments, the determining part 701 is further configured to: determine the resource unit based on the minimum resource supporting the virtual machine to implement the image processing function; and determine the resource configuration option based on the resource unit.
[0173] In some embodiments, the resource unit includes a computing power resource unit; the determination part 701 is further configured to: determine the minimum computing power resource that supports the virtual machine to implement the image processing function based on the hardware conditions of the image processor in the physical graphics card; and use the minimum computing power resource as the computing power resource unit in the resource unit.
[0174] In some embodiments, the resource unit includes a graphics memory resource unit; the determination part 701 is further configured to: determine the minimum graphics memory resources that support the virtual machine to implement image processing functions based on the graphics memory resource usage information of at least one virtual machine; wherein each of the graphics memory resource usage information represents the graphics memory resources used by the corresponding virtual machine when processing image-related services; based on the minimum graphics memory resources and target conditions, determine the graphics memory resource unit in the resource unit; wherein the target condition includes: the size of the graphics memory resource unit is less than or equal to the size of the minimum graphics memory resource.
[0175] In some embodiments, the resource unit includes a computing power resource unit and a video memory resource unit; the processing part 702 is further configured to: determine a plurality of computing power resource options based on the total computing power resources of the computing power resource unit and the image processor in the physical graphics card; determine a plurality of video memory resource options based on the total video memory resources of the video memory resource unit and the physical graphics card; and determine the resource configuration option based on each of the computing power resource options and each of the video memory resource options.
[0176] In some embodiments, the target resource configuration options include target computing power resources and target video memory resources; the processing part 702 is further configured to: based on the target computing power resources, determine at least one target first computing power resource unit from at least one first computing power resource unit in the computing power resource pool; wherein the sum of the sizes of each of the target first computing power resource units matches the size of the target computing power resources; based on the target video memory resources, determine at least one target first video memory resource unit from at least one first video memory resource unit in the video memory resource pool; wherein the sum of the sizes of each of the target first video memory resource units matches the size of the target video memory resources; and use the at least one target first computing power resource unit and the at least one target first video memory resource unit as the target number of resource units.
[0177] In some embodiments, the processing portion 702 is further configured to: determine at least one second computing resource unit from each of the first computing resource units based on a state of each of the first computing resource units in the computing resource pool, and determine the at least one target first computing resource unit from the at least one second computing resource unit based on the target computing resource;
[0178] Accordingly, the processing part 702 is further configured to: determine at least one second video memory resource unit from each first video memory resource unit based on the state of each first video memory resource unit in the video memory resource pool; and determine at least one target first video memory resource unit from the at least one second video memory resource unit based on the target video memory resource.
[0179] In some embodiments, the resource units include computing power resource units and video memory resource units; the processing part 702 is further configured to: divide the total computing power resources of the image processor in the physical graphics card based on the computing power resource units in the resource units to obtain at least one first computing power resource unit, and construct the computing power resource pool based on each of the first computing power resource units; divide the total video memory resources of the physical graphics card based on the video memory resource units in the resource units to obtain at least one first video memory resource unit, and construct the video memory resource pool based on each of the first video memory resource units.
[0180] In some embodiments, the target virtual graphics processor device includes at least one target first graphics memory resource unit; the processing part 702 is further configured to: if the at least one target first graphics memory resource unit is a plurality of consecutive first graphics memory resource units, map the at least one target first graphics memory resource unit as a whole to the target virtual machine, so as to run the target virtual machine based on the target virtual graphics processor device; if the at least one target first graphics memory resource unit is a plurality of discontinuous first graphics memory resource units, map the at least one target first graphics memory resource unit in segments to the target virtual machine, so as to run the target virtual machine based on the target virtual graphics processor device.
[0181] In some embodiments, the resource size of the target virtual GPU device is different from the resource size of at least one created virtual GPU device.
[0182] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present disclosure, please refer to the description of the method embodiment of the present disclosure for understanding.
[0183] It should be noted that the division of modules in the virtual resource creation device shown in Figure 7 in the embodiment of the present disclosure is schematic and is only a logical functional division. There may be other division methods in actual implementation. In addition, the functional units in the various embodiments of the present disclosure can be integrated into a processing unit, or can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units. It can also be implemented in the form of a combination of software and hardware.
[0184] It should be noted that, in the embodiments of the present disclosure, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present disclosure is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present disclosure. The aforementioned storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiments of the present disclosure are not limited to any specific combination of hardware and software.
[0185] An embodiment of the present disclosure provides an electronic device. FIG8 is a schematic diagram of the hardware entity of the electronic device provided by the embodiment of the present disclosure. As shown in FIG8 , the electronic device 80 includes a first memory 801 and a first processor 802. The first memory 801 stores a computer program that can be run on the first processor 802. When the first processor 802 executes the program, the method described in the embodiment of the present disclosure is implemented.
[0186] It should be noted that the first memory 801 is configured to store instructions and applications executable by the first processor 802, and can also cache data to be processed or processed by various modules in the first processor 802 and the electronic device 80 (for example, image data, audio data, voice communication data and video communication data), which can be implemented through flash memory (FLASH) or random access memory (RAM).
[0187] In the embodiment of the present disclosure, the electronic device 80 can be various types of devices with information processing capabilities during the implementation of the vgpu device creation method described in the embodiment of the present disclosure. For example, the electronic device 80 can include a mobile phone, a tablet computer, a desktop computer, a laptop computer, a host computer, etc.
[0188] An embodiment of the present disclosure provides a chip. FIG9 is a schematic structural diagram of the chip provided by the embodiment of the present disclosure. As shown in FIG9 , the chip 90 includes a second memory 901 and a second processor 902. The second memory 901 stores a computer program that can be run on the second processor 902. When the second processor 902 executes the program, the method described in the embodiment of the present disclosure is implemented.
[0189] An embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method provided in the above embodiment are implemented.
[0190] An embodiment of the present disclosure provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the steps of the method provided in the above method embodiment.
[0191] It should be noted that the descriptions of the above storage medium, chip, and device embodiments are similar to the descriptions of the above method embodiments and have similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium, chip, and device embodiments of the present disclosure, please refer to the descriptions of the method embodiments of the present disclosure for understanding.
[0192] It should be understood that "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present disclosure. Therefore, "in one embodiment" or "in an embodiment" or "in some embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present disclosure, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure. The serial numbers of the embodiments of the present disclosure are for description only and do not represent the advantages and disadvantages of the embodiments. The above description of the various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other. For the sake of brevity, they will not be repeated here.
[0193] The term "and / or" in this article is only a description of the association relationship between associated objects, indicating that there can be three relationships. For example, object A and / or object B can mean: object A exists alone, object A and object B exist at the same time, and object B exists alone.
[0194] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0195] In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be electrical, mechanical or other forms.
[0196] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed across multiple network units; some or all of the modules may be selected according to actual needs to achieve the purpose of this embodiment.
[0197] In addition, all functional modules in the embodiments of the present disclosure may be integrated into one processing unit, or each module may be a separate unit, or two or more modules may be integrated into one unit; the above-mentioned integrated modules may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0198] Those skilled in the art will understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, and other media that can store program codes.
[0199] Alternatively, if the above-mentioned integrated unit of the present disclosure is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present disclosure, or the part that contributes to the relevant technology, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks or optical disks.
[0200] The methods disclosed in the several method embodiments provided in this disclosure can be arbitrarily combined without conflict to obtain new method embodiments.
[0201] The features disclosed in the several product embodiments provided in this disclosure can be arbitrarily combined without conflict to obtain new product embodiments.
[0202] The features disclosed in several method or device embodiments provided in this disclosure may be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0203] The above is only an embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the present disclosure, and they should all be covered by the protection scope of the present disclosure. Industrial Applicability
[0204] The embodiments of the present disclosure provide a virtual resource creation method and apparatus, electronic device, chip, storage medium, and computer program product; the virtual resource creation method includes: determining a target resource configuration option from a plurality of resource configuration options based on a virtual resource creation request; wherein the resource configuration option is determined based on a resource unit located on a physical graphics card that supports a virtual machine to implement image processing functions; determining a target number of resource units based on the target resource configuration option; creating a target virtual graphics processor device based on the target number of resource units, and running a target virtual machine based on the target virtual graphics processor device. The above scheme is not restricted by the virtual graphics processor devices that have been created, and realizes the creation of virtual graphics processor devices (vGPU devices) with different resource sizes for different virtual machines, flexibly allocating vGPU resources, and meeting the various resource requirements of virtual machines, with good flexibility.
Claims
1. A method for creating a virtual resource, the method comprising: Based on the virtual resource creation request, determining a target resource configuration option from a plurality of resource configuration options; wherein the resource configuration option is determined based on a resource unit located on a physical graphics card and supporting the virtual machine to implement an image processing function; Determining a target number of the resource units based on the target resource configuration option; A target virtual graphics processor device is created based on the target number of resource units, and a target virtual machine is run based on the target virtual graphics processor device.
2. The virtual resource creation method according to claim 1, further comprising: Determining the resource unit based on the minimum resource supporting the virtual machine to implement the image processing function; Based on the resource units, the resource configuration options are determined.
3. The virtual resource creation method according to claim 2, wherein the resource unit includes a computing power resource unit; The determining of the resource unit based on the minimum resource supporting the virtual machine to implement the image processing function includes: Determine the minimum computing power resources that support the virtual machine to implement the image processing function based on the hardware conditions of the image processor in the physical graphics card; The minimum computing power resource is used as the computing power resource unit in the resource unit.
4. The virtual resource creation method according to claim 2, wherein the resource unit includes a video memory resource unit; The determining of the resource unit based on the minimum resource supporting the virtual machine to implement the image processing function includes: Determine the minimum video memory resource that supports the virtual machine to implement the image processing function based on the video memory resource usage information of at least one virtual machine; wherein each of the video memory resource usage information represents the video memory resource used by the corresponding virtual machine when processing image-related services; Based on the minimum video memory resource and the target condition, a video memory resource unit in the resource unit is determined; wherein the target condition includes: the size of the video memory resource unit is less than or equal to the size of the minimum video memory resource.
5. The virtual resource creation method according to any one of claims 2 to 4, wherein the resource unit includes a computing resource unit and a video memory resource unit; The determining the resource configuration option based on the resource unit includes: Determining a plurality of computing resource options based on the total computing resource of the computing resource unit and the image processor in the physical graphics card; Determining a plurality of video memory resource options based on the video memory resource unit and the total video memory resource of the physical graphics card; Based on each of the computing power resource options and each of the graphics memory resource options, the resource configuration option is determined.
6. The virtual resource creation method according to any one of claims 1 to 5, wherein the target resource configuration options include target computing resources and target video memory resources; The determining a target number of resource units based on the target resource configuration option includes: Based on the target computing power resource, determine at least one target first computing power resource unit from at least one first computing power resource unit in the computing power resource pool; wherein the sum of the sizes of each of the target first computing power resource units matches the size of the target computing power resource; Based on the target video memory resource, determining at least one target first video memory resource unit from at least one first video memory resource unit in the video memory resource pool; wherein the sum of the sizes of each of the target first video memory resource units matches the size of the target video memory resource; The at least one target first computing power resource unit and the at least one target first graphics memory resource unit are taken as the target number of resource units.
7. The method for creating virtual resources according to claim 6, The determining, based on the target computing resource, at least one target first computing resource unit from at least one first computing resource unit in the computing resource pool includes: Based on the state of each of the first computing resource units in the computing resource pool, determine at least one second computing resource unit from each of the first computing resource units, and based on the target computing resource, determine the at least one target first computing resource unit from the at least one second computing resource unit; The step of determining at least one first video memory resource unit from a video memory resource pool based on the target video memory resource. a target first video memory resource unit, comprising: determining at least one second video memory resource unit from each of the first video memory resource units based on a state of each of the first video memory resource units in the video memory resource pool; Based on the target video memory resource, the at least one target first video memory resource unit is determined from the at least one second video memory resource unit.
8. The method for creating virtual resources according to claim 6, wherein the resource unit includes a computing resource unit and a video memory resource unit; the method further comprises: Based on the computing power resource units in the resource units, the total computing power resources of the image processor in the physical graphics card are divided to obtain at least one first computing power resource unit, and the computing power resource pool is constructed based on each of the first computing power resource units; Based on the video memory resource units in the resource units, the total video memory resources of the physical graphics card are divided to obtain at least one first video memory resource unit, and the video memory resource pool is constructed based on each of the first video memory resource units.
9. The virtual resource creation method according to any one of claims 1 to 8, wherein the target virtual graphics processor device comprises at least one target first video memory resource unit; The step of running a target virtual machine based on the target virtual graphics processor device includes: In a case where the at least one target first graphics memory resource unit is a plurality of continuous first graphics memory resource units, mapping the at least one target first graphics memory resource unit as a whole to the target virtual machine, so as to run the target virtual machine based on the target virtual graphics processor device; In the case that the at least one target first graphics memory resource unit is a plurality of discontinuous first graphics memory resource units, the at least one target first graphics memory resource unit is segmented and mapped to the target virtual machine, so as to run the target virtual machine based on the target virtual graphics processor device. 10 . The method for creating virtual resources according to claim 1 , wherein a resource size of the target virtual GPU device is different from a resource size of at least one created virtual GPU device.
11. A virtual resource creation device, the virtual resource creation device comprising: The determination part is configured to determine a target resource configuration option from a plurality of resource configuration options based on the virtual resource creation request; wherein the resource configuration option is determined based on a resource unit located on a physical graphics card and supporting the virtual machine to implement an image processing function; The determining part is configured to determine a target number of the resource units based on the target resource configuration option; The processing part is configured to create a target virtual graphics processor device based on the target number of resource units, and run a target virtual machine based on the target virtual graphics processor device.
12. An electronic device comprising a first memory and a first processor, wherein the first memory stores a computer program executable on the first processor, and the first processor implements the method according to any one of claims 1 to 10 when executing the program.
13. A chip, comprising a second memory and a second processor, wherein the second memory stores a computer program executable on the second processor, and the second processor implements the method according to any one of claims 1 to 10 when executing the program.
14. A storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1 to 10.
15. A computer program product, comprising a non-transitory computer-readable storage medium storing a computer program, wherein when the computer program is read and executed by a computer, the method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Graphics processing resource allocation method and device, equipment and storage medium
CN113342534A
Method for creating flexible allocation of multi-specification vGPU virtual machines based on an OpenStack platform
CN113672344A
Virtual resource configuration method and device for graphic display, equipment and medium
CN116089090A
Virtual resource creation method and device, electronic equipment, chip and storage medium
CN116755843A
Hardware accelerator device management method and apparatus, and electronic device and storage medium
WO2023000673A1