CN112099905A - Method and device for acquiring dirty pages of virtual machine, electronic equipment and readable storage medium - Google Patents

Method and device for acquiring dirty pages of virtual machine, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN112099905A
CN112099905A CN202010868100.1A CN202010868100A CN112099905A CN 112099905 A CN112099905 A CN 112099905A CN 202010868100 A CN202010868100 A CN 202010868100A CN 112099905 A CN112099905 A CN 112099905A
Authority
CN
China
Prior art keywords
virtual machine
page
dirty
memory page
physical address
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.)
Granted
Application number
CN202010868100.1A
Other languages
Chinese (zh)
Other versions
CN112099905B (en
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.)
Haiguang Information Technology Co Ltd
Original Assignee
Haiguang Information Technology Co Ltd
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 Haiguang Information Technology Co Ltd filed Critical Haiguang Information Technology Co Ltd
Priority to CN202010868100.1A priority Critical patent/CN112099905B/en
Publication of CN112099905A publication Critical patent/CN112099905A/en
Application granted granted Critical
Publication of CN112099905B publication Critical patent/CN112099905B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45579I/O management, e.g. providing access to device drivers or storage

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The embodiment of the invention discloses a method and a device for acquiring dirty pages of a virtual machine, electronic equipment and a readable storage medium, relates to the technical field of management of dirty pages of the virtual machine, and aims to acquire dirty pages of the virtual machine in time. The method comprises the following steps: monitoring a write event of a memory page of the virtual machine in the running process of the virtual machine; if a virtual machine memory page write-in event occurs, acquiring a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write-in event according to the virtual machine memory page write-in event, and storing the acquired virtual machine physical address into virtual machine exit information; exiting the virtual machine and entering a host mode; and the host operating system acquires the physical address of the virtual machine from the exit information of the virtual machine and updates the dirty page recording bitmap of the virtual machine based on the physical address of the virtual machine. The method and the device are suitable for obtaining the dirty pages of the virtual machine.

Description

Method and device for acquiring dirty pages of virtual machine, electronic equipment and readable storage medium
Technical Field
The invention relates to the technical field of virtual machine dirty page management, in particular to a method and a device for acquiring a virtual machine dirty page, electronic equipment and a readable storage medium.
Background
Cloud computing is increasingly used, and vendors must support the live migration function of virtual machines for maintenance and continuous customer support. In the live migration process, the client virtual machine still keeps normal operation of the service, the virtual machine monitor continuously sends dirty page data in the source virtual machine to the target machine, and after all dirty page data of the source virtual machine are sent, the source virtual machine is stopped, and meanwhile, the virtual machine of the target machine is started, so that the downtime of the client service is minimized, and the risk of the client service is reduced.
At present, during the running period of a virtual machine, a processor automatically stores a virtual machine dirty page address into a PML cache (PML buffer), exits the virtual machine when the PML buffer is full, and updates virtual machine dirty page address information into a virtual machine dirty page recording bitmap (dirty _ bitmap).
Disclosure of Invention
In view of this, embodiments of the present application provide a method and an apparatus for acquiring a dirty page of a virtual machine, an electronic device, and a readable storage medium, which are capable of acquiring a dirty page of a virtual machine in time.
In a first aspect, an embodiment of the present application provides a method for acquiring a dirty page of a virtual machine, including: monitoring a write event of a memory page of the virtual machine in the running process of the virtual machine; if a virtual machine memory page write-in event occurs, acquiring a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write-in event according to the virtual machine memory page write-in event, and storing the acquired virtual machine physical address into virtual machine exit information; exiting the virtual machine and entering a host mode; and the host operating system acquires the physical address of the virtual machine from the exit information of the virtual machine and updates the dirty page recording bitmap of the virtual machine based on the physical address of the virtual machine.
According to a specific implementation manner of the embodiment of the present application, after a virtual machine memory page write event occurs, before a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write event is acquired according to the virtual machine memory page write event, the method further includes: and inquiring whether the dirty page recording function of the virtual machine is started, if so, executing the step of acquiring the virtual machine physical address of the virtual machine memory page corresponding to the write-in event of the virtual machine memory page according to the write-in event of the virtual machine memory page.
According to a specific implementation manner of the embodiment of the present application, the querying whether the dirty page recording function of the virtual machine is started includes: and inquiring the state of a preset field in the virtual machine control block, and determining whether the dirty page recording function of the virtual machine is started or not according to the state of the preset field in the virtual machine control block.
According to a specific implementation manner of the embodiment of the present application, after determining that a dirty page recording function of a virtual machine is started, before executing the write event according to the memory page of the virtual machine and acquiring a physical address of the virtual machine of the memory page of the virtual machine corresponding to the write event of the memory page of the virtual machine, the method further includes: checking dirty page flag bits in system page table entries corresponding to the physical addresses of the virtual machines; if the dirty page flag bit is a first flag, executing the step of obtaining the virtual machine physical address of the virtual machine memory page corresponding to the virtual machine memory page write event according to the virtual machine memory page write event; wherein the first flag indicates that no dirty page is recorded.
According to a specific implementation manner of the embodiment of the present application, after the obtained physical address of the virtual machine is stored in the virtual machine exit information and before the virtual machine exits, the method further includes: setting the dirty page flag bit as a second flag; wherein the second flag indicates that a dirty page is recorded.
In a second aspect, an embodiment of the present application provides a device for acquiring a dirty page of a virtual machine, including: the system comprises a monitoring module, a storage module, an entry module and an update module, wherein the monitoring module is used for monitoring write events of a memory page of the virtual machine in the running process of the virtual machine; the obtaining and storing module is configured to, if a virtual machine memory page write event occurs, obtain, according to the virtual machine memory page write event, a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write event, and store the obtained virtual machine physical address in virtual machine exit information; the entry module is used for exiting the virtual machine and entering a host mode; and the updating module is used for acquiring the physical address of the virtual machine from the exit information of the virtual machine by the host operating system and updating the dirty page recording bitmap of the virtual machine based on the physical address of the virtual machine.
According to a specific implementation manner of the embodiment of the application, the method further includes: and the query module is used for querying whether the dirty page recording function of the virtual machine is started or not, and if the dirty page recording function of the virtual machine is started, the acquisition and storage module is informed.
According to a specific implementation manner of the embodiment of the present application, the query module is specifically configured to query a state of a preset field in a virtual machine control block, and determine whether a dirty page recording function of a virtual machine is started according to the state of the preset field in the virtual machine control block.
According to a specific implementation manner of the embodiment of the application, the method further includes: the checking module is used for checking a dirty page flag bit in a system page table entry corresponding to the physical address of the virtual machine; wherein the first flag indicates that a dirty page is not recorded; and if the dirty page flag bit is a first flag, notifying the acquisition and storage module.
According to a specific implementation manner of the embodiment of the application, the method further includes: the setting module is used for setting the dirty page flag bit as a second flag; wherein the second flag indicates that a dirty page is recorded.
In a third aspect, an embodiment of the present application provides an electronic device, including: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space enclosed by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the electronic apparatus; the memory is used for storing executable program codes; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory, for executing the method of any of the foregoing embodiments.
In a fourth aspect, the present application also provides a computer readable storage medium storing one or more programs, the one or more programs being executable by one or more processors to implement the method of any of the preceding embodiments.
In the method, the device, the electronic device, and the readable storage medium for acquiring dirty pages of a virtual machine provided by the embodiments of the present application, a virtual machine memory page write event is monitored during the running of the virtual machine, if the virtual machine memory page write event occurs, a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write event is acquired according to the virtual machine memory page write event, the acquired virtual machine physical address is stored in virtual machine exit information, the virtual machine exits from the virtual machine and enters a host mode, a host operating system acquires the virtual machine physical address from the virtual machine exit information, and updates a virtual machine dirty page record bitmap based on the virtual machine physical address, because the virtual machine physical address corresponding to the virtual machine memory page write event is stored in the virtual machine exit information, compared with the prior art, the method has the advantages that the virtual machine data can be directly written into the memory, and different dirty page recording bitmap acquisition modes are adopted, so that the host operating system can acquire the dirty pages of the virtual machine in time, and the problem that the dirty pages of the virtual machine cannot be acquired in time because the PML cache is used for storing the physical address of the virtual machine and the recording bitmap of the virtual machine is updated after the storage is full is solved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flowchart illustrating an embodiment of updating a bitmap of dirty pages in a virtual machine using a page read only/writeable mechanism;
FIG. 2 is a flow diagram of a virtual machine monitor synchronization virtual machine dirty page bitmap corresponding to FIG. 1;
FIG. 3 is a flowchart illustrating obtaining a bitmap of dirty pages of a virtual machine using a PML scheme according to another embodiment of the present application;
fig. 4 is a schematic flowchart illustrating a method for acquiring dirty pages of a virtual machine according to an embodiment of the present application;
fig. 5 is a schematic flowchart of a method for acquiring a dirty page of a virtual machine according to another embodiment of the present application;
fig. 6 is a flowchart of a method for acquiring a dirty page of a virtual machine according to an embodiment of the present application;
FIG. 7 is a flowchart of a virtual machine monitor synchronization virtual machine dirty page record bitmap corresponding to FIG. 6;
fig. 8 is a block diagram of a dirty page acquiring apparatus of a virtual machine according to an embodiment of the present application;
fig. 9 is a block diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
It should be understood that the embodiments described are only a few embodiments of the present application, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
To obtain virtual machine dirty pages, the operating system uses shadow page tables to simulate the setting of page table entry access and dirty fields before processor nested page table techniques occur. And capturing the page state information of the virtual machine by setting the page table entry in the shadow page table to be read only. When data is written into a memory page of the virtual machine, a page fault writing exception is triggered, the virtual machine is exited and enters a host, the host operating system processes the page fault writing exception of the virtual machine, access fields and dirty fields in a shadow page table of the virtual machine are set, and a dirty page recording bitmap dirty _ bitmap is updated.
After the nested page table is introduced into the CPU architecture, the performance of the virtual machine is greatly improved, the kernel of the host operating System does not need to simulate the page table of the virtual machine through a shadow page table, the kernel is specially responsible for the conversion from a Physical Address (GPA) of the virtual machine to a Physical Address (SPA) of the System by hardware, and the corresponding access bit and dirty bit of the page table are set. The dirty page memory is obtained by traversing the dirty field of the nested page table entry, and the time cost of traversal is large because the nested page table is large.
Referring to fig. 1 and fig. 2, most operating systems currently use a Readonly flag bit in a processor System Page Table Entry (SPTE) and combine a memory write missing exception to track and record dirty Page information of a virtual machine, and then clear the SPTE Readonly flag bit to set a writeable attribute in a corresponding memory Page. When the VMM synchronizes the dirty page bitmap of the virtual machine, a reverse mapping table (rmap) maintained in the kernel is utilized to traverse all memories of the virtual machine and set the SPTE Readonly flag bit. According to the method, the virtual machine needs to quit the virtual machine firstly when writing data into the memory, the host updates the page writeable attribute and then returns to the virtual machine mode to execute data writing operation to reduce the memory writing performance of the virtual machine, and the performance of the virtual machine is reduced and user service is influenced when the frequent setting of rmap and SPTE Readonly/writeable is traversed.
Referring to fig. 3, the Intel PML scheme introduces an additional dirty page buffer (PML buffer) to store the dirty page information of the virtual machine, thereby improving the performance degradation problem caused by frequent memory page faults. introducing a PML (Page Modification Logging) function into an intel, introducing a new hardware device on a CPU framework by the function, recording GPA (general purpose application) corresponding to a Page with dirty bit changed from 0 to 1 into a PML buffer (PML cache) by CPU hardware when a write-in event occurs in the virtual machine, exiting the virtual machine when the PML buffer is full, and updating a plurality of groups of virtual machine dirty Page addresses stored in the PML buffer into a dirty _ bitmap (virtual machine dirty Page recording bitmap) of a host kernel by the host kernel. The VMM initiates a request for recording the synchronous dirty pages, so that a VCPU (virtual CPU) to which the virtual machine belongs is completely exited, the PML buffer is refreshed to a dirty _ bitmap of the host memory and the dirty _ bitmap is copied to the VMM, and finally, the rmap is traversed, and the dirty flag bit of the spte is cleared. According to the scheme, when the PML buffer is required to be fully stored and quit the virtual machine, a plurality of groups of virtual machine dirty page addresses are updated to the dirty _ bitmap of the host kernel at one time, and when the PML buffer stores the virtual machine dirty page addresses but is not fully stored, the virtual machine dirty page recording bitmap cannot be updated, so that the virtual machine dirty page addresses cannot be timely acquired, and the performance of the virtual machine is influenced.
Fig. 4 is a flowchart illustrating a method for acquiring a dirty page of a virtual machine according to an embodiment of the present application, and referring to fig. 4, the method according to the embodiment may include:
step 101, monitoring a virtual machine memory page write event in the running process of the virtual machine.
A Virtual Machine (VM) refers to a complete computer system with complete hardware system functions, which is simulated by software and runs in a completely isolated environment. When creating a virtual machine in a physical computer (host computer or host computer), it is necessary to use a part of the hard disk and memory capacity of the physical computer as the hard disk and memory capacity of the virtual machine. Each virtual machine has an independent storage space and an independent operating system, and the operating system of the virtual machine can be the same as or different from that of the physical computer; the virtual machine may run within the CPU core.
A virtual machine memory page is a block (which may be called a page frame) on the host physical memory, and one virtual machine memory page is a page frame on the host physical memory.
The virtual machine memory page write event may be that the virtual machine memory page has data written to it.
The process of writing data to the memory page of the virtual machine by the virtual machine comprises the following steps: a process or thread in a virtual machine sends a write data request, a CPU core sends a virtual address of the virtual machine to which data is to be written to a Memory Management Unit (MMU), the MMU firstly queries a page table in a Control Register CR3(Control Register 3) of the virtual machine, the virtual address of the virtual machine to which the data is to be written is converted into a virtual machine physical address GPA, the MMU then converts the GPA into an SPA through a nested page table, the CPU core (hardware) updates the data to be written to a cache (cache), and timely sends the data to be written to a Memory controller and writes the data to be written into the Memory according to the SPA.
Step 102, if a virtual machine memory page write event occurs, acquiring a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write event according to the virtual machine memory page write event, and storing the acquired virtual machine physical address into virtual machine exit information.
In one example, the Virtual Machine EXIT information may be field information in a Virtual Machine Control Block in the memory, and specifically, the Virtual Machine Control field may be a VMCB (Virtual Machine Control Block) field, the Virtual Machine EXIT event is EXIT _ DIRTY _ LOG, and the EXIT information VMCB. The virtual machine exit information may include information in a virtual machine exit event.
And step 103, exiting the virtual machine and entering a host mode.
The host may be a physical computer or a host on which the virtual machine is created.
And step 104, the host operating system acquires the physical address of the virtual machine from the exit information of the virtual machine, and updates the dirty page recording bitmap of the virtual machine based on the physical address of the virtual machine.
The virtual machine dirty page recording bitmap is a bitmap which is maintained by a host operating system and is used for recording virtual machine physical address information of a virtual machine dirty page, and specifically, bits in the virtual machine dirty page recording bitmap are modified to represent virtual machine physical addresses of the virtual machine dirty page.
In this embodiment, by monitoring a virtual machine memory page write event during the running of a virtual machine, if the virtual machine memory page write event occurs, obtaining a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write event according to the virtual machine memory page write event, storing the obtained virtual machine physical address in virtual machine exit information, exiting the virtual machine and entering a host mode, where a host operating system obtains the virtual machine physical address from the virtual machine exit information and updates a virtual machine dirty page recording bitmap based on the virtual machine physical address, and since the virtual machine physical address corresponding to the virtual machine memory page write event is stored in the virtual machine exit information, when the virtual machine exits the host mode, the host operating system can obtain the virtual machine physical address from the virtual machine exit information, and based on the virtual machine physical address, updating the virtual machine dirty page recording bitmap, compared with the prior art, the method and the device can directly write the virtual machine data into the memory, and adopt different dirty page recording bitmap acquisition modes, so that a host operating system can timely and efficiently acquire the virtual machine dirty pages, further, on the premise of maintaining the virtual machine performance, the virtual machine dirty page processing efficiency is improved, and the problem that the virtual machine dirty page recording bitmap cannot be updated to cause that the virtual machine dirty page address cannot be acquired in time because the virtual machine physical address is stored but is not fully stored by using the PML buffer is solved.
A flow diagram of a method for obtaining dirty pages of a virtual machine according to another embodiment of the present application is basically the same as the method described in the foregoing embodiment, except that the method for obtaining dirty pages of a virtual machine according to another embodiment of the present application further includes, after a virtual machine memory page write event occurs, before obtaining a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write event according to the virtual machine memory page write event:
step 105, inquiring whether the dirty page recording function of the virtual machine is started, if so, executing the step of obtaining the virtual machine physical address of the virtual machine memory page corresponding to the virtual machine memory page writing event according to the virtual machine memory page writing event.
In one example, querying whether the virtual machine dirty page recording function is turned on may include: and inquiring the state of a preset field in the virtual machine control block, and determining whether the dirty page recording function of the virtual machine is started or not according to the state of the preset field in the virtual machine control block.
The Virtual Machine Control Block may be a Virtual Machine Control Block (VMCB), and the preset field may be dirty _ log _ enable, and in one example, the state of the preset field in the Virtual Machine Control Block may be 1, that is, the state of the preset field in the Virtual Machine Control Block is VMCB — dirty _ log _ enable is 1, which indicates that the Virtual Machine dirty page recording function is started. In another example, the status of a preset field in the virtual machine control block may be 0, that is, vmcb. dirty _ log _ enable ═ 0, which indicates that the virtual machine dirty page recording function is not turned on.
In practical application, when vmcb. dirty _ log _ enable is equal to 0, it may indicate that the dirty page recording function of the virtual machine is started; when vmcb _ dirty _ log _ enable is equal to 1, it indicates that the virtual machine dirty page recording function is not turned on.
In one example, the start virtual machine dirty page record function may be set by the virtual machine manager.
In this embodiment, whether a virtual machine dirty page recording function is started is queried, and if the virtual machine dirty page recording function is started, the virtual machine physical address of the virtual machine memory page corresponding to the virtual machine memory page write event is acquired according to the virtual machine memory page write event, so that the process for acquiring the virtual machine dirty page of the present application can be implemented according to the actual operation requirement.
In another embodiment of the present application, the method is basically the same as the above embodiments, except that after determining that the recording function of the dirty page of the virtual machine is started, before executing the method according to the write event of the memory page of the virtual machine and acquiring the physical address of the virtual machine of the memory page of the virtual machine corresponding to the write event of the memory page of the virtual machine, the method further includes:
and 106, checking a dirty page flag bit in a system page table entry corresponding to the physical address of the virtual machine.
The system page table entry contains a physical address of a page and page attribute information, wherein the physical address is used to locate a physical base address of a page in a physical address space, and a Dirty page flag bit in the page attribute information may be a Dirty (which may be abbreviated as D) flag bit. In some embodiments of the present application, a dirty page flag bit in a system page table entry corresponding to a virtual machine physical address is checked, where the dirty page flag bit may indicate whether a virtual machine physical address corresponding to a virtual machine memory page write event is recorded in virtual machine exit information.
Step 107, if the dirty page flag bit is a first flag, executing the step of obtaining the virtual machine physical address of the virtual machine memory page corresponding to the virtual machine memory page write event according to the virtual machine memory page write event; wherein the first flag indicates that no dirty page is recorded.
The first flag indicates that a dirty page is not recorded, that is, indicates that a virtual machine physical address corresponding to a virtual machine memory page write event is not recorded.
And when the flag bit is the first flag bit, acquiring the virtual machine physical address of the virtual machine memory page corresponding to the virtual machine memory page write-in event, and storing the virtual machine physical address in the virtual machine exit information.
In some examples, after saving the virtual machine physical address in the virtual machine exit information and before exiting the virtual machine, the method further comprises: setting the dirty page flag bit as a second flag; wherein the second flag indicates that a dirty page is recorded.
In one example, the dirty page flag bit may be set by the memory management unit.
In this embodiment, after the physical address of the virtual machine obtained in step 107 is stored in the exit information of the virtual machine, the dirty page flag bit in the system page table entry corresponding to the physical address of the virtual machine may be set to record the dirty page flag, so that, in the process of executing the method of the present application again, it is not necessary to obtain the physical address of the virtual machine of the memory page of the virtual machine corresponding to the write event of the memory page of the virtual machine again, and thus, the running time and the consumption of system resources may be saved.
Fig. 5 is a method for acquiring a dirty page of a virtual machine according to another embodiment of the present application, where after a dirty page recording bitmap of the virtual machine is updated, the method may further include:
step 108, the virtual machine monitor sends a dirty page bitmap synchronization request to the host operating system.
A Virtual Machine Monitor (VMM) isolates the Virtual system from the hardware of the host computer (physical computer). The VMM may also be referred to as a virtual machine manager and may run directly on the system hardware or on the operating system of the host computer. The VMM performs the mapping from virtual resources to physical resources and performs computations using local physical resources. When the virtual system accesses the system resource, the VMM takes over the request and returns the processing result to the virtual machine system, thus realizing the virtualization of a plurality of hardware devices and ensuring the effective isolation of the virtual system.
And step 109, the host operating system sends the updated virtual machine dirty page recording bitmap to the virtual machine monitor according to the dirty page bitmap synchronization request, so that the virtual machine monitor synchronizes the virtual machine dirty page recording bitmap.
And copying the updated dirty page recording bitmap of the virtual machine by the host operating system, and sending the updated dirty page recording bitmap of the virtual machine to the virtual machine monitor, so that the virtual machine monitor can synchronize the dirty page recording bitmap of the virtual machine.
In some embodiments, after step 109, the hypervisor traverses the virtual machine physical address to the reflective table of the system page table entry, changing the dirty page flag bit in the system page table entry from the second flag to the first flag.
Aiming at the existing virtual machine dirty page processing mechanism, the method adds a new dirty page processing mechanism in a CPU framework, is different from a scheme adopting a spen ready flag bit, the virtual machine directly writes a memory in the method, then conditionally exits a virtual machine mode and informs an operating system kernel to update a dirty _ bitmap recording bitmap, the memory writing efficiency of the virtual machine is improved, meanwhile, the frequent use of a page ready/write mechanism to synchronize the dirty pages of the virtual machine is avoided, and the problem that the PML scheme can update the virtual machine dirty page recording bitmap only when the PML buffer is full of the dirty page address of the virtual machine is also avoided.
The following describes a method for acquiring a dirty page of a virtual machine according to an embodiment, with reference to fig. 6 and 7.
The CPU virtual machine framework is additionally provided with the following mechanisms:
a new VMCB (Virtual Machine Control Block) field dirty _ log _ enable is added. Dirty _ log _ enable ═ 1, enable VM dirty page record function; otherwise, the VM dirty page recording function in the method is disabled.
The new virtual machine EXIT event EXIT _ DIRTY _ LOG, EXIT information vmcb. EXIT _ INFO is GPA (guest physical address) corresponding to the DIRTY page in the virtual machine memory, where GPA is aligned with 4K bytes, indicating that the 4K page of GPA has data written in.
When a memory write event occurs in the virtual machine during the operation (VMRUN), the following process is executed, see fig. 6:
step 1, if the vmcb _ dirty _ log _ enable is equal to 1, executing step 2, otherwise, continuing the running of the virtual machine;
step 2, checking that the written virtual machine memory corresponds to DIRTY flag bit in SPTE, if the DIRTY flag bit of SPTE is 0, storing the virtual machine physical address GPA corresponding to the DIRTY page of the memory into VMCB.EXIT _ INFO, setting the EXIT code of the virtual machine to EXIT _ DIRTY _ LOG, setting the DIRTY flag bit of SPTE to 1, and continuing to execute the step 3; and if the dirty flag bit in the corresponding SPTE is already 1, continuing the running of the virtual machine.
And 3, exiting the virtual machine mode (VMEXIT) and entering the host mode.
And 4, after the virtual machine EXITs and enters a host mode, processing a virtual machine EXIT event of EXIT _ DIRTY _ LOG by a host operating system kernel, acquiring a DIRTY page GPA from VMCB.
In some embodiments, steps 1-3 above may be performed by CPU hardware.
Referring to fig. 7, the VMM enables the virtual machine dirty page logging function and performs the dirty page synchronization process:
setting vmcb _ log _ enable to be 1 by VMM, and executing the above steps 1 to 4 in the running process of the virtual machine;
step 1a, the VMM synchronizes a dirty page bitmap dirty _ bitmap of the virtual machine to a kernel of a host operating system.
The VMM can synchronize a dirty page bitmap dirty _ bitmap of the virtual machine to the kernel of the host operating system according to the actual running condition. In some examples, during a virtual machine data migration process, the source VMM may issue a request to synchronize a virtual machine dirty page bitmap to the host operating system kernel before sending the virtual machine dirty page information.
And 2a, copying dirty _ bitmap to VMM by the kernel of the host operating system.
And 3a, the VMM traverses the rmap to clear the dirty bit in the spte.
After the virtual machine dirty log function is introduced, the virtual machine memory address GPA with data written in is directly stored in the VMCB _ exit _ info field, and the host can efficiently acquire dirty page information of the virtual machine in real time, so that the problem of low memory performance caused by abnormal page missing written in pages of the virtual machine is solved.
Fig. 8 is a block diagram of a virtual machine dirty page acquisition apparatus according to an embodiment of the present application, and referring to fig. 8, the virtual machine dirty page acquisition apparatus according to the present embodiment includes: a monitoring module 11, a saving module 12, an entering module 13 and an updating module 14, wherein,
the monitoring module 11 is configured to monitor a write event of a memory page of the virtual machine during the running process of the virtual machine;
the saving module 12 is configured to, if a virtual machine memory page write event occurs, obtain, according to the virtual machine memory page write event, a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write event, and save the obtained virtual machine physical address in virtual machine exit information;
the entry module 13 is configured to exit the virtual machine and enter a host mode;
the updating module 14 is configured to obtain the virtual machine physical address from the virtual machine exit information by the host operating system, and update the virtual machine dirty page recording bitmap based on the virtual machine physical address.
In some embodiments, further comprising: and the query module 15 is configured to query whether the dirty page recording function of the virtual machine is started, and if the dirty page recording function of the virtual machine is started, notify the storage module.
In some embodiments, the querying module 15 is specifically configured to query a state of a preset field in the virtual machine control block, and determine whether the dirty page recording function of the virtual machine is started according to the state of the preset field in the virtual machine control block.
In some embodiments, further comprising: the checking module 16, configured to check a dirty page flag bit in a system page table entry corresponding to the virtual machine physical address; wherein the first flag indicates that a dirty page is not recorded; if the dirty page flag bit is the first flag, the saving module 12 is notified.
In some embodiments, further comprising: a setting module 17, configured to set the dirty page flag bit as a second flag; wherein the second flag indicates that a dirty page is recorded.
The apparatus of this embodiment may be used to implement the technical solutions of the method embodiments shown in fig. 4 and fig. 5, and the implementation principles and technical effects are similar, which are not described herein again.
Fig. 9 is a block diagram of an electronic device according to an embodiment of the present application, and referring to fig. 9, the electronic device may include: the device comprises a shell 41, a processor 42, a memory 43, a circuit board 44 and a power circuit 45, wherein the circuit board 44 is arranged inside a space enclosed by the shell 41, and the processor 42 and the memory 43 are arranged on the circuit board 44; a power supply circuit 45 for supplying power to each circuit or device of the electronic apparatus; the memory 43 is used for storing executable program code; the processor 42 executes a program corresponding to the executable program code by reading the executable program code stored in the memory 43, for executing the method described in any of the foregoing embodiments.
For a specific execution process of the above steps by the processor 42 and further steps executed by the processor 42 by running the executable program code, reference may be made to the description of the embodiments shown in fig. 1 and fig. 3 to fig. 9 in this application, which is not described herein again.
The electronic device exists in a variety of forms, including but not limited to: the server or other equipment for providing computing service, the server comprises a processor, a hard disk, a memory, a system bus and the like, the server is similar to a general computer architecture, but the server needs to provide highly reliable service, so the requirements on processing capability, stability, reliability, safety, expandability, manageability and the like are high.
Embodiments of the present application also provide a computer-readable storage medium, which stores one or more programs, where the one or more programs are executable by one or more processors to implement the method of any of the foregoing embodiments.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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 an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can 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.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present application should be covered within the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (12)

1. A method for acquiring dirty pages of a virtual machine is characterized by comprising the following steps:
monitoring a write event of a memory page of the virtual machine in the running process of the virtual machine;
if a virtual machine memory page write-in event occurs, acquiring a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write-in event according to the virtual machine memory page write-in event, and storing the acquired virtual machine physical address into virtual machine exit information;
exiting the virtual machine and entering a host mode;
and the host operating system acquires the physical address of the virtual machine from the exit information of the virtual machine and updates the dirty page recording bitmap of the virtual machine based on the physical address of the virtual machine.
2. The method according to claim 1, wherein after a virtual machine memory page write event occurs, before acquiring a virtual machine physical address of a virtual machine memory page corresponding to the virtual machine memory page write event according to the virtual machine memory page write event, the method further comprises:
and inquiring whether the dirty page recording function of the virtual machine is started, if so, executing the step of acquiring the virtual machine physical address of the virtual machine memory page corresponding to the write-in event of the virtual machine memory page according to the write-in event of the virtual machine memory page.
3. The method of claim 2, wherein querying whether a virtual machine dirty page record function is enabled comprises:
and inquiring the state of a preset field in the virtual machine control block, and determining whether the dirty page recording function of the virtual machine is started or not according to the state of the preset field in the virtual machine control block.
4. The method according to claim 2, wherein after determining that the dirty page recording function of the virtual machine is started, before executing the virtual machine physical address of the virtual machine memory page corresponding to the virtual machine memory page write event according to the virtual machine memory page write event and acquiring the virtual machine physical address of the virtual machine memory page corresponding to the virtual machine memory page write event, the method further comprises:
checking dirty page flag bits in system page table entries corresponding to the physical addresses of the virtual machines;
if the dirty page flag bit is a first flag, executing the step of obtaining the virtual machine physical address of the virtual machine memory page corresponding to the virtual machine memory page write event according to the virtual machine memory page write event; wherein the first flag indicates that no dirty page is recorded.
5. The method according to claim 4, wherein after saving the obtained physical address of the virtual machine in the virtual machine exit information and before exiting the virtual machine, the method further comprises:
setting the dirty page flag bit as a second flag; wherein the second flag indicates that a dirty page is recorded.
6. A virtual machine dirty page acquisition device, comprising: a monitoring module, a saving module, an entering module and an updating module, wherein,
the monitoring module is used for monitoring the write-in event of the memory page of the virtual machine in the running process of the virtual machine;
the storage module is used for acquiring a virtual machine physical address of a virtual machine memory page corresponding to a virtual machine memory page write event according to the virtual machine memory page write event if the virtual machine memory page write event occurs, and storing the acquired virtual machine physical address into virtual machine exit information;
the entry module is used for exiting the virtual machine and entering a host mode;
and the updating module is used for acquiring the physical address of the virtual machine from the exit information of the virtual machine by the host operating system and updating the dirty page recording bitmap of the virtual machine based on the physical address of the virtual machine.
7. The apparatus of claim 6, further comprising:
and the query module is used for querying whether the dirty page recording function of the virtual machine is started or not, and if the dirty page recording function of the virtual machine is started, the storage module is informed.
8. The apparatus according to claim 7, wherein the query module is specifically configured to query a state of a preset field in a virtual machine control block, and determine whether a dirty page recording function of the virtual machine is turned on according to the state of the preset field in the virtual machine control block.
9. The apparatus of claim 7, further comprising: the checking module is used for checking the data of the mobile terminal,
the checking module is used for checking a dirty page flag bit in a system page table entry corresponding to the physical address of the virtual machine; wherein the first flag indicates that a dirty page is not recorded; and if the dirty page flag bit is a first flag, notifying the storage module.
10. The apparatus of claim 9, further comprising: the setting module is used for setting the dirty page flag bit as a second flag; wherein the second flag indicates that a dirty page is recorded.
11. An electronic device, comprising: the device comprises a shell, a processor, a memory, a circuit board and a power circuit, wherein the circuit board is arranged in a space enclosed by the shell, and the processor and the memory are arranged on the circuit board; a power supply circuit for supplying power to each circuit or device of the electronic apparatus; the memory is used for storing executable program codes; the processor executes a program corresponding to the executable program code by reading the executable program code stored in the memory for performing the method of any one of the preceding claims 1-5.
12. A computer readable storage medium, characterized in that the computer readable storage medium stores one or more programs which are executable by one or more processors to implement the method of any of the preceding claims 1-5.
CN202010868100.1A 2020-08-26 2020-08-26 Virtual machine dirty page acquisition method and device, electronic equipment and readable storage medium Active CN112099905B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010868100.1A CN112099905B (en) 2020-08-26 2020-08-26 Virtual machine dirty page acquisition method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010868100.1A CN112099905B (en) 2020-08-26 2020-08-26 Virtual machine dirty page acquisition method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112099905A true CN112099905A (en) 2020-12-18
CN112099905B CN112099905B (en) 2024-01-26

Family

ID=73753397

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010868100.1A Active CN112099905B (en) 2020-08-26 2020-08-26 Virtual machine dirty page acquisition method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112099905B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342473A (en) * 2021-06-28 2021-09-03 海光信息技术股份有限公司 Data processing method, migration method of secure virtual machine, related device and architecture
CN115586943A (en) * 2022-09-16 2023-01-10 杭州熠芯科技有限公司 Hardware marking implementation method for dirty pages of virtual machine of intelligent network card
CN117539797A (en) * 2024-01-10 2024-02-09 深圳星云智联科技有限公司 Dirty page recording method and related equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009245216A (en) * 2008-03-31 2009-10-22 Toshiba Corp Information processor and failure restoring method
US20100250869A1 (en) * 2009-03-27 2010-09-30 Vmware, Inc. Virtualization system using hardware assistance for shadow page table coherence
CN105824689A (en) * 2016-03-30 2016-08-03 国云科技股份有限公司 Storage synchronization method for virtual machine
CN108037980A (en) * 2018-01-02 2018-05-15 腾讯科技(深圳)有限公司 Control performs the method, apparatus and readable storage medium storing program for executing of live migration of virtual machine

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009245216A (en) * 2008-03-31 2009-10-22 Toshiba Corp Information processor and failure restoring method
US20100250869A1 (en) * 2009-03-27 2010-09-30 Vmware, Inc. Virtualization system using hardware assistance for shadow page table coherence
CN105824689A (en) * 2016-03-30 2016-08-03 国云科技股份有限公司 Storage synchronization method for virtual machine
CN108037980A (en) * 2018-01-02 2018-05-15 腾讯科技(深圳)有限公司 Control performs the method, apparatus and readable storage medium storing program for executing of live migration of virtual machine

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
龙怡清;: "嵌入式虚拟机管理器内存虚拟化方法研究", 科技资讯, no. 06 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342473A (en) * 2021-06-28 2021-09-03 海光信息技术股份有限公司 Data processing method, migration method of secure virtual machine, related device and architecture
CN113342473B (en) * 2021-06-28 2024-01-19 海光信息技术股份有限公司 Data processing method, migration method of secure virtual machine, related device and architecture
CN115586943A (en) * 2022-09-16 2023-01-10 杭州熠芯科技有限公司 Hardware marking implementation method for dirty pages of virtual machine of intelligent network card
CN115586943B (en) * 2022-09-16 2023-08-15 杭州熠芯科技有限公司 Hardware marking implementation method for dirty pages of virtual machine of intelligent network card
CN117539797A (en) * 2024-01-10 2024-02-09 深圳星云智联科技有限公司 Dirty page recording method and related equipment
CN117539797B (en) * 2024-01-10 2024-04-19 深圳星云智联科技有限公司 Dirty page recording method and related equipment

Also Published As

Publication number Publication date
CN112099905B (en) 2024-01-26

Similar Documents

Publication Publication Date Title
US7360022B2 (en) Synchronizing an instruction cache and a data cache on demand
US10540092B2 (en) Method and system for memory oversubscription for virtual machines
CN112099905B (en) Virtual machine dirty page acquisition method and device, electronic equipment and readable storage medium
Park et al. Fast and space-efficient virtual machine checkpointing
US10896129B2 (en) Method and system for storage virtualization
US8086823B2 (en) Method for speeding up page table address update on virtual machine
US9213651B2 (en) Synchronizing a translation lookaside buffer with page tables
US9032157B2 (en) Virtual machine failover
JP2020534589A (en) Cache-based trace recording with cache coherence protocol data
JP4783392B2 (en) Information processing apparatus and failure recovery method
US20150378770A1 (en) Virtual machine backup
US20220269615A1 (en) Cache-based trace logging using tags in system memory
Kourai Fast and correct performance recovery of operating systems using a virtual machine monitor
EP4278265B1 (en) Memory address compression within an execution trace
JP2017033375A (en) Parallel calculation system, migration method, and migration program
US20220269614A1 (en) Treating main memory as a collection of tagged cache lines for trace logging
CN114840330A (en) Memory recovery method and device and control equipment
CN115485668A (en) Memory page marking as a logging hint for processor-based execution tracing
US11687453B2 (en) Cache-based trace logging using tags in an upper-level cache
EP4278262B1 (en) Physical memory address omission or obfuscation within an execution trace
US11561896B2 (en) Cache-based trace logging using tags in an upper-level cache
US20230280904A1 (en) Monitoring memory locations to identify whether data stored at the memory locations has been modified
JP3061818B2 (en) Access monitor device for microprocessor
CN112269716A (en) Flexibly defined processor abnormal access real-time monitoring method and electronic device
WO2022177698A1 (en) Treating main memory as a collection of tagged cache lines for trace logging

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
GR01 Patent grant
GR01 Patent grant