A hard disk mounting method, system, device and medium
By generating and parsing configuration files in the cloud platform to mount vhost-user hard disks and extending the virtualization engine to parse vhost-user devices, the problem of libvirt being unable to create vhost-user devices is solved, and efficient I/O performance of virtual machines is achieved.
Patent Information
- Application Number
- CN202111237017.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-24
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2041-10-24
AI Technical Summary
The cloud platform's virtualization engine, libvirt, does not have the ability to create vhost-user devices, which prevents cloud hosts from using vhost-user technology to improve I/O performance.
By generating a configuration file containing preset parameters and using the virtual machine engine to parse and generate commands, the cloud host can mount vhost-user type hard disks, expand the cloud platform's virtualization engine to parse vhost-user devices, and connect to the vhost-user server when creating virtual machines through the Hypervisor.
This enables cloud hosts to obtain vhost-user accelerated I/O devices, improving the I/O performance of virtual machines.
Smart Images

Figure CN114064202B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of cloud platforms, and in particular to a hard disk mounting method, system, device and storage medium. BACKGROUND
[0002] We know that in the host linux-based KVM virtualization scheme, IO is basically implemented by QEMU simulation. In the initial implementation scheme, since the VM Context needs to be switched every time I / O, the switching cost is relatively high, so virtio is born, which uses front-end and back-end drivers and I / O buffer queues to reduce this consumption.
[0003] In short, virtio introduces the technology of front-end and back-end, and connects the front-end and back-end through a virtual queue to achieve high-performance IO virtualization.
[0004] With the development of cloud computing, the demand of users for the I / O performance of virtual machines will not stop, so on the basis of virtio, the vhost-user technology is developed, which is an improvement of virtio.
[0005] Because virtio uses virtual machine queues to achieve efficient transmission of front-end and back-end, the number of VM Exit is reduced; the front-end is responsible for I / O requests, and the back-end is responsible for I / O device simulation. If the I / O device simulation efficiency is low, the virtual queue under the virtio architecture will not be able to perform its due performance. The idea of vhost-user is to unload the device simulation work of the back-end from the QEMU layer to other processes dedicated to device acceleration (such as SPDK, DPDK, etc.) on the basis of virtio. This not only reduces the burden of QEMU, but also significantly improves the I / O performance of virtual machines.
[0006] However, the current cloud platform virtualization engine libvirt does not have the ability to create a vhost-user device, and the cloud host created through the cloud platform cannot take advantage of the performance improvement brought by vhost-user. SUMMARY
[0007] Therefore, in order to overcome at least one aspect of the above problems, the embodiments of the present application propose a hard disk mounting method, comprising the following steps:
[0008] In response to receiving a hard disk mounting request, a configuration file including a first preset parameter and a second preset parameter is generated;
[0009] The configuration file is sent to a virtual machine engine;
[0010] The configuration file is parsed by using the virtual machine engine, and a corresponding command is generated according to the first preset parameter and the second preset parameter;
[0011] The command is sent to the cloud host to make the cloud host mount a corresponding hard disk according to the command.
[0012] In some embodiments, the configuration file is parsed by using the virtual machine engine, and the parsing further includes:
[0013] The type of the hard disk to be mounted is determined according to the first preset parameter.
[0014] In some embodiments, the configuration file is parsed by using the virtual machine engine, and the parsing further includes:
[0015] The interface file address of the hard disk to be mounted is determined according to the second preset parameter.
[0016] In some embodiments, the command is sent to the cloud host to make the cloud host mount a corresponding hard disk according to the command, and the sending further includes:
[0017] In response to the value of the first preset parameter carried in the command being a first preset value, parameter information of a first process of the cloud host is sent to a process corresponding to the hard disk to be mounted according to a second preset parameter in the command, so that the process corresponding to the hard disk to be mounted is initialized according to the parameter information.
[0018] In some embodiments, the parameter information of the first process of the cloud host is sent to the process corresponding to the hard disk to be mounted according to the second preset parameter in the command, and the sending further includes:
[0019] The parameter information including the address information of the virtual queue is sent to the process corresponding to the hard disk to be mounted by using the first process in the cloud host.
[0020] Based on the same inventive concept, according to another aspect of the present application, embodiments of the present application also provide a hard disk mounting system, comprising:
[0021] The receiving module is configured to generate a configuration file including a first preset parameter and a second preset parameter in response to receiving a hard disk mounting request;
[0022] The first sending module is configured to send the configuration file to a virtual machine engine;
[0023] The engine module is configured to parse the configuration file by using the virtual machine engine, and generate a corresponding command according to the first preset parameter and the second preset parameter;
[0024] The second sending module is configured to send the command to the cloud host to make the cloud host mount the corresponding hard disk according to the command.
[0025] In some embodiments, the engine module is further configured to:
[0026] determine the type of the hard disk to be mounted according to the first preset parameter.
[0027] In some embodiments, the engine module is further configured to
[0028] determine the interface file address of the hard disk to be mounted according to the second preset parameter.
[0029] Based on the same inventive concept, according to another aspect of the present application, embodiments of the present application further provide a computer device, comprising:
[0030] at least one processor; and
[0031] a memory, the memory storing a computer program capable of running on the processor, characterized in that the processor executes the program to execute the steps of any of the hard disk mounting methods described above.
[0032] Based on the same inventive concept, according to another aspect of the present application, embodiments of the present application further provide a computer readable storage medium, the computer readable storage medium storing a computer program, the computer program being executed by a processor to execute the steps of any of the hard disk mounting methods described above.
[0033] The present application has one of the following beneficial technical effects: the scheme provided by the present application expands the virtualization engine of the cloud platform, so that it can analyze the I / O device with the vhost-user type, then connects the vhost-user server when creating the virtual machine through the Hypervisor, so that the virtual machine can obtain the vhost-user accelerated I / O device. BRIEF DESCRIPTION OF DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other embodiments can also be obtained from these drawings without creative labor.
[0035] Figure 1 The flowchart of the hard disk mounting method provided by the embodiments of the present application is shown in the figure;
[0036] Figure 2A flow chart of a hard disk mounting method provided for an embodiment of the present application is shown in the figure;
[0037] Figure 3 A structural schematic diagram of a hard disk mounting system provided for an embodiment of the present application is shown in the figure;
[0038] Figure 4 A structural schematic diagram of a computer device provided for an embodiment of the present application is shown in the figure;
[0039] Figure 5 A structural schematic diagram of a computer readable storage medium provided for an embodiment of the present application is shown in the figure. DETAILED DESCRIPTION
[0040] In order to make the objects, technical solutions and advantages of the present application clearer, the embodiments of the present application are further described in detail below with reference to the accompanying drawings.
[0041] It should be noted that all the expressions of "first" and "second" in the embodiments of the present application are used to distinguish two same-named different entities or different parameters, and it can be seen that "first" and "second" are only used for the convenience of description, and should not be understood as a limitation on the embodiments of the present application, and the subsequent embodiments will not be described one by one.
[0042] According to one aspect of the present application, an embodiment of the present application provides a hard disk mounting method, as shown in the figure, which can include the following steps: Figure 1
[0043] S1, in response to receiving a hard disk mounting request, generating a configuration file including a first preset parameter and a second preset parameter;
[0044] S2, sending the configuration file to a virtual machine engine;
[0045] S3, using the virtual machine engine to parse the configuration file and generating a corresponding command according to the first preset parameter and the second preset parameter;
[0046] S4, sending the command to a cloud host to make the cloud host mount a corresponding hard disk according to the command.
[0047] The scheme provided by the present application can realize mounting of a vhost-user type I / O device for a cloud host through a cloud platform, thereby providing high-performance I / O services for the cloud host by virtue of the technical advantages of vhost-user.
[0048] In some embodiments, using the virtual machine engine to parse the configuration file further includes:
[0049] According to the first preset parameter, determining the type of the hard disk to be mounted.
[0050] In some embodiments, parsing the configuration file by the virtual machine engine further comprises:
[0051] According to the second preset parameter, determining an interface file address of the hard disk to be mounted.
[0052] Specifically, as shown in Figure 2 When the cloud platform receives a request to mount a hard disk for a cloud host, i.e., a virtual machine (which can be created by a Hypervisor, such as QEMU / KVM), the cloud platform can send an XML with a vhost-user hard disk request to the virtual machine engine.
[0053] In some embodiments, the XML format can be:
[0054] <disk type=’vhost’device=’disk’>
[0055] <source sock=’ path to vhost-user-server vhost.0’>
[0056] <target dev=’vda’bus=’virtio’ / >
[0057] <address type=’pci’domain=’0x0000’bus=’0x00’slot=’0x03’function=’0x0’>< / address>
[0058]
[0059] The type attribute of disk (the first preset parameter) indicates the type of the hard disk to be mounted for the virtual machine, for example, when it is vhost, it indicates that a vhost-user type hard disk is mounted for the cloud host, and the sock (the second preset parameter) of source indicates the socket file address exposed by the vhost-user server. The bus of target is set to virtio, indicating that the virtio driver is used to read and write the hard disk in the virtual machine.
[0060] It should be noted that when the vhost-user type hard disk is created, a corresponding vhost-user server is generated, and the process exposes a corresponding socket file address. Because the vhost-user technology essentially unloads the device simulation in QEMU / KVM to other processes (vhost-user server), we need to deploy the vhost-user server service. Taking SPDK as an example, after installing SPDK, by executing vhost-S / path / to / vhost-user-server-m 0x1, a socket file vhost.0 can be found in the / path / to / vhost-user-server / directory.
[0061] In some embodiments, sending the command to the cloud host to make the cloud host mount the corresponding hard disk according to the command further comprises:
[0062] In response to the value of the first preset parameter carried in the command being a first preset value, sending parameter information of a first process of the cloud host to a process corresponding to the hard disk to be mounted according to a second preset parameter in the command, so that the process corresponding to the hard disk to be mounted is initialized according to the parameter information.
[0063] Specifically, when the virtual machine engine libvirt receives the XML and parses it, it generates command parameters that can be understood by QEMU / KVM and sends them to the first process (for example, vhost driver) of QEMU / KVM.
[0064] For example, the virtualization engine libvirt can parse the above XML content, and then convert it into the corresponding QEMU command line: / usr / libexec / qemu-kvm…-chardev socket, id=chr-vu-virtio-disk0, path= / path / to / vhost-user-server / vhost.0-device vhost-user-blk-pci, chardev=chr-vu-virtio-disk0, bus=pci.0, addr=0x03.
[0065] In some embodiments, sending the parameter information of the first process of the cloud host to the process corresponding to the hard disk to be mounted according to the second preset parameter in the command further comprises:
[0066] Sending parameter information including address information of a virtual queue to the process corresponding to the hard disk to be mounted by using the first process in the cloud host.
[0067] Specifically, the vhost driver process of QEMU / KVM can inform the vhost-user server of address information about the virtual queue virtqueue according to the socket file address exposed by the vhost-user server, so that the vhost-user server is initialized, and then the virtual machine is started. The virtual machine performs I / O data plane operations with the vhost-user server through the virtiqueue.
[0068] Among them, the virtual queue virtqueue informs one or more buffers that have been added to the queue, and in turn, the device can interrupt the driver to report the used buffer. The correct method is provided by the underlying driver to dispatch the actual notification.
[0069] The scheme provided by the application extends the virtualization engine of the cloud platform, so that it can analyze the I / O device with the vhost-user type, and then through the Hypervisor to create a virtual machine, the virtual machine can obtain the vhost-user accelerated I / O device by connecting the vhost-user server.
[0070] Based on the same inventive concept, according to another aspect of the application, embodiments of the application also provide a hard disk mounting system 400, as shown, comprising: Figure 3
[0071] The receiving module 401 is configured to generate a configuration file including a first preset parameter and a second preset parameter in response to receiving a hard disk mounting request;
[0072] The first sending module 402 is configured to send the configuration file to the virtual machine engine;
[0073] The engine module 403 is configured to parse the configuration file by using the virtual machine engine and generate a corresponding command according to the first preset parameter and the second preset parameter;
[0074] The second sending module 404 is configured to send the command to the cloud host to make the cloud host mount the corresponding hard disk according to the command.
[0075] In some embodiments, the engine module 403 is further configured to:
[0076] Determine the type of the hard disk to be mounted according to the first preset parameter.
[0077] In some embodiments, the engine module 403 is further configured to
[0078] Determine the interface file address of the hard disk to be mounted according to the second preset parameter. In some embodiments, parsing the configuration file by using the virtual machine engine further includes:
[0079] Determine the type of the hard disk to be mounted according to the first preset parameter.
[0080] In some embodiments, parsing the configuration file by using the virtual machine engine further includes:
[0081] Determine the interface file address of the hard disk to be mounted according to the second preset parameter.
[0082] In some embodiments, sending the command to the cloud host to make the cloud host mount the corresponding hard disk according to the command further comprises:
[0083] In response to the value of the first preset parameter carried in the command being a first preset value, sending parameter information of a first process of the cloud host to a process corresponding to the hard disk to be mounted according to a second preset parameter in the command, so that the process corresponding to the hard disk to be mounted is initialized according to the parameter information.
[0084] In some embodiments, sending the parameter information of the first process of the cloud host to the process corresponding to the hard disk to be mounted according to the second preset parameter in the command further comprises:
[0085] Sending the parameter information including the address information of the virtual queue to the process corresponding to the hard disk to be mounted by the first process in the cloud host.
[0086] The scheme provided by the application expands the virtualization engine of the cloud platform, so that it can analyze the I / O device with the vhost-user type, and then connects the vhost-user server when the virtual machine is created by the Hypervisor, so that the virtual machine can obtain the vhost-user accelerated I / O device.
[0087] Based on the same inventive concept, according to another aspect of the application, as Figure 4 shown, the embodiments of the application also provide a computer device 501, which comprises:
[0088] at least one processor 520; and
[0089] a memory 510, the memory 510 storing a computer program 511 executable on the processor, and the processor 520 executes the following steps when executing the program:
[0090] S1, in response to receiving a hard disk mounting request, generating a configuration file including a first preset parameter and a second preset parameter;
[0091] S2, sending the configuration file to a virtual machine engine;
[0092] S3, analyzing the configuration file by the virtual machine engine and generating a corresponding command according to the first preset parameter and the second preset parameter;
[0093] S4, sending the command to the cloud host to make the cloud host mount the corresponding hard disk according to the command.
[0094] In some embodiments, analyzing the configuration file by the virtual machine engine further comprises:
[0095] determine the type of the hard disk to be mounted according to the first preset parameter.
[0096] In some embodiments, the parsing of the configuration file by the virtual machine engine further includes:
[0097] determine the interface file address of the hard disk to be mounted according to the second preset parameter.
[0098] In some embodiments, the sending of the command to the cloud host to make the cloud host mount the corresponding hard disk according to the command further includes:
[0099] In response to the value of the first preset parameter carried in the command being a first preset value, the parameter information of the first process of the cloud host is sent to the process corresponding to the hard disk to be mounted according to the second preset parameter in the command, so that the process corresponding to the hard disk to be mounted is initialized according to the parameter information.
[0100] In some embodiments, the sending of the parameter information of the first process of the cloud host to the process corresponding to the hard disk to be mounted according to the second preset parameter in the command further includes:
[0101] The parameter information including the address information of the virtual queue is sent to the process corresponding to the hard disk to be mounted by the first process in the cloud host.
[0102] The scheme provided by the application expands the virtualization engine of the cloud platform, so that it can parse the I / O device with the vhost-user type, and then connects the vhost-user server when the virtual machine is created by the Hypervisor, so that the virtual machine can obtain the I / O device accelerated by the vhost-user.
[0103] Based on the same inventive concept, according to another aspect of the application, as shown in the accompanying drawings, Figure 5 The embodiment of the application also provides a computer readable storage medium 601, which stores computer program instructions 610, and the computer program instructions 610 are executed by a processor to perform the following steps:
[0104] S1, in response to receiving a hard disk mounting request, generating a configuration file including a first preset parameter and a second preset parameter;
[0105] S2, sending the configuration file to a virtual machine engine;
[0106] S3, parsing the configuration file by the virtual machine engine and generating a corresponding command according to the first preset parameter and the second preset parameter;
[0107] S4, sending the command to the cloud host to make the cloud host mount the corresponding hard disk according to the command.
[0108] In some embodiments, parsing the configuration file by using the virtual machine engine further includes:
[0109] According to the first preset parameter, the type of the hard disk to be mounted is determined.
[0110] In some embodiments, parsing the configuration file by using the virtual machine engine further includes:
[0111] According to the second preset parameter, the interface file address of the hard disk to be mounted is determined.
[0112] In some embodiments, sending the command to the cloud host to make the cloud host mount the corresponding hard disk according to the command further includes:
[0113] In response to the value of the first preset parameter carried in the command being a first preset value, parameter information of a first process of the cloud host is sent to a process corresponding to the hard disk to be mounted according to a second preset parameter in the command, so that the process corresponding to the hard disk to be mounted is initialized according to the parameter information.
[0114] In some embodiments, sending the parameter information of the first process of the cloud host to the process corresponding to the hard disk to be mounted according to the second preset parameter in the command further includes:
[0115] The parameter information including the address information of the virtual queue is sent to the process corresponding to the hard disk to be mounted by using the first process in the cloud host.
[0116] The scheme provided by the application can expand the virtualization engine of the cloud platform, enable the virtualization engine to parse the I / O device with the vhost-user type, and then connect the vhost-user server when the virtual machine is created by the Hypervisor, so that the virtual machine can obtain the I / O device accelerated by the vhost-user.
[0117] Finally, it should be noted that those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by a computer program to instruct related hardware to complete, and the program can be stored in a computer readable storage medium. When the program is executed, it can include the processes of the above-mentioned embodiments.
[0118] In addition, it should be understood that the computer readable storage medium (for example, the memory) herein can be a volatile memory or a non-volatile memory, or can include both volatile memory and non-volatile memory.
[0119] Those skilled in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein can be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans can implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present embodiments.
[0120] The above are exemplary embodiments disclosed by the present embodiments, but it should be noted that various changes and modifications can be made without departing from the scope of the present embodiments disclosed by the claims. The functions, steps and / or actions of the method claims described above need not be performed in any particular order. Furthermore, although elements of the present embodiments disclosed can be described or claimed in individual forms, unless expressly limited to the singular, these elements can also be understood to be implemented in a plurality of forms. The use of "including," "comprising," or "having" and variations thereof herein is meant to encompass the items listed thereafter and equivalents thereof as well as additional items.
[0121] It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0122] The above-mentioned embodiment number of the present embodiments is only for description, not representing the advantages or disadvantages of the embodiments.
[0123] Those skilled in the art can understand that all or part of the steps of the above-mentioned embodiments can be completed by hardware, or can be completed by programs instructing relevant hardware, and the programs can be stored in a computer readable storage medium, such as a read-only memory, a magnetic disk or an optical disk.
[0124] It should be understood by those of ordinary skill in the art that the above discussion of any of the embodiments is merely exemplary and is not intended to suggest that the scope of the present embodiments disclosed (including the claims) is limited to these examples; the embodiments or technical features in different embodiments can also be combined, and there are many other changes of the above aspects of the present embodiments. In order to be brief, they are not provided in detail. Therefore, any omission, modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present embodiments should be included in the protection scope of the present embodiments.
Claims
1. A hard disk mounting method characterized by comprising: The method comprises the following steps: In response to receiving a hard disk mounting request, a configuration file including a first preset parameter and a second preset parameter is generated; The configuration file is sent to a virtual machine engine; The configuration file is parsed by the virtual machine engine, and corresponding commands are generated according to the first preset parameter and the second preset parameter; The commands are sent to a cloud host to make the cloud host mount corresponding hard disks according to the commands; The configuration file is parsed by the virtual machine engine, further comprising: The interface file address of the hard disk to be mounted is determined according to the second preset parameter; The commands are sent to the cloud host to make the cloud host mount corresponding hard disks according to the commands, further comprising: In response to the value of the first preset parameter carried in the commands being a first preset value, the parameter information of the first process of the cloud host is sent to the process corresponding to the hard disk to be mounted according to the second preset parameter in the commands, so that the process corresponding to the hard disk to be mounted is initialized according to the parameter information.
2. The method of claim 1, wherein, The configuration file is parsed by the virtual machine engine, further comprising: The type of the hard disk to be mounted is determined according to the first preset parameter.
3. The method of claim 1, wherein, Further comprising: The parameter information including the address information of the virtual queue is sent to the process corresponding to the hard disk to be mounted by the first process in the cloud host. Comprising:
4. A hard disk mounting system characterized by comprising: A receiving module configured to generate a configuration file including a first preset parameter and a second preset parameter in response to receiving a hard disk mounting request; A first sending module configured to send the configuration file to a virtual machine engine; An engine module configured to parse the configuration file by the virtual machine engine and generate corresponding commands according to the first preset parameter and the second preset parameter; A second sending module configured to send the commands to a cloud host to make the cloud host mount corresponding hard disks according to the commands; The engine module is further configured to: Determine the interface file address of the hard disk to be mounted according to the second preset parameter; The second sending module is further configured to: In response to the value of the first preset parameter carried in the commands being a first preset value, the parameter information of the first process of the cloud host is sent to the process corresponding to the hard disk to be mounted according to the second preset parameter in the commands, so that the process corresponding to the hard disk to be mounted is initialized according to the parameter information. The engine module is further configured to:
5. The system of claim 4, wherein, Determine the type of the hard disk to be mounted according to the first preset parameter.
6. A computer device, comprising: At least one processor; And A memory storing a computer program executable on the processor, characterized in that the processor executes the program to execute the steps of the method of any one of claims 1-3. The computer program is executed by the processor to execute the steps of the method of any one of claims 1-3.
7. A computer-readable storage medium storing a computer program, wherein the computer program comprises the following steps of: receiving a request for a resource from a client; determining whether the client is authorized to access the resource; and if the client is authorized to access the resource, providing the resource to the client.
Citation Information
Patent Citations
A method and system for creating a mirror image by a cloud platform
CN109634718A
Method and system for mounting virtual disk on cloud physical machine, equipment and medium
CN113504872A