Skip to contentSkip to conversation

Migration pull request

GIT PULL Applied Juan Quintela 2 participants 12 messages Oct 15, 2014 Kbuild

lore
Share & tools
lore
#0 lore raw

From: Juan Quintela <[email protected]>

Hi

This patches have been on the list for a while:

- ram flags from Peter Lieven
- qemu-file cleanups from Eduardo (just code movement)
- QEMUSizedBuffer from David (they have already have 6 versions)
- VBUFFER (new macro, can't break old things) (Alexey)
- invalidate state (Alexey)

Please, apply.

The following changes since commit b1d28ec6a7dbdaadda39d29322f0de694aeb0b74:

Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20141010' into staging (2014-10-10 14:55:29 +0100)

are available in the git repository at:

git://github.com/juanquintela/qemu.git migration/20141015

for you to fetch changes up to 5b0e9dd46fbda5152566a4a26fd96bc0d0452bf7:

migration: catch unknown flag combinations in ram_load (2014-10-14 11:24:20 +0200)

----------------------------------------------------------------
migration/next for 20141015

----------------------------------------------------------------
Alexey Kardashevskiy (2):
block/migration: Disable cache invalidate for incoming migration
vmstate: Allow dynamic allocation for VBUFFER during migration

Dr. David Alan Gilbert (2):
QEMUSizedBuffer based QEMUFile
Tests: QEMUSizedBuffer/QEMUBuffer

Eduardo Habkost (5):
qemu-file: Add copyright header to qemu-file.c
qemu-file: Make qemu_file_is_writable() non-static
qemu-file: Use qemu_file_is_writable() on stdio_fclose()
qemu-file: Move unix and socket implementations to qemu-file-unix.c
qemu-file: Move stdio implementation to qemu-file-stdio.c

Peter Lieven (1):
migration: catch unknown flag combinations in ram_load

 Makefile.objs                 |   2 +-
 arch_init.c                   |  62 ++--
 block.c                       |  18 +-
 include/migration/qemu-file.h |  27 ++
 include/migration/vmstate.h   |  11 +
 include/qemu/typedefs.h       |   1 +
 migration.c                   |   1 -
 nbd.c                         |   6 +
 qemu-file-stdio.c             | 194 ++++++++++
 qemu-file-unix.c              | 223 +++++++++++
 qemu-file.c                   | 843 ++++++++++++++++++++++++------------------
 tests/Makefile                |   4 +-
 tests/test-vmstate.c          |  74 ++--
 vmstate.c                     |  13 +-
 14 files changed, 1029 insertions(+), 450 deletions(-)
 create mode 100644 qemu-file-stdio.c
 create mode 100644 qemu-file-unix.c
#1 lore raw

[Qemu-devel] [PULL 02/10] Tests: QEMUSizedBuffer/QEMUBuffer

From: "Dr. David Alan Gilbert" <[email protected]>

Modify some of tests/test-vmstate.c to use the in memory file based on QEMUSizedBuffer to provide basic testing of QEMUSizedBuffer and the associated memory backed QEMUFile type.

Only some of the tests are changed so that the fd backed QEMUFile is still tested.

---
 tests/Makefile       |  2 +-
 tests/test-vmstate.c | 74 +++++++++++++++++++++++++++-------------------------
 2 files changed, 39 insertions(+), 37 deletions(-)
tests/Makefile +1 -1
index ffa8312..31e867f 100644
@@ -259,7 +259,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	libqemuutil.a libqemustub.a
 tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
 	vmstate.o qemu-file.o \
-	libqemuutil.a
+	libqemuutil.a libqemustub.a
 
 tests/test-qapi-types.c tests/test-qapi-types.h :\
 $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
tests/test-vmstate.c +38 -36

143 lines not on this page · raw message

Signature · 1 line
2.1.0
#2 lore raw

[Qemu-devel] [PULL 01/10] QEMUSizedBuffer based QEMUFile

In reply to Juan Quintela

From: "Dr. David Alan Gilbert" <[email protected]>

This is based on Stefan and Joel's patch that creates a QEMUFile that goes to a memory buffer; from:

http://lists.gnu.org/archive/html/qemu-devel/2013-03/msg05036.html

Using the QEMUFile interface, this patch adds support functions for operating on in-memory sized buffers that can be written to or read from.

For fixes/tweeks I've done:

---
 include/migration/qemu-file.h |  26 +++
 include/qemu/typedefs.h       |   1 +
 qemu-file.c                   | 455 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 482 insertions(+)
include/migration/qemu-file.h +26 -0
index c90f529..70ff347 100644
@@ -25,6 +25,8 @@
 #define QEMU_FILE_H 1
 #include "exec/cpu-common.h"
 
+#include <stdint.h>
+
 /* This function writes a chunk of data to a file at the given position.
  * The pos argument can be ignored if the file is only being used for
  * streaming.  The handler should try to write all of the data it can.
@@ -94,11 +96,19 @@ typedef struct QEMUFileOps {
     QEMURamSaveFunc *save_page;
 } QEMUFileOps;
 
+struct QEMUSizedBuffer {
+    struct iovec *iov;
+    size_t n_iov;
+    size_t size; /* total allocated size in all iov's */
+    size_t used; /* number of used bytes */
+};
+
 QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops);
 QEMUFile *qemu_fopen(const char *filename, const char *mode);
 QEMUFile *qemu_fdopen(int fd, const char *mode);
 QEMUFile *qemu_fopen_socket(int fd, const char *mode);
 QEMUFile *qemu_popen_cmd(const char *command, const char *mode);
+QEMUFile *qemu_bufopen(const char *mode, QEMUSizedBuffer *input);
 int qemu_get_fd(QEMUFile *f);
 int qemu_fclose(QEMUFile *f);
 int64_t qemu_ftell(QEMUFile *f);
@@ -111,6 +121,22 @@ void qemu_put_byte(QEMUFile *f, int v);
 void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size);
 bool qemu_file_mode_is_not_valid(const char *mode);
 
+QEMUSizedBuffer *qsb_create(const uint8_t *buffer, size_t len);
+QEMUSizedBuffer *qsb_clone(const QEMUSizedBuffer *);
+void qsb_free(QEMUSizedBuffer *);
+size_t qsb_set_length(QEMUSizedBuffer *qsb, size_t length);
+size_t qsb_get_length(const QEMUSizedBuffer *qsb);
+ssize_t qsb_get_buffer(const QEMUSizedBuffer *, off_t start, size_t count,
+                       uint8_t *buf);
+ssize_t qsb_write_at(QEMUSizedBuffer *qsb, const uint8_t *buf,
+                     off_t pos, size_t count);
+
+
+/*
+ * For use on files opened with qemu_bufopen
+ */
+const QEMUSizedBuffer *qemu_buf_get(QEMUFile *f);
+
 static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v)
 {
     qemu_put_byte(f, (int)v);
include/qemu/typedefs.h +1 -0
index 04df51b..168a408 100644
@@ -71,6 +71,7 @@ typedef struct SSIBus SSIBus;
 typedef struct EventNotifier EventNotifier;
 typedef struct VirtIODevice VirtIODevice;
 typedef struct QEMUSGList QEMUSGList;
+typedef struct QEMUSizedBuffer QEMUSizedBuffer;
 typedef struct SHPCDevice SHPCDevice;
 typedef struct FWCfgState FWCfgState;
 typedef struct PcGuestInfo PcGuestInfo;
qemu-file.c +455 -0

458 lines not on this page · raw message

Signature · 1 line
2.1.0
#3 lore raw

[Qemu-devel] [PULL 03/10] block/migration: Disable cache invalidate for incoming migration

In reply to Juan Quintela

From: Alexey Kardashevskiy <[email protected]>

When migrated using libvirt with "--copy-storage-all", at the end of migration there is race between NBD mirroring task trying to do flush and migration completion, both end up invalidating cache. Since qcow2 driver does not handle this situation very well, random crashes happen.

This disables the BDRV_O_INCOMING flag for the block device being migrated once the cache has been invalidated.

--

fixed parens by hand

---
 block.c     | 18 +++++-------------
 migration.c |  1 -
 nbd.c       |  6 ++++++
 3 files changed, 11 insertions(+), 14 deletions(-)
block.c +5 -13
index d3aebeb..27533f3 100644
@@ -5043,6 +5043,11 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
         return;
     }
 
+    if (!(bs->open_flags & BDRV_O_INCOMING)) {
+        return;
+    }
+    bs->open_flags &= ~BDRV_O_INCOMING;
+
     if (bs->drv->bdrv_invalidate_cache) {
         bs->drv->bdrv_invalidate_cache(bs, &local_err);
     } else if (bs->file) {
@@ -5078,19 +5083,6 @@ void bdrv_invalidate_cache_all(Error **errp)
     }
 }
 
-void bdrv_clear_incoming_migration_all(void)
-{
-    BlockDriverState *bs;
-
-    QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
-        AioContext *aio_context = bdrv_get_aio_context(bs);
-
-        aio_context_acquire(aio_context);
-        bs->open_flags = bs->open_flags & ~(BDRV_O_INCOMING);
-        aio_context_release(aio_context);
-    }
-}
-
 int bdrv_flush(BlockDriverState *bs)
 {
     Coroutine *co;
migration.c +0 -1
index 8d675b3..c49a05a 100644
@@ -103,7 +103,6 @@ static void process_incoming_migration_co(void *opaque)
     }
     qemu_announce_self();
 
-    bdrv_clear_incoming_migration_all();
     /* Make sure all file formats flush their mutable metadata */
     bdrv_invalidate_cache_all(&local_err);
     if (local_err) {
nbd.c +6 -0
index e9b539b..a7bce45 100644
@@ -972,6 +972,12 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset,
     exp->ctx = bdrv_get_aio_context(bs);
     bdrv_ref(bs);
     bdrv_add_aio_context_notifier(bs, bs_aio_attached, bs_aio_detach, exp);
+    /*
+     * NBD exports are used for non-shared storage migration.  Make sure
+     * that BDRV_O_INCOMING is cleared and the image is ready for write
+     * access since the export could be available before migration handover.
+     */
+    bdrv_invalidate_cache(bs, NULL);
     return exp;
 }
 
Signature · 1 line
2.1.0
#4 lore raw

[Qemu-devel] [PULL 04/10] vmstate: Allow dynamic allocation for VBUFFER during migration

In reply to Juan Quintela

From: Alexey Kardashevskiy <[email protected]>

This extends use of VMS_ALLOC flag from arrays to VBUFFER as well.

This defines VMSTATE_VBUFFER_ALLOC_UINT32 which makes use of VMS_ALLOC and uses uint32_t type for a size.

---
 include/migration/vmstate.h | 11 +++++++++++
 vmstate.c                   | 13 ++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)
include/migration/vmstate.h +11 -0
index 9a001bd..e45fc49 100644
@@ -484,6 +484,17 @@ extern const VMStateInfo vmstate_info_bitmap;
     .start        = (_start),                                        \
 }
 
+#define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, _test, _start, _field_size) { \
+    .name         = (stringify(_field)),                             \
+    .version_id   = (_version),                                      \
+    .field_exists = (_test),                                         \
+    .size_offset  = vmstate_offset_value(_state, _field_size, uint32_t),\
+    .info         = &vmstate_info_buffer,                            \
+    .flags        = VMS_VBUFFER|VMS_POINTER|VMS_ALLOC,               \
+    .offset       = offsetof(_state, _field),                        \
+    .start        = (_start),                                        \
+}
+
 #define VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, _info, _size) { \
     .name       = (stringify(_field)),                               \
     .version_id = (_version),                                        \
vmstate.c +10 -3
index ef2f87b..3dde574 100644
@@ -49,9 +49,16 @@ static void *vmstate_base_addr(void *opaque, VMStateField *field, bool alloc)
 
     if (field->flags & VMS_POINTER) {
         if (alloc && (field->flags & VMS_ALLOC)) {
-            int n_elems = vmstate_n_elems(opaque, field);
-            if (n_elems) {
-                gsize size = n_elems * field->size;
+            gsize size = 0;
+            if (field->flags & VMS_VBUFFER) {
+                size = vmstate_size(opaque, field);
+            } else {
+                int n_elems = vmstate_n_elems(opaque, field);
+                if (n_elems) {
+                    size = n_elems * field->size;
+                }
+            }
+            if (size) {
                 *((void **)base_addr + field->start) = g_malloc(size);
             }
         }
Signature · 1 line
2.1.0
#5 lore raw

[Qemu-devel] [PULL 05/10] qemu-file: Add copyright header to qemu-file.c

In reply to Juan Quintela

From: Eduardo Habkost <[email protected]>

The person who created qemu-file.c (me, on commit 093c455a8c6d8f715eabd8c8d346f08f17d686ec) didn't add a copyright/license header to the file, even though the whole code was copied from savevm.c (which had a copyright/license header).

To correct this, copy the copyright information and license from savevm.c, that's where the original code came from.

Luckily, very few changes were made on qemu-file.c after it was created. All the authors who touched the code are being CCed, so they can confirm if they are OK with the copyright/license information being added.

---
 qemu-file.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
qemu-file.c +23 -0
index cdda745..a5bbe7e 100644
@@ -1,3 +1,26 @@
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
 #include "qemu-common.h"
 #include "qemu/iov.h"
 #include "qemu/sockets.h"
Signature · 1 line
2.1.0
#6 lore raw

[Qemu-devel] [PULL 06/10] qemu-file: Make qemu_file_is_writable() non-static

In reply to Juan Quintela

From: Eduardo Habkost <[email protected]>

The QEMUFileStdio code will use qemu_file_is_writable() and will be moved to a separate file.

---
 include/migration/qemu-file.h | 1 +
 qemu-file.c                   | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
include/migration/qemu-file.h +1 -0
index 70ff347..401676b 100644
@@ -120,6 +120,7 @@ void qemu_put_byte(QEMUFile *f, int v);
  */
 void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size);
 bool qemu_file_mode_is_not_valid(const char *mode);
+bool qemu_file_is_writable(QEMUFile *f);
 
 QEMUSizedBuffer *qsb_create(const uint8_t *buffer, size_t len);
 QEMUSizedBuffer *qsb_clone(const QEMUSizedBuffer *);
qemu-file.c +1 -1
index a5bbe7e..c303b61 100644
@@ -456,7 +456,7 @@ void qemu_file_set_error(QEMUFile *f, int ret)
     }
 }
 
-static inline bool qemu_file_is_writable(QEMUFile *f)
+bool qemu_file_is_writable(QEMUFile *f)
 {
     return f->ops->writev_buffer || f->ops->put_buffer;
 }
Signature · 1 line
2.1.0
#7 lore raw

[Qemu-devel] [PULL 07/10] qemu-file: Use qemu_file_is_writable() on stdio_fclose()

In reply to Juan Quintela

From: Eduardo Habkost <[email protected]>

Use the existing function which checks if writev_buffer() or put_buffer() are set, instead of duplicating it.

---
 qemu-file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-file.c +1 -1
index c303b61..9cb1223 100644
@@ -175,7 +175,7 @@ static int stdio_fclose(void *opaque)
     QEMUFileStdio *s = opaque;
     int ret = 0;
 
-    if (s->file->ops->put_buffer || s->file->ops->writev_buffer) {
+    if (qemu_file_is_writable(s->file)) {
         int fd = fileno(s->stdio_file);
         struct stat st;
 
Signature · 1 line
2.1.0
#8 lore raw

[Qemu-devel] [PULL 08/10] qemu-file: Move unix and socket implementations to qemu-file-unix.c

In reply to Juan Quintela

From: Eduardo Habkost <[email protected]>

Separate the QEMUFile interface from the implementation, to reduce dependencies from code using QEMUFile.

All the code that is being moved to the new file is exactly the same code that was on savevm.c (moved by commit 093c455a8c6d8f715eabd8c8d346f08f17d686ec), so I am using the copyright and license header from savevm.c for the new file.

---
 Makefile.objs    |   2 +-
 qemu-file-unix.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 qemu-file.c      | 195 ------------------------------------------------
 tests/Makefile   |   2 +-
 4 files changed, 225 insertions(+), 197 deletions(-)
 create mode 100644 qemu-file-unix.c
Makefile.objs +1 -1
index add8375..957e56c 100644
@@ -50,7 +50,7 @@ common-obj-$(CONFIG_LINUX) += fsdev/
 
 common-obj-y += migration.o migration-tcp.o
 common-obj-y += vmstate.o
-common-obj-y += qemu-file.o
+common-obj-y += qemu-file.o qemu-file-unix.o
 common-obj-$(CONFIG_RDMA) += migration-rdma.o
 common-obj-y += qemu-char.o #aio.o
 common-obj-y += block-migration.o
qemu-file-unix.c new file +223 -0

223 lines not on this page · raw message

qemu-file.c +0 -195

213 lines not on this page · raw message

tests/Makefile +1 -1
index 31e867f..ba8c6b5 100644
@@ -258,7 +258,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	$(test-qapi-obj-y) \
 	libqemuutil.a libqemustub.a
 tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
-	vmstate.o qemu-file.o \
+	vmstate.o qemu-file.o qemu-file-unix.o \
 	libqemuutil.a libqemustub.a
 
 tests/test-qapi-types.c tests/test-qapi-types.h :\
Signature · 1 line
2.1.0
#9 lore raw

[Qemu-devel] [PULL 09/10] qemu-file: Move stdio implementation to qemu-file-stdio.c

In reply to Juan Quintela

From: Eduardo Habkost <[email protected]>

Separate the QEMUFile interface from the stdio-specific implementation, to reduce dependencies from code using QEMUFile.

The code that is being moved is similar to the one that was on savevm.c before it was moved in commit 093c455a8c6d8f715eabd8c8d346f08f17d686ec, except for some changes done by Markus, Juan, and myself. So, I am using the copyright and license header from savevm.c, but CCing Juan and Markus so they can review the copyright/license header.

---
 Makefile.objs     |   2 +-
 qemu-file-stdio.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 qemu-file.c       | 168 ----------------------------------------------
 3 files changed, 195 insertions(+), 169 deletions(-)
 create mode 100644 qemu-file-stdio.c
Makefile.objs +1 -1
index 957e56c..18fd35c 100644
@@ -50,7 +50,7 @@ common-obj-$(CONFIG_LINUX) += fsdev/
 
 common-obj-y += migration.o migration-tcp.o
 common-obj-y += vmstate.o
-common-obj-y += qemu-file.o qemu-file-unix.o
+common-obj-y += qemu-file.o qemu-file-unix.o qemu-file-stdio.o
 common-obj-$(CONFIG_RDMA) += migration-rdma.o
 common-obj-y += qemu-char.o #aio.o
 common-obj-y += block-migration.o
qemu-file-stdio.c new file +194 -0

194 lines not on this page · raw message

qemu-file.c +0 -168

180 lines not on this page · raw message

Signature · 1 line
2.1.0
#10 lore raw

[Qemu-devel] [PULL 10/10] migration: catch unknown flag combinations in ram_load

In reply to Juan Quintela

From: Peter Lieven <[email protected]>

this patch extends commit db80fac by not only checking for unknown flags, but also filtering out unknown flag combinations.

---
 arch_init.c | 62 +++++++++++++++++++++++++++++++------------------------------
 1 file changed, 32 insertions(+), 30 deletions(-)
arch_init.c +32 -30
index 9b3e25d..88a5ba0 100644
@@ -1040,8 +1040,7 @@ void ram_handle_compressed(void *host, uint8_t ch, uint64_t size)
 
 static int ram_load(QEMUFile *f, void *opaque, int version_id)
 {
-    ram_addr_t addr;
-    int flags, ret = 0;
+    int flags = 0, ret = 0;
     static uint64_t seq_iter;
 
     seq_iter++;
@@ -1050,21 +1049,24 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
         ret = -EINVAL;
     }
 
-    while (!ret) {
-        addr = qemu_get_be64(f);
+    while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) {
+        ram_addr_t addr, total_ram_bytes;
+        void *host;
+        uint8_t ch;
 
+        addr = qemu_get_be64(f);
         flags = addr & ~TARGET_PAGE_MASK;
         addr &= TARGET_PAGE_MASK;
 
-        if (flags & RAM_SAVE_FLAG_MEM_SIZE) {
+        switch (flags & ~RAM_SAVE_FLAG_CONTINUE) {
+        case RAM_SAVE_FLAG_MEM_SIZE:
             /* Synchronize RAM block list */
-            char id[256];
-            ram_addr_t length;
-            ram_addr_t total_ram_bytes = addr;
-
-            while (total_ram_bytes) {
+            total_ram_bytes = addr;
+            while (!ret && total_ram_bytes) {
                 RAMBlock *block;
                 uint8_t len;
+                char id[256];
+                ram_addr_t length;
 
                 len = qemu_get_byte(f);
                 qemu_get_buffer(f, (uint8_t *)id, len);
@@ -1088,16 +1090,11 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
                                  "accept migration", id);
                     ret = -EINVAL;
                 }
-                if (ret) {
-                    break;
-                }
 
                 total_ram_bytes -= length;
             }
-        } else if (flags & RAM_SAVE_FLAG_COMPRESS) {
-            void *host;
-            uint8_t ch;
-
+            break;
+        case RAM_SAVE_FLAG_COMPRESS:
             host = host_from_stream_offset(f, addr, flags);
             if (!host) {
                 error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
@@ -1107,9 +1104,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
 
             ch = qemu_get_byte(f);
             ram_handle_compressed(host, ch, TARGET_PAGE_SIZE);
-        } else if (flags & RAM_SAVE_FLAG_PAGE) {
-            void *host;
-
+            break;
+        case RAM_SAVE_FLAG_PAGE:
             host = host_from_stream_offset(f, addr, flags);
             if (!host) {
                 error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
@@ -1118,8 +1114,9 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
             }
 
             qemu_get_buffer(f, host, TARGET_PAGE_SIZE);
-        } else if (flags & RAM_SAVE_FLAG_XBZRLE) {
-            void *host = host_from_stream_offset(f, addr, flags);
+            break;
+        case RAM_SAVE_FLAG_XBZRLE:
+            host = host_from_stream_offset(f, addr, flags);
             if (!host) {
                 error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
                 ret = -EINVAL;
@@ -1132,17 +1129,22 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
                 ret = -EINVAL;
                 break;
             }
-        } else if (flags & RAM_SAVE_FLAG_HOOK) {
-            ram_control_load_hook(f, flags);
-        } else if (flags & RAM_SAVE_FLAG_EOS) {
-            /* normal exit */
             break;
-        } else {
-            error_report("Unknown migration flags: %#x", flags);
-            ret = -EINVAL;
+        case RAM_SAVE_FLAG_EOS:
+            /* normal exit */
             break;
+        default:
+            if (flags & RAM_SAVE_FLAG_HOOK) {
+                ram_control_load_hook(f, flags);
+            } else {
+                error_report("Unknown combination of migration flags: %#x",
+                             flags);
+                ret = -EINVAL;
+            }
+        }
+        if (!ret) {
+            ret = qemu_file_get_error(f);
         }
-        ret = qemu_file_get_error(f);
     }
 
     DPRINTF("Completed load of VM with exit code %d seq iteration "
Signature · 1 line
2.1.0
#11 lore raw
In reply to Juan Quintela
Quoted 18 lines · Juan Quintela

From: Juan Quintela <[email protected]>

Hi

This patches have been on the list for a while:

- ram flags from Peter Lieven
- qemu-file cleanups from Eduardo (just code movement)
- QEMUSizedBuffer from David (they have already have 6 versions)
- VBUFFER (new macro, can't break old things) (Alexey)
- invalidate state (Alexey)

Please, apply.

The following changes since commit b1d28ec6a7dbdaadda39d29322f0de694aeb0b74:

Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20141010' into staging (2014-10-10 14:55:29 +0100)

Quoted 8 lines

are available in the git repository at:

git://github.com/juanquintela/qemu.git migration/20141015

for you to fetch changes up to 5b0e9dd46fbda5152566a4a26fd96bc0d0452bf7:

migration: catch unknown flag combinations in ram_load (2014-10-14 11:24:20 +0200)

Applied, thanks.

-- PMM