[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V1 07/26] migration: VMStateId
From: |
Steve Sistare |
Subject: |
[PATCH V1 07/26] migration: VMStateId |
Date: |
Mon, 29 Apr 2024 08:55:16 -0700 |
Define a type for the 256 byte id string to guarantee the same length is
used and enforced everywhere.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
include/exec/ramblock.h | 3 ++-
include/migration/vmstate.h | 2 ++
migration/savevm.c | 8 ++++----
migration/vmstate.c | 3 ++-
4 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h
index 0babd10..61deefe 100644
--- a/include/exec/ramblock.h
+++ b/include/exec/ramblock.h
@@ -23,6 +23,7 @@
#include "cpu-common.h"
#include "qemu/rcu.h"
#include "exec/ramlist.h"
+#include "migration/vmstate.h"
struct RAMBlock {
struct rcu_head rcu;
@@ -35,7 +36,7 @@ struct RAMBlock {
void (*resized)(const char*, uint64_t length, void *host);
uint32_t flags;
/* Protected by the BQL. */
- char idstr[256];
+ VMStateId idstr;
/* RCU-enabled, writes protected by the ramlist lock */
QLIST_ENTRY(RAMBlock) next;
QLIST_HEAD(, RAMBlockNotifier) ramblock_notifiers;
diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 4691334..a39c0e6 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -1210,6 +1210,8 @@ int vmstate_save_state_v(QEMUFile *f, const
VMStateDescription *vmsd,
bool vmstate_section_needed(const VMStateDescription *vmsd, void *opaque);
+typedef char (VMStateId)[256];
+
#define VMSTATE_INSTANCE_ID_ANY -1
/* Returns: 0 on success, -1 on failure */
diff --git a/migration/savevm.c b/migration/savevm.c
index a30bcd9..9b1a335 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -197,13 +197,13 @@ const VMStateInfo vmstate_info_timer = {
typedef struct CompatEntry {
- char idstr[256];
+ VMStateId idstr;
int instance_id;
} CompatEntry;
typedef struct SaveStateEntry {
QTAILQ_ENTRY(SaveStateEntry) entry;
- char idstr[256];
+ VMStateId idstr;
uint32_t instance_id;
int alias_id;
int version_id;
@@ -814,7 +814,7 @@ int register_savevm_live(const char *idstr,
void unregister_savevm(VMStateIf *obj, const char *idstr, void *opaque)
{
SaveStateEntry *se, *new_se;
- char id[256] = "";
+ VMStateId id = "";
if (obj) {
char *oid = vmstate_if_get_id(obj);
@@ -2650,7 +2650,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type)
uint32_t instance_id, version_id, section_id;
int64_t start_ts, end_ts;
SaveStateEntry *se;
- char idstr[256];
+ VMStateId idstr;
int ret;
/* Read section start */
diff --git a/migration/vmstate.c b/migration/vmstate.c
index ef26f26..437f156 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -471,7 +471,8 @@ static int vmstate_subsection_load(QEMUFile *f, const
VMStateDescription *vmsd,
trace_vmstate_subsection_load(vmsd->name);
while (qemu_peek_byte(f, 0) == QEMU_VM_SUBSECTION) {
- char idstr[256], *idstr_ret;
+ VMStateId idstr;
+ char *idstr_ret;
int ret;
uint8_t version_id, len, size;
const VMStateDescription *sub_vmsd;
--
1.8.3.1
- [PATCH V1 06/26] migration: precreate vmstate for exec, (continued)
- [PATCH V1 06/26] migration: precreate vmstate for exec, Steve Sistare, 2024/04/29
- [PATCH V1 11/26] migration: vmstate_register at init time, Steve Sistare, 2024/04/29
- [PATCH V1 12/26] migration: vmstate factory object, Steve Sistare, 2024/04/29
- [PATCH V1 04/26] migration: delete unused parameter mis, Steve Sistare, 2024/04/29
- [PATCH V1 03/26] migration: SAVEVM_FOREACH, Steve Sistare, 2024/04/29
- [PATCH V1 05/26] migration: precreate vmstate, Steve Sistare, 2024/04/29
- [PATCH V1 22/26] migration: ram block cpr-exec blockers, Steve Sistare, 2024/04/29
- [PATCH V1 10/26] migration: vmstate_unregister_named, Steve Sistare, 2024/04/29
- [PATCH V1 24/26] seccomp: cpr-exec blocker, Steve Sistare, 2024/04/29
- [PATCH V1 09/26] migration: vmstate_register_named, Steve Sistare, 2024/04/29
- [PATCH V1 07/26] migration: VMStateId,
Steve Sistare <=
- [PATCH V1 25/26] migration: fix mismatched GPAs during cpr-exec, Steve Sistare, 2024/04/29
- [PATCH V1 17/26] machine: memfd-alloc option, Steve Sistare, 2024/04/29
- [PATCH V1 19/26] physmem: preserve ram blocks for cpr, Steve Sistare, 2024/04/29
- [PATCH V1 26/26] migration: only-migratable-modes, Steve Sistare, 2024/04/29
- [PATCH V1 15/26] physmem: hoist host memory allocation, Steve Sistare, 2024/04/29
- [PATCH V1 14/26] physmem: hoist guest_memfd creation, Steve Sistare, 2024/04/29
- [PATCH V1 18/26] migration: cpr-exec-args parameter, Steve Sistare, 2024/04/29
- [PATCH V1 20/26] migration: cpr-exec mode, Steve Sistare, 2024/04/29
- [PATCH V1 13/26] physmem: ram_block_create, Steve Sistare, 2024/04/29
- [PATCH V1 08/26] migration: vmstate_info_void_ptr, Steve Sistare, 2024/04/29