[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v7 09/16] migration/qemu-file: add qemu_put_counted_
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH v7 09/16] migration/qemu-file: add qemu_put_counted_string() |
Date: |
Mon, 10 Jul 2017 19:30:22 +0300 |
Add function opposite to qemu_get_counted_string.
qemu_put_counted_string puts one-byte length of the string (string
should not be longer than 255 characters), and then it puts the string,
without last zero byte.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: John Snow <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
---
migration/qemu-file.c | 13 +++++++++++++
migration/qemu-file.h | 2 ++
2 files changed, 15 insertions(+)
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index 2ab2bf362d..e85f501f86 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -734,6 +734,19 @@ size_t qemu_get_counted_string(QEMUFile *f, char buf[256])
}
/*
+ * Put a string with one preceding byte containing its length. The length of
+ * the string should be less than 256.
+ */
+void qemu_put_counted_string(QEMUFile *f, const char *str)
+{
+ size_t len = strlen(str);
+
+ assert(len < 256);
+ qemu_put_byte(f, len);
+ qemu_put_buffer(f, (const uint8_t *)str, len);
+}
+
+/*
* Set the blocking state of the QEMUFile.
* Note: On some transports the OS only keeps a single blocking state for
* both directions, and thus changing the blocking on the main
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
index aae4e5ed36..f4f356ab12 100644
--- a/migration/qemu-file.h
+++ b/migration/qemu-file.h
@@ -174,4 +174,6 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t
block_offset,
ram_addr_t offset, size_t size,
uint64_t *bytes_sent);
+void qemu_put_counted_string(QEMUFile *f, const char *name);
+
#endif
--
2.11.1
- [Qemu-block] [PATCH v7 16/16] iotests: add dirty bitmap postcopy test, (continued)
- [Qemu-block] [PATCH v7 16/16] iotests: add dirty bitmap postcopy test, Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 15/16] iotests: add dirty bitmap migration test, Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 03/16] migration: split common postcopy out of ram postcopy, Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 14/16] iotests: add default node-name, Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 07/16] block/dirty-bitmap: add bdrv_dirty_bitmap_release_successor, Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 01/16] migration: add has_postcopy savevm handler, Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 05/16] block/dirty-bitmap: add bdrv_dirty_bitmap_enable_successor(), Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 11/16] block/dirty-bitmap: add bdrv_dirty_bitmap_set_frozen, Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 09/16] migration/qemu-file: add qemu_put_counted_string(),
Vladimir Sementsov-Ogievskiy <=
- [Qemu-block] [PATCH v7 10/16] migration: add is_active_iterate handler, Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 04/16] migration: introduce postcopy-only pending, Vladimir Sementsov-Ogievskiy, 2017/07/10
- [Qemu-block] [PATCH v7 12/16] migration: add postcopy migration of dirty bitmaps, Vladimir Sementsov-Ogievskiy, 2017/07/10