From: Ruslan Ruslichenko <[email protected]>

Add a new global option '-sync-quantum' to specify the maximum time
interval, in nanoseconds, between synchronizations with remote peers.

In co-simulation environments (such as QEMU coupled with a SystemC
simulator), time must be synchronized periodically to ensure functional
accuracy. The 'sync-quantum' defines the maximum amount of time QEMU
can simulate ahead of its remote peers before a mandatory synchronization
event (sync packet) occurs.

This value is stored in the global 'global_sync_quantum' variable and
serves as a default hint for device models and Remote Port instances
to manage their simulation time.

Signed-off-by: Edgar E. Iglesias <[email protected]>
Signed-off-by: Takahiro Nakata <[email protected]>
Signed-off-by: Ruslan Ruslichenko <[email protected]>
---
 include/system/system.h |  2 ++
 qemu-options.hx         | 11 +++++++++++
 system/vl.c             |  8 ++++++++
 3 files changed, 21 insertions(+)

diff --git a/include/system/system.h b/include/system/system.h
index 0cd012004d..f187544147 100644
--- a/include/system/system.h
+++ b/include/system/system.h
@@ -59,6 +59,8 @@ extern MlockState mlock_state;
 
 extern const char *machine_path;
 
+extern uint64_t global_sync_quantum;
+
 #define MAX_OPTION_ROMS 16
 typedef struct QEMUOptionRom {
     const char *name;
diff --git a/qemu-options.hx b/qemu-options.hx
index b7dd2a64f0..8ef0c57507 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -765,6 +765,17 @@ SRST
     Preallocate memory when using -mem-path.
 ERST
 
+DEF("sync-quantum", HAS_ARG, QEMU_OPTION_sync_quantum,
+    "-sync-quantum Max time between synchroniation, nanoseconds.\n",
+    QEMU_ARCH_ALL)
+SRST
+``-sync-quantum val``
+    Maximum time between synchronization <val>.
+    This value is used to drive periodic synchronization with remote port 
peers.
+    It is also used to set device models sync-quantum properties controlling
+    the maximum amount of ahead of time simulation that is prefered (only a 
hint).
+ERST
+
 DEF("machine-path", HAS_ARG, QEMU_OPTION_machine_path,
     "-machine-path DIR A directory in which to create machine nodes\n",
     QEMU_ARCH_ALL)
diff --git a/system/vl.c b/system/vl.c
index 4750b1cf69..467646c3ff 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -182,6 +182,7 @@ static QemuPluginList plugin_list = 
QTAILQ_HEAD_INITIALIZER(plugin_list);
 static BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
 static bool nographic = false;
 static int mem_prealloc; /* force preallocation of physical target memory */
+uint64_t global_sync_quantum;
 const char *machine_path;
 static const char *vga_model = NULL;
 static DisplayOptions dpy;
@@ -3129,6 +3130,13 @@ void qemu_init(int argc, char **argv)
             case QEMU_OPTION_mem_prealloc:
                 mem_prealloc = 1;
                 break;
+            case QEMU_OPTION_sync_quantum:
+                if (qemu_strtou64(optarg, &optarg, 10,
+                                  &global_sync_quantum)) {
+                    error_report("failed to parse sync_quantum");
+                    exit(1);
+                }
+                break;
             case QEMU_OPTION_machine_path:
                 machine_path = optarg;
                 break;
-- 
2.43.0


Reply via email to