[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 13/17] background snapshot: add write-protected p
From: |
Denis Plotnikov |
Subject: |
[Qemu-devel] [PATCH v1 13/17] background snapshot: add write-protected page access handler function |
Date: |
Wed, 18 Jul 2018 18:41:56 +0300 |
The handler does all the necessary operations to save the page being
accessed to the snapshot file(stream).
Signed-off-by: Denis Plotnikov <address@hidden>
---
migration/ram.c | 43 +++++++++++++++++++++++++++++++++++++++++++
migration/ram.h | 1 +
2 files changed, 44 insertions(+)
diff --git a/migration/ram.c b/migration/ram.c
index b1623e96e7..04a4bf708d 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1762,6 +1762,49 @@ int ram_copy_page(RAMBlock *block, unsigned long page_nr,
return 1;
}
+/**
+ * ram_process_page_fault
+ *
+ * Used in the background snapshot to queue the copy of the memory
+ * page for writing.
+ *
+ * Returns:
+ * 0 > - on error
+ * 0 - success
+ *
+ * @address: guest address
+ *
+ */
+int ram_process_page_fault(void *address)
+{
+ int ret;
+ void *page_copy = NULL;
+ unsigned long page_nr;
+ ram_addr_t offset;
+
+ RAMBlock *block = ram_bgs_block_find(address, &offset);
+
+ if (!block) {
+ return -1;
+ }
+
+ page_nr = offset >> TARGET_PAGE_BITS;
+
+ ret = ram_copy_page(block, page_nr, &page_copy);
+
+ if (ret < 0) {
+ return ret;
+ } else if (ret > 0) {
+ if (ram_save_queue_pages(block, NULL, offset,
+ TARGET_PAGE_SIZE, page_copy)) {
+ ram_page_buffer_free(page_copy);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
/**
* ram_find_and_save_block: finds a dirty page and sends it to f
*
diff --git a/migration/ram.h b/migration/ram.h
index 76ab0a3377..2b565ce620 100644
--- a/migration/ram.h
+++ b/migration/ram.h
@@ -76,4 +76,5 @@ int ram_block_list_set_readonly(void);
int ram_block_list_set_writable(void);
int ram_copy_page(RAMBlock *block, unsigned long page_nr, void **page_copy);
+int ram_process_page_fault(void *address);
#endif
--
2.17.0
- [Qemu-devel] [PATCH v1 00/17] Background snapshots, Denis Plotnikov, 2018/07/18
- [Qemu-devel] [PATCH v1 05/17] ram: extend the data structures for background snapshotting, Denis Plotnikov, 2018/07/18
- [Qemu-devel] [PATCH v1 01/17] migration: add background snapshot capability, Denis Plotnikov, 2018/07/18
- [Qemu-devel] [PATCH v1 13/17] background snapshot: add write-protected page access handler function,
Denis Plotnikov <=
- [Qemu-devel] [PATCH v1 06/17] background snapshot: add helpers to manage a copy of ram block list, Denis Plotnikov, 2018/07/18
- [Qemu-devel] [PATCH v1 08/17] migration: add helpers to change VM memory protection rights, Denis Plotnikov, 2018/07/18
- [Qemu-devel] [PATCH v1 02/17] bitops: add some atomic versions of bitmap operations, Denis Plotnikov, 2018/07/18
- [Qemu-devel] [PATCH v1 10/17] background snapshots: adapt the page queueing code for using page copies, Denis Plotnikov, 2018/07/18
- [Qemu-devel] [PATCH v1 09/17] background snapshot: extend RAM request for holding a page copy pointer, Denis Plotnikov, 2018/07/18