File read-write method and device, electronic equipment and storage medium

By implementing read and write operations to the target image file in QEMU, the problem of excessive size of the microkernel mirror system is solved, ensuring the normal startup and operation of the QEMU.

CN119690574APending Publication Date: 2025-03-25BEIJING CO WHEELS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311234533.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-22
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

In the prior art, the microkernel mirroring system started by QEMU needs to package the image files of other file systems into the mirror of the microkernel FS service process, resulting in a huge size of the mirroring system, which may cause the QEMU to be unable to start.

Method used

By sending a read and write request for the target image file to the fast emulator QEMU, the QEMU parses and performs read and write operations to realize the read and write of the target image file stored in the host, avoiding packaging it into the image of the microkernel FS service process.

Benefits of technology

The microkernel FS service process directly reads and writes other file system image files stored in the host, without increasing the volume of the microkernel image system to ensure that the QEMU can be started normally.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690574A_ABST
    Figure CN119690574A_ABST
Patent Text Reader

Abstract

The invention provides a file reading and writing method and device, electronic equipment and a storage medium. The method comprises the following steps: sending a first read-write request for a target mirror image file to a quick emulator QEMU; in response to a read-write success identifier fed back by the QEMU, receiving a read-write result sent by the QEMU; the read-write success identifier indicates that the QEMU successfully performs read-write operation on a target mirror image file in the host machine according to the first read-write request, and the read-write result is a result obtained by performing read-write operation on the target mirror image file in the host machine by the QEMU according to the first read-write request. According to the microkernel FS service process disclosed by the invention, the first read-write request for the target mirror image file stored in the host machine is sent to the QEMU, so that the read-write operation of the microkernel FS service process on the target mirror image file stored in the host machine is realized through the QEMU by utilizing the reading capability of the QEMU on the mirror image file of the host machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of microkernel systems based on a fast emulator QEMU, and in particular to a file reading and writing method and device, an electronic device, and a storage medium. Background Art

[0002] Quick Emulator (QEMU) is a simulation software that can implement a virtual machine on a host machine, such as a microkernel image system with a microkernel Micro kernel as the core.

[0003] In the related art, the microkernel image system started by QEMU is formed by linking the microkernel image and the images compiled by the microkernel file system FS (File System) service process, the microkernel network NET service process, and the microkernel application APP service process. Among them, the microkernel FS service process includes the support of the root file system and other file systems. The root file system only needs to provide the most basic file service, and the amount of data is very small, so the image file of the root file system in the host can be packaged into the image of the microkernel FS service process, and then the microkernel FS service process can directly read and write the image file of the root file system. Other file systems, such as ext4, btrfs, xfs, etc., have complex logic and large data volume. If the image files of other file systems in the host are also packaged into the image of the microkernel FS service process, the volume of the microkernel image system will be huge, and then due to the limitation of the host memory, it may directly cause the QEMU to be unable to start the microkernel image system.

[0004] In order to overcome the above defects, the microkernel FS service process is required to directly read and write image files of other file systems stored in the host machine without packaging the image files of other file systems in the host machine into the image of the microkernel FS service process. Summary of the invention

[0005] The present disclosure provides a file reading and writing method, device, electronic device and storage medium.

[0006] According to a first aspect of the present disclosure, a file reading and writing method is provided, comprising:

[0007] Sending a first read / write request for a target image file to a fast emulator QEMU; the target image file refers to an image file of other file systems in a host machine except a root file system in a microkernel file system service process, and the microkernel file system service process is started by the QEMU;

[0008] In response to the read / write success flag fed back by the QEMU, the read / write result sent by the QEMU is received; the read / write success flag indicates that the QEMU successfully performs a read / write operation on the target image file in the host machine according to the first read / write request, and the read / write result refers to a result obtained by the QEMU performing a read / write operation on the target image file in the host machine according to the first read / write request.

[0009] In some embodiments of the present disclosure, before sending the first read / write request for the target image file to the fast emulator QEMU, the method further includes:

[0010] Obtaining a second read / write request for the target image file, and storing the second read / write request in a cache queue; the cache queue is used to store the read / write requests in the order of the read / write requests for the target image file;

[0011] Traversing at least one third read / write request for the target image file stored in the cache queue, and judging whether the second read / write request can be merged with at least one third read / write request according to the second read / write request and the read / write parameters of each of the third read / write requests; the read / write parameters include a read / write direction, a read / write address, and a read / write length;

[0012] In response to the judgment result being yes, the second read / write request is merged with at least one of the third read / write requests to generate a first read / write request.

[0013] In some embodiments of the present disclosure, judging whether the second read / write request can be merged with at least one of the third read / write requests according to the read / write parameters of the second read / write request and each of the third read / write requests includes:

[0014] Determine a third read / write request having the same read / write direction as the second read / write request among all the third read / write requests;

[0015] Whether the first read / write request can be merged with at least one of the second read / write requests is determined based on whether there is a third read / write request with the same read / write direction as the second read / write request and a third read / write request with a continuous read / write address and read / write length corresponding to the second read / write request.

[0016] According to a second aspect of the present disclosure, a file reading and writing method is provided, comprising:

[0017] Receive a first read / write request for a target image file from a microkernel file system service process; the target image file refers to an image file of other file systems in a host machine except a root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU;

[0018] Parsing the first read / write request, and performing read / write operations on the target image file in the host machine based on the parsing result;

[0019] Sending a read / write success flag and a read / write operation result to the microkernel file system service process; the read / write success flag indicates that the QEMU successfully performs a read / write operation on the target image file in the host machine according to the first read / write request, and the read / write result refers to a result obtained by the QEMU performing a read / write operation on the target image file in the host machine according to the first read / write request.

[0020] In some embodiments of the present disclosure, parsing the first read / write request and performing read / write operations on the target image file in the host machine based on the parsing result includes:

[0021] Parsing the first read / write request to obtain a read / write direction, a read / write address, and a read / write length corresponding to the first read / write request;

[0022] Obtaining a storage path of the target image file in the host machine;

[0023] The target image file is opened through the storage path of the target image file in the host machine, and according to the read / write address and read / write length corresponding to the first read / write request, a read function or a write function corresponding to the read / write direction is called to perform read / write operations on the target image file.

[0024] In some embodiments of the present disclosure, after performing the read and write operations on the target image file in the host machine, the method includes:

[0025] A read / write failure flag is sent to the microkernel file system service process; the read / write failure flag indicates that the QEMU fails to successfully perform a read / write operation on the target image file in the host machine according to the first read / write request.

[0026] According to a third aspect of the present disclosure, a file reading and writing device is provided, comprising:

[0027] A first sending unit sends a first read / write request for a target image file to a fast emulator QEMU; the target image file refers to an image file of other file systems in a host machine except a root file system in a microkernel file system service process, and the microkernel file system service process is started by the QEMU;

[0028] The first receiving unit is used to receive the read-write result sent by the QEMU in response to the read-write success flag fed back by the QEMU; the read-write success flag indicates that the QEMU successfully performs a read-write operation on the target image file in the host machine according to the first read-write request, and the read-write result refers to a result obtained by the QEMU performing a read-write operation on the target image file in the host machine according to the first read-write request.

[0029] According to a fourth aspect of the present disclosure, a file reading and writing device is provided, comprising:

[0030] A second receiving unit is used to receive a first read / write request of a microkernel file system service process for a target image file; the target image file refers to an image file of other file systems in the host machine except the root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU;

[0031] An execution unit, configured to parse the first read / write request, and based on the parsing result, perform a read / write operation on a target image file in a host machine;

[0032] The second sending unit is used to send a read-write success flag and a read-write operation result to the microkernel file system service process; the read-write success flag indicates that the QEMU successfully performs a read-write operation on the target image file in the host machine according to the first read-write request, and the read-write result refers to a result obtained by the QEMU performing a read-write operation on the target image file in the host machine according to the first read-write request.

[0033] According to a fifth aspect of the present disclosure, there is provided an electronic device, including:

[0034] at least one processor; and

[0035] a memory communicatively connected to the at least one processor; wherein,

[0036] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect or the second aspect.

[0037] According to a sixth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method described in the first aspect or the second aspect.

[0038] According to a seventh aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the method as described in the first aspect or the second aspect.

[0039] The present disclosure provides a file reading and writing method, device, electronic device and storage medium, wherein the file reading and writing method comprises:

[0040] The microkernel FS service process sends a first read / write request for a target image file to QEMU; the target image file refers to an image file of a file system other than a root file system in a host machine in the microkernel FS service process, and the microkernel FS service process is started by the QEMU; QEMU receives the first read / write request for the target image file from the microkernel FS service process; the QEMU parses the first read / write request, and based on the parsing result, performs a read / write operation on the target image file in the host machine; the QEMU sends a read / write success flag and a read / write operation result to the microkernel FS service process; the read / write success flag indicates that the QEMU successfully performs a read / write operation on the target image file in the host machine according to the first read / write request, and the read / write result refers to a result obtained by the QEMU performing a read / write operation on the target image file in the host machine according to the first read / write request; the microkernel FS service process receives the read / write result sent by the QEMU in response to the read / write success flag fed back by the QEMU.

[0041] Through the solution provided by the present disclosure, the microkernel FS service process can send a first read / write request for a target image file stored in a host machine to the QEMU, and then parse the first read / write request through the QEMU, and perform read / write operations on the target image file in the host machine according to the parsing result, and send a read / write success flag and a read / write operation result to the microkernel FS service process; that is, the microkernel FS service process implements the read / write operation on the target image file stored in the host machine through the QEMU, without packaging other file systems in the host machine except the root file system into the image of the microkernel FS service process.

[0042] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0044] Figure 1 Provided is a schematic diagram of the operation of a microkernel system in a QEMU virtualization platform for an embodiment of the present disclosure;

[0045] Figure 2 A flowchart of a first file reading and writing method provided in an embodiment of the present disclosure;

[0046] Figure 3 A flowchart of a second file reading and writing method provided in an embodiment of the present disclosure;

[0047] Figure 4 A flowchart of a file reading and writing method provided for an application example of the present disclosure;

[0048] Figure 5 A schematic diagram of the structure of a first file reading and writing device provided by an embodiment of the present disclosure;

[0049] Figure 6 A schematic diagram of the structure of a second file reading and writing device provided by an embodiment of the present disclosure;

[0050] Figure 7 A schematic block diagram of an exemplary electronic device 700 provided for an embodiment of the present disclosure. DETAILED DESCRIPTION

[0051] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0052] The following describes the file reading and writing method, device, electronic device and storage medium of the embodiments of the present disclosure with reference to the accompanying drawings.

[0053] Quick Emulator (QEMU) is a simulation software that can implement a virtual machine on a host machine, such as a microkernel image system with a microkernel Micro kernel as the core.

[0054] In the related art, the microkernel image system started by QEMU is formed by linking the microkernel image and the images compiled by the microkernel file system FS (File System) service process, the microkernel network NET service process, and the microkernel application APP service process. Among them, the microkernel FS service process includes the support of the root file system and other file systems. The root file system only needs to provide the most basic file service, and the amount of data is very small, so the image file of the root file system in the host can be packaged into the image of the microkernel FS service process, and then the microkernel FS service process can directly read and write the image file of the root file system. Other file systems, such as ext4, btrfs, xfs, etc., have complex logic and large data volume. If the image files of other file systems in the host are also packaged into the image of the microkernel FS service process, the volume of the microkernel image system will be huge, and then due to the limitation of the host memory, it may directly cause the QEMU to be unable to start the microkernel image system.

[0055] In order to overcome the above defects, the microkernel FS service process is required to directly read and write image files of other file systems stored in the host machine without packaging the image files of other file systems in the host machine into the image of the microkernel FS service process.

[0056] In order to implement the read and write operations of the microkernel FS service process on the target image file stored in the host machine without packaging the target image file stored in the host machine, such as ext4, btrfs, xfs, etc., into the image of the microkernel FS service process, the embodiment of the present disclosure provides a file reading and writing method.

[0057] Figure 2 The flowchart of the first file reading and writing method provided by the embodiment of the present disclosure is as follows. Figure 2 As shown, the execution subject of the method is the microkernel FS service process, and the method includes the following steps:

[0058] Step 201: Sending a first read / write request for a target image file to a fast emulator QEMU; the target image file refers to an image file of other file systems in a host machine except a root file system in a microkernel file system service process, and the microkernel file system service process is started by the QEMU;

[0059] In one embodiment, the microkernel FS service process may send a first read / write request to the QEMU via a virtio interface; virtio, which is a virtual input and output in English, is an IO semi-virtualization solution that can provide a communication framework and programming interface between the guest OS and the hypervisor virtualization device.

[0060] In the microkernel system of the virtualization platform based on the QEMU, the microkernel FS service process can communicate with the QEMU through the virtio interface. The first read and write request is used to indicate the read and write requirements of the microkernel FS service process for the target image file; the target image file can be one or more of ext4, btrfs, xfs and other image files, which is not limited in the present disclosure.

[0061] Step 202: In response to the read / write success flag fed back by the QEMU, receiving the read / write result sent by the QEMU; the read / write success flag indicates that the QEMU successfully performs the read / write operation on the target image file in the host machine according to the first read / write request, and the read / write result refers to the result obtained by the QEMU performing the read / write operation on the target image file in the host machine according to the first read / write request.

[0062] In one embodiment, the microkernel FS service process may receive the read and write results sent by the QEMU through a virtio interface. In the related art, the QEMU may perform read and write operations on the target image file by mounting the target image file in the host machine. Based on this, the microkernel FS service process may send a first read and write request for the target image file stored in the host machine to the QEMU through the virtio interface, and then utilize the read and write capabilities of the QEMU for the image file of the host machine to implement the read and write operations on the target image file stored in the host machine through the QEMU.

[0063] In one embodiment, the QEMU may successfully perform read and write operations on the target image file in the host machine according to the first read and write request, or may fail to successfully perform read and write operations on the target image file in the host machine due to reasons such as communication failure.

[0064] In one embodiment, if the QEMU successfully performs read and write operations on the target image file in the host machine, the QEMU feeds back a read and write success flag to the microkernel FS service process, and sends the read and write results to the microkernel FS service process.

[0065] In one embodiment, if the QEMU fails to successfully perform a read / write operation on the target image file in the host machine, the QEMU feeds back a read / write failure flag to the microkernel FS service process.

[0066] In one embodiment, the return value of the read / write function called by QEMU can be used to determine whether QEMU successfully performs the read / write operation on the target image file in the host machine.

[0067] In summary, the present disclosure provides a file reading and writing method applied to a microkernel FS service process, comprising: sending a first read and write request for a target image file to a fast emulator QEMU; the target image file refers to an image file of other file systems in a host machine except a root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU; in response to a read and write success flag fed back by the QEMU, receiving a read and write result sent by the QEMU; the read and write success flag indicates that the QEMU successfully performs a read and write operation on the target image file in the host machine according to the first read and write request, and the read and write result refers to a result obtained by the QEMU performing a read and write operation on the target image file in the host machine according to the first read and write request.

[0068] Through the solution provided by the present disclosure, the microkernel FS service process can send a first read / write request for a target image file stored in a host machine to the QEMU, and then parse the first read / write request through the QEMU, and perform read / write operations on the target image file in the host machine according to the parsing result, and send a read / write success flag and a read / write operation result to the microkernel FS service process; that is, the microkernel FS service process implements the read / write operation on the target image file stored in the host machine through the QEMU, without packaging other file systems in the host machine except the root file system into the image of the microkernel FS service process.

[0069] In one embodiment, before the microkernel FS service process sends the first read / write request to the QEMU, the microkernel FS service process needs to determine the first read / write request.

[0070] In one embodiment, before the microkernel FS service process sends a read / write request to the QEMU, the read / write request can be first stored in the cache queue of the microkernel FS service process, and then compared with the existing read / write requests in the cache queue. If the read / write directions, read / write addresses and read / write lengths of multiple read / write requests in the cache queue match, the multiple read / write requests can be merged into the first read / write request to reduce the interaction between the microkernel FS service process and the QEMU and reduce the pressure on the host machine.

[0071] Based on this, in one embodiment, before sending the first read / write request for the target image file to the fast emulator QEMU, the method further includes:

[0072] Obtaining a second read / write request for the target image file, and storing the second read / write request in a cache queue; the cache queue is used to store the read / write requests in the order of the read / write requests for the target image file;

[0073] Traversing at least one third read / write request for the target image file stored in the cache queue, and judging whether the second read / write request can be merged with at least one third read / write request according to the second read / write request and the read / write parameters of each of the third read / write requests; the read / write parameters include a read / write direction, a read / write address, and a read / write length;

[0074] In response to the judgment result being yes, the second read / write request is merged with at least one of the third read / write requests to generate a first read / write request.

[0075] In one embodiment, if the judgment result is no, the microkernel FS service process directly sends the second read / write request to the QEMU in response to the judgment result being no.

[0076] In one embodiment, the merging rule is to determine the read / write requests with the same read / write direction, continuous read / write address and continuous read / write length based on the read / write direction, read / write address and read / write length of the second read / write request and each third read / write request, merge the continuous read / write requests in sequence, and generate the first read / write request.

[0077] Based on this, in one embodiment, judging whether the second read / write request can be merged with at least one of the third read / write requests according to the read / write parameters of the second read / write request and each of the third read / write requests includes:

[0078] Determine a third read / write request having the same read / write direction as the second read / write request among all the third read / write requests;

[0079] Whether the first read / write request can be merged with at least one of the second read / write requests is determined based on whether there is a third read / write request with the same read / write direction as the second read / write request and a third read / write request with a continuous read / write address and read / write length corresponding to the second read / write request.

[0080] In one embodiment, the read / write direction is used to indicate whether the read / write request is used to read data or write data; the read / write address indicates the data address corresponding to the read / write requirement; the read / write length indicates the data length of each read / write operation of the read / write requirement, and the unit of the read / write length is bytes.

[0081] like Figure 3 As shown, Figure 3 The flowchart of the second file reading and writing method provided by the embodiment of the present disclosure is shown in FIG. The execution subject of the method is QEMU, and the method includes the following steps:

[0082] Step 301: receiving a first read / write request for a target image file from a microkernel file system service process; the target image file refers to an image file of other file systems in a host machine except a root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU;

[0083] In one embodiment, the first read / write request of the microkernel file system FS service process may be received through the virtio interface; virtio is an IO semi-virtualization solution that can provide a communication framework and programming interface between the host machine and the hypervisor virtualization device. Among them, the hypervisor is the core supporting component of the virtualization function, which is mainly responsible for processing virtual machine sinking and managing actual physical resources.

[0084] In the microkernel system of the virtualization platform based on the QEMU, the QEMU can communicate with the microkernel FS service process through the virtio interface. The first read and write request is used to indicate the read and write requirements of the microkernel FS service process for the target image file; the target image file can be ext4, btrfs, xfs and other target image files, which are not limited in the present disclosure.

[0085] Step 302: parsing the first read / write request, and performing read / write operations on the target image file in the host machine based on the parsing result;

[0086] In one embodiment, the parsing result refers to the read-write direction, read-write address and read-write length corresponding to the first read-write request parsed by QEMU based on the first read-write request; the read-write direction is used to indicate that the read-write request is used to read data or write data; the read-write address indicates the data address corresponding to the read-write requirement; the read-write length indicates the data length of each read-write operation of the read-write requirement, and the unit of the read-write length is bytes.

[0087] Step 303: Send a read / write success flag and a read / write operation result to the microkernel file system service process; the read / write success flag indicates that the QEMU successfully performs a read / write operation on the target image file in the host machine according to the first read / write request, and the read / write result refers to a result obtained by the QEMU performing a read / write operation on the target image file in the host machine according to the first read / write request.

[0088] In one embodiment, sending the result of the read / write operation to the microkernel FS service process may be sending the result of the read / write operation to the microkernel FS service process through a virtio interface.

[0089] In one embodiment, the QEMU may successfully perform read and write operations on the target image file in the host machine according to the first read and write request, or may fail to successfully perform read and write operations on the target image file in the host machine due to reasons such as communication failure.

[0090] In one embodiment, if the QEMU successfully performs read and write operations on the target image file in the host machine, the QEMU feeds back a read and write success flag to the microkernel FS service process, and sends the read and write results to the microkernel FS service process.

[0091] In one embodiment, if the QEMU fails to successfully perform a read / write operation on the target image file in the host machine, the QEMU feeds back a read / write failure flag to the microkernel FS service process.

[0092] In one embodiment, the return value of the read / write function called by QEMU can be used to determine whether QEMU successfully performs the read / write operation on the target image file in the host machine.

[0093] Based on the description of step 302 above, in one embodiment, parsing the first read / write request and performing read / write operations on the target image file in the host machine based on the parsing result includes:

[0094] Parsing the first read / write request to obtain a read / write direction, a read / write address, and a read / write length corresponding to the first read / write request;

[0095] Obtaining a storage path of the target image file in the host machine;

[0096] In one embodiment, when starting the QEMU to run the microkernel system, the following command can be used to start: qemu-system-aarch64-kernel Image-drive file=ext4.img, where Image represents the microkernel image, and ext4.img represents the image file of the ext4 file system in the image file of the file system stored in the host machine, that is, the target image file. Here, the image file of the ext4 file system is only used as an example, not a limitation on the target image file. In one embodiment, the target image file can also be an image file of a file system such as btrfs, xfs, etc.

[0097] The target image file is opened through the storage path of the target image file in the host machine, and according to the read / write address and read / write length corresponding to the first read / write request, a read function or a write function corresponding to the read / write direction is called to perform read / write operations on the target image file.

[0098] In one embodiment, the QEMU may open the target image file according to the storage path of the target image file in the host machine by calling an open function.

[0099] In one embodiment, the return value of the read / write function called by QEMU can be used to determine whether QEMU successfully performs the read / write operation on the target image file in the host machine.

[0100] In one embodiment, if the QEMU fails to successfully perform a read / write operation on the target image file in the host machine, the QEMU feeds back a read / write failure flag to the microkernel FS service process.

[0101] Based on this, in one embodiment, after performing the read and write operations on the target image file in the host machine, the method includes:

[0102] A read / write failure flag is sent to the microkernel file system service process; the read / write failure flag indicates that the QEMU fails to successfully perform a read / write operation on the target image file in the host machine according to the first read / write request.

[0103] The file reading and writing method provided by the embodiment of the present disclosure will be further described below with specific application examples.

[0104] The application scenario of the disclosed application example is a client system started by the QEMU on the host machine, such as a microkernel system. The microkernel image system started by QEMU is formed by linking the images compiled by the microkernel image and the microkernel file system FS (FileSystem) service process, the microkernel network NET service process, and the microkernel application APP service process. Among them, the microkernel FS service process includes the support of the root file system and other file systems. The root file system only needs to provide the most basic file service, and the amount of data is very small, so the image file of the root file system in the host machine can be packaged into the image of the microkernel FS service process, and then the microkernel FS service process can directly read and write the image file of the root file system. Other file systems, such as ext4, btrfs, xfs, etc., have complex logic and large data volume. If the image files of other file systems in the host machine are also packaged into the image of the microkernel FS service process, the volume of the microkernel image system will be huge, and then due to the limitation of the host machine memory, it may directly cause the QEMU to be unable to start the microkernel image system.

[0105] In order to overcome the above defects, the microkernel FS service process is required to directly read and write image files of other file systems stored in the host machine without packaging the image files of other file systems in the host machine into the image of the microkernel FS service process.

[0106] In order to solve the above-mentioned defects in the application examples of the present disclosure, Figure 4 As shown, the application example of the present disclosure provides a file reading and writing method, comprising the following steps:

[0107] Step 401: The QEMU runs the microkernel system and obtains the storage path of ext4.img in the host machine; specifically:

[0108] In an environment where the host system is Linux, the QEMU is started, and the microkernel system is run through the QEMU. Specifically, the following command can be used to start the microkernel system: qemu-system-aarch64-kernel Image-drivefile=ext4.img.

[0109] Step 402: the microkernel FS service process is started, and a second read / write request is determined according to the user's read / write requirements for the ext4.img;

[0110] In one embodiment, determining the second read / write request according to the user's read / write requirements for the ext4.img includes: determining the read / write direction, read / write address, and read / write length of the second read / write request according to the user's read requirements for the ext4.img and in combination with the storage path of the ext4.img in the host machine;

[0111] Step 403: The microkernel FS service process merges the second read / write request with at least one third read / write request in the cache queue to determine a first read / write request for the ext4.img; specifically:

[0112] The microkernel FS service process stores the second read-write request in a cache queue; and based on at least one third read-write request for ext4.img stored in the cache queue, according to the second read-write request and the read-write parameters of each of the third read-write requests, merges the second read-write request with at least one of the third read-write requests to determine the first read-write request.

[0113] Step 404: The microkernel FS service process sends the first read / write request to the QEMU through the virtio interface;

[0114] In one embodiment, the microkernel FS service process packages the first read and write request into a data format recognizable by the virtio interface, and sends the first read and write request to the QEMU through the virtio interface.

[0115] Step 405: The QEMU receives the first read / write request through the virtio interface;

[0116] Step 406: the QEMU parses the first read / write request to obtain the read / write direction, read / write address, and read / write length corresponding to the first read / write request;

[0117] Step 407: the QEMU calls the open function to open the ext4.img, and calls the read function or the write function to perform read and write operations on the ext4.img according to the read and write addresses and read and write lengths corresponding to the first read and write request;

[0118] In one embodiment, the QEMU calls the open function to open the ext4.img, including: the QEMU calls the open function to open the ext4.img according to the storage path of the ext4.img in the host machine.

[0119] Step 408: The QEMU determines whether the read or write operation is successful according to the return value of the read function or the write function;

[0120] Step 409: If the read / write operation fails, the QEMU sends a read / write failure flag to the FS service process;

[0121] If the read / write operation is successful, the QEMU sends a read / write success flag to the FS service process; and sends a read / write result to the FS service process.

[0122] Corresponding to the above-mentioned file reading and writing method applied to the microkernel FS service process, the present invention also proposes a file reading and writing device applied to the microkernel FS service process. Since the device embodiment of the present invention corresponds to the above-mentioned method embodiment, the details not disclosed in the device embodiment can be referred to the above-mentioned method embodiment, and will not be repeated in the present invention.

[0123] Figure 5 A schematic diagram of the structure of a first file reading and writing device provided in an embodiment of the present disclosure is shown in FIG. Figure 5 As shown, the file reading and writing device 500 is applied to a microkernel FS service process based on QEMU, and includes:

[0124] The first sending unit 501 is used to send a first read / write request for a target image file to the fast emulator QEMU; the target image file refers to an image file of other file systems in the host machine except the root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU;

[0125] The first receiving unit 502 is used to receive the read-write result sent by the QEMU in response to the read-write success flag fed back by the QEMU; the read-write success flag indicates that the QEMU successfully performs a read-write operation on the target image file in the host machine according to the first read-write request, and the read-write result refers to the result obtained by the QEMU performing a read-write operation on the target image file in the host machine according to the first read-write request.

[0126] The file reading and writing device 500 further includes a generating unit, which is used to:

[0127] storing the second read / write request in a cache queue; the cache queue is used to store the read / write requests in the order of the read / write requests for the target image file;

[0128] Traversing at least one third read / write request for the target image file stored in the cache queue, and judging whether the second read / write request can be merged with at least one third read / write request according to the second read / write request and the read / write parameters of each of the third read / write requests; the read / write parameters include a read / write direction, a read / write address, and a read / write length;

[0129] In response to the judgment result being yes, the second read / write request is merged with at least one of the third read / write requests to generate a first read / write request.

[0130] In one embodiment, the generating unit is further configured to:

[0131] Determine a third read / write request having the same read / write direction as the second read / write request among all the third read / write requests;

[0132] Whether the first read / write request can be merged with at least one of the second read / write requests is determined based on whether there is a third read / write request with the same read / write direction as the second read / write request and a third read / write request with a continuous read / write address and read / write length corresponding to the second read / write request.

[0133] Corresponding to the above-mentioned file reading and writing method applied to QEMU, the present invention also proposes a file reading and writing device applied to QEMU. Since the device embodiment of the present invention corresponds to the above-mentioned method embodiment, the details not disclosed in the device embodiment can be referred to the above-mentioned method embodiment, and will not be repeated in the present invention.

[0134] Figure 6 A schematic diagram of the structure of a second file reading and writing device provided in an embodiment of the present disclosure, such as Figure 6 As shown, the file reading and writing device 600 is applied to QEMU and includes:

[0135] The second receiving unit 601 is used to receive a first read / write request of a microkernel file system service process for a target image file; the target image file refers to an image file of other file systems in the host machine except the root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU;

[0136] An execution unit 602 is used to parse the first read / write request, and based on the parsing result, perform a read / write operation on the target image file in the host machine;

[0137] The second sending unit 603 is used to send a read-write success flag and a read-write operation result to the microkernel file system service process; the read-write success flag indicates that QEMU successfully performs a read-write operation on the target image file in the host machine according to the first read-write request, and the read-write result refers to the result obtained by QEMU performing a read-write operation on the target image file in the host machine according to the first read-write request.

[0138] In one embodiment, the execution unit 602 is specifically configured to:

[0139] Parsing the first read / write request to obtain a read / write direction, a read / write address, and a read / write length corresponding to the first read / write request;

[0140] Obtaining a storage path of the target image file in the host machine;

[0141] The target image file is opened through the storage path of the target image file in the host machine, and according to the read / write address and read / write length corresponding to the first read / write request, a read function or a write function corresponding to the read / write direction is called to perform read / write operations on the target image file.

[0142] In one embodiment, the file reading and writing device 600 further includes a third sending unit, and the third sending unit is used to:

[0143] A read / write failure flag is sent to the microkernel file system service process; the read / write failure flag indicates that the QEMU fails to successfully perform a read / write operation on the target image file in the host machine according to the first read / write request.

[0144] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and the principle is the same, which is not limited in this embodiment.

[0145] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a non-transitory computer-readable storage medium storing computer instructions.

[0146] Specifically, an embodiment of the present disclosure provides an electronic device, including:

[0147] at least one processor; and

[0148] a memory communicatively connected to the at least one processor; wherein,

[0149] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the steps of the aforementioned file reading and writing method.

[0150] An embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the steps of the aforementioned file reading and writing method.

[0151] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, vehicle-mounted devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0152] like Figure 7 As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a ROM (Read-Only Memory) 702 or a computer program loaded from a storage unit 708 to a RAM (Random Access Memory) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An I / O (Input / Output) interface 705 is also connected to the bus 704.

[0153] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0154] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, CPU (Central Processing Unit), GPU (Graphic Processing Units), various dedicated AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, DSP (Digital Signal Processor), and any appropriate processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as file reading and writing methods. For example, in some embodiments, the file reading and writing method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to execute the aforementioned file reading and writing method in any other appropriate manner (for example, by means of firmware).

[0155] Various embodiments of the systems and techniques described above herein may be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application Specific Standard Products), SOCs (System On Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor that may be a dedicated or general-purpose programmable processor that may receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0156] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0157] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include electrical connections based on one or more lines, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0158] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0159] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: LAN (Local Area Network), WAN (Wide Area Network), the Internet, and blockchain networks.

[0160] A computer system may include a client and a server. The client and the server are generally far away from each other and usually interact through a communication network. The relationship between the client and the server is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services ("Virtual Private Server", or "VPS" for short). The server may also be a server of a distributed system, or a server combined with a blockchain. Among them, it should be noted that artificial intelligence is a discipline that studies how to use computers to simulate certain thinking processes and intelligent behaviors of people (such as learning, reasoning, thinking, planning, etc.), and it has both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural language processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.

[0161] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0162] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A file reading and writing method, characterized in that: include: Sending a first read / write request for a target image file to a fast emulator QEMU; The target image file refers to an image file of other file systems in the host machine except the root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU; In response to the read / write success flag fed back by the QEMU, the read / write result sent by the QEMU is received; the read / write success flag indicates that the QEMU successfully performs a read / write operation on the target image file in the host machine according to the first read / write request, and the read / write result refers to a result obtained by the QEMU performing a read / write operation on the target image file in the host machine according to the first read / write request.

2. The method according to claim 1, before sending the first read / write request for the target image file to the fast emulator QEMU, the method further comprises: Obtaining a second read / write request for the target image file, and storing the second read / write request in a cache queue; The cache queue is used to store the read and write requests for the target image file in the order of the read and write requests; Traversing at least one third read / write request for the target image file stored in the cache queue, and judging whether the second read / write request can be merged with at least one third read / write request according to the second read / write request and the read / write parameters of each of the third read / write requests; the read / write parameters include a read / write direction, a read / write address, and a read / write length; In response to the judgment result being yes, the second read / write request is merged with at least one of the third read / write requests to generate a first read / write request.

3. The method according to claim 2, characterized in that The determining, according to the second read / write request and the read / write parameters of each of the third read / write requests, whether the second read / write request can be merged with at least one of the third read / write requests comprises: Determine a third read / write request having the same read / write direction as the second read / write request among all the third read / write requests; Whether the first read / write request can be merged with at least one of the second read / write requests is determined based on whether there is a third read / write request with the same read / write direction as the second read / write request and a third read / write request with a continuous read / write address and read / write length corresponding to the second read / write request.

4. A file reading and writing method, characterized in that: include: Receiving a first read / write request from the microkernel file system service process for a target image file; The target image file refers to an image file of other file systems in the host machine except the root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU; Parsing the first read / write request, and performing read / write operations on the target image file in the host machine based on the parsing result; Sending a read / write success flag and a read / write operation result to the microkernel file system service process; the read / write success flag indicates that the QEMU successfully performs a read / write operation on the target image file in the host machine according to the first read / write request, and the read / write result refers to a result obtained by the QEMU performing a read / write operation on the target image file in the host machine according to the first read / write request.

5. The method according to claim 4, characterized in that The parsing of the first read / write request and performing read / write operations on the target image file in the host machine based on the parsing result includes: Parsing the first read / write request to obtain a read / write direction, a read / write address, and a read / write length corresponding to the first read / write request; Obtaining a storage path of the target image file in the host machine; The target image file is opened through the storage path of the target image file in the host machine, and according to the read / write address and read / write length corresponding to the first read / write request, a read function or a write function corresponding to the read / write direction is called to perform read / write operations on the target image file.

6. The method according to claim 4, characterized in that After the target image file in the host machine is read and written, the method includes: A read / write failure flag is sent to the microkernel file system service process; the read / write failure flag indicates that the QEMU fails to successfully perform a read / write operation on the target image file in the host machine according to the first read / write request.

7. A file reading and writing device, characterized in that: include: A first sending unit sends a first read / write request for a target image file to the fast emulator QEMU; The target image file refers to an image file of other file systems in the host machine except the root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU; The first receiving unit is used to receive the read-write result sent by the QEMU in response to the read-write success flag fed back by the QEMU; the read-write success flag indicates that the QEMU successfully performs a read-write operation on the target image file in the host machine according to the first read-write request, and the read-write result refers to a result obtained by the QEMU performing a read-write operation on the target image file in the host machine according to the first read-write request.

8. A file reading and writing device, characterized in that: include: A second receiving unit is used to receive a first read / write request for a target image file from a microkernel file system service process; The target image file refers to an image file of other file systems in the host machine except the root file system in the microkernel file system service process, and the microkernel file system service process is started by the QEMU; An execution unit, configured to parse the first read / write request, and based on the parsing result, perform a read / write operation on a target image file in a host machine; The second sending unit is used to send a read-write success flag and a read-write operation result to the microkernel file system service process; the read-write success flag indicates that the QEMU successfully performs a read-write operation on the target image file in the host machine according to the first read-write request, and the read-write result refers to a result obtained by the QEMU performing a read-write operation on the target image file in the host machine according to the first read-write request.

9. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 3 or claims 4 to 6.

10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 5 or claims 6 to 8.