mirror of
https://gitlab.com/qemu-project/qemu.git
synced 2026-10-28 14:04:39 +08:00
migration: add QEMU_COUNTED_STRING_SIZE for counted string buffers
A counted string carries its length in one byte, so the buffer that qemu_get_counted_string() fills must hold 256 bytes. The dirty bitmap load state spells that size as a bare 256 for both of its alias buffers. Name it next to the qemu_get_counted_string() prototype and use it there, in the length assert of qemu_put_counted_string() and in DBMLoadState. Suggested-by: Eric Blake <eblake@redhat.com> Signed-off-by: Denis V. Lunev <den@openvz.org> Cc: Peter Xu <peterx@redhat.com> Cc: Fabiano Rosas <farosas@suse.de> Cc: Eric Blake <eblake@redhat.com> Cc: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Cc: qemu-stable@nongnu.org Message-ID: <20261006170738.453977-2-den@openvz.org> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
1 parent
901ac73874
commit
319cd41f11
3 files changed
+10
-5
No files matched your search
@@ -163,7 +163,11 @@ static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv)
|
||||
qemu_get_be64s(f, (uint64_t *)pv);
|
||||
}
|
||||
|
||||
size_t coroutine_mixed_fn qemu_get_counted_string(QEMUFile *f, char buf[256]);
|
||||
/* Buffer size for a string whose length is sent as a single byte */
|
||||
#define QEMU_COUNTED_STRING_SIZE 256
|
||||
|
||||
size_t coroutine_mixed_fn
|
||||
qemu_get_counted_string(QEMUFile *f, char buf[QEMU_COUNTED_STRING_SIZE]);
|
||||
|
||||
void qemu_put_counted_string(QEMUFile *f, const char *name);
|
||||
|
||||
|
||||
@@ -145,8 +145,8 @@ typedef struct LoadBitmapState {
|
||||
/* State of the dirty bitmap migration (DBM) during load process */
|
||||
typedef struct DBMLoadState {
|
||||
uint32_t flags;
|
||||
char node_alias[256];
|
||||
char bitmap_alias[256];
|
||||
char node_alias[QEMU_COUNTED_STRING_SIZE];
|
||||
char bitmap_alias[QEMU_COUNTED_STRING_SIZE];
|
||||
char bitmap_name[BDRV_BITMAP_MAX_NAME_SIZE + 1];
|
||||
BlockDriverState *bs;
|
||||
BdrvDirtyBitmap *bitmap;
|
||||
|
||||
@@ -829,7 +829,8 @@ uint64_t qemu_get_be64(QEMUFile *f)
|
||||
* else 0
|
||||
* (Note a 0 length string will return 0 either way)
|
||||
*/
|
||||
size_t coroutine_mixed_fn qemu_get_counted_string(QEMUFile *f, char buf[256])
|
||||
size_t coroutine_mixed_fn
|
||||
qemu_get_counted_string(QEMUFile *f, char buf[QEMU_COUNTED_STRING_SIZE])
|
||||
{
|
||||
size_t len = qemu_get_byte(f);
|
||||
size_t res = qemu_get_buffer(f, (uint8_t *)buf, len);
|
||||
@@ -847,7 +848,7 @@ void qemu_put_counted_string(QEMUFile *f, const char *str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
|
||||
assert(len < 256);
|
||||
assert(len < QEMU_COUNTED_STRING_SIZE);
|
||||
qemu_put_byte(f, len);
|
||||
qemu_put_buffer(f, (const uint8_t *)str, len);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user