Message ID | 1424268014-13293-15-git-send-email-vsementsov@parallels.com |
---|---|
State | New |
Headers | show |
On 02/18/2015 09:00 AM, Vladimir Sementsov-Ogievskiy wrote: > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@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 084ba22..8ebf7e5 100644 > --- a/migration/block-dirty-bitmap.c > +++ b/migration/block-dirty-bitmap.c > @@ -161,41 +161,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); > +} > Reviewed-by: John Snow <jsnow@redhat.com>
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 084ba22..8ebf7e5 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -161,41 +161,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); +}
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@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(-)