CN117667309A - Snapshot mirror image loading method and device, storage medium and electronic equipment - Google Patents

Snapshot mirror image loading method and device, storage medium and electronic equipment Download PDF

Info

Publication number
CN117667309A
CN117667309A CN202311665953.5A CN202311665953A CN117667309A CN 117667309 A CN117667309 A CN 117667309A CN 202311665953 A CN202311665953 A CN 202311665953A CN 117667309 A CN117667309 A CN 117667309A
Authority
CN
China
Prior art keywords
memory page
virtual machine
page
mirror image
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311665953.5A
Other languages
Chinese (zh)
Inventor
白永树
杨智慧
高丰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Lab
Original Assignee
Zhejiang Lab
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Lab filed Critical Zhejiang Lab
Priority to CN202311665953.5A priority Critical patent/CN117667309A/en
Publication of CN117667309A publication Critical patent/CN117667309A/en
Pending legal-status Critical Current

Links

Abstract

The specification discloses a snapshot mirror loading method, a snapshot mirror loading device, a storage medium and an electronic device, wherein the snapshot mirror loading method comprises the following steps: and the starting platform generates a snapshot mirror image corresponding to the virtual machine and marks whether each memory page in the snapshot mirror image is empty. Starting a virtual machine and a page fault processing program, when a kernel accesses the internal memory of the virtual machine from the virtual machine, determining an internal memory page which is not loaded into the internal memory of the virtual machine in the snapshot mirror image as a target internal memory page, sending information of the target internal memory page to the page fault processing program, enabling the page fault processing program to determine a mark in the snapshot mirror image according to the information of the target internal memory page, loading the empty internal memory page into the internal memory of the virtual machine when the mark represents that the target internal memory page is empty, and reading the target internal memory page in the snapshot mirror image and loading the target internal memory into the internal memory of the virtual machine when the mark represents that the target internal memory page is not empty, thereby reducing the operation of reading the snapshot mirror image and saving the loading time of the snapshot mirror image.

Description

Snapshot mirror image loading method and device, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and apparatus for loading a snapshot image, a storage medium, and an electronic device.
Background
With the continuous development of technology, snapshot mechanisms are increasingly widely applied, and particularly, the snapshot mechanisms are applied to the field of virtual machines. Meanwhile, the no-server computing is widely focused, and the no-server computing (Serverless Computing), also called function as a service (Function as a Service, abbreviated as FaaS), is a cloud computing model for providing computing resources on demand, and aims to provide a very good elastic capacity expansion and contraction mechanism and low-cost service deployment for users.
Currently, in the serverless computing, the started function sandboxes can be saved to the hard disk in a snapshot mirror mode through a virtual machine snapshot mechanism. When the function sandbox is called, the snapshot image corresponding to the function sandbox is loaded into the memory of the virtual machine to restore the function sandbox, so that the processes of kernel initialization and function service initialization are avoided. However, when accessing the internal memory of the virtual machine, the virtual machine needs to read the memory pages from the snapshot mirror image corresponding to the function sandbox as required, thereby causing a large number of hard disk reading operations and reducing the performance of the function sandbox. Therefore, how to load snapshot images is a very important issue.
Based on the above, a snapshot image loading method is provided in the specification.
Disclosure of Invention
The present disclosure provides a method, an apparatus, a storage medium, and an electronic device for loading a snapshot image, so as to partially solve the foregoing problems in the prior art.
The technical scheme adopted in the specification is as follows:
the specification provides a loading method of snapshot mirror images, which is applied to a starting platform and comprises the following steps:
generating a snapshot mirror image corresponding to the virtual machine;
marking whether each memory page in the snapshot mirror image is empty or not;
starting the virtual machine and a page fault processing program, when the kernel accesses the internal memory of the virtual machine, determining an internal memory page which is not loaded to the internal memory of the virtual machine in the snapshot mirror image as a target internal memory page, and sending information of the target internal memory page to the page fault processing program, so that the page fault processing program determines a mark of the target internal memory page in the snapshot mirror image according to the information of the target internal memory page, when the mark represents that the target internal memory page is empty, loading the empty internal memory page into the internal memory of the virtual machine, and when the mark represents that the target internal memory page is not empty, reading the target internal memory page in the snapshot mirror image and loading the target internal memory page into the internal memory of the virtual machine.
Optionally, generating a snapshot image corresponding to the virtual machine specifically includes:
sending a first instruction to a virtual machine, and enabling the virtual machine to set the content of an idle memory page in a memory of the virtual machine to be a specified value according to the first instruction;
and generating a snapshot mirror image corresponding to the virtual machine based on the updated memory.
Optionally, marking whether each memory page in the snapshot mirror image is empty specifically includes:
judging whether the content of each memory page in the snapshot mirror image is a specified value or not according to each memory page in the snapshot mirror image;
if yes, determining that the memory page is empty, and marking the position corresponding to the memory page in a preset bitmap as empty;
if not, determining that the memory page is non-empty, and marking the position corresponding to the memory page in the bitmap as non-empty.
Optionally, starting the virtual machine and the page fault processing program specifically includes:
determining a communication port number of the page fault handler;
generating a first starting instruction according to the communication port number, and sending the first starting instruction to a virtual machine monitor so that the virtual machine monitor starts the virtual machine;
and generating a second starting instruction according to the communication port number to start the page fault handling program, and sending the bitmap to the page fault handling program.
The present specification also provides a method for loading a snapshot image, where the method is applied to a page fault handling program, and includes:
receiving information of a target memory page sent by a kernel; the target memory page is a memory page which is not loaded into the memory of the virtual machine in a snapshot mirror image, and the snapshot mirror image is a mirror image corresponding to the virtual machine generated by a starting platform;
determining a mark in the snapshot mirror image according to the information of the target memory page; the mark is obtained by marking whether each memory page in the snapshot mirror image is empty or not by the starting platform;
when the mark indicates that the target memory page is empty, loading the empty memory page into the memory of the virtual machine;
and when the mark indicates that the target memory page is non-empty, the target memory page is read in the snapshot mirror image and is loaded into the memory of the virtual machine.
Optionally, the information of the target memory page includes a virtual address corresponding to the target memory page;
receiving information of a target memory page sent by a kernel, wherein the information specifically comprises:
receiving a bitmap corresponding to the snapshot mirror image sent by the starting platform, wherein the bitmap is used for storing marks of the starting platform on each memory page in the snapshot mirror image;
Receiving information of a virtual address block corresponding to a memory of the virtual machine, which is sent by the virtual machine, wherein the virtual address block generates an address block for storing a snapshot image loaded to the memory for the virtual machine;
and when the memory page which is not loaded to the memory of the virtual machine is determined in the snapshot mirror image, receiving the virtual address corresponding to the target memory page sent by the kernel.
Optionally, the information includes a start address and a unit length of the virtual address block;
determining the mark in the snapshot mirror image of the target memory page according to the information of the target memory page, wherein the method specifically comprises the following steps:
determining a difference value of a virtual address corresponding to the target memory page minus the initial address;
determining an offset address according to the difference value and the unit length;
and determining a mark corresponding to the offset address from the bitmap, and taking the mark as the mark corresponding to the target memory page.
The present specification provides a loading device for snapshot mirror, where the device is applied to a start platform, and includes:
the generation module is used for generating a snapshot mirror image corresponding to the virtual machine;
the marking module is used for marking whether each memory page in the snapshot mirror image is empty or not;
The starting module is used for starting the virtual machine and the page fault processing program, when the kernel accesses the internal memory of the virtual machine, determining an internal memory page which is not loaded to the internal memory of the virtual machine in the snapshot mirror image as a target internal memory page, and sending the information of the target internal memory page to the page fault processing program, so that the page fault processing program determines a mark of the target internal memory page in the snapshot mirror image according to the information of the target internal memory page, when the mark indicates that the target internal memory page is empty, the empty internal memory page is loaded into the internal memory of the virtual machine, and when the mark indicates that the target internal memory page is not empty, the target internal memory page is read in the snapshot mirror image and is loaded into the internal memory of the virtual machine.
The present specification also provides a loading apparatus of a snapshot mirror, the apparatus being applied to a page fault handling program, comprising:
the receiving module is used for receiving the information of the target memory page sent by the kernel; the target memory page is a memory page which is not loaded to a memory of the virtual machine in a snapshot mirror image, and the snapshot mirror image is a mirror image corresponding to the virtual machine generated by a starting platform;
The determining module is used for determining marks in the snapshot mirror image of the target memory page according to the information of the target memory page; the mark is obtained by marking whether each memory page in the snapshot mirror image is empty or not by the starting platform;
the loading module is used for loading the empty memory page into the memory of the virtual machine when the mark indicates that the target memory page is empty; and when the mark indicates that the target memory page is non-empty, the target memory page is read in the snapshot mirror image and is loaded into the memory of the virtual machine.
The present specification provides a computer readable storage medium storing a computer program which when executed by a processor implements the above-described snapshot mirroring loading method.
The present specification provides an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the above-described snapshot image loading method when executing the program.
The above-mentioned at least one technical scheme that this specification adopted can reach following beneficial effect:
According to the snapshot image loading method provided by the specification, the platform is started to generate the snapshot image corresponding to the virtual machine, and whether all memory pages in the snapshot image are empty or not is marked. And then, starting the virtual machine and the page fault processing program, when the kernel accesses the internal memory of the virtual machine, determining the internal memory page which is not loaded into the internal memory of the virtual machine in the snapshot mirror image as a target internal memory page, and sending the information of the target internal memory page to the page fault processing program, so that the page fault processing program determines the mark of the target internal memory page in the snapshot mirror image according to the information of the target internal memory page, when the mark indicates that the target internal memory page is empty, loading the empty internal memory page into the internal memory of the virtual machine, and when the mark indicates that the target internal memory page is not empty, reading the target internal memory page in the snapshot mirror image and loading the mark into the internal memory of the virtual machine.
According to the method, when the snapshot mirror image is loaded, the starting platform generates the snapshot mirror image corresponding to the virtual machine and marks whether each memory page in the snapshot mirror image is empty or not. And then, starting the virtual machine and the page fault processing program, when the kernel accesses the internal memory of the virtual machine, determining the internal memory page which is not loaded into the internal memory of the virtual machine in the snapshot mirror image as a target internal memory page, and sending the information of the target internal memory page to the page fault processing program, so that the page fault processing program determines the mark of the target internal memory page in the snapshot mirror image according to the information of the target internal memory page, when the mark indicates that the target internal memory page is empty, loading the empty internal memory page into the internal memory of the virtual machine, and when the mark indicates that the target internal memory page is not empty, reading the target internal memory page in the snapshot mirror image and loading the mark into the internal memory of the virtual machine. By loading only the empty memory page when the target memory page is empty and reading the target memory page and loading when the target memory page is not empty, the operation of reading the snapshot mirror image is reduced, the loading time of the snapshot mirror image is saved, and the running time of function service is reduced.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification, illustrate and explain the exemplary embodiments of the present specification and their description, are not intended to limit the specification unduly. In the drawings:
FIG. 1 is a flow chart of a method for loading snapshot images provided in the present specification;
FIG. 2 is a schematic illustration of a bitmap of a snapshot mirror provided in the present specification;
FIG. 3 is another snapshot image loading method provided in this specification;
FIG. 4 is a schematic diagram of a process for loading snapshot images provided in this specification;
FIG. 5 is a schematic diagram of a snapshot mirror loading device of one of the types provided in the present specification;
FIG. 6 is a schematic diagram of a snapshot mirror loading device of one of the types provided in the present specification;
fig. 7 is a schematic structural diagram of an electronic device corresponding to fig. 1 provided in the present specification.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the present specification more apparent, the technical solutions of the present specification will be clearly and completely described below with reference to specific embodiments of the present specification and corresponding drawings. It will be apparent that the described embodiments are only some, but not all, of the embodiments of the present specification. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
The following describes in detail the technical solutions provided by the embodiments of the present specification with reference to the accompanying drawings.
Fig. 1 is a flow chart of a loading method of snapshot mirror provided in the present specification, where the method is applied to a starting platform, and specifically includes the following steps:
s100: and generating a snapshot mirror image corresponding to the virtual machine.
At present, the execution time of a large number of server-free computing function services is short, so that the starting time of the function plays an important role in the response time of the function. Meanwhile, the function sandbox based on the virtual machine can provide a safe running environment for the function, but increases the starting delay of the function. Therefore, the started function sandbox can be stored in the hard disk in a snapshot mirror mode through a snapshot mechanism, and when a function is called, the snapshot mirror of the function sandbox is loaded into the memory of the virtual machine to restore the function sandbox, so that the processes of initializing the kernel of the virtual machine and initializing the function service are avoided, and the starting time of the function is greatly shortened.
When the snapshot image of the function sandbox is loaded into the memory of the virtual machine, the virtual machine accesses the memory of the virtual machine, when a memory page which is not loaded into the memory of the virtual machine exists, page errors are generated, and the kernel reads the corresponding content of the memory page in the snapshot image from the hard disk and loads the content into the memory of the virtual machine. Alternatively, the kernel sends page fault memory page information (i.e., memory pages that are not loaded into the virtual machine's memory in the snapshot image) to the page fault handler, which loads the desired memory page from the snapshot image. However, a large number of hard disk read operations not only affect the function start-up process, but also increase the function execution time, thereby increasing the function response time.
Based on this, in this specification, the startup platform may generate a snapshot image corresponding to the virtual machine. The starting platform may be a server, a cloud computing platform, a system, a program, or an electronic device such as a desktop computer or a notebook computer, which is not specifically limited in this specification. For convenience of explanation, the following description will be made with the start-up platform as the execution subject. The virtual machine is used for realizing a function sandbox and running a function without server calculation in the function sandbox. The snapshot mirror image is a mirror image corresponding to a function sandbox generated through a snapshot mechanism, functions in the function sandbox corresponding to the snapshot mirror image are all started functions, namely functions which are initialized through a kernel and function services, and the functions are subsequently loaded into a virtual machine and can be directly called. The snapshot image is an image of the virtual machine generated by the starting platform and is stored in the hard disk, wherein the snapshot image comprises an image corresponding to the memory of the virtual machine, CPU state information, equipment state information and the like. In this description, unless otherwise specified, the snapshot images below all refer to images corresponding to the memory of the virtual machine, and the snapshot images correspond to the entire memory of the virtual machine itself. Specifically, the starting platform may generate a snapshot image based on the memory of the virtual machine itself.
In this specification, the virtual machine may store contents such as functions and programs in its own memory according to pages, so there are memory pages in its own memory, each memory page corresponds to a storage address, and the contents of each memory page are the contents stored in each storage address. In addition, since the snapshot image is generated based on the memory of the virtual machine, the content in the snapshot image is the content stored in the memory of the virtual machine, that is, the content in the snapshot image is the content corresponding to each memory page of the virtual machine.
Because the free memory page exists in the memory of the virtual machine, the free memory page is the memory which is not used by the kernel of the virtual machine or the user program, and when the snapshot mirror image is loaded later, the whole snapshot mirror image can be directly loaded because the part of memory pages in the snapshot mirror image corresponding to the free memory page in the memory of the virtual machine cannot be known, wherein the content corresponding to the free memory page is included, but in fact, the content corresponding to the free memory page is not needed to be loaded, so that the hard disk reading operation is increased. Therefore, in order to reduce the hard disk reading operation, the starting platform may send a first instruction to the virtual machine, so that the virtual machine sets the content of the free memory page in the memory of the virtual machine to a specified value according to the first instruction. And then, based on the updated memory, generating a snapshot mirror image corresponding to the virtual machine. The first instruction is used for indicating the virtual machine to set the content of the idle memory page in the internal memory of the virtual machine to be a specified value, so that the content corresponding to the idle memory page of the virtual machine stored in the snapshot mirror image can be prevented from being loaded when the snapshot mirror image is loaded later, and the specified value is a preset value, such as 0.
When the virtual machine sets the content of the idle memory page in the memory of the virtual machine to the specified value according to the first instruction, the virtual machine can acquire the idle memory page in the idle linked list according to the first instruction, and set the content of the acquired idle memory page to the specified value. And simultaneously, acquiring the free memory page cached in the per_cpu variable, and setting the content of the acquired free memory page as a specified value.
S102: and marking whether each memory page in the snapshot mirror image is empty.
The startup platform can mark whether each memory page in the snapshot mirror is empty. Specifically, the starting platform may determine, for each memory page in the snapshot image, whether the content of the memory page is empty, and if so, mark the memory page as empty. If not, the memory page is marked as non-empty. Each memory page in the snapshot mirror image is obtained by cutting the content in the snapshot mirror image according to pages, and the memory pages in the snapshot mirror image represent the content in the snapshot mirror image. The size of the page in the cutting process is preset, and can be consistent with the size of the memory page (i.e. the range of the memory address) in the memory of the virtual machine. If the content corresponding to the memory page in the snapshot mirror image is empty, the memory page is an idle memory page of the virtual machine, and the content of the memory page does not need to be loaded, so that the memory page can be marked as empty. If the content corresponding to the memory page in the snapshot mirror image is non-empty, it indicates that the memory page is not an idle memory page of the virtual machine, and the content of the memory page needs to be loaded, so that the memory page can be marked as non-empty.
In addition, since the starting platform sets the content in the free memory pages as the specified value in the step S102, the starting platform may also determine, for each memory page in the snapshot image, whether the content of the memory page is the specified value. If yes, determining that the memory page is empty, and marking the memory page as empty. If not, determining that the memory page is non-empty, and marking the memory page as non-empty.
S104: and starting the virtual machine and the page fault processing program.
The boot platform may boot the virtual machine and the page fault handler. The subsequent kernel can determine that the memory page which is not loaded into the memory of the virtual machine in the snapshot mirror image is a target memory page when the virtual machine accesses the memory of the virtual machine, and send the information of the target memory page to the page fault processing program, so that the page fault processing program determines the mark of the target memory page in the snapshot mirror image according to the information of the target memory page. When the mark indicates that the target memory page is empty, the empty memory page is loaded into the memory of the virtual machine, and when the mark indicates that the target memory page is not empty, the target memory page is read in the snapshot mirror image and is loaded into the memory of the virtual machine.
The page fault processing program may be a program written by a user in advance, or may be any existing program for loading a snapshot mirror image, which is not specifically limited in this specification. The kernel is the kernel of the host, when the virtual machine accesses the internal memory of the virtual machine, if the snapshot image is not loaded on the internal memory of the virtual machine, the virtual machine cannot access the content in the snapshot image, so that the snapshot image needs to be loaded on the internal memory of the virtual machine, and the virtual machine does not know that the mapping relation exists between the internal memory of the virtual machine and the snapshot image. In the above case, the kernel determines that a memory page of the memory that is not loaded into the virtual machine in the snapshot mirror image is a target memory page, where the target memory page is a memory page in the snapshot mirror image, and the target memory page characterizes contents in the snapshot mirror image.
The information of the target memory page may include a virtual address corresponding to the target memory page, where the virtual address is an address in a virtual address block created in advance by the virtual machine, and the virtual address block is used to store the snapshot image loaded into the memory, that is, to load the snapshot image into the virtual address block. The virtual address of each page in the virtual address block corresponds to a snapshot mirrored memory page. The virtual machine may send the information of the virtual address block to the page fault handler in advance, so that the subsequent page fault handler may load the target memory page in the snapshot mirror. The information of the virtual address block includes a start address of the virtual address block and a unit length.
After the kernel determines the target memory page which is not loaded into the memory of the virtual machine in the snapshot mirror image, the kernel can determine the virtual address corresponding to the target memory page, and send the virtual address of the target memory page to the page fault processing program, so that the page fault processing program determines the mark of the target memory page in the snapshot mirror image according to the virtual address of the target memory page. When the mark indicates that the target memory page is empty, the target memory page is the idle memory page, and the target memory page does not need to be loaded into the memory of the virtual machine, so that the empty memory page can be directly loaded into the memory of the virtual machine. When the mark indicates that the target memory page is not empty, it indicates that the target memory page is not the above-mentioned idle memory page, and needs to be loaded into the memory of the virtual machine itself, so that the target memory page can be read in the snapshot image and loaded into the memory of the virtual machine itself, and the specific process is as follows in the method shown in fig. 3. By only reading and loading the target memory page when the target memory page is non-empty, the read operation is reduced, and the response time of the function is reduced.
In this specification, the start-up platform may determine the communication port number of the page fault handler when starting up the virtual machine and the page fault handler. And generating a first starting instruction according to the communication port number, and sending the first starting instruction to the virtual machine monitor so as to enable the virtual machine monitor to start the virtual machine. And meanwhile, generating a second starting instruction according to the communication port number so as to start the page fault processing program, and sending marks corresponding to all memory pages in the snapshot mirror image to the page fault processing program. The virtual machine monitor may determine the communication port number in the first start instruction and send the communication port number to the virtual machine when the virtual machine communicates with the page fault handler, so that communication is established with the page fault handler through the communication port number and information of the virtual address block is sent to the page fault handler. The virtual machine monitor is used for starting and monitoring the virtual machine.
The first starting instruction is used for indicating the virtual machine monitor to start the virtual machine, and the first starting instruction carries a communication port number of the page fault processing program, so that the virtual machine can communicate with the page fault processing program and carry out subsequent snapshot mirror loading. The second starting instruction is used for starting the page fault processing program, after the page fault processing program is started, the starting platform can send marks corresponding to all memory pages in the snapshot mirror image to the page fault processing program, and the subsequent page fault processing program can load the snapshot mirror image according to the marks corresponding to all memory pages in the snapshot mirror image and the information of the target memory pages sent by the virtual machine.
According to the method, when the snapshot mirror image is loaded, the starting platform generates the snapshot mirror image corresponding to the virtual machine and marks whether each memory page in the snapshot mirror image is empty or not. And then, starting the virtual machine and the page fault processing program, when the kernel accesses the internal memory of the virtual machine, determining the internal memory page which is not loaded into the internal memory of the virtual machine in the snapshot mirror image as a target internal memory page, and sending the information of the target internal memory page to the page fault processing program, so that the page fault processing program determines the mark of the target internal memory page in the snapshot mirror image according to the information of the target internal memory page, when the mark indicates that the target internal memory page is empty, loading the empty internal memory page into the internal memory of the virtual machine, and when the mark indicates that the target internal memory page is not empty, reading the target internal memory page in the snapshot mirror image and loading the mark into the internal memory of the virtual machine. By loading only the empty memory page when the target memory page is empty and reading the target memory page and loading when the target memory page is not empty, the operation of reading the snapshot mirror image is reduced, the loading time of the snapshot mirror image is saved, and the running time of function service is reduced.
In this specification, in order to facilitate the subsequent loading of contents in the snapshot image other than the contents corresponding to the free memory pages according to the marks of the memory pages in the snapshot image, when the step S102 is described above to mark whether the memory pages in the snapshot image are empty, the starting platform may determine, for each memory page in the snapshot image, whether the contents of the memory page are specified values. If yes, determining that the memory page is empty, and marking the position of the memory page corresponding to the memory page in a preset bitmap as empty. If not, determining that the memory is non-empty, and marking the position corresponding to the memory page in the bitmap as non-empty. The bitmap is used for storing marks of memory pages in the snapshot mirror image. Each memory page in the snapshot mirror image has a one-to-one correspondence with each position in the bitmap. The marks corresponding to each position in the preset bitmap are empty, and after each memory page in the snapshot mirror image is marked, each position in the bitmap corresponds to the mark of each memory page.
Further, after determining that the memory page is empty, the server marks the corresponding position of the memory page as a first bit value in the preset bitmap. And marking the position corresponding to the memory page in the bitmap as a second bit value after the memory page is determined to be non-empty. The bitmap includes bit values (i.e., marks of each memory page) corresponding to each memory page in the snapshot mirror. The first bit value indicates that the memory page is empty and may be 1. The second bit value indicates that the memory page is not empty and may be 0.
For example, as shown in fig. 2, fig. 2 is a schematic diagram of a bitmap of a snapshot mirror provided in the present specification, and it is assumed that the snapshot mirror includes 5 memory pages, namely, memory pages a to E, where contents of memory pages A, B and E include specified values, that is, contents of memory pages A, B and E correspond to contents of free memory pages, so when regarding memory pages a to E in the snapshot mirror, it is assumed that regarding memory page a, it is determined whether the contents of memory page a include specified values, and it is obvious that the contents of memory page a include specified values, so that it is determined that memory page a is empty, and a location corresponding to memory page a in a preset bitmap is marked as a first bit value (i.e., 1). According to the above description, for other memory pages, the position corresponding to the memory page B in the bitmap is marked as the first bit value (i.e. 1), the position corresponding to the memory page C is marked as the second bit value (i.e. 0), the position corresponding to the memory page D is marked as the second bit value (i.e. 0), and the position corresponding to the memory page E is marked as the first bit value (i.e. 1).
Based on this, when the virtual machine and the page fault handling program are started in step S104, the starting platform may determine the communication port number of the page fault handling program, generate a first starting instruction according to the communication port number, and send the first starting instruction to the virtual machine monitor, so that the virtual machine monitor starts the virtual machine. Meanwhile, a second start instruction is generated according to the communication port number to start the page fault handler, and the bitmap is sent to the page fault handler. The starting platform may send the storage path of the bitmap to the page fault handling program, or may directly send the content of the bitmap to the page fault handling program, which is not specifically limited in this specification. In this specification, since the free memory page may store a lot of content, when the start-up platform sets the content in the free memory page to the specified value in step S102, the start-up platform may set the content in the free memory page to a specified value directly, that is, replace the content in the free memory with a specified value, for example, the content in the free memory is A, B and C, and the start-up platform may set A, B and C in the free memory page to 0 directly. And the size of each memory page in the snapshot mirror image is consistent with the size of the memory page of the virtual machine, so that the content of each memory page in the snapshot mirror image is consistent with the content of each memory page in the memory of the virtual machine, and the content of the memory pages of the snapshot mirror image and the content of the memory page of the virtual machine are in one-to-one correspondence.
In this specification, a method for loading a snapshot image is further provided, where the method is applied to a page fault handling program, as shown in fig. 3, and fig. 3 is another method for loading a snapshot image provided in this specification, and specifically includes the following steps:
s200: receiving information of a target memory page sent by a kernel; the target memory page is a memory page which is not loaded into the memory of the virtual machine in a snapshot mirror image, and the snapshot mirror image is a mirror image corresponding to the virtual machine generated by a starting platform.
In this specification, the page fault handler may receive information of a target memory page sent by the kernel. The page fault processing program may be a program written by a user in advance, or may be any existing program for loading a snapshot mirror image, which is not specifically limited in this specification. The kernel is the kernel of the host, the target memory page is a memory page which is not loaded into the memory of the virtual machine in the snapshot mirror image, the information of the target memory page comprises a virtual address corresponding to the target memory page, and the snapshot mirror image is a mirror image corresponding to the virtual machine generated by the starting platform.
In this specification, in order to be able to receive information of a target memory page, a snapshot image can be loaded in a memory of a virtual machine later, and when receiving information of the target memory page sent by a kernel, a page fault handling program needs to receive a flag corresponding to each memory page in the snapshot image sent by a starting platform. And receiving information of a virtual address block corresponding to the memory of the virtual machine, which is sent by the virtual machine. And when the memory page which is not loaded to the memory of the virtual machine is determined in the snapshot mirror image, receiving the virtual address corresponding to the target memory page sent by the kernel. The virtual address block is an address block for generating a snapshot mirror image for the virtual machine, wherein the snapshot mirror image is a mirror image corresponding to the memory of the virtual machine generated by the starting platform.
Further, when receiving the information of the target memory page sent by the kernel, the page fault handling program may also receive a bitmap corresponding to the snapshot mirror image sent by the starting platform. And receiving information of a virtual address block corresponding to the memory of the virtual machine, which is sent by the virtual machine. And when the memory page which is not loaded to the memory of the virtual machine is determined in the snapshot mirror image, receiving the virtual address corresponding to the target memory page sent by the kernel. The bitmap is used for storing marks of the starting platform on each memory page in the snapshot mirror image.
S202: determining a mark in the snapshot mirror image according to the information of the target memory page; the mark is obtained by marking whether each memory page in the snapshot mirror image is empty or not by the starting platform.
And the page fault processing program determines the mark in the snapshot mirror image of the target memory page according to the information of the target memory page. The mark is obtained by marking whether each memory page in the snapshot mirror image is empty or not by the starting platform. The information of the target memory page is a virtual address corresponding to the target memory page, and the virtual address has a corresponding relation with the memory page in the snapshot mirror image, so that the page fault processing program can determine the memory page corresponding to the virtual address in the snapshot mirror image according to the virtual address of the target memory page, and takes the mark corresponding to the memory page as the mark of the target memory page.
Specifically, the page fault handling program may determine the flag in the snapshot mirror image of the target memory page according to the flag corresponding to each memory page in the snapshot mirror image received in step S200, the information of the virtual address block, and the information of the target memory page. The information of the target memory page comprises a virtual address corresponding to the target memory page, the information of the virtual address block can be sent to the page fault processing program in advance by the virtual machine, the information of the virtual address block comprises a starting address of the virtual address block and a unit length, and the unit length is the preset size of each memory page and is consistent with the size of each memory page in the snapshot mirror image.
Therefore, when determining the mark in the snapshot mirror image according to the information of the target memory page, the page fault processing program can determine the difference value of the virtual address corresponding to the target memory page minus the starting address, and then determine the offset address according to the difference value and the unit length. And then, determining the mark of the target memory page in the snapshot mirror image from the marks corresponding to the memory pages in the snapshot mirror image according to the offset address. The offset address is a target memory page of the memory page corresponding to the snapshot mirror image.
Further, when determining the tag in the snapshot image of the target memory page according to the information of the target memory page, the page fault handling program may further determine a difference value of the virtual address corresponding to the target memory page minus the start address, and determine the offset address according to the difference value and the unit length. And determining a mark corresponding to the offset address from the bitmap, and taking the mark as a mark corresponding to the target memory page. The bitmap includes marks corresponding to memory pages in the snapshot mirror image, so that the page fault processing program can determine the memory page corresponding to the target memory page in the snapshot mirror image according to the offset address, and determine the mark of the position corresponding to the memory page from the bitmap. The flag is one of a first bit value and a second bit value.
For example, the virtual address of the target memory page is 3, the start address is 0, and the unit length is 1, so the difference is 3, and the determined offset address is 3 according to the difference 3 and the unit length 1. Then, according to the offset address 3, a flag corresponding to the offset address is determined from the bitmap and used as a flag corresponding to the target memory page, and the flag corresponding to the offset address 3 is assumed to be 0 in the bitmap, so the flag corresponding to the target memory page is assumed to be 0.
S204: and when the mark indicates that the target memory page is empty, loading the empty memory page into the memory of the virtual machine.
When the flag determined in step S202 indicates that the target memory page is empty, the page fault handling program may load the empty memory page into the memory of the virtual machine itself. Specifically, when the flag indicates that the target memory page is empty, the page fault handling program may load the empty memory page into a location of a virtual address corresponding to the target memory page in the memory of the virtual machine itself. The empty memory page may be a memory page with empty content allocated by the page fault handling program, where the size of the memory page is consistent with the size of the target memory page.
In addition, when the flag indicates that the target memory page is empty, the page fault handler may further generate a first load instruction and send the first load instruction to the kernel, so that the kernel loads the empty memory page into the memory of the virtual machine according to the first load instruction. The first loading instruction is used for indicating the kernel to load the empty memory page. The kernel is the kernel of the host.
S206: and when the mark indicates that the target memory page is non-empty, the target memory page is read in the snapshot mirror image and is loaded into the memory of the virtual machine.
When the flag determined in step S202 indicates that the target memory page is not empty, the page fault handling program may read the target memory page from the snapshot image and load the target memory page into the memory of the virtual machine itself. The method mainly comprises the steps of loading a target memory page to a position of a virtual address corresponding to the target memory page in a memory of a virtual machine.
In addition, when the flag indicates that the target memory page is not empty, the page fault handler may further generate a second loading instruction and send the second loading instruction to the kernel, so that the kernel reads the target memory page in the snapshot mirror image according to the second loading instruction and loads the target memory page into the memory of the virtual machine. The second loading instruction is used for indicating the kernel to load the target memory page in the snapshot mirror image.
In this specification, when loading a snapshot image, as shown in fig. 4, fig. 4 is a schematic diagram of a process of loading a snapshot image provided in this specification, and fig. 4 includes a boot platform, a virtual machine, a page fault handler, and a kernel. The kernel is the kernel of the host. The starting platform firstly sends a first instruction to the virtual machine, and the virtual machine sets the content of an idle memory page in the memory of the virtual machine to be a specified value according to the first instruction. And the starting platform generates a snapshot mirror image corresponding to the memory of the virtual machine based on the updated memory. After that, it is marked whether each memory page in the snapshot mirror is empty, and the specific process is as in the above step S102, which is not described herein again. The specific process of the starting platform to start the virtual machine and the page fault handling procedure in step S104 is not described herein. The virtual machine creates an address block for saving the snapshot image loaded to the memory, i.e., a virtual address block, and sends information of the virtual address block to the page fault handler. Specifically, the virtual machine may create a userfaultfd object, register a virtual address block to the userfaultfd object, and transfer information of the virtual address block and the userfaultfd object to the user space page fault handler through an unix socket. After receiving the information of the virtual address block and the userfaultfd object sent by the virtual machine, the page fault processing program monitors the userfaultfd object through an epoll mechanism.
When the virtual machine accesses the memory of the virtual machine, the kernel determines that the memory page which is not loaded into the memory of the virtual machine in the snapshot mirror image is a target memory page, namely, determines that the memory page generating the page error is the target memory page, and transmits page error information (namely, the information of the target memory page) to the page error processing program through a userfaultfd mechanism. Then, the page fault handling program receives the event generated by the userfaultfd object, and obtains the virtual address of the memory page (i.e. the target memory page) generating the page fault. And determining a difference value of the virtual address corresponding to the target memory page minus the initial address, and determining an offset address according to the difference value and the unit length. And then, the mark corresponding to the target memory page is found on the bitmap through the offset address. If the flag is the first bit value, that is, if the flag indicates that the target memory page is empty, the page fault handler generates a uffdio_zero_alloc command (i.e., a first load instruction) by calling a user related IO function, such as ioctl, and sends the uffdio_zero_alloc command to the kernel, so that the kernel loads the empty memory page into the memory of the virtual machine according to the received first load instruction. If the flag is a second bit value, that is, if the flag indicates that the target memory page is not empty, the page fault handler reads the target memory page in the snapshot mirror image, generates a second loading instruction by calling an IO function related to userfaultfd, for example, ioctl, and sends the second loading instruction to the kernel, so that the kernel loads the read target memory page into the memory of the virtual machine according to the received second loading instruction.
The foregoing is a method implemented by one or more embodiments of the present disclosure, and based on the same concept, the present disclosure further provides a corresponding snapshot mirror loading device, as shown in fig. 5.
FIG. 5 is a schematic diagram of a snapshot mirror loading device provided in the present specification, where the device is applied to a boot platform, and includes:
the generating module 300 is configured to generate a snapshot image corresponding to the virtual machine;
a marking module 302, configured to mark whether each memory page in the snapshot image is empty;
the starting module 304 is configured to start the virtual machine and the page fault handling program, so that when the kernel accesses the memory of the virtual machine, it determines that a memory page that is not loaded into the memory of the virtual machine in the snapshot image is a target memory page, and sends information of the target memory page to the page fault handling program, so that the page fault handling program determines, according to the information of the target memory page, a flag of the target memory page in the snapshot image, when the flag indicates that the target memory page is empty, loads the empty memory page into the memory of the virtual machine, and when the flag indicates that the target memory page is not empty, reads the target memory page in the snapshot image and loads the target memory page into the memory of the virtual machine.
Optionally, the generating module 300 is specifically configured to send a first instruction to a virtual machine, so that the virtual machine sets, according to the first instruction, the content of an idle memory page in a memory of the virtual machine to a specified value; and generating a snapshot mirror image corresponding to the virtual machine based on the updated memory.
Optionally, the marking module 302 is specifically configured to determine, for each memory page in the snapshot image, whether the content of the memory page is a specified value; if yes, determining that the memory page is empty, and marking the position corresponding to the memory page in a preset bitmap as empty; if not, determining that the memory page is non-empty, and marking the position corresponding to the memory page in the bitmap as non-empty.
Optionally, the starting module 304 is specifically configured to determine a communication port number of the page fault handler; generating a first starting instruction according to the communication port number, and sending the first starting instruction to a virtual machine monitor so that the virtual machine monitor starts the virtual machine; and generating a second starting instruction according to the communication port number to start the page fault handling program, and sending the bitmap to the page fault handling program.
The present disclosure also provides a corresponding snapshot mirror loading device, as shown in fig. 5.
FIG. 6 is a schematic diagram of a snapshot mirror loading apparatus provided in the present specification, the apparatus being applied to a page fault handling program, and including:
a receiving module 400, configured to receive information of a target memory page sent by a kernel; the target memory page is a memory page which is not loaded into the memory of the virtual machine in a snapshot mirror image, and the snapshot mirror image is a mirror image corresponding to the virtual machine generated by a starting platform;
a determining module 402, configured to determine, according to the information of the target memory page, a flag in the snapshot mirror image of the target memory page; the mark is obtained by marking whether each memory page in the snapshot mirror image is empty or not by the starting platform;
a loading module 404, configured to load an empty memory page into the memory of the virtual machine itself when the flag indicates that the target memory page is empty; and when the mark indicates that the target memory page is non-empty, the target memory page is read in the snapshot mirror image and is loaded into the memory of the virtual machine.
Optionally, the information of the target memory page includes a virtual address corresponding to the target memory page;
the receiving module 400 is specifically configured to receive a bitmap corresponding to the snapshot image sent by the starting platform, where the bitmap is used to store a flag of the starting platform on each memory page in the snapshot image; receiving information of a virtual address block corresponding to a memory of the virtual machine, which is sent by the virtual machine, wherein the virtual address block generates an address block for storing a snapshot image loaded to the memory for the virtual machine; and when the memory page which is not loaded to the memory of the virtual machine is determined in the snapshot mirror image, receiving the virtual address corresponding to the target memory page sent by the kernel.
Optionally, the information includes a start address and a unit length of the virtual address block;
the determining module 402 is specifically configured to determine a difference value of a virtual address corresponding to the target memory page minus the start address; determining an offset address according to the difference value and the unit length; and determining a mark corresponding to the offset address from the bitmap, and taking the mark as the mark corresponding to the target memory page.
The present specification also provides a computer readable storage medium storing a computer program operable to perform a method of loading a snapshot image as provided in fig. 1 above.
The present specification also provides a schematic structural diagram of an electronic device corresponding to fig. 1 shown in fig. 7. At the hardware level, as shown in fig. 7, the electronic device includes a processor, an internal bus, a network interface, a memory, and a nonvolatile storage, and may of course include hardware required by other services. The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to implement the snapshot mirror loading method described in fig. 1.
Of course, other implementations, such as logic devices or combinations of hardware and software, are not excluded from the present description, that is, the execution subject of the following processing flows is not limited to each logic unit, but may be hardware or logic devices.
In the 90 s of the 20 th century, improvements to one technology could clearly be distinguished as improvements in hardware (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software (improvements to the process flow). However, with the development of technology, many improvements of the current method flows can be regarded as direct improvements of hardware circuit structures. Designers almost always obtain corresponding hardware circuit structures by programming improved method flows into hardware circuits. Therefore, an improvement of a method flow cannot be said to be realized by a hardware entity module. For example, a programmable logic device (Programmable Logic Device, PLD) (e.g., field programmable gate array (Field Programmable Gate Array, FPGA)) is an integrated circuit whose logic function is determined by the programming of the device by a user. A designer programs to "integrate" a digital system onto a PLD without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, such programming is mostly implemented by using "logic compiler" software, which is similar to the software compiler used in program development and writing, and the original code before the compiling is also written in a specific programming language, which is called hardware description language (Hardware Description Language, HDL), but not just one of the hdds, but a plurality of kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), lava, lola, myHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog are currently most commonly used. It will also be apparent to those skilled in the art that a hardware circuit implementing the logic method flow can be readily obtained by merely slightly programming the method flow into an integrated circuit using several of the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable logic controllers, and embedded microcontrollers, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic of the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller in a pure computer readable program code, it is well possible to implement the same functionality by logically programming the method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Such a controller may thus be regarded as a kind of hardware component, and means for performing various functions included therein may also be regarded as structures within the hardware component. Or even means for achieving the various functions may be regarded as either software modules implementing the methods or structures within hardware components.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being functionally divided into various units, respectively. Of course, the functions of each element may be implemented in one or more software and/or hardware elements when implemented in the present specification.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present description is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
It will be appreciated by those skilled in the art that embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the present specification may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing is merely exemplary of the present disclosure and is not intended to limit the disclosure. Various modifications and alterations to this specification will become apparent to those skilled in the art. Any modifications, equivalent substitutions, improvements, or the like, which are within the spirit and principles of the present description, are intended to be included within the scope of the claims of the present description.

Claims (11)

1. A method for loading a snapshot image, wherein the method is applied to a starting platform and comprises the following steps:
generating a snapshot mirror image corresponding to the virtual machine;
marking whether each memory page in the snapshot mirror image is empty or not;
starting the virtual machine and a page fault processing program, when the kernel accesses the internal memory of the virtual machine, determining an internal memory page which is not loaded to the internal memory of the virtual machine in the snapshot mirror image as a target internal memory page, and sending information of the target internal memory page to the page fault processing program, so that the page fault processing program determines a mark of the target internal memory page in the snapshot mirror image according to the information of the target internal memory page, when the mark represents that the target internal memory page is empty, loading the empty internal memory page into the internal memory of the virtual machine, and when the mark represents that the target internal memory page is not empty, reading the target internal memory page in the snapshot mirror image and loading the target internal memory page into the internal memory of the virtual machine.
2. The method of claim 1, wherein generating the snapshot image corresponding to the virtual machine specifically comprises:
sending a first instruction to a virtual machine, and enabling the virtual machine to set the content of an idle memory page in a memory of the virtual machine to be a specified value according to the first instruction;
and generating a snapshot mirror image corresponding to the virtual machine based on the updated memory.
3. The method as claimed in claim 2, wherein marking whether each memory page in the snapshot image is empty comprises:
judging whether the content of each memory page in the snapshot mirror image is a specified value or not according to each memory page in the snapshot mirror image;
if yes, determining that the memory page is empty, and marking the position corresponding to the memory page in a preset bitmap as empty;
if not, determining that the memory page is non-empty, and marking the position corresponding to the memory page in the bitmap as non-empty.
4. The method of claim 3, wherein starting the virtual machine and page fault handler specifically comprises:
determining a communication port number of the page fault handler;
generating a first starting instruction according to the communication port number, and sending the first starting instruction to a virtual machine monitor so that the virtual machine monitor starts the virtual machine;
And generating a second starting instruction according to the communication port number to start the page fault handling program, and sending the bitmap to the page fault handling program.
5. A method for loading a snapshot image, the method being applied to a page fault handler, comprising:
receiving information of a target memory page sent by a kernel; the target memory page is a memory page which is not loaded into the memory of the virtual machine in a snapshot mirror image, and the snapshot mirror image is a mirror image corresponding to the virtual machine generated by a starting platform;
determining a mark in the snapshot mirror image according to the information of the target memory page; the mark is obtained by marking whether each memory page in the snapshot mirror image is empty or not by the starting platform;
when the mark indicates that the target memory page is empty, loading the empty memory page into the memory of the virtual machine;
and when the mark indicates that the target memory page is non-empty, the target memory page is read in the snapshot mirror image and is loaded into the memory of the virtual machine.
6. The method of claim 5, wherein the information of the target memory page includes a virtual address corresponding to the target memory page;
Receiving information of a target memory page sent by a kernel, wherein the information specifically comprises:
receiving a bitmap corresponding to the snapshot mirror image sent by the starting platform, wherein the bitmap is used for storing marks of the starting platform on each memory page in the snapshot mirror image;
receiving information of a virtual address block corresponding to a memory of the virtual machine, which is sent by the virtual machine, wherein the virtual address block generates an address block for storing a snapshot image loaded to the memory for the virtual machine;
and when the memory page which is not loaded to the memory of the virtual machine is determined in the snapshot mirror image, receiving the virtual address corresponding to the target memory page sent by the kernel.
7. The method of claim 6, wherein the information includes a start address of the virtual address block and a unit length;
determining the mark in the snapshot mirror image of the target memory page according to the information of the target memory page, wherein the method specifically comprises the following steps:
determining a difference value of a virtual address corresponding to the target memory page minus the initial address;
determining an offset address according to the difference value and the unit length;
and determining a mark corresponding to the offset address from the bitmap, and taking the mark as the mark corresponding to the target memory page.
8. A snapshot mirror loading device, wherein the device is applied to a start-up platform, and comprises:
the generation module is used for generating a snapshot mirror image corresponding to the virtual machine;
the marking module is used for marking whether each memory page in the snapshot mirror image is empty or not;
the starting module is used for starting the virtual machine and the page fault processing program, when the kernel accesses the internal memory of the virtual machine, determining an internal memory page which is not loaded to the internal memory of the virtual machine in the snapshot mirror image as a target internal memory page, and sending the information of the target internal memory page to the page fault processing program, so that the page fault processing program determines a mark of the target internal memory page in the snapshot mirror image according to the information of the target internal memory page, when the mark indicates that the target internal memory page is empty, the empty internal memory page is loaded into the internal memory of the virtual machine, and when the mark indicates that the target internal memory page is not empty, the target internal memory page is read in the snapshot mirror image and is loaded into the internal memory of the virtual machine.
9. A snapshot mirror loading device, the device being applied to a page fault handler, comprising:
The receiving module is used for receiving the information of the target memory page sent by the kernel; the target memory page is a memory page which is not loaded to a memory of the virtual machine in a snapshot mirror image, and the snapshot mirror image is a mirror image corresponding to the virtual machine generated by a starting platform;
the determining module is used for determining marks in the snapshot mirror image of the target memory page according to the information of the target memory page; the mark is obtained by marking whether each memory page in the snapshot mirror image is empty or not by the starting platform;
the loading module is used for loading the empty memory page into the memory of the virtual machine when the mark indicates that the target memory page is empty; and when the mark indicates that the target memory page is non-empty, the target memory page is read in the snapshot mirror image and is loaded into the memory of the virtual machine.
10. A computer-readable storage medium, characterized in that the storage medium stores a computer program which, when executed by a processor, implements the method of any of the preceding claims 1-7.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of the preceding claims 1-7 when executing the program.
CN202311665953.5A 2023-12-05 2023-12-05 Snapshot mirror image loading method and device, storage medium and electronic equipment Pending CN117667309A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311665953.5A CN117667309A (en) 2023-12-05 2023-12-05 Snapshot mirror image loading method and device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311665953.5A CN117667309A (en) 2023-12-05 2023-12-05 Snapshot mirror image loading method and device, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN117667309A true CN117667309A (en) 2024-03-08

Family

ID=90065698

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311665953.5A Pending CN117667309A (en) 2023-12-05 2023-12-05 Snapshot mirror image loading method and device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN117667309A (en)

Similar Documents

Publication Publication Date Title
TW201833792A (en) User interface rendering method and device
CN110737608B (en) Data operation method, device and system
WO2018176911A1 (en) Virtual disk file format conversion method and device
CN108628688B (en) Message processing method, device and equipment
CN108549562A (en) A kind of method and device of image load
CN111095205A (en) Multi-core framework for pre-boot environment of system-on-chip
CN113032099B (en) Cloud computing node, file management method and device
US9417884B2 (en) Method for enabling calibration during start-up of a micro controller unit and integrated circuit therefor
CN113312182B (en) Cloud computing node, file processing method and device
CN111273965B (en) Container application starting method, system and device and electronic equipment
CN117112227A (en) Memory management method, system, device, storage medium and electronic equipment
CN110275782B (en) Data processing method and device
CN117667309A (en) Snapshot mirror image loading method and device, storage medium and electronic equipment
CN113127263A (en) Kernel crash recovery method, device, equipment and storage medium
CN116302616A (en) Data processing method and device, storage medium and electronic equipment
CN113243008A (en) Distributed VFS with shared page cache
CN115291998A (en) Rbd-nbd mapping method and device
CN117041980B (en) Network element management method and device, storage medium and electronic equipment
CN116880905B (en) Data storage method and device, storage medium and electronic equipment
CN117234857B (en) Endophytic security architecture system and anomaly detection method
CN116743550B (en) Processing method of fault storage nodes of distributed storage cluster
CN117032739B (en) Mirror image generation method, system, storage medium and electronic equipment
CN117093161B (en) Memory management system, method, medium and equipment based on optical transceiver chip
US9483399B2 (en) Sub-OS virtual memory management layer
US9798479B2 (en) Relocatable and resizable tables in a computing device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination