Received: from eggs.gnu.org ([2001:4830:134:3::10]:39835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z4p-0003My-D7 for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:21:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4Z4R-0007iy-Js for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:21:11 -0400 Received: from e32.co.us.ibm.com ([32.97.110.150]:38111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4Z4R-0007iZ-9J for qemu-devel@nongnu.org; Tue, 08 Jul 2014 13:20:47 -0400 Received: from /spool/local by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Jul 2014 11:20:46 -0600 From: Michael Roth Date: Tue, 8 Jul 2014 12:17:14 -0500 Message-Id: <1404839947-1086-44-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1404839947-1086-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 043/156] Fix vmstate_info_int32_le comparison/assign List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: "Dr. David Alan Gilbert" Fix comparison of vmstate_info_int32_le so that it succeeds if loaded value is (l)ess than or (e)qual When the comparison succeeds, assign the value loaded This is a change in behaviour but I think the original intent, since the idea is to check if the version/size of the thing you're loading is less than some limit, but you might well want to do something based on the actual version/size in the file Fix up comment and name text Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Juan Quintela (cherry picked from commit 24a370ef2351dc596a7e47508b952ddfba79ef94) Conflicts: vmstate.c *removed dependency on b6fcfa59 (Move VMState code to vmstate.c) Signed-off-by: Michael Roth --- savevm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/savevm.c b/savevm.c index 8a22807..40054cf 100644 --- a/savevm.c +++ b/savevm.c @@ -1111,22 +1111,24 @@ const VMStateInfo vmstate_info_int32_equal = { .put = put_int32, }; -/* 32 bit int. See that the received value is the less or the same - than the one in the field */ +/* 32 bit int. Check that the received value is less than or equal to + the one in the field */ static int get_int32_le(QEMUFile *f, void *pv, size_t size) { - int32_t *old = pv; - int32_t new; - qemu_get_sbe32s(f, &new); + int32_t *cur = pv; + int32_t loaded; + qemu_get_sbe32s(f, &loaded); - if (*old <= new) + if (loaded <= *cur) { + *cur = loaded; return 0; + } return -EINVAL; } const VMStateInfo vmstate_info_int32_le = { - .name = "int32 equal", + .name = "int32 le", .get = get_int32_le, .put = put_int32, }; -- 1.9.1