{"id":818207,"url":"http://patchwork.ozlabs.org/api/patches/818207/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170925112917.21340-7-dgilbert@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170925112917.21340-7-dgilbert@redhat.com>","list_archive_url":null,"date":"2017-09-25T11:29:17","name":"[v2,6/6] migration: Route more error paths","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"205a0554b2acfd1ef6548d7392015756d78da3ed","submitter":{"id":48102,"url":"http://patchwork.ozlabs.org/api/people/48102/?format=json","name":"Dr. David Alan Gilbert","email":"dgilbert@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20170925112917.21340-7-dgilbert@redhat.com/mbox/","series":[{"id":4941,"url":"http://patchwork.ozlabs.org/api/series/4941/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=4941","date":"2017-09-25T11:29:11","name":"migration: let pre_save fail","version":2,"mbox":"http://patchwork.ozlabs.org/series/4941/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/818207/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/818207/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=dgilbert@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y127V125Mz9t67\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 25 Sep 2017 21:35:02 +1000 (AEST)","from localhost ([::1]:41812 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dwRfA-0003w8-9o\n\tfor incoming@patchwork.ozlabs.org; Mon, 25 Sep 2017 07:35:00 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:59863)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <dgilbert@redhat.com>) id 1dwRZy-00080e-Qt\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 07:29:40 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <dgilbert@redhat.com>) id 1dwRZx-000263-Hb\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 07:29:38 -0400","from mx1.redhat.com ([209.132.183.28]:34843)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <dgilbert@redhat.com>) id 1dwRZx-00024V-8s\n\tfor qemu-devel@nongnu.org; Mon, 25 Sep 2017 07:29:37 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 50590CD25D;\n\tMon, 25 Sep 2017 11:29:36 +0000 (UTC)","from dgilbert-t530.redhat.com (ovpn-116-100.ams2.redhat.com\n\t[10.36.116.100])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id CB6076C410;\n\tMon, 25 Sep 2017 11:29:34 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 50590CD25D","From":"\"Dr. David Alan Gilbert (git)\" <dgilbert@redhat.com>","To":"qemu-devel@nongnu.org, quintela@redhat.com, peterx@redhat.com,\n\tfamz@redhat.com","Date":"Mon, 25 Sep 2017 12:29:17 +0100","Message-Id":"<20170925112917.21340-7-dgilbert@redhat.com>","In-Reply-To":"<20170925112917.21340-1-dgilbert@redhat.com>","References":"<20170925112917.21340-1-dgilbert@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tMon, 25 Sep 2017 11:29:36 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"[Qemu-devel] [PATCH v2 6/6] migration: Route more error paths","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"peter.maydell@linaro.org, cohuck@redhat.com, rth@twiddle.net","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"From: \"Dr. David Alan Gilbert\" <dgilbert@redhat.com>\n\nvmstate_save is called in a few places, and vmstate_save_state is\ncalled in lots of places.\n\nRoute error returns from the easier cases back up;  there are lots\nof more complex cases where their own error paths need fixing.\n\nSigned-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>\n---\n hw/display/virtio-gpu.c    |  4 +---\n hw/virtio/virtio.c         | 13 +++++++------\n include/hw/virtio/virtio.h |  2 +-\n migration/vmstate-types.c  | 11 ++++++++---\n tests/test-vmstate.c       |  9 ++++++---\n 5 files changed, 23 insertions(+), 16 deletions(-)","diff":"diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c\nindex 3a8f1e1a2d..2becbfda59 100644\n--- a/hw/display/virtio-gpu.c\n+++ b/hw/display/virtio-gpu.c\n@@ -1050,9 +1050,7 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,\n     }\n     qemu_put_be32(f, 0); /* end of list */\n \n-    vmstate_save_state(f, &vmstate_virtio_gpu_scanouts, g, NULL);\n-\n-    return 0;\n+    return vmstate_save_state(f, &vmstate_virtio_gpu_scanouts, g, NULL);\n }\n \n static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,\ndiff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c\nindex 3129d25c00..311929e9df 100644\n--- a/hw/virtio/virtio.c\n+++ b/hw/virtio/virtio.c\n@@ -1897,7 +1897,7 @@ static const VMStateDescription vmstate_virtio = {\n     }\n };\n \n-void virtio_save(VirtIODevice *vdev, QEMUFile *f)\n+int virtio_save(VirtIODevice *vdev, QEMUFile *f)\n {\n     BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));\n     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);\n@@ -1947,20 +1947,21 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)\n     }\n \n     if (vdc->vmsd) {\n-        vmstate_save_state(f, vdc->vmsd, vdev, NULL);\n+        int ret = vmstate_save_state(f, vdc->vmsd, vdev, NULL);\n+        if (ret) {\n+            return ret;\n+        }\n     }\n \n     /* Subsections */\n-    vmstate_save_state(f, &vmstate_virtio, vdev, NULL);\n+    return vmstate_save_state(f, &vmstate_virtio, vdev, NULL);\n }\n \n /* A wrapper for use as a VMState .put function */\n static int virtio_device_put(QEMUFile *f, void *opaque, size_t size,\n                               VMStateField *field, QJSON *vmdesc)\n {\n-    virtio_save(VIRTIO_DEVICE(opaque), f);\n-\n-    return 0;\n+    return virtio_save(VIRTIO_DEVICE(opaque), f);\n }\n \n /* A wrapper for use as a VMState .get function */\ndiff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h\nindex 80c45c321e..5abada6966 100644\n--- a/include/hw/virtio/virtio.h\n+++ b/include/hw/virtio/virtio.h\n@@ -188,7 +188,7 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,\n void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq);\n void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);\n \n-void virtio_save(VirtIODevice *vdev, QEMUFile *f);\n+int virtio_save(VirtIODevice *vdev, QEMUFile *f);\n \n extern const VMStateInfo virtio_vmstate_info;\n \ndiff --git a/migration/vmstate-types.c b/migration/vmstate-types.c\nindex c056c98bdb..48184c380d 100644\n--- a/migration/vmstate-types.c\n+++ b/migration/vmstate-types.c\n@@ -550,13 +550,14 @@ static int put_tmp(QEMUFile *f, void *pv, size_t size, VMStateField *field,\n {\n     const VMStateDescription *vmsd = field->vmsd;\n     void *tmp = g_malloc(size);\n+    int ret;\n \n     /* Writes the parent field which is at the start of the tmp */\n     *(void **)tmp = pv;\n-    vmstate_save_state(f, vmsd, tmp, vmdesc);\n+    ret = vmstate_save_state(f, vmsd, tmp, vmdesc);\n     g_free(tmp);\n \n-    return 0;\n+    return ret;\n }\n \n const VMStateInfo vmstate_info_tmp = {\n@@ -657,12 +658,16 @@ static int put_qtailq(QEMUFile *f, void *pv, size_t unused_size,\n     /* offset of the QTAILQ entry in a QTAILQ element*/\n     size_t entry_offset = field->start;\n     void *elm;\n+    int ret;\n \n     trace_put_qtailq(vmsd->name, vmsd->version_id);\n \n     QTAILQ_RAW_FOREACH(elm, pv, entry_offset) {\n         qemu_put_byte(f, true);\n-        vmstate_save_state(f, vmsd, elm, vmdesc);\n+        ret = vmstate_save_state(f, vmsd, elm, vmdesc);\n+        if (ret) {\n+            return ret;\n+        }\n     }\n     qemu_put_byte(f, false);\n \ndiff --git a/tests/test-vmstate.c b/tests/test-vmstate.c\nindex e643ac662b..087844b6c8 100644\n--- a/tests/test-vmstate.c\n+++ b/tests/test-vmstate.c\n@@ -70,7 +70,8 @@ static void save_vmstate(const VMStateDescription *desc, void *obj)\n     QEMUFile *f = open_test_file(true);\n \n     /* Save file with vmstate */\n-    vmstate_save_state(f, desc, obj, NULL);\n+    int ret = vmstate_save_state(f, desc, obj, NULL);\n+    g_assert(!ret);\n     qemu_put_byte(f, QEMU_VM_EOF);\n     g_assert(!qemu_file_get_error(f));\n     qemu_fclose(f);\n@@ -381,7 +382,8 @@ static void test_save_noskip(void)\n     QEMUFile *fsave = open_test_file(true);\n     TestStruct obj = { .a = 1, .b = 2, .c = 3, .d = 4, .e = 5, .f = 6,\n                        .skip_c_e = false };\n-    vmstate_save_state(fsave, &vmstate_skipping, &obj, NULL);\n+    int ret = vmstate_save_state(fsave, &vmstate_skipping, &obj, NULL);\n+    g_assert(!ret);\n     g_assert(!qemu_file_get_error(fsave));\n \n     uint8_t expected[] = {\n@@ -402,7 +404,8 @@ static void test_save_skip(void)\n     QEMUFile *fsave = open_test_file(true);\n     TestStruct obj = { .a = 1, .b = 2, .c = 3, .d = 4, .e = 5, .f = 6,\n                        .skip_c_e = true };\n-    vmstate_save_state(fsave, &vmstate_skipping, &obj, NULL);\n+    int ret = vmstate_save_state(fsave, &vmstate_skipping, &obj, NULL);\n+    g_assert(!ret);\n     g_assert(!qemu_file_get_error(fsave));\n \n     uint8_t expected[] = {\n","prefixes":["v2","6/6"]}