summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock10
-rw-r--r--crosvm_plugin/Cargo.toml2
-rw-r--r--crosvm_plugin/crosvm.h8
-rw-r--r--crosvm_plugin/src/lib.rs6
-rw-r--r--plugin_proto/Cargo.toml2
-rw-r--r--plugin_proto/protos/plugin.proto5
-rw-r--r--src/plugin/process.rs8
-rw-r--r--tests/plugin_adder.c2
-rw-r--r--tests/plugin_dirty_log.c2
-rw-r--r--tests/plugin_ioevent.c2
-rw-r--r--tests/plugin_irqfd.c2
11 files changed, 30 insertions, 19 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 472f529..c810954 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -18,7 +18,7 @@ name = "crosvm"
 version = "0.1.0"
 dependencies = [
  "byteorder 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "crosvm_plugin 0.7.0",
+ "crosvm_plugin 0.8.0",
  "data_model 0.1.0",
  "devices 0.1.0",
  "io_jail 0.1.0",
@@ -28,7 +28,7 @@ dependencies = [
  "kvm_sys 0.1.0",
  "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
  "net_util 0.1.0",
- "plugin_proto 0.7.0",
+ "plugin_proto 0.8.0",
  "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "qcow 0.1.0",
  "qcow_utils 0.1.0",
@@ -41,12 +41,12 @@ dependencies = [
 
 [[package]]
 name = "crosvm_plugin"
-version = "0.7.0"
+version = "0.8.0"
 dependencies = [
  "kvm 0.1.0",
  "kvm_sys 0.1.0",
  "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
- "plugin_proto 0.7.0",
+ "plugin_proto 0.8.0",
  "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "sys_util 0.1.0",
 ]
@@ -160,7 +160,7 @@ dependencies = [
 
 [[package]]
 name = "plugin_proto"
-version = "0.7.0"
+version = "0.8.0"
 dependencies = [
  "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)",
  "protobuf 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/crosvm_plugin/Cargo.toml b/crosvm_plugin/Cargo.toml
index 5b6833a..b650f3a 100644
--- a/crosvm_plugin/Cargo.toml
+++ b/crosvm_plugin/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "crosvm_plugin"
-version = "0.7.0"
+version = "0.8.0"
 authors = ["The Chromium OS Authors"]
 
 [lib]
diff --git a/crosvm_plugin/crosvm.h b/crosvm_plugin/crosvm.h
index 47f3eb9..d6eafb6 100644
--- a/crosvm_plugin/crosvm.h
+++ b/crosvm_plugin/crosvm.h
@@ -47,7 +47,7 @@ extern "C" {
  * do not indicate anything about what version of crosvm is running.
  */
 #define CROSVM_API_MAJOR 0
-#define CROSVM_API_MINOR 7
+#define CROSVM_API_MINOR 8
 #define CROSVM_API_PATCH 0
 
 enum crosvm_address_space {
@@ -236,10 +236,14 @@ int crosvm_io_event_fd(struct crosvm_io*);
  *
  * If |read_only| is true, attempts by the guest to write to this memory region
  * will trigger an IO access exit.
+ *
+ * To use the `crosvm_memory_get_dirty_log` method with the returned object,
+ * |__dirty_log| must be true.
  */
 int crosvm_create_memory(struct crosvm*, int __fd, uint64_t __offset,
                          uint64_t __length, uint64_t __start,
-                         bool __read_only, struct crosvm_memory**);
+                         bool __read_only, bool __dirty_log,
+                         struct crosvm_memory**);
 
 /*
  * Destroys the given shared memory and unregisters it from guest physical
diff --git a/crosvm_plugin/src/lib.rs b/crosvm_plugin/src/lib.rs
index 91335d7..e383a1b 100644
--- a/crosvm_plugin/src/lib.rs
+++ b/crosvm_plugin/src/lib.rs
@@ -433,7 +433,8 @@ impl crosvm_memory {
               offset: u64,
               length: u64,
               start: u64,
-              read_only: bool)
+              read_only: bool,
+              dirty_log: bool)
               -> result::Result<crosvm_memory, c_int> {
         const PAGE_MASK: u64 = 0x0fff;
         if offset & PAGE_MASK != 0 || length & PAGE_MASK != 0 {
@@ -449,6 +450,7 @@ impl crosvm_memory {
             memory.start = start;
             memory.length = length;
             memory.read_only = read_only;
+            memory.dirty_log = dirty_log;
         }
         let ret = match crosvm.main_transaction(&r, &[fd]) {
             Ok(_) => return Ok(crosvm_memory { id, length }),
@@ -471,7 +473,7 @@ impl crosvm_memory {
 
 impl_ctor_dtor!(
     crosvm_memory,
-    crosvm_create_memory(fd: c_int, offset: u64, length: u64, start: u64, read_only: bool),
+    crosvm_create_memory(fd: c_int, offset: u64, length: u64, start: u64, read_only: bool, dirty_log: bool),
     crosvm_destroy_memory,
 );
 
diff --git a/plugin_proto/Cargo.toml b/plugin_proto/Cargo.toml
index c9d771d..d8f1509 100644
--- a/plugin_proto/Cargo.toml
+++ b/plugin_proto/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "plugin_proto"
-version = "0.7.0"
+version = "0.8.0"
 authors = ["The Chromium OS Authors"]
 build = "build.rs"
 
diff --git a/plugin_proto/protos/plugin.proto b/plugin_proto/protos/plugin.proto
index 7e7f137..8bcdcc9 100644
--- a/plugin_proto/protos/plugin.proto
+++ b/plugin_proto/protos/plugin.proto
@@ -31,6 +31,8 @@ message MainRequest {
             uint64 start = 2;
             uint64 length = 3;
             bool read_only = 4;
+            // Must be true for the MemoryDirtyLog method to work on this object.
+            bool dirty_log = 5;
         }
 
         message IrqEvent {
@@ -121,7 +123,8 @@ message MainRequest {
         PauseVcpus pause_vcpus = 9;
         GetVcpus get_vcpus = 10;
         Start start = 11;
-        // Method for a Memory type object for retrieving the dirty bitmap.
+        // Method for a Memory type object for retrieving the dirty bitmap. Only valid if the memory
+        // object was created with dirty_log set.
         MemoryDirtyLog dirty_log = 101;
     }
 }
diff --git a/src/plugin/process.rs b/src/plugin/process.rs
index a40f6fc..42cad80 100644
--- a/src/plugin/process.rs
+++ b/src/plugin/process.rs
@@ -288,7 +288,8 @@ impl Process {
                      offset: u64,
                      start: u64,
                      length: u64,
-                     read_only: bool)
+                     read_only: bool,
+                     dirty_log: bool)
                      -> SysResult<()> {
         let shm = SharedMemory::from_raw_fd(memfd)?;
         // Checking the seals ensures the plugin process won't shrink the mmapped file, causing us
@@ -305,7 +306,7 @@ impl Process {
         }
         let mem = MemoryMapping::from_fd_offset(&shm, length as usize, offset as usize)
             .map_err(mmap_to_sys_err)?;
-        let slot = vm.add_device_memory(GuestAddress(start), mem, read_only, true)?;
+        let slot = vm.add_device_memory(GuestAddress(start), mem, read_only, dirty_log)?;
         entry.insert(PluginObject::Memory {
                          slot,
                          length: length as usize,
@@ -423,7 +424,8 @@ impl Process {
                                                     memory.offset,
                                                     memory.start,
                                                     memory.length,
-                                                    memory.read_only)
+                                                    memory.read_only,
+                                                    memory.dirty_log)
                             }
                             None => Err(SysError::new(-EBADF)),
                         }
diff --git a/tests/plugin_adder.c b/tests/plugin_adder.c
index f6c514f..8728614 100644
--- a/tests/plugin_adder.c
+++ b/tests/plugin_adder.c
@@ -168,7 +168,7 @@ int main(int argc, char** argv) {
     memcpy(mem, code, sizeof(code));
 
     struct crosvm_memory *mem_obj;
-    ret = crosvm_create_memory(crosvm, mem_fd, 0x1000, 0x1000, 0x1000, false, &mem_obj);
+    ret = crosvm_create_memory(crosvm, mem_fd, 0x1000, 0x1000, 0x1000, false, false, &mem_obj);
     if (ret) {
         fprintf(stderr, "failed to create memory in crosvm: %d\n", ret);
         return 1;
diff --git a/tests/plugin_dirty_log.c b/tests/plugin_dirty_log.c
index bc3db83..f266cdf 100644
--- a/tests/plugin_dirty_log.c
+++ b/tests/plugin_dirty_log.c
@@ -128,7 +128,7 @@ int main(int argc, char** argv) {
     memcpy(mem + LOAD_ADDRESS, code, sizeof(code));
 
     struct crosvm_memory *mem_obj;
-    ret = crosvm_create_memory(crosvm, mem_fd, 0, mem_size, 0, false, &mem_obj);
+    ret = crosvm_create_memory(crosvm, mem_fd, 0, mem_size, 0, false, true, &mem_obj);
     if (ret) {
         fprintf(stderr, "failed to create memory in crosvm: %d\n", ret);
         return 1;
diff --git a/tests/plugin_ioevent.c b/tests/plugin_ioevent.c
index 3662810..2a0eca9 100644
--- a/tests/plugin_ioevent.c
+++ b/tests/plugin_ioevent.c
@@ -151,7 +151,7 @@ int main(int argc, char** argv) {
     memcpy(mem + LOAD_ADDRESS, code, sizeof(code));
 
     struct crosvm_memory *mem_obj;
-    ret = crosvm_create_memory(crosvm, mem_fd, 0, mem_size, 0, false, &mem_obj);
+    ret = crosvm_create_memory(crosvm, mem_fd, 0, mem_size, 0, false, false, &mem_obj);
     if (ret) {
         fprintf(stderr, "failed to create memory in crosvm: %d\n", ret);
         return 1;
diff --git a/tests/plugin_irqfd.c b/tests/plugin_irqfd.c
index c6951df..490ebab 100644
--- a/tests/plugin_irqfd.c
+++ b/tests/plugin_irqfd.c
@@ -172,7 +172,7 @@ int main(int argc, char** argv) {
     memcpy(mem + LOAD_ADDRESS, g_code, sizeof(g_code));
 
     struct crosvm_memory *mem_obj;
-    ret = crosvm_create_memory(crosvm, mem_fd, 0, mem_size, 0, false, &mem_obj);
+    ret = crosvm_create_memory(crosvm, mem_fd, 0, mem_size, 0, false, false, &mem_obj);
     if (ret) {
         fprintf(stderr, "failed to create memory in crosvm: %d\n", ret);
         return 1;