[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v1 2/7] migration/snapshot: Introduce qemu_ftell2() routine
From: |
Andrey Gruzdev |
Subject: |
[RFC PATCH v1 2/7] migration/snapshot: Introduce qemu_ftell2() routine |
Date: |
Wed, 12 May 2021 22:26:14 +0300 |
In qemu-snapshot it is needed to retrieve current QEMUFile offset as a
number of bytes read by qemu_get_byte()/qemu_get_buffer().
The existing qemu_ftell() routine would give read position as a number
of bytes fetched from underlying IOChannel which is not the same.
Signed-off-by: Andrey Gruzdev <andrey.gruzdev@virtuozzo.com>
---
migration/qemu-file.c | 6 ++++++
migration/qemu-file.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
index d6e03dbc0e..66be5e6460 100644
--- a/migration/qemu-file.c
+++ b/migration/qemu-file.c
@@ -657,6 +657,12 @@ int64_t qemu_ftell(QEMUFile *f)
return f->pos;
}
+int64_t qemu_ftell2(QEMUFile *f)
+{
+ qemu_fflush(f);
+ return f->pos + f->buf_index - f->buf_size;
+}
+
int qemu_file_rate_limit(QEMUFile *f)
{
if (f->shutdown) {
diff --git a/migration/qemu-file.h b/migration/qemu-file.h
index a9b6d6ccb7..bd1a6def02 100644
--- a/migration/qemu-file.h
+++ b/migration/qemu-file.h
@@ -124,6 +124,7 @@ void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks
*hooks);
int qemu_get_fd(QEMUFile *f);
int qemu_fclose(QEMUFile *f);
int64_t qemu_ftell(QEMUFile *f);
+int64_t qemu_ftell2(QEMUFile *f);
int64_t qemu_ftell_fast(QEMUFile *f);
/*
* put_buffer without copying the buffer.
--
2.27.0
- [RFC PATCH v1 0/7] migration/snapshot: External snapshot utility, Andrey Gruzdev, 2021/05/12
- [RFC PATCH v1 3/7] migration/snapshot: Move RAM_SAVE_FLAG_xxx defines to migration/ram.h, Andrey Gruzdev, 2021/05/12
- [RFC PATCH v1 4/7] migration/snapshot: Block layer AIO support in qemu-snapshot, Andrey Gruzdev, 2021/05/12
- [RFC PATCH v1 2/7] migration/snapshot: Introduce qemu_ftell2() routine,
Andrey Gruzdev <=
- [RFC PATCH v1 7/7] migration/snapshot: Implementation of qemu-snapshot load path in postcopy mode, Andrey Gruzdev, 2021/05/12
- [RFC PATCH v1 1/7] migration/snapshot: Introduce qemu-snapshot tool, Andrey Gruzdev, 2021/05/12
- [RFC PATCH v1 6/7] migration/snapshot: Implementation of qemu-snapshot load path, Andrey Gruzdev, 2021/05/12
- [RFC PATCH v1 5/7] migration/snapshot: Implementation of qemu-snapshot save path, Andrey Gruzdev, 2021/05/12
- Re: [RFC PATCH v1 0/7] migration/snapshot: External snapshot utility, no-reply, 2021/05/12