Disclosure of Invention
In view of this, an object of the embodiments of the present invention is to provide a method for encrypting a snapshot of a virtual machine memory, where snapshot contents related to the virtual machine memory are encrypted and decrypted when the snapshot is recovered, and the entire process ensures that the snapshot information contents are kept confidential without affecting the snapshot function of the existing virtual machine memory.
Based on the above object, an aspect of the embodiments of the present invention provides a method for encrypting a memory snapshot of a virtual machine, including the following steps:
adding an encryption algorithm to a memory storage pre-processing function in a virtual machine equipment state linked list in the analog processor;
reading the virtual machine content stored in the Libvirt, encrypting the content, and storing the encrypted content in a memory snapshot file;
reading and traversing the virtual machine equipment state linked list to acquire the memory storage preprocessing function, reading the configuration information and the memory information of the virtual machine equipment through the memory storage preprocessing function and encrypting the information into encrypted information;
and encrypting other information stored in the analog processor into encrypted information, and storing all the encrypted information into the memory snapshot file.
In some embodiments, the adding an encryption algorithm to a pre-memory-save processing function in a virtual machine device state linked list in the simulation processor further comprises:
and adding a decryption algorithm corresponding to the encryption algorithm to the memory loading post-processing function in the linked list.
In some embodiments, the method encrypts the virtual machine content information using an AES encryption algorithm.
In some embodiments, the method further comprises:
and after the memory snapshot file is obtained, decrypting the file through a corresponding decryption algorithm.
In some embodiments, after the obtaining the memory snapshot file, decrypting the file through a corresponding decryption algorithm further includes:
firstly, decrypting the encrypted Libvirt content stored in the memory snapshot file, and starting a virtual machine through the decrypted Libvirt content.
In some embodiments, after the obtaining the memory snapshot file, decrypting the file through a corresponding decryption algorithm further includes:
decrypting other information stored in the analog processor;
traversing the virtual machine device state linked list of the simulation processor stored in the memory snapshot file to obtain the memory loading post-processing function of each virtual machine device in the linked list, and decrypting the configuration information and the memory information of the virtual machine device through the memory loading post-processing function;
and loading the information into the memory of the virtual machine.
In some embodiments, the method is used for virtual machine memory snapshot encryption under KVM virtualization.
In some embodiments, the analog processor is Qemu.
Another aspect of the embodiments of the present invention provides a device for encrypting a memory snapshot of a virtual machine, including:
at least one processor; and
a memory storing program code executable by the processor, the program code implementing the following steps when executed by the processor:
adding an encryption algorithm to a memory storage pre-processing function in a virtual machine equipment state linked list in the analog processor;
reading the virtual machine content stored in the Libvirt, encrypting the content, and storing the encrypted content in a memory snapshot file;
reading and traversing the virtual machine equipment state linked list to acquire the memory storage preprocessing function, reading the configuration information and the memory information of the virtual machine equipment through the memory storage preprocessing function and encrypting the information into encrypted information;
and encrypting other information stored in the analog processor into encrypted information, and storing all the encrypted information into the memory snapshot file.
In some embodiments, the adding an encryption algorithm to a pre-memory-save processing function in a virtual machine device state linked list in the simulation processor further comprises:
and adding a decryption algorithm corresponding to the encryption algorithm to the memory loading post-processing function in the linked list.
The invention has the following beneficial technical effects: according to the method and the device for encrypting the virtual machine memory snapshot, provided by the embodiment of the invention, the snapshot content related to the virtual machine memory is encrypted, and the content is decrypted when the snapshot is recovered, so that the problem that the virtual machine sensitive information is stored in the memory snapshot file in a plaintext mode is solved, the security of the cloud product virtual machine memory snapshot is improved, and the leakage of the virtual machine sensitive information is prevented; the whole process ensures that the memory snapshot function of the existing virtual machine is not influenced under the condition that the snapshot information content is kept confidential.
Detailed Description
Embodiments of the present invention are described below. However, it is to be understood that the disclosed embodiments are merely examples and that other embodiments may take various and alternative forms. The figures are not necessarily to scale; certain features may be exaggerated or minimized to show details of particular components. Therefore, specific structural and functional details disclosed herein are not to be interpreted as limiting, but merely as a representative basis for teaching one skilled in the art to variously employ the present invention. As one of ordinary skill in the art will appreciate, various features illustrated and described with reference to any one of the figures may be combined with features illustrated in one or more other figures to produce embodiments that are not explicitly illustrated or described. The combination of features shown provides a representative embodiment for a typical application. However, various combinations and modifications of the features consistent with the teachings of the present invention may be desired for certain specific applications or implementations.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
In the prior art, the virtual machine memory snapshot is stored in a specific format and a plaintext manner, and this unsafe memory information storage manner inevitably has a great potential safety hazard, so that it is necessary to encrypt the snapshot content related to the virtual machine memory and decrypt the content when the snapshot is recovered, as shown in fig. 2, to ensure the security of the virtual machine memory snapshot file.
Based on the above object, an embodiment of the present invention provides a method for encrypting a memory snapshot of a virtual machine, as shown in fig. 3, including the following steps:
step S301: adding an encryption algorithm to a memory storage pre-processing function in a virtual machine equipment state linked list in the analog processor;
step S302: reading the virtual machine content stored in the Libvirt, encrypting the content, and storing the encrypted content in a memory snapshot file;
step S303: reading and traversing the virtual machine equipment state linked list to obtain the modified memory storage preprocessing function, reading the configuration information and the memory information of the virtual machine equipment through the memory storage preprocessing function and encrypting the information into encrypted information;
step S304: and encrypting other information stored in the analog processor into encrypted information, and storing all the encrypted information into the memory snapshot file.
In some embodiments, adding the encryption algorithm to a pre-memory save processing function (pre _ save function) in a virtual machine device state linked list in an analog processor (e.g., Qemu) further comprises: adding a decryption algorithm to a post-memory-loading processing function (post _ load function) in the linked list, wherein the modified pre-memory-storage processing function can encrypt read information through an encryption algorithm, and the modified post-memory-loading processing function can decrypt the encrypted information through a decryption algorithm corresponding to the encryption algorithm. In some embodiments, the method encrypts the virtual machine content information using an AES encryption algorithm.
In some embodiments, the method further comprises: and after the memory snapshot file is obtained, decrypting the file through a corresponding decryption algorithm.
In some embodiments, after the memory snapshot file is obtained, decrypting the file through a corresponding decryption algorithm includes: firstly, decrypting the encrypted Libvirt content stored in the memory snapshot file, and starting a virtual machine through the decrypted Libvirt content. In other embodiments, other information stored in the analog processor is then decrypted; traversing the virtual machine device state linked list of the analog processor stored in the memory snapshot file to obtain the memory loading post-processing function of each virtual machine device in the linked list, and decrypting the configuration information and the memory information of the virtual machine device through the memory loading post-processing function; and loading the information into the memory of the virtual machine.
In some embodiments, the method is used for virtual machine memory snapshot encryption under KVM virtualization.
In an embodiment according to the present invention, the virtual machine memory snapshot includes two parts, one part is the configuration file and the runtime content of the virtual machine stored by Libvirt, and the other part is the content of Qemu runtime. As shown in fig. 4, it is first required to obtain the virtual machine configuration file and content stored in Libvirt during the encryption process, and the virtual machine configuration file and content are stored in a specific format. And reading the virtual machine content stored in the Libvirt by a specific format, and encrypting the content by using an encryption algorithm such as AES (advanced encryption standard) after the reading is finished.
The method comprises the steps of obtaining runtime information of a virtual machine in Qemu, wherein the runtime information comprises information of Qemu software, configuration information of virtual machine equipment, and memory allocation conditions and contents of the equipment in runtime. Wherein, Qemu provides a virtual machine device state linked list (i.e. vmState linked list), and names and positions of all devices of the virtual machine and a memory storage pre-processing function (pre _ save function) and a memory loading post-processing function (post _ load function) corresponding to the devices are registered in the linked list. And modifying a pre _ save function and a post _ load function in advance, wherein the modified pre _ save function can encrypt the read information through an encryption algorithm, and the modified post _ load function can decrypt the encrypted information through a decryption algorithm corresponding to the encryption algorithm. The method comprises the steps of acquiring a pre _ save function after modification of devices needing encryption by traversing the linked list, acquiring configuration information of virtual machine devices and memory allocation conditions and contents in the memories when the devices run by executing the pre _ save function, encrypting the acquired contents by a proper encryption algorithm (such as an AES algorithm), and storing the encrypted data in a vmState linked list.
And after other information stored in Qemu is encrypted, all data stored in Qemu and the content of Libvirt are stored in the memory snapshot file together.
In one embodiment according to the present invention, Libvirt configuration and runtime information about the virtual machine, and Qemu configuration and runtime information are stored in the memory snapshot file. As shown in fig. 5, in the process of recovering the virtual machine, it is necessary to first designate a corresponding memory snapshot file, and decrypt the content of Libvirt in the memory snapshot file to obtain a plaintext configuration file and runtime information; and starting a virtual machine through the configuration file and the running information of the Libvirt, wherein the virtual machine is in a waiting state and is not really in normal running until new memory information is loaded again.
Traversing a qmeu vmState linked list to obtain information of equipment to be decrypted and a memory, wherein the obtained information is ciphertext content; and executing a post _ load function of each device in the vmState linked list, decrypting the ciphertext information, acquiring plaintext information, and loading the plaintext information into the memory of the virtual machine. And finishing the memory loading of the virtual machine, and enabling the virtual machine to run normally.
Where technically feasible, the technical features listed above for the different embodiments may be combined with each other or changed, added, omitted, etc. to form further embodiments within the scope of the invention.
As can be seen from the foregoing embodiments, the method for encrypting the virtual machine memory snapshot according to the embodiments of the present invention encrypts the snapshot content related to the virtual machine memory, and decrypts the content when the snapshot is recovered, so as to solve the problem that the memory snapshot file stores the virtual machine sensitive information in the plaintext, improve the security of the cloud product virtual machine memory snapshot, and prevent the leakage of the virtual machine sensitive information; the whole process ensures that the memory snapshot function of the existing virtual machine is not influenced under the condition that the snapshot information content is kept confidential.
In view of the foregoing, another aspect of the embodiments of the present invention provides an embodiment of an apparatus for encrypting a memory snapshot of a virtual machine.
The device for encrypting the memory snapshot of the virtual machine comprises a storage and at least one processor, wherein the storage stores a computer program capable of running on the processor, and the processor executes any one of the methods when executing the computer program.
Fig. 6 is a schematic hardware structure diagram of an embodiment of a device for encrypting a memory snapshot of a virtual machine according to the present invention.
Taking the computer device shown in fig. 6 as an example, the computer device includes a processor 601 and a memory 602, and may further include: an input device 603 and an output device 604.
The processor 601, the memory 602, the input device 603 and the output device 604 may be connected by a bus or other means, and fig. 6 illustrates the connection by a bus as an example.
The memory 602, serving as a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions/modules corresponding to the method for encrypting the snapshot of the virtual machine memory in the embodiment of the present application. The processor 601 executes various functional applications and data processing of the server by running the nonvolatile software program, instructions and modules stored in the storage 602, that is, the method for encrypting the memory snapshot of the virtual machine according to the above-described method embodiment is implemented.
The memory 602 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area can store data and the like created according to the virtual machine memory snapshot encryption method. Further, the memory 602 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, memory 602 optionally includes memory located remotely from processor 601, which may be connected to local modules via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 603 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the computer apparatus of the method for encrypting the memory snapshot of the virtual machine. The output device 604 may include a display device such as a display screen.
Program instructions/modules corresponding to the one or more methods for encrypting the memory snapshot of the virtual machine are stored in the storage 602, and when executed by the processor 601, the method for encrypting the memory snapshot of the virtual machine in any of the above-described method embodiments is executed.
Any embodiment of the computer device executing the method for encrypting the memory snapshot of the virtual machine may achieve the same or similar effects as any corresponding embodiment of the foregoing method.
Finally, it should be noted that, as will be understood by those skilled in the art, all or part of the processes in the methods of the above embodiments may be implemented by a computer program, which may be stored in a computer-readable storage medium, and when executed, may include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), a Random Access Memory (RAM), or the like.
In addition, the apparatuses, devices and the like disclosed in the embodiments of the present invention may be various electronic terminal devices, such as a mobile phone, a Personal Digital Assistant (PDA), a tablet computer (PAD), a smart television and the like, or may be a large terminal device, such as a server and the like, and therefore the scope of protection disclosed in the embodiments of the present invention should not be limited to a specific type of apparatus, device. The client disclosed in the embodiment of the present invention may be applied to any one of the above electronic terminal devices in the form of electronic hardware, computer software, or a combination of both.
Furthermore, the method disclosed according to an embodiment of the present invention may also be implemented as a computer program executed by a CPU, and the computer program may be stored in a computer-readable storage medium. The computer program, when executed by the CPU, performs the above-described functions defined in the method disclosed in the embodiments of the present invention.
Further, the above method steps and system elements may also be implemented using a controller and a computer readable storage medium for storing a computer program for causing the controller to implement the functions of the above steps or elements.
Further, it should be appreciated that the computer-readable storage media (e.g., memory) described herein can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. By way of example, and not limitation, nonvolatile memory can include Read Only Memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which can act as external cache memory. By way of example and not limitation, RAM is available in a variety of forms such as synchronous RAM (DRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The storage devices of the disclosed aspects are intended to comprise, without being limited to, these and other suitable types of memory.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments of the present invention.
The various illustrative logical blocks, modules, and circuits described in connection with the disclosure herein may be implemented or performed with the following components designed to perform the functions described herein: a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. A general purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP, and/or any other such configuration.
The steps of a method or algorithm described in connection with the disclosure herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In the alternative, the processor and the storage medium may reside as discrete components in a user terminal.
In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Also, any connection is properly termed a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of medium. Disk and disc, as used herein, includes Compact Disc (CD), laser disc, optical disc, Digital Versatile Disc (DVD), floppy disk, blu-ray disc where disks usually reproduce data magnetically, while discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk, an optical disk, or the like.
The above-described embodiments are possible examples of implementations and are presented merely for a clear understanding of the principles of the invention. Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of an embodiment of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.