A data processing method, device, equipment and medium based on virtual machine

By deploying a virtual machine on the host and using event-driven mechanism to monitor the data reading requirements of the virtual communication device, obtaining and updating the virtual machine data, the problem that the host is difficult to obtain virtual machine data efficiently is solved, and the data reading process is realized Optimization and convenience improvement.

CN118885259BActive Publication Date: 2025-02-07JINAN INSPUR DATA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411346333.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-02-07
Estimated Expiration
2044-09-26

AI Technical Summary

Technical Problem

In virtualization scenarios, it is difficult for the host to obtain the virtual machine's data efficiently, and the implementation of the existing technology is complex.

Method used

By deploying a virtual machine on the host, an event-driven mechanism such as an epoll mechanism is used to monitor the data reading requirements of the virtual communication device, obtain file descriptors, and connect to the virtual communication device through a socket instance to read and update the data.

Benefits of technology

The process of the host reading data sent by the virtual machine through the virtual communication device is optimized, and the convenience of the host obtaining data in the virtual machine is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885259B_ABST
    Figure CN118885259B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a data processing method, device, equipment and medium based on a virtual machine, which is applied to the field of virtualization technology. A host machine is deployed with one or more virtual machines, and each virtual machine communicates with the host machine through a corresponding virtual communication device. The method includes: when monitoring that a target virtual communication device of a target virtual machine has target data that needs to be read, obtaining a target file descriptor; wherein each file descriptor has a corresponding socket instance; when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, reading the target data, and updating the target data to the table item corresponding to the target virtual communication device in the preset virtual communication device list. Through the embodiment of the present invention, the process of optimizing the host machine to read the data sent by the virtual machine through the virtual communication device is realized, and the convenience of the host machine to obtain data in the virtual machine is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of virtualization technology, and in particular to a data processing method, device, equipment and medium based on a virtual machine. Background Art

[0002] In a virtualization scenario, a virtual machine runs on a host machine, but the resources of the virtual machine and the host machine are isolated. In general, the host machine program cannot obtain the data of the virtual machine.

[0003] In practical applications, in order to obtain certain monitoring data more accurately, it is necessary to obtain part of the data of the virtual machine from the virtual machine system, and this data acquisition process is relatively complicated to implement. Summary of the invention

[0004] In view of the above problems, a data processing method, apparatus, device and medium based on a virtual machine are proposed to overcome the above problems or at least partially solve the above problems, including:

[0005] A data processing method based on a virtual machine, characterized in that the method is applied to a host machine, the host machine is deployed with one or more virtual machines, each virtual machine communicates with the host machine through a corresponding virtual communication device, and the method comprises:

[0006] When monitoring that the target virtual communication device of the target virtual machine has target data that needs to be read, obtaining the target file descriptor; wherein each file descriptor has a corresponding socket instance;

[0007] In a case where the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, the target data is read and the target data is updated to an entry corresponding to the target virtual communication device in a preset virtual communication device list.

[0008] Optionally, when monitoring that the target virtual communication device of the target virtual machine has target data that needs to be read, obtaining the target file descriptor includes:

[0009] The event-driven mechanism is used to monitor whether there is data that needs to be read by the virtual communication device, and when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, the target file descriptor is obtained.

[0010] Optionally, when monitoring that the target virtual communication device of the target virtual machine has target data that needs to be read, obtaining the target file descriptor includes:

[0011] When it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, a target event is generated through an event-driven mechanism, and when the target event is detected, a target file descriptor is obtained.

[0012] Optionally, when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, before obtaining the target file descriptor, the method further includes: creating a virtual machine instance for the virtual machine running in the host machine.

[0013] Optionally, after creating a virtual machine instance for the virtual machine running in the host machine, the method further includes:

[0014] Acquire information of a virtual communication device corresponding to the virtual machine, and create an entry corresponding to the virtual communication device in a preset virtual communication device list according to the information of the virtual communication device;

[0015] A socket instance for the virtual communication device is created, and a connection is established between the socket instance and the virtual communication device.

[0016] Optionally, the creating a socket instance for the virtual communication device includes:

[0017] Registering the virtual communication device, and creating a socket instance for the virtual communication device when registering the virtual communication device;

[0018] The socket information of the socket instance is added to a newly registered socket information dictionary; wherein the newly registered socket information dictionary records relevant information of the newly registered socket instance.

[0019] Optionally, before creating an entry corresponding to the virtual communication device in a preset virtual communication device list according to the information of the virtual communication device, the method further includes: acquiring a virtual communication device list lock;

[0020] After adding the socket information of the socket instance to the new registered socket information dictionary, the method further includes: releasing the virtual communication device list lock.

[0021] Optionally, the entry corresponding to the virtual communication device in the virtual communication device list stores any one or more of the following items:

[0022] The name of the virtual communication device, the device path of the virtual communication device, the socket information of the socket instance corresponding to the virtual communication device, and the data read from the virtual communication device.

[0023] Optionally, when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, before reading the target data and updating the target data to the entry corresponding to the target virtual communication device in the preset virtual communication device list, the method further includes:

[0024] Determine whether the target file descriptor is in a connected socket information dictionary; wherein the connected socket information dictionary records relevant information of a connected virtual communication device;

[0025] If the target file descriptor is in the connected socket information dictionary, it is determined that the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device.

[0026] Optionally, it also includes:

[0027] If the target file descriptor is not in the connected socket information dictionary, the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, and after the connection is successful, the connected socket information dictionary is updated.

[0028] Optionally, after the connection is successful, updating the connected socket information dictionary includes:

[0029] After the connection is successful, the socket information of the target socket instance is updated from the unconnected socket information dictionary to the connected socket information dictionary; wherein the unconnected socket information dictionary records the relevant information of the socket instance that has been registered but has not yet connected to the virtual communication device;

[0030] The relevant information of the target socket instance is removed from the unconnected socket information dictionary.

[0031] Optionally, before updating the socket information of the target socket instance from the unconnected socket information dictionary to the connected socket information dictionary, the method further includes: acquiring a socket list update lock;

[0032] After removing the relevant information of the target socket instance from the unconnected socket information dictionary, the method further includes: releasing a socket list update lock.

[0033] Optionally, before connecting the target socket instance corresponding to the target file descriptor and the target virtual communication device, the method further includes:

[0034] According to the target socket instance corresponding to the target file descriptor, the newly registered socket information dictionary is updated; wherein the newly registered socket information dictionary records the relevant information of the newly registered socket instance;

[0035] According to the newly registered socket information dictionary, the unconnected socket information dictionary is updated, and the newly registered socket information dictionary is cleared; wherein the unconnected socket information dictionary records the relevant information of the socket instance that has been registered but has not yet connected to the virtual communication device.

[0036] Optionally, before updating the newly registered socket information dictionary according to the target socket instance corresponding to the target file descriptor, the method further includes:

[0037] Get the socket list update lock;

[0038] After clearing the newly registered socket information dictionary, the method further includes:

[0039] Release the socket list update lock.

[0040] Optionally, it also includes:

[0041] When it is detected that the target virtual machine is shut down, the target socket instance corresponding to the target virtual communication device is deregistered, and the relevant information corresponding to the target socket instance is deleted.

[0042] Optionally, it also includes:

[0043] After an external request is monitored, a request operation type corresponding to the external request is determined, and an operation function corresponding to the request operation type is called to perform a corresponding operation.

[0044] A data processing device based on a virtual machine, the device is applied to a host machine, the host machine is deployed with one or more virtual machines, each virtual machine communicates with the host machine through a corresponding virtual communication device, the device comprises:

[0045] A read monitoring module is used to obtain a target file descriptor when monitoring that a target virtual communication device of a target virtual machine has target data to be read; wherein each file descriptor has a corresponding socket instance;

[0046] The data updating module is used to read the target data and update the target data to the entry corresponding to the target virtual communication device in the preset virtual communication device list when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device.

[0047] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the method described above when executed by the processor.

[0048] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.

[0049] A computer program product comprises a computer program, wherein when the computer program is executed by a processor, the computer program implements the method as described above.

[0050] The embodiments of the present invention have the following advantages:

[0051] In an embodiment of the present invention, the host machine obtains a target file descriptor when it monitors that a target virtual communication device of a target virtual machine has target data that needs to be read, and each file descriptor has a corresponding socket instance; when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, the target data is read and the target data is updated to the table entry corresponding to the target virtual communication device in a preset virtual communication device list, thereby optimizing the process of the host machine reading data sent by the virtual machine through the virtual communication device and improving the convenience of the host machine in obtaining data in the virtual machine. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0053] Figure 1 is a flowchart of a data processing method based on a virtual machine provided by some embodiments of the present invention;

[0054] Figure 2 is a schematic diagram of a communication module data transmission process provided by some embodiments of the present invention;

[0055] Figure 3 is a schematic diagram of a virtual machine instance creation process provided by some embodiments of the present invention;

[0056] Figure 4 is a schematic diagram of a virtual machine instance management module processing process provided by some embodiments of the present invention;

[0057] Figure 5 is a structural block diagram of a data processing device based on a virtual machine provided in some embodiments of the present invention;

[0058] Figure 6 is a structural block diagram of an electronic device provided by some embodiments of the present invention;

[0059] Figure 7is a structural block diagram of a storage medium provided by some embodiments of the present invention;

[0060] Figure 8 It is a structural block diagram of a program product provided by some embodiments of the present invention. DETAILED DESCRIPTION

[0061] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0062] Reference Figure 1 , showing a step flow chart of a data processing method based on a virtual machine provided in some embodiments of the present invention, the method is applied to a host machine, the host machine is deployed with one or more virtual machines, and each virtual machine communicates with the host machine through a corresponding virtual communication device.

[0063] In actual applications, multiple virtual machines will run on the host machine, and each virtual machine can be set with one or more virtual communication devices to communicate with the host program so that the host can obtain the data of the virtual machine. Due to the large number of virtual machines and virtual communication devices, how the host side reads the data sent by multiple virtual machines through virtual communication devices is a relatively complicated problem.

[0064] In an embodiment of the present invention, an event-driven mechanism based on the Linux system, such as the epoll mechanism, is used to read system data of multiple virtual machines in an event-monitoring manner. In the process of executing the data acquisition program, data acquisition of newly started virtual machines and operations of removing shut down virtual machines can be added, thereby enabling the host machine to more efficiently obtain virtual machine system data through virtual communication devices.

[0065] In actual applications, a virtual machine instance module, a virtual machine instance management module, and a communication module are set. The virtual machine instance management module maintains the running data and provides the ability to request operations. The virtual machine instance maintains and saves information of multiple virtual communication devices, and updates and saves data through related callback functions. The communication module uses the epoll mechanism to listen to the file descriptor (fd, file descriptor) that needs to read data. When there is data, the corresponding callback function is called to update the data. The dynamic addition and removal of virtual communication devices are provided through the maintenance of each file descriptor dictionary.

[0066] For the VM instance module:

[0067] The virtual machine instance module is an instance of a virtual machine, that is, each virtual machine is a virtual machine instance. This instance includes member variables and functions, and records the information of the virtual machine, including:

[0068] Virtual machine ID variable (vmId): used to identify the unique ID of a virtual machine. Each virtual machine has an ID.

[0069] Virtual communication device list (vChannels_list): Each list item records an information instance of a virtual communication device, including the name of the virtual communication device (vChannelName), the device path (vChannelPath), related information of the socket instance, and the data read from the virtual communication device (channelData).

[0070] Communication device list lock (vChannels_listLock): Update the virtual communication device list. Get the lock first and close the lock after the update is complete.

[0071] Create a socket callback function (create_fd_callback): used to create a socket. The socket instance created here will be saved in the information instance of the specified virtual communication device and return the corresponding file descriptor.

[0072] Connect virtual communication device callback function (connected_callback): This function is used for the socket instance to connect to the virtual communication device to read and send data.

[0073] Data read callback function (read_callback): This function is used to call this function to read data when a virtual communication device has data to read. Different virtual communication devices may process different data, so different virtual communication devices may also process differently after reading.

[0074] Virtual communication device registration function (register_vChannel): runs when a virtual machine instance is created, and is used to register the virtual communication devices in the virtual communication device list (vChannels_list) with the communication module.

[0075] For the VM instance management module:

[0076] The virtual machine instance management module manages multiple virtual machine instances and provides different interfaces for external requests to obtain virtual machine data. The module itself is a thread. After the thread is started, it will initialize the virtual machine instance list and wait for the server to listen for operation requests, including:

[0077] Virtual machine instance list (vmInstanceList): This list records the instances of the virtual machines. When the virtual machine is started, a virtual machine instance is generated and then added to the list.

[0078] Virtual machine instance lock (vmInstanceListLock): The deletion or addition of a virtual machine instance will be performed on multiple threads, so only one thread can use this lock to control the update of the virtual machine instance. The thread locks before the update and releases the lock after the update.

[0079] Service module (serverMode): A socket instance that is started when the virtual machine instance management module is started and is used to listen to external requests.

[0080] Operation function (optFunction): represents different functions. When a request comes in, the server module receives the request, determines the specific operation function, and executes the corresponding task.

[0081] For communication modules:

[0082] The communication module is used to obtain the data sent from the virtual machine to the virtual communication device, and transmit the data to the virtual machine instance through the callback function of the virtual machine instance, so as to obtain the information sent from the virtual machine system, specifically including:

[0083] epoll (event-driven model) example: used to monitor virtual communication device data and generate events to obtain the data of the corresponding device file descriptor (fd);

[0084] Newly registered socket information dictionary (new_fd_dict): This item is a dictionary data structure. The key of the dictionary is the file descriptor (fd). The value of each key is also a dictionary structure that stores information related to the virtual machine instance. The specific information includes the virtual machine instance (vmInstance), the virtual communication device name (vChannelName), the socket creation callback function (create_fd_callback), the virtual communication device connection callback function (connected_callback) and the data reading callback function (read_callback).

[0085] Unconnected socket information dictionary (fd_dict_unconnected): This dictionary stores the virtual machine instance information that has been registered socket information but has not yet connected to the virtual communication device.

[0086] Connected socket information dictionary (fd_dict_connected): This dictionary records the socket information that has been connected to the virtual communication device. After epoll generates an event, it will pass a file descriptor, and then find the corresponding fd from the unconnected socket information dictionary (fd_dict_unconnected) to read the data.

[0087] To unregister the socket information dictionary (del_fd_dict): This dictionary records the socket information that needs to be removed.

[0088] Socket list update lock: involves multi-threaded operations. In order to ensure that only one thread updates the list when updating the information in the list, a list lock is required. The process locks when updating the list information and releases the lock after the update is completed.

[0089] Register socket information function (register_function): When each virtual machine instance is initialized, the virtual communication device will be added to the virtual communication device list (vChannels_list), and each device will be registered to the communication module. When registering, the socket callback function is called to create the socket instance corresponding to the virtual communication device, and the corresponding file descriptor is obtained. The file descriptor (fd) is used as the key, and the dictionary structure that stores the virtual machine instance related information is generated. The specific information includes the virtual machine instance (vmInstance), the virtual communication device name (vChannelName), the socket callback function (create_fd_callback), the virtual communication device callback function (connected_callback), and the data reading callback function as the value.

[0090] Event processing function (hendle_events): This function continuously loops to obtain events of the epoll instance to obtain the file descriptor that needs to read data, updates the data in the newly registered socket information dictionary (new_fd_dict), the unconnected socket information dictionary (fd_dict_unconnected), the connected socket information dictionary (fd_dict_connected), and the socket information dictionary to be deregistered (del_fd_dict). After obtaining the file descriptor of the data, it determines whether the file descriptor is in the connected socket list (fd_list_connected). If so, the data is read through the corresponding data read callback function (read_callback) and the data is updated to the channelData corresponding to the virtual communication device list (vChannels_list).

[0091] Dictionary update function (update_fd_dict): used to update the data of the newly registered socket information dictionary (new_fd_dict) and the unconnected socket information dictionary (fd_dict_unconnected). Each update will update the data of the newly registered socket information dictionary (new_fd_dict) to the unconnected socket information dictionary (fd_dict_unconnected), and clear the newly registered socket information dictionary (new_fd_dict).

[0092] Connect an unconnected socket function (socket_connect): traverse the unconnected socket information dictionary (fd_dict_unconnected), call the connection virtual communication device callback function (connected_callback) to connect the corresponding socket and communication device, and if the connection is successful, move the socket information from the unconnected socket information dictionary (fd_dict_unconnected) to the connected socket information dictionary (fd_dict_connected).

[0093] Unregister socket information function (unregister_function): add the socket information to be unregistered to the socket information dictionary (del_fd_dict), and call the delete socket information function (del_fd_function) to remove the socket information.

[0094] Delete socket information function (del_fd_function): used to delete socket information, re-register the socket information dictionary (new_fd_dict), the unconnected socket information dictionary (fd_dict_unconnected), and remove the socket information to be deregistered from the connected socket information dictionary (fd_dict_connected).

[0095] Specifically, the following steps may be included:

[0096] Step 101, when monitoring that a target virtual communication device of a target virtual machine has target data to be read, obtain a target file descriptor; wherein each file descriptor has a corresponding socket instance.

[0097] In some embodiments of the present invention, when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, obtaining the target file descriptor includes: monitoring whether there is data that needs to be read by the virtual communication device through an event-driven mechanism, and obtaining the target file descriptor when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read.

[0098] In some embodiments of the present invention, when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, obtaining the target file descriptor includes: when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, generating a target event through an event-driven mechanism, and when the target event is detected, obtaining the target file descriptor.

[0099] As an example, the event-driven mechanism may be an epoll mechanism.

[0100] In actual applications, you can create an epoll instance, which is used to monitor the data of virtual communication devices and generate events. You can get the data of the corresponding device file descriptor (fd). After epoll generates an event, it will pass a file descriptor, and then find the corresponding fd from the unconnected socket information dictionary (fd_dict_unconnected) to read the data.

[0101] Step 102, when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, read the target data and update the target data to the entry corresponding to the target virtual communication device in the preset virtual communication device list.

[0102] In some embodiments of the present invention, when the target socket instance corresponding to the target file descriptor is already connected to the target virtual communication device, before reading the target data and updating the target data to the table entry corresponding to the target virtual communication device in the preset virtual communication device list, it also includes: determining whether the target file descriptor is in the connected socket information dictionary; if the target file descriptor is in the connected socket information dictionary, determining that the target socket instance corresponding to the target file descriptor is already connected to the target virtual communication device.

[0103] The connected socket information dictionary records relevant information of the connected virtual communication device.

[0104] In some embodiments of the present invention, it also includes: if the target file descriptor is not in the connected socket information dictionary, connecting the target socket instance corresponding to the target file descriptor and the target virtual communication device, and after the connection is successful, updating the connected socket information dictionary.

[0105] In some embodiments of the present invention, updating the connected socket information dictionary after the connection is successful includes: after the connection is successful, updating the socket information of the target socket instance from the unconnected socket information dictionary to the connected socket information dictionary; removing the relevant information of the target socket instance from the unconnected socket information dictionary.

[0106] The unconnected socket information dictionary records relevant information of a socket instance that has been registered but has not yet been connected to a virtual communication device.

[0107] In some embodiments of the present invention, before updating the socket information of the target socket instance from the unconnected socket information dictionary to the connected socket information dictionary, it also includes: acquiring a socket list update lock; after removing the relevant information of the target socket instance from the unconnected socket information dictionary, it also includes: releasing the socket list update lock.

[0108] In some embodiments of the present invention, before connecting the target socket instance corresponding to the target file descriptor and the target virtual communication device, it also includes: updating a newly registered socket information dictionary according to the target socket instance corresponding to the target file descriptor; updating an unconnected socket information dictionary according to the newly registered socket information dictionary, and clearing the newly registered socket information dictionary.

[0109] The newly registered socket information dictionary records the relevant information of the newly registered socket instance, and the unconnected socket information dictionary records the relevant information of the socket instance that has been registered but has not yet been connected to the virtual communication device.

[0110] In some embodiments of the present invention, before updating the newly registered socket information dictionary according to the target socket instance corresponding to the target file descriptor, it also includes: acquiring a socket list update lock; after clearing the newly registered socket information dictionary, it also includes: releasing the socket list update lock.

[0111] In some examples, combined Figure 2 , the communication module data transmission sub-process is as follows:

[0112] Run the event processing function (hendle_events) to determine whether the file descriptor with data is in the connected socket information dictionary (fd_dict_connected). If the file descriptor with data is in the connected socket information dictionary (fd_dict_connected), the data read callback function (read_callback) of the virtual machine instance corresponding to the descriptor will be called to update the corresponding data (channelData) in the virtual communication device list (vChannels_list). Lock operations are required before and after the list data is updated. Among them, the event processing function (hendle_events): This function continuously loops to obtain the events of the epoll instance to obtain the file descriptor that needs to read data, updates the data in the newly registered socket information dictionary (new_fd_dict), the unconnected socket information dictionary (fd_dict_unconnected), the connected socket information dictionary (fd_dict_connected), and the socket information dictionary to be deregistered (del_fd_dict). After obtaining the file descriptor of the data, it determines whether the file descriptor is in the connected socket list (fd_list_connected). If so, the data is read through the corresponding data read callback function (read_callback) and the data is updated to the channelData corresponding to the virtual communication device list (vChannels_list).

[0113] Data read callback function (read_callback): This function is used to call this function to read data when a virtual communication device has data to read. Different virtual communication devices may process different data, so different virtual communication devices may also process differently after reading.

[0114] Connected socket information dictionary (fd_dict_connected): This dictionary records the socket information that has been connected to the virtual communication device. After epoll generates an event, it will pass a file descriptor, and then find the corresponding fddes from the unconnected socket information dictionary (fd_dict_unconnected), and then read the data.

[0115] Virtual communication device list (vChannels_list): Each list item records an information instance of a virtual communication device, including the name of the virtual communication device (vChannelName), the device path (vChannelPath), related information of the socket instance, and the data read from the virtual communication device (channelData).

[0116] 2. If it is not in the connected socket information dictionary (fd_dict_connected), call the dictionary update function (update_fd_dict) to update the newly registered socket information dictionary (new_fd_dict) and the unconnected socket information dictionary (fd_dict_unconnected). Before updating, first obtain the socket list update lock, update the data items of the newly registered socket information dictionary (new_fd_dict) to the unconnected socket information dictionary (fd_dict_unconnected), then clear the newly registered socket information dictionary (new_fd_dict), and release the socket list update lock.

[0117] Among them, the dictionary update function (update_fd_dict): is used to update the data of the newly registered socket information dictionary (new_fd_dict) and the unconnected socket information dictionary (fd_dict_unconnected). Each update will update the data of the newly registered socket information dictionary (new_fd_dict) to the unconnected socket information dictionary (fd_dict_unconnected), and clear the newly registered socket information dictionary (new_fd_dict).

[0118] Newly registered socket information dictionary (new_fd_dict): This item is a dictionary data structure. The key of the dictionary is the file descriptor (fd). The value of each key is also a dictionary structure that stores information related to the virtual machine instance. The specific information includes the virtual machine instance (vmInstance), the virtual communication device name (vChannelName), the socket creation callback function (create_fd_callback), the virtual communication device connection callback function (connected_callback) and the data reading callback function (read_callback).

[0119] Unconnected socket information dictionary (fd_dict_unconnected): This dictionary stores the virtual machine instance information that has been registered socket information but has not yet connected to the virtual communication device.

[0120] 3. Call the function to connect an unconnected socket (socket_connect), update the unconnected socket information dictionary (fd_dict_unconnected) and the connected socket information dictionary (fd_dict_connected). Connect the described socket instance to the corresponding virtual communication device, obtain the socket list update lock before updating, and if the connection is successful, update the data item from the unconnected socket information dictionary (fd_dict_unconnected) to the connected socket information dictionary (fd_dict_connected), remove the data item from the unconnected socket information dictionary (fd_dict_unconnected), release the socket list update lock after updating, and use the communication module to register the descriptor to the epoll instance.

[0121] Among them, the function of connecting an unconnected socket (socket_connect): traverses the unconnected socket information dictionary (fd_dict_unconnected), calls the callback function of connecting the virtual communication device (connected_callback) to connect the corresponding socket and the communication device, and if the connection is successful, moves the socket information from the unconnected socket information dictionary (fd_dict_unconnected) to the connected socket information dictionary (fd_dict_connected).

[0122] epoll instance: used to monitor virtual communication device data and generate events, and can obtain the data of the corresponding device file descriptor (fd).

[0123] In some embodiments of the present invention, when monitoring that the target virtual communication device of the target virtual machine has target data that needs to be read, before obtaining the target file descriptor, it also includes: creating a virtual machine instance for the virtual machine running in the host machine.

[0124] In some embodiments of the present invention, after creating a virtual machine instance for the virtual machine running in the host machine, it also includes: obtaining information of a virtual communication device corresponding to the virtual machine, and creating a table entry corresponding to the virtual communication device in a preset virtual communication device list based on the information of the virtual communication device; creating a socket instance for the virtual communication device, and connecting to the virtual communication device through the socket instance.

[0125] In some embodiments of the present invention, the table entry corresponding to the virtual communication device in the virtual communication device list stores any one or more of the following: the name of the virtual communication device, the device path of the virtual communication device, the socket information of the socket instance corresponding to the virtual communication device, and the data read from the virtual communication device.

[0126] In some embodiments of the present invention, the creation of a socket instance for the virtual communication device includes: registering the virtual communication device, and creating a socket instance for the virtual communication device when registering the virtual communication device; adding socket information of the socket instance to a newly registered socket information dictionary; wherein the newly registered socket information dictionary records relevant information of the newly registered socket instance.

[0127] In some embodiments of the present invention, before creating an entry corresponding to the virtual communication device in a preset virtual communication device list according to the information of the virtual communication device, the method further includes: acquiring a virtual communication device list lock.

[0128] In some embodiments of the present invention, after adding the socket information of the socket instance to the newly registered socket information dictionary, the method further includes: releasing the virtual communication device list lock.

[0129] In some examples, combined Figure 3 , the virtual machine instance module creation sub-process is as follows:

[0130] 1. Create a virtual machine instance, obtain the information of all virtual communication devices of the virtual machine, obtain the virtual communication device list lock, and update the information of the virtual communication device to the virtual communication device list (vChannels_list). The information of each list item is the name of the virtual communication device (vChannelName), the device path (vChannelPath), the socket instance corresponding to the virtual communication device, and the data read from the virtual communication device (channelData).

[0131] Among them, the virtual communication device list (vChannels_list): each list item records the information instance of a virtual communication device, including the name of the virtual communication device (vChannelName), the device path (vChannelPath), the relevant information of the socket instance, and the data read from the virtual communication device (channelData).

[0132] 2. The virtual communication device that needs to communicate, through the communication module's register socket information function (register_function), adds the virtual machine instance (vmInstance), virtual communication device name (vChannelName), create socket callback function (create_fd_callback), connect virtual communication device callback function (connected_callback), and data read callback function (read_callback) data to the newly registered socket information dictionary (new_fd_dict).

[0133] Among them, register socket information function (register_function): when each virtual machine instance is initialized, the virtual communication device will be added to the virtual communication device list (vChannels_list), and each device will be registered to the communication module. When registering, the socket creation callback function is called to create the socket instance corresponding to the virtual communication device, and the corresponding file descriptor is obtained. The file descriptor (fd) is used as the key, and the dictionary structure that saves the virtual machine instance related information is generated. The specific information includes the virtual machine instance (vmInstance), the virtual communication device name (vChannelName), the creation socket callback function (create_fd_callback), the connection virtual communication device callback function (connected_callback) and the data reading callback function as the value.

[0134] Newly registered socket information dictionary (new_fd_dict): This item is a dictionary data structure. The key of the dictionary is the file descriptor (fd). The value of each key is also a dictionary structure that stores information related to the virtual machine instance. The specific information includes the virtual machine instance (vmInstance), the virtual communication device name (vChannelName), the socket creation callback function (create_fd_callback), the virtual communication device connection callback function (connected_callback) and the data reading callback function (read_callback).

[0135] 3. Release the virtual communication device list lock.

[0136] In some embodiments of the present invention, it also includes:

[0137] After an external request is monitored, a request operation type corresponding to the external request is determined, and an operation function corresponding to the request operation type is called to perform a corresponding operation.

[0138] In some examples, the virtual machine instance management module is the entire main thread. The virtual machine instance management module is responsible for overall management and main process startup. Figure 4 The implementation process is as follows:

[0139] 1. First, initialize the module, obtain the running virtual machine, create a virtual machine instance, obtain the virtual machine instance lock (vmInstanceListLock), update the virtual machine instance to the virtual machine instance list (vmInstanceList), and release the virtual machine instance lock (vmInstanceListLock).

[0140] 2. Create a communication module instance and create a thread to run the event processing function (hendle_events) to monitor the virtual communication device.

[0141] Among them, the event processing function (hendle_events): This function continuously loops to obtain the events of the epoll instance to obtain the file descriptor that needs to read data, updates the data in the newly registered socket information dictionary (new_fd_dict), the unconnected socket information dictionary (fd_dict_unconnected), the connected socket information dictionary (fd_dict_connected), and the socket information dictionary to be deregistered (del_fd_dict). After obtaining the file descriptor of the data, it determines whether the file descriptor is in the connected socket list (fd_list_connected). If so, the data is read through the corresponding data read callback function (read_callback) and the data is updated to the channelData corresponding to the virtual communication device list (vChannels_list).

[0142] 3. Initialize the service module (serverMode) and start to listen to external requests in a loop. When a request is received, determine the operation to be performed, and then call the corresponding operation function (optFunction). For example, when the communication device of a virtual machine instance is no longer used and the communication needs to be deregistered, a deregistration request can be made here.

[0143] Among them, the service module (serverMode) is a socket instance, which is started when the virtual machine instance management module is started and is used to listen to external requests.

[0144] Operation function (optFunction): represents different functions. When a request comes in, the server module receives the request, determines the specific operation function, and executes the corresponding task.

[0145] 4. When the loop monitor receives a stop command, it will exit the process.

[0146] In some embodiments of the present invention, it also includes:

[0147] When it is detected that the target virtual machine is shut down, the target socket instance corresponding to the target virtual communication device is deregistered, and the relevant information corresponding to the target socket instance is deleted.

[0148] In practical applications, dynamic addition and removal of virtual communication devices are provided through the maintenance of various file descriptor dictionaries, so that during the execution of the data acquisition program, data acquisition of newly started virtual machines and removal of shut down virtual machines can be added.

[0149] In an embodiment of the present invention, the host machine obtains a target file descriptor when it monitors that a target virtual communication device of a target virtual machine has target data that needs to be read, and each file descriptor has a corresponding socket instance; when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, the target data is read and the target data is updated to the table entry corresponding to the target virtual communication device in a preset virtual communication device list, thereby optimizing the process of the host machine reading data sent by the virtual machine through the virtual communication device and improving the convenience of the host machine in obtaining data in the virtual machine.

[0150] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0151] Reference Figure 5 , showing a structural schematic diagram of a virtual machine-based data processing device provided in some embodiments of the present invention, the device is applied to a host machine, the host machine is deployed with one or more virtual machines, and each virtual machine communicates with the host machine through a corresponding virtual communication device.

[0152] Specifically, the following modules may be included:

[0153] The reading monitoring module 501 is used to obtain the target file descriptor when monitoring that the target virtual communication device of the target virtual machine has target data to be read; wherein each file descriptor has a corresponding socket instance;

[0154] The data updating module 502 is used to read the target data and update the target data to the entry corresponding to the target virtual communication device in the preset virtual communication device list when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device.

[0155] Optionally, when monitoring that the target virtual communication device of the target virtual machine has target data that needs to be read, obtaining the target file descriptor includes:

[0156] The event-driven mechanism is used to monitor whether there is data that needs to be read by the virtual communication device, and when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, the target file descriptor is obtained.

[0157] Optionally, when monitoring that the target virtual communication device of the target virtual machine has target data that needs to be read, obtaining the target file descriptor includes:

[0158] When it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, a target event is generated through an event-driven mechanism, and when the target event is detected, a target file descriptor is obtained.

[0159] Optionally, when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, before obtaining the target file descriptor, the method further includes: creating a virtual machine instance for the virtual machine running in the host machine.

[0160] Optionally, after creating a virtual machine instance for the virtual machine running in the host machine, the method further includes:

[0161] Acquire information of a virtual communication device corresponding to the virtual machine, and create an entry corresponding to the virtual communication device in a preset virtual communication device list according to the information of the virtual communication device;

[0162] A socket instance for the virtual communication device is created, and a connection is established between the socket instance and the virtual communication device.

[0163] Optionally, the creating a socket instance for the virtual communication device includes:

[0164] Registering the virtual communication device, and creating a socket instance for the virtual communication device when registering the virtual communication device;

[0165] The socket information of the socket instance is added to a newly registered socket information dictionary; wherein the newly registered socket information dictionary records relevant information of the newly registered socket instance.

[0166] Optionally, before creating an entry corresponding to the virtual communication device in a preset virtual communication device list according to the information of the virtual communication device, the method further includes: acquiring a virtual communication device list lock;

[0167] After adding the socket information of the socket instance to the new registered socket information dictionary, the method further includes: releasing the virtual communication device list lock.

[0168] Optionally, the entry corresponding to the virtual communication device in the virtual communication device list stores any one or more of the following items:

[0169] The name of the virtual communication device, the device path of the virtual communication device, the socket information of the socket instance corresponding to the virtual communication device, and the data read from the virtual communication device.

[0170] Optionally, when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, before reading the target data and updating the target data to the entry corresponding to the target virtual communication device in the preset virtual communication device list, the method further includes:

[0171] Determine whether the target file descriptor is in a connected socket information dictionary; wherein the connected socket information dictionary records relevant information of a connected virtual communication device;

[0172] If the target file descriptor is in the connected socket information dictionary, it is determined that the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device.

[0173] Optionally, it also includes:

[0174] If the target file descriptor is not in the connected socket information dictionary, the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, and after the connection is successful, the connected socket information dictionary is updated.

[0175] Optionally, after the connection is successful, updating the connected socket information dictionary includes:

[0176] After the connection is successful, the socket information of the target socket instance is updated from the unconnected socket information dictionary to the connected socket information dictionary; wherein the unconnected socket information dictionary records the relevant information of the socket instance that has been registered but has not yet connected to the virtual communication device;

[0177] The relevant information of the target socket instance is removed from the unconnected socket information dictionary.

[0178] Optionally, before updating the socket information of the target socket instance from the unconnected socket information dictionary to the connected socket information dictionary, the method further includes: acquiring a socket list update lock;

[0179] After removing the relevant information of the target socket instance from the unconnected socket information dictionary, the method further includes: releasing a socket list update lock.

[0180] Optionally, before connecting the target socket instance corresponding to the target file descriptor and the target virtual communication device, the method further includes:

[0181] According to the target socket instance corresponding to the target file descriptor, the newly registered socket information dictionary is updated; wherein the newly registered socket information dictionary records the relevant information of the newly registered socket instance;

[0182] According to the newly registered socket information dictionary, the unconnected socket information dictionary is updated, and the newly registered socket information dictionary is cleared; wherein the unconnected socket information dictionary records the relevant information of the socket instance that has been registered but has not yet connected to the virtual communication device.

[0183] Optionally, before updating the newly registered socket information dictionary according to the target socket instance corresponding to the target file descriptor, the method further includes:

[0184] Get the socket list update lock;

[0185] After clearing the newly registered socket information dictionary, the method further includes:

[0186] Release the socket list update lock.

[0187] Optionally, it also includes:

[0188] When it is detected that the target virtual machine is shut down, the target socket instance corresponding to the target virtual communication device is deregistered, and the relevant information corresponding to the target socket instance is deleted.

[0189] Optionally, it also includes:

[0190] After an external request is monitored, a request operation type corresponding to the external request is determined, and an operation function corresponding to the request operation type is called to perform a corresponding operation.

[0191] In an embodiment of the present invention, the host machine obtains a target file descriptor when it monitors that a target virtual communication device of a target virtual machine has target data that needs to be read, and each file descriptor has a corresponding socket instance; when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, the target data is read and the target data is updated to the table entry corresponding to the target virtual communication device in a preset virtual communication device list, thereby optimizing the process of the host machine reading data sent by the virtual machine through the virtual communication device and improving the convenience of the host machine in obtaining data in the virtual machine.

[0192] Reference Figure 6 , shows an electronic device provided by some embodiments of the present invention, including a processor 601, a memory 602, and a computer program stored in the memory 602 and capable of running on the processor 601, and the above method is implemented when the computer program is executed by the processor.

[0193] Reference Figure 7 , shows a computer-readable storage medium 700 provided in some embodiments of the present invention, on which a computer program is stored, and the computer program implements the above method when executed by a processor.

[0194] Reference Figure 8 , shows a computer program product 800 provided by some embodiments of the present invention, including a computer program, which implements the above method when executed by a processor.

[0195] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0196] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0197] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0198] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0199] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0200] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0201] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0202] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0203] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.

[0204] The above is a detailed introduction to a data processing method, device, equipment and medium based on a virtual machine. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for a person skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A data processing method based on a virtual machine, characterized in that: The method is applied to a host machine, the host machine is deployed with one or more virtual machines, each virtual machine communicates with the host machine through a corresponding virtual communication device, and the method includes: When monitoring that the target virtual communication device of the target virtual machine has target data that needs to be read, obtaining the target file descriptor; wherein each file descriptor has a corresponding socket instance; In the case that the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, reading the target data, and updating the target data to the entry corresponding to the target virtual communication device in the preset virtual communication device list; The step of obtaining the target file descriptor when monitoring that the target virtual communication device of the target virtual machine has target data to be read includes: Through the event-driven mechanism, monitor whether there is data that needs to be read by the virtual communication device, and when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, obtain the target file descriptor; Wherein, when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, before reading the target data and updating the target data to the entry corresponding to the target virtual communication device in the preset virtual communication device list, the method further includes: Determine whether the target file descriptor is in a connected socket information dictionary; wherein the connected socket information dictionary records relevant information of a connected virtual communication device; If the target file descriptor is in the connected socket information dictionary, it is determined that the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device.

2. The method according to claim 1, characterized in that The method of acquiring a target file descriptor when monitoring that a target virtual communication device of a target virtual machine has target data to be read includes: When it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, a target event is generated through an event-driven mechanism, and when the target event is detected, a target file descriptor is obtained.

3. The method according to any one of claims 1 to 2, characterized in that: When it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, before obtaining the target file descriptor, the method further includes: creating a virtual machine instance for the virtual machine running in the host machine.

4. The method according to claim 3, characterized in that After the virtual machine instance for the virtual machine running in the host machine is created, the method further includes: Acquire information of a virtual communication device corresponding to the virtual machine, and create an entry corresponding to the virtual communication device in a preset virtual communication device list according to the information of the virtual communication device; A socket instance for the virtual communication device is created, and a connection is established between the socket instance and the virtual communication device.

5. The method according to claim 4, characterized in that The creating a socket instance for the virtual communication device comprises: Registering the virtual communication device, and creating a socket instance for the virtual communication device when registering the virtual communication device; The socket information of the socket instance is added to a newly registered socket information dictionary; wherein the newly registered socket information dictionary records relevant information of the newly registered socket instance.

6. The method according to claim 5, characterized in that Before creating an entry corresponding to the virtual communication device in a preset virtual communication device list according to the information of the virtual communication device, the method further includes: acquiring a virtual communication device list lock; After adding the socket information of the socket instance to the new registered socket information dictionary, the method further includes: releasing the virtual communication device list lock.

7. The method according to claim 4, characterized in that The entry corresponding to the virtual communication device in the virtual communication device list stores any one or more of the following items: The name of the virtual communication device, the device path of the virtual communication device, the socket information of the socket instance corresponding to the virtual communication device, and the data read from the virtual communication device.

8. The method according to claim 1, characterized in that Also includes: If the target file descriptor is not in the connected socket information dictionary, the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, and after the connection is successful, the connected socket information dictionary is updated.

9. The method according to claim 8, characterized in that After the connection is successful, updating the connected socket information dictionary includes: After the connection is successful, the socket information of the target socket instance is updated from the unconnected socket information dictionary to the connected socket information dictionary; wherein the unconnected socket information dictionary records the relevant information of the socket instance that has been registered but has not yet connected to the virtual communication device; The relevant information of the target socket instance is removed from the unconnected socket information dictionary.

10. The method according to claim 9, characterized in that Before updating the socket information of the target socket instance from the unconnected socket information dictionary to the connected socket information dictionary, the method further includes: acquiring a socket list update lock; After removing the relevant information of the target socket instance from the unconnected socket information dictionary, the method further includes: releasing a socket list update lock.

11. The method according to claim 8, characterized in that Before connecting the target socket instance corresponding to the target file descriptor and the target virtual communication device, the method further includes: According to the target socket instance corresponding to the target file descriptor, the newly registered socket information dictionary is updated; wherein the newly registered socket information dictionary records the relevant information of the newly registered socket instance; According to the newly registered socket information dictionary, the unconnected socket information dictionary is updated, and the newly registered socket information dictionary is cleared; wherein the unconnected socket information dictionary records the relevant information of the socket instance that has been registered but has not yet connected to the virtual communication device.

12. The method according to claim 11, characterized in that Before updating the newly registered socket information dictionary according to the target socket instance corresponding to the target file descriptor, the method further includes: Get the socket list update lock; After clearing the newly registered socket information dictionary, the method further includes: Release the socket list update lock.

13. The method according to any one of claims 1 to 2, characterized in that: Also includes: When it is detected that the target virtual machine is shut down, the target socket instance corresponding to the target virtual communication device is deregistered, and the relevant information corresponding to the target socket instance is deleted.

14. The method according to any one of claims 1 to 2, characterized in that: Also includes: After an external request is monitored, a request operation type corresponding to the external request is determined, and an operation function corresponding to the request operation type is called to perform a corresponding operation.

15. A data processing device based on a virtual machine, characterized in that: The device is applied to a host machine, the host machine is deployed with one or more virtual machines, each virtual machine communicates with the host machine through a corresponding virtual communication device, and the device includes: A read monitoring module is used to obtain a target file descriptor when monitoring that a target virtual communication device of a target virtual machine has target data to be read; wherein each file descriptor has a corresponding socket instance; A data updating module, configured to read the target data and update the target data to an entry corresponding to the target virtual communication device in a preset virtual communication device list when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device; Among them, the reading monitoring module is specifically used for: Monitor whether there is data that needs to be read by the virtual communication device through an event-driven mechanism, and when it is monitored that the target virtual communication device of the target virtual machine has target data that needs to be read, obtain the target file descriptor; Wherein, when the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device, before reading the target data and updating the target data to the entry corresponding to the target virtual communication device in the preset virtual communication device list, the method further includes: Determine whether the target file descriptor is in a connected socket information dictionary; wherein the connected socket information dictionary records relevant information of a connected virtual communication device; If the target file descriptor is in the connected socket information dictionary, it is determined that the target socket instance corresponding to the target file descriptor is connected to the target virtual communication device.

16. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the method according to any one of claims 1 to 14 when executed by the processor.

17. 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 processor, the method according to any one of claims 1 to 14 is implemented.

18. A computer program product, characterized in that A computer program is included which, when executed by a processor, implements the method according to any one of claims 1 to 14.

Citation Information

Patent Citations

  • Communication method and system for virtual machine and client during network isolation

    CN112565372A