A file system shared access method, device, and storage medium
By mounting a virtual file system on the host machine and using a shared file driver, the problems of high resource overhead and low security in virtual machine file sharing are solved, and file sharing access with low resource consumption and high security is achieved.
Patent Information
- Application Number
- CN202111566741.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-12-20
AI Technical Summary
Sharing virtual machine files incurs high resource overhead and low security. Existing technologies make data sharing between virtual machines or between a virtual machine and a host machine difficult and prone to security vulnerabilities.
Mount a virtual file system that is consistent with the file system of the virtual machine on the host machine, and set up a shared file driver on the virtual machine. Directly operate the virtual machine file system through the shared file driver to avoid starting network services and file conflicts, reduce resource consumption and network intrusion risks.
It reduces virtual machine resource consumption, improves virtual machine security, supports the integrity and efficient response of file operations, and reduces virtual machine energy consumption and network exposure risks.
Smart Images

Figure CN114238254B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, and storage medium for shared access to a file system. Background Art
[0002] A virtual machine is a virtual environment created on a physical hardware system that acts as a virtual computer system. It simulates the entire hardware corresponding to a computer, including the CPU (Central Processing Unit), memory, network interfaces, and storage. Through software called a hypervisor, users can separate the machine's resources from the hardware and appropriately provision the resources and hardware for use by the virtual machine. Virtual machines are isolated and independent from the rest of the system, and multiple virtual machines can exist on a single piece of hardware (such as a server). The isolation of virtual machines brings the advantages of independence and security, but it also makes data sharing between virtual machines or between virtual machines and the host computer more difficult and requires more resources.
[0003] Currently, sharing files between virtual machines typically involves enabling a shared file service within the virtual machine, and then mounting the file system on other virtual machines or physical machines over the network. This requires opening up the virtual machine's network, which can lead to security vulnerabilities in the file sharing service and make the virtual machine more vulnerable to attacks.
[0004] Therefore, when sharing virtual machine files in the prior art, the virtual machine resource overhead is high and the security of the virtual machine is low. Summary of the Invention
[0005] The purpose of the embodiments of the present application is to provide a method, device, and storage medium for shared access to a file system, so as to realize file sharing of virtual machines while reducing virtual machine resource overhead and ensuring the security of virtual machines.
[0006] In a first aspect, an embodiment of the present application provides a method for shared access to a file system, which is applied to a host machine corresponding to a virtual machine, wherein the virtual machine includes a file system and a shared file driver, and the host machine pre-mounts a virtual file system consistent with the file system of the virtual machine. The shared access method includes: receiving a file operation through the virtual file system; generating an operation command for the file system of the virtual machine based on the file operation; and sending the operation command to the shared file driver so that the shared file driver executes the operation command, thereby completing the file operation on the file system of the virtual machine.
[0007] In the embodiments of the present application, compared to the prior art, by mounting a virtual file system consistent with the virtual machine's file system on the host machine, the virtual machine's file system can be fully simulated. Furthermore, a shared file driver is provided on the virtual machine. When performing file operations, all file operations are implemented through this shared file driver, rather than directly by the module on the host machine. This shared file driver is simply an ordinary program within the virtual machine, directly operating the file system on the virtual machine without causing file conflicts or file system damage caused by multiple virtual disk mounts. Consequently, the virtual file system can support file operations such as creating, deleting, and writing data.
[0008] General virtual machine file sharing solutions require enabling a shared storage service in the virtual machine. This service is usually large and will occupy more virtual machine resources. In the embodiment of the present application, only the shared file driver needs to complete the relevant file operations according to the command. Compared with the existing technology, there is no need to start network services and process file system related logic, so the virtual machine resources consumed are less, reducing the resource consumption of the virtual machine.
[0009] Moreover, since there is no need to start network services, there is no need to open network ports inside the virtual machine, which reduces the risk of network intrusion and improves the security of the virtual machine.
[0010] As a possible implementation method, the shared access method also includes: determining whether the file data corresponding to the file operation is locally cached file data; correspondingly, generating an operation command for the file system of the virtual machine based on the file operation includes: when it is determined that the file data corresponding to the file operation is not locally cached file data, generating an operation command for the file system of the virtual machine based on the file operation.
[0011] In the embodiment of the present application, after receiving a file operation, it is first determined whether the file data is locally cached. If not, an instruction is sent to the virtual machine to perform the file operation. In other words, by caching file data, the number of communications between the host machine and the virtual machine is reduced, thereby reducing the energy consumption of the virtual machine.
[0012] As a possible implementation manner, the shared access method further includes: when it is determined that the file data corresponding to the file operation is locally cached file data, returning the locally cached file data to complete the file operation.
[0013] In an embodiment of the present application, if the file data corresponding to the file operation is locally cached file data, the corresponding file data is directly returned to improve the response efficiency of the file operation.
[0014] As a possible implementation manner, sending the operation command to the shared file driver includes: sending the operation command to the shared file driver at a preset command sending speed.
[0015] In an embodiment of the present application, the communication frequency between the host machine and the virtual machine can be limited by the preset command sending speed, thereby avoiding high-frequency file operations and thus avoiding excessive resource consumption of the virtual machine and affecting the performance of the virtual machine.
[0016] As a possible implementation, the virtual machine is provided with a first virtual communication interface and a second virtual communication interface, the host machine sends data to the virtual machine through the first virtual communication interface, and the host machine receives the data sent by the virtual machine through the second virtual communication interface.
[0017] In an embodiment of the present application, the virtual machine is provided with two virtual communication interfaces, one for sending data and the other for receiving data, thereby avoiding the consumption of virtual machine resources caused by the same communication interface receiving and sending data at the same time, and improving communication performance.
[0018] As a possible implementation manner, the shared access method further includes: receiving a file operation execution result returned by the shared file driver.
[0019] In an embodiment of the present application, after the shared file driver executes the corresponding file operation, the file operation execution result is fed back to implement the result feedback of the file operation.
[0020] As a possible implementation method, the file operation includes: a read file operation and a write file operation; the file operation execution result corresponding to the read file operation is the file data corresponding to the read file operation, and the file operation execution result corresponding to the write file operation includes the write information corresponding to the write file operation.
[0021] In an embodiment of the present application, for a file read operation, the file driver returns the file data corresponding to the file read operation; for a file write operation, the file driver returns the corresponding write information, thereby achieving effective feedback on the execution results of the file operation.
[0022] In a second aspect, an embodiment of the present application provides a shared access device for a file system, which is applied to a host machine corresponding to a virtual machine, wherein the virtual machine includes a file system and a shared file driver, and the host machine pre-mounts a virtual file system consistent with the file system of the virtual machine, including: various functional modules for implementing the shared access method for the file system described in the first aspect and any one of the implementation methods of the first aspect.
[0023] In a third aspect, an embodiment of the present application provides an electronic device comprising: a processor, a memory, and a communication bus; the communication bus is used to realize connection and communication between the processor and the memory; the processor is used to execute one or more programs stored in the memory to realize the shared access method of the file system described in the first aspect and any one of the implementation methods of the first aspect.
[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a computer, it executes the shared access method of the file system described in the first aspect and any one of the implementation methods of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0026] Figure 1 A schematic diagram of the interaction between a virtual machine and a host machine provided in an embodiment of the present application;
[0027] Figure 2 A flowchart of a method for shared access to a file system provided in an embodiment of the present application;
[0028] Figure 3 A schematic diagram of the structure of a shared access device for a file system provided in an embodiment of the present application;
[0029] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0030] Icons: 300 - shared access device; 310 - receiving module; 320 - processing module; 400 - electronic device; 410 - processor; 420 - memory; 430 - communication bus. DETAILED DESCRIPTION
[0031] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0032] The technical solutions provided by the embodiments of this application can be applied to various scenarios requiring shared access to files on virtual machines. For example, they can be applied to hyper-converged and desktop cloud products to enable shared access to virtual machine file systems from the host machine with low overhead and without compromising the security of the virtual machines.
[0033] As an optional application, this technical solution can be applied to agentless antivirus for virtual machines. While the virtual machine is running, the virtual machine's file system is shared with the host machine without the virtual machine's awareness. Antivirus software can then be run on the host machine to scan and disinfect all files in the virtual machine. The entire antivirus process does not require running an antivirus agent service in the virtual machine, and no custom development of the antivirus software is required.
[0034] As another optional application, this technical solution can be applied to video redirection scenarios. By sharing the virtual machine's video files with the host machine, the host machine then starts the HTTP (Hypertext Transfer Protocol) service to convert the video files into videos that can be played online. This eliminates the need for video encoding and decoding in the virtual machine when playing the video. The virtual machine is only involved in simple file reading and writing, significantly reducing CPU consumption when the virtual machine is playing the video.
[0035] In conjunction with the above application scenarios, it can be understood that the purpose of the technical solution provided by the embodiments of this application is to share files on a virtual machine with a host machine. A virtual machine can be understood as a virtual computer system installed on a host machine. Therefore, the hardware operating environment of the technical solution provided by the embodiments of this application is essentially a host machine, which can be a terminal device such as a computer or personal computer, and is not limited here.
[0036] Please refer to Figure 1 The diagram shown is a schematic diagram of the interaction between the virtual machine and the host machine provided in the embodiment of the present application. Figure 1 In the example, the virtual machine includes a file system and a shared file driver, and the host machine includes a pre-mounted virtual file system that is consistent with the file system of the virtual machine.
[0037] For virtual machines, a shared file driver can be thought of as a pre-installed program that operates the file system. Upon receiving a file system operation command, it performs the corresponding operation based on the command. For example, if the operation command is to read a file, the shared file driver directly reads the corresponding file and returns it.
[0038] For the host machine, a virtual file system can be mounted by specifying the virtual machine name. The virtual file system is consistent with the file system of the virtual machine and has a mapping relationship. Alternatively, other implementation methods can be used to achieve the mounting of the virtual file system, which is not limited here.
[0039] All file system operations on the virtual file system, such as create, open, delete, read, write, etc., can ultimately be reflected on the virtual machine's file system, enabling shared access to the virtual machine's file system.
[0040] Based on the above application scenarios, please refer to Figure 2 , is a flowchart of a shared access method for a file system provided in an embodiment of the present application, the shared access method comprising:
[0041] Step 210: Receive a file operation via the virtual file system.
[0042] Step 220: Generate an operation command for the file system of the virtual machine according to the file operation.
[0043] Step 230: Send the operation command to the shared file driver so that the shared file driver executes the operation command, thereby completing the file operation on the file system of the virtual machine.
[0044] In the embodiments of the present application, compared to the prior art, by mounting a virtual file system consistent with the virtual machine's file system on the host machine, the virtual machine's file system can be fully simulated. Furthermore, a shared file driver is provided on the virtual machine. When performing file operations, all file operations are implemented through this shared file driver, rather than directly by the module on the host machine. This shared file driver is simply an ordinary program within the virtual machine, directly operating the file system on the virtual machine without causing file conflicts or file system damage caused by multiple virtual disk mounts. Consequently, the virtual file system can support file operations such as creating, deleting, and writing data.
[0045] General virtual machine file sharing solutions require enabling a shared storage service in the virtual machine. This service is usually large and will occupy more virtual machine resources. In the embodiment of the present application, only the shared file driver needs to complete the relevant file operations according to the command. Compared with the existing technology, there is no need to start network services and process file system related logic, so the virtual machine resources consumed are less, reducing the resource consumption of the virtual machine.
[0046] Moreover, since there is no need to start network services, there is no need to open network ports inside the virtual machine, which reduces the risk of network intrusion and improves the security of the virtual machine.
[0047] Next, the detailed implementation of the shared access method is introduced.
[0048] Since data needs to be transmitted between the virtual machine and the host machine, before executing step 210 , both the virtual machine and the host machine need to make some preliminary preparations.
[0049] For a virtual machine, start the virtual machine and add a communication interface to the virtual machine. The virtual machine starts the shared file driver, and the driver keeps reading the communication interface and listening for messages sent by the host machine.
[0050] For the host machine, a fuse kernel module and a fuse user module are pre-installed. Both modules can be understood as applications (clients) on the host machine.
[0051] On the host machine, the Fuse user module is started and a connection is established with the virtual machine through the aforementioned communication interface. The virtual file system is then mounted and generated. The Fuse kernel module monitors file operations on the virtual file system. When a file operation is detected, it is sent to the Fuse user module. The Fuse user module then generates an operation command based on the file operation and sends it to the shared file driver through the aforementioned communication interface.
[0052] As an optional implementation, when adding a communication interface to a virtual machine, a first virtual communication interface and a second virtual communication interface are added. The host machine sends data to the virtual machine through the first virtual communication interface, and the host machine receives data sent by the virtual machine through the second virtual communication interface.
[0053] In the above embodiment, the virtual machine uses one communication interface to receive data sent by the host machine and uses another communication interface to send data to the host machine. That is, the data interface for sending data is different from the data interface for receiving data.
[0054] In an embodiment of the present application, the virtual machine is provided with two virtual communication interfaces, one for sending data and the other for receiving data, thereby avoiding the consumption of virtual machine resources caused by the same communication interface receiving and sending data at the same time, and improving communication performance.
[0055] As an optional embodiment, the aforementioned virtual communication interfaces are all virtual serial ports. Accordingly, after startup, the file sharing driver program continuously reads the virtual serial port for receiving data to monitor messages sent by the host machine. Furthermore, the fuse user module also sends operation commands to the file sharing driver program of the virtual machine through the aforementioned virtual serial port for receiving data.
[0056] When the virtual machine needs to send data to the host machine, the virtual serial port used to send data is used to return the data to the host machine.
[0057] It is understood that in the embodiment of the present application, the host machine communicates with the virtual machine through two serial ports. The virtual serial port itself has good performance. Each serial port implements unidirectional data transmission. In this way, only one data transmission operation (for example, only sending or only receiving) can exist on one side of the serial port, and no two data transmission operations can exist simultaneously. This reduces the locking operation of the serial port, making the serial port communication performance higher and the CPU resource consumption lower. In addition, with serial port communication, the virtual machine does not need to open the network port, reducing the risk of network intrusion.
[0058] After completing the above initialization, the host machine can wait for the user to initiate file operations.
[0059] In the aforementioned embodiments, a virtual file system is already mounted on the host machine. Therefore, when a user requires shared access, they can directly operate on the virtual file system. For example, if a new file needs to be created on the virtual machine's file system, a new file creation operation is initiated on the virtual file system. At this point, the file creation operation is considered to have been received.
[0060] Therefore, in step 210, when the user operates the virtual file system, it can be considered as receiving a file operation. Among them, file operations include but are not limited to: read file operations, write file operations, delete file operations, etc. For write file operations, it can be a file creation operation or a file modification operation.
[0061] In addition, in step 210, although the virtual file system receives the file operation initiated by the user, the fuse kernel module introduced in the above embodiment should be the one that finally monitors the file operation.
[0062] After the fuse kernel module detects the file operation, it sends the call information of the file system involved in the file operation to the fuse user module. Then, in step 220, the fuse user module generates an operation command of the file system of the virtual machine according to the file operation.
[0063] In the embodiment of the present application, the fuse user module may also have a file cache function. For the file cache function, the file data corresponding to the file operation may be cached.
[0064] It is understandable that not all file operations can cache the corresponding file data. Generally speaking, when the file operation is a read file operation, the virtual machine's file system will return the corresponding read file. At this time, the fuse user module can cache the read file.
[0065] Furthermore, when a file operation related to the locally cached file data is received next time, the locally cached file data can be directly returned without operating the file system on the virtual machine.
[0066] Therefore, as an optional implementation, the shared access method also includes: determining whether the file data corresponding to the file operation is locally cached file data; correspondingly, step 220 includes: when it is determined that the file data corresponding to the file operation is not locally cached file data, generating an operation command for the virtual machine's file system based on the file operation.
[0067] In this embodiment, a determination is first made as to whether the file data corresponding to the file operation matches the locally cached file data. For example, if the file operation is to read a specified file from a specified virtual disk, the locally cached file data is checked to see whether the specified file exists. If so, the file data corresponding to the file operation is determined to be the locally cached file data. If not, the file data corresponding to the file operation is determined not to be the locally cached file data.
[0068] It can also be seen from this implementation that when caching file data, in addition to directly caching the file data itself, the file data and corresponding file information need to be saved to facilitate subsequent comparison of the file data.
[0069] In the embodiment of the present application, after receiving a file operation, it is first determined whether the file data is locally cached. If not, an instruction is sent to the virtual machine to perform the file operation. In other words, by caching file data, the number of communications between the host machine and the virtual machine is reduced, thereby reducing the energy consumption of the virtual machine.
[0070] Of course, as an optional implementation, when it is determined that the file data corresponding to the file operation is locally cached file data, the corresponding locally cached file data is returned to complete the file operation.
[0071] In an embodiment of the present application, if the file data corresponding to the file operation is locally cached file data, the corresponding file data is directly returned to improve the response efficiency of the file operation.
[0072] Furthermore, in embodiments of the present application, corresponding limits may be set when caching file data locally. For example, a maximum file data size for local caching may be set; or, for example, a periodic check may be performed to determine whether the locally cached file data has been updated, and if so, the cached file data may be deleted.
[0073] When detecting whether the locally cached file data has been updated, if the file operation involves operations such as modification and deletion of the locally cached file, it can be determined that the locally cached file data has been updated.
[0074] Furthermore, in step 220, when generating the operation command, the operation command may be generated using different encoding methods in combination with the actual application scenario. The encoding method of the operation command may depend on the shared file driver. That is, the encoding method must be an encoding method acceptable to the shared file driver so that the shared file driver can decode the operation command and determine the file operation to be performed.
[0075] After the operation command is generated in step 220, step 230 is executed, and the fuse user module sends the operation command to the shared file driver.
[0076] As an optional implementation, a command sending speed is preset on the fuse user module, and the command sending speed is used to limit the operation speed of the file system.
[0077] Therefore, in step 230, the operation command is sent to the shared file driver according to the preset command sending speed.
[0078] In this embodiment, the fuse user module determines whether the transmission speed of the currently-to-be-sent operation command meets the preset command transmission speed based on the previously-sent operation command. If so, the operation command is sent to the shared file driver; if not, the currently-to-be-sent operation command is sent again after the preset command transmission speed is met.
[0079] The preset command sending speed includes, for example, sending a preset number of operation commands per second, sending an operation command once every preset time, and the like.
[0080] Correspondingly, in combination with different settings for the command sending speed, different information can be combined to determine whether the preset command sending speed is met. For example, assuming that the preset command sending speed is to send a preset number of operation commands per second, the fuse user module determines how many operation commands have been sent in the current second. If the number of operation commands sent plus the number of operation commands currently to be sent is less than or equal to the preset number, it is determined that the preset command sending speed is met. If the speed of the operation commands sent plus the number of operation commands currently to be sent is greater than the preset number, it is determined that the preset command sending speed is not met.
[0081] For another example, assuming that the preset command sending speed is to send an operation command once for each preset time, the fuse user module determines the time interval between the last operation command sent and the current time. If the time interval is greater than the preset time interval, it is determined that the preset command sending speed is met; if the time interval is less than the preset time interval, it is determined that the preset command sending speed is not met.
[0082] In actual applications, more implementation methods of command sending speed can be adopted. Correspondingly, corresponding judgment methods are adopted to judge whether the command sending speed meets the preset conditions, and step 230 is executed according to the judgment result. This is not limited in the embodiments of this application.
[0083] In an embodiment of the present application, the communication frequency between the host machine and the virtual machine can be limited by the preset command sending speed, thereby avoiding high-frequency file operations and thus avoiding excessive resource consumption of the virtual machine and affecting the performance of the virtual machine.
[0084] After the operation command is sent to the shared file driver in step 230, the shared file driver executes the operation command and performs corresponding file operations on the involved files to complete the file operation on the file system of the virtual machine.
[0085] After the shared file driver completes the file operation, it can also return the result to the host machine. In combination with the introduction in the above embodiment, the shared file driver returns the result to the fuse user module through the virtual serial port that sends data, and the fuse user module returns it to the fuse kernel module, which then feeds it back to the user.
[0086] Therefore, as an optional implementation, the shared access method further includes: receiving a file operation execution result returned by the shared file driver.
[0087] In this embodiment, for a file read operation, the corresponding file operation execution result may be file data corresponding to the file read operation.
[0088] Furthermore, at this time, the fuse user module will also cache the file data corresponding to the file read operation. For details, please refer to the introduction in the above embodiment.
[0089] For a file write operation, the corresponding file operation execution result includes write information corresponding to the file write operation, wherein the write information may include: whether the write is successful, the amount of data written, etc., which are not limited here.
[0090] In the embodiment of the present application, after the shared file driver executes the corresponding file operation, it feeds back the result of the file operation, thus implementing the result feedback of the file operation. In addition, for a file read operation, the file driver returns the file data corresponding to the read operation; for a file write operation, the file driver returns the corresponding write information, thus implementing the effective feedback of the file operation execution result.
[0091] As can be seen from the above examples, the technical solutions provided by the embodiments of this application enable shared access to the entire virtual machine file system by implementing a virtual machine file system on the host machine and communicating with the virtual machine via a serial port. This not only supports shared read-write access to the entire virtual machine file system, but also reduces the CPU and memory resource overhead of the virtual machine, avoids the virtual machine opening network ports, and enhances the security of the virtual machine when sharing the file system.
[0092] Based on the same invention concept, please refer to Figure 3 In an embodiment of the present application, a file system shared access device 300 is also provided. The device corresponds to the aforementioned shared access method and includes: a receiving module 310 and a processing module 320.
[0093] The receiving module 310 is configured to receive a file operation via the virtual file system. The processing module 320 is configured to generate an operation command for the file system of the virtual machine based on the file operation and send the operation command to the shared file driver so that the shared file driver executes the operation command, thereby completing the file operation on the file system of the virtual machine.
[0094] In this embodiment of the present application, the processing module 320 is further configured to determine whether the file data corresponding to the file operation is locally cached file data, and specifically to generate an operation command for the file system of the virtual machine based on the file operation when it is determined that the file data corresponding to the file operation is not locally cached file data.
[0095] In the embodiment of the present application, the processing module 320 is further configured to: when it is determined that the file data corresponding to the file operation is locally cached file data, return the locally cached file data to complete the file operation.
[0096] In the embodiment of the present application, the processing module 320 is specifically configured to send the operation command to the shared file driver according to a preset command sending speed.
[0097] In the embodiment of the present application, the receiving module 310 is further configured to receive the file operation execution result returned by the shared file driver.
[0098] The shared access device 300 corresponds to the aforementioned shared access method, and each functional module corresponds to each step of the shared access method. Therefore, the implementation of each functional module refers to the introduction in the aforementioned embodiment and will not be repeated here.
[0099] Based on the same invention concept, please refer to Figure 4, an embodiment of the present application further provides an electronic device 400, which can serve as a hardware operating environment for the aforementioned shared access method.
[0100] The electronic device 400 includes a processor 410 , a memory 420 and a communication bus 430 .
[0101] The processor 410, memory 420 and communication bus 430 can be set in the device body. The device body can have different implementation methods in different application scenarios, such as different shapes, different sizes, different materials, etc., which are not limited in the embodiments of this application.
[0102] The processor 410, memory 420, and communication bus 430 are electrically connected, directly or indirectly, to enable data transmission or interaction. For example, the electrical connection can be achieved via one or more communication buses or signal buses. The aforementioned shared access methods each include at least one software functional module that can be stored in the memory 420 in the form of software or firmware, such as the software functional module or computer program included in the shared access device 300.
[0103] Processor 410 can be an integrated circuit chip with signal processing capabilities. Processor 410 can be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), etc.; it can also be a digital signal processor, an application-specific integrated circuit, an off-the-shelf programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor.
[0104] Memory 420 can store various software programs and modules, such as the program instructions / modules corresponding to the shared access method and apparatus provided in the embodiments of the present application. Processor 410 executes the software programs and modules stored in memory 420 to perform various functional applications and data processing, thereby implementing the methods in the embodiments of the present application.
[0105] The memory 420 may include, but is not limited to, RAM (Random Access Memory), ROM (Read Only Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0106] In some embodiments, the electronic device 400 may further include an input / output module. The input / output module can be understood as a tool for users to implement human-computer interaction. Through the input / output module, the user can operate the electronic device 400 to initiate file operations, etc.
[0107] In some embodiments, the input and output module may be a mouse, a keyboard, etc., which is not limited here.
[0108] It should be noted that Figure 4 The structure of the electronic device 400 shown in the figure does not constitute a limitation on the electronic device 400. The actual electronic device 400 may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0109] In addition, the technical effects of the electronic device 400 can refer to the technical effects of the aforementioned shared access method, which will not be repeated here.
[0110] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a computer, the shared access method described in the aforementioned embodiment is executed.
[0111] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0112] In addition, the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0113] Furthermore, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0114] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any actual relationship or order between these entities or operations.
[0115] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for shared access to a file system, characterized in that: Applied to a host machine corresponding to a virtual machine, the virtual machine includes a file system and a shared file driver, the host machine pre-mounts a virtual file system consistent with the file system of the virtual machine, and the shared access method includes: Receiving a file operation through the virtual file system; wherein, when the user operates the virtual file system, it can be regarded as receiving the file operation; Generate an operation command for the file system of the virtual machine according to the file operation; The operation command is sent to the shared file driver so that the shared file driver executes the operation command, thereby completing the file operation on the file system of the virtual machine.
2. The shared access method according to claim 1, wherein: The shared access method further includes: Determining whether the file data corresponding to the file operation is locally cached file data; Correspondingly, generating an operation command for the file system of the virtual machine according to the file operation includes: When it is determined that the file data corresponding to the file operation is not the locally cached file data, an operation command for the file system of the virtual machine is generated according to the file operation.
3. The shared access method according to claim 2, wherein: The shared access method further includes: When it is determined that the file data corresponding to the file operation is locally cached file data, the locally cached file data is returned to complete the file operation.
4. The shared access method according to claim 1, wherein: The sending the operation command to the shared file driver comprises: The operation command is sent to the shared file driver according to a preset command sending speed.
5. The shared access method according to claim 1, wherein: The virtual machine is provided with a first virtual communication interface and a second virtual communication interface. The host machine sends data to the virtual machine through the first virtual communication interface, and the host machine receives the data sent by the virtual machine through the second virtual communication interface.
6. The shared access method according to claim 1, wherein: The shared access method further includes: Receive the file operation execution result returned by the shared file driver.
7. The shared access method according to claim 1, wherein: The file operations include: a read file operation and a write file operation; the file operation execution result corresponding to the read file operation is the file data corresponding to the read file operation, and the file operation execution result corresponding to the write file operation includes the write information corresponding to the write file operation.
8. A shared access device for a file system, characterized in that: Applied to a host machine corresponding to a virtual machine, the virtual machine includes a file system and a shared file driver, the host machine pre-mounts a virtual file system consistent with the file system of the virtual machine, and the shared access device includes: A receiving module, configured to receive a file operation through the virtual file system; wherein, when a user operates the virtual file system, it is considered that the file operation has been received; Processing module for: Generate an operation command for the file system of the virtual machine according to the file operation; The operation command is sent to the shared file driver so that the shared file driver executes the operation command, thereby completing the file operation on the file system of the virtual machine.
9. An electronic device, characterized in that: include: Processor, memory and communication bus; the communication bus is used to achieve connection and communication between the processor and the memory; The processor is configured to execute one or more programs stored in the memory to implement the shared access method for the file system according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the method for shared access to a file system according to any one of claims 1 to 7 is executed.
Citation Information
Patent Citations
Cloud storage service client high-efficiency fine-granularity data caching system and method
CN102014158A
Method and device for file system isolation of host machine and virtual machine
CN103593607A
Shared file access method and system and associated equipment
CN105447203A
Method, device and system for controlling data transmission rate
CN111866100A