diff mbox series

[RFC,18/19] tools/vhost-user-rpmb: allow setting of the write_count

Message ID 20200925125147.26943-19-alex.bennee@linaro.org
State New
Headers show
Series vhost-user-rpmb (Replay Protected Memory Block) | expand

Commit Message

Alex Bennée Sept. 25, 2020, 12:51 p.m. UTC
This is mostly useful for testing. Practically all guest operations
will probe the write count before any write transaction.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tools/vhost-user-rpmb/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/tools/vhost-user-rpmb/main.c b/tools/vhost-user-rpmb/main.c
index 34607ad19429..c798a6f66cd2 100644
--- a/tools/vhost-user-rpmb/main.c
+++ b/tools/vhost-user-rpmb/main.c
@@ -39,6 +39,7 @@ 
 static gchar *socket_path;
 static char *flash_path;
 static char *key_path;
+static gint initial_counter;
 static gint socket_fd = -1;
 static gboolean print_cap;
 static gboolean verbose;
@@ -49,6 +50,7 @@  static GOptionEntry options[] =
 {
     { "socket-path", 0, 0, G_OPTION_ARG_FILENAME, &socket_path, "Location of vhost-user Unix domain socket, incompatible with --fd", "PATH" },
     { "flash-path", 0, 0, G_OPTION_ARG_FILENAME, &flash_path, "Location of raw flash image file", "PATH" },
+    { "initial-counter", 0, 0, G_OPTION_ARG_INT, &initial_counter, "Set initial value of write counter", NULL},
     { "key-path", 0, 0, G_OPTION_ARG_FILENAME, &key_path, "Location of persistent keyfile", "KEY"},
     { "key-set", 0, 0, G_OPTION_ARG_NONE, &key_set, "Is the key already programmed", NULL},
     { "fd", 0, 0, G_OPTION_ARG_INT, &socket_fd, "Specify the file-descriptor of the backend, incompatible with --socket-path", "FD" },
@@ -797,6 +799,10 @@  int main(int argc, char *argv[])
         vrpmb_set_key(&rpmb, key_path);
     }
 
+    if (initial_counter) {
+        rpmb.write_count = initial_counter;
+    }
+
     if (!socket_path && socket_fd < 0) {
         g_printerr("Please specify either --fd or --socket-path\n");
         exit(EXIT_FAILURE);