Reviewed-by: John Snow <js...@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@parallels.com> --- include/migration/qemu-file.h | 17 +++++++++++++++++ migration/block-dirty-bitmap.c | 35 ----------------------------------- migration/qemu-file.c | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index a923cec..178ae63 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -310,4 +310,21 @@ static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) { qemu_get_be64s(f, (uint64_t *)pv); } + +/* read name from qemu file: + * format: + * 1 byte : len = name length (<256) + * len bytes : name without last zero byte + * + * name should point to the buffer >= 256 bytes length + */ +char *qemu_get_string(QEMUFile *f, char *name); + +/* write name to qemu file: + * format: + * same as for qemu_get_string + * + * maximum name length is 255 + */ +void qemu_put_string(QEMUFile *f, const char *name); #endif diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 2d3ba23..3c610af 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -164,41 +164,6 @@ static void qemu_put_flags(QEMUFile *f, uint32_t flags) qemu_put_be32(f, flags | DIRTY_BITMAP_MIG_FLAGS_SIZE_32); } -/* read name from qemu file: - * format: - * 1 byte : len = name length (<256) - * len bytes : name without last zero byte - * - * name should point to the buffer >= 256 bytes length - */ -static char *qemu_get_string(QEMUFile *f, char *name) -{ - int len = qemu_get_byte(f); - qemu_get_buffer(f, (uint8_t *)name, len); - name[len] = '\0'; - - DPRINTF("get name: %d %s\n", len, name); - - return name; -} - -/* write name to qemu file: - * format: - * same as for qemu_get_string - * - * maximum name length is 255 - */ -static void qemu_put_string(QEMUFile *f, const char *name) -{ - int len = strlen(name); - - DPRINTF("put name: %d %s\n", len, name); - - assert(len < 256); - qemu_put_byte(f, len); - qemu_put_buffer(f, (const uint8_t *)name, len); -} - static void send_bitmap_header(QEMUFile *f, DirtyBitmapMigBitmapState *dbms, uint32_t additional_flags) { diff --git a/migration/qemu-file.c b/migration/qemu-file.c index e66e557..5439f84 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -545,3 +545,21 @@ uint64_t qemu_get_be64(QEMUFile *f) v |= qemu_get_be32(f); return v; } + +char *qemu_get_string(QEMUFile *f, char *name) +{ + int len = qemu_get_byte(f); + qemu_get_buffer(f, (uint8_t *)name, len); + name[len] = '\0'; + + return name; +} + +void qemu_put_string(QEMUFile *f, const char *name) +{ + int len = strlen(name); + + assert(len < 256); + qemu_put_byte(f, len); + qemu_put_buffer(f, (const uint8_t *)name, len); +} -- 1.9.1