From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz1r4-0004Q5-UG for qemu-devel@nongnu.org; Tue, 25 Oct 2016 09:33:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bz1r0-0000nO-FY for qemu-devel@nongnu.org; Tue, 25 Oct 2016 09:33:26 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44407) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bz1r0-0000n4-75 for qemu-devel@nongnu.org; Tue, 25 Oct 2016 09:33:22 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u9PDSRoL122041 for ; Tue, 25 Oct 2016 09:33:19 -0400 Received: from e06smtp08.uk.ibm.com (e06smtp08.uk.ibm.com [195.75.94.104]) by mx0a-001b2d01.pphosted.com with ESMTP id 26a5v0gtve-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 25 Oct 2016 09:33:19 -0400 Received: from localhost by e06smtp08.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Oct 2016 14:33:17 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 5F0642190063 for ; Tue, 25 Oct 2016 14:32:31 +0100 (BST) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u9PDXF8N17236036 for ; Tue, 25 Oct 2016 13:33:15 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u9PCXG3V032028 for ; Tue, 25 Oct 2016 06:33:17 -0600 References: <20161021143741.8597-1-pasic@linux.vnet.ibm.com> <20161021143741.8597-4-pasic@linux.vnet.ibm.com> <20161025101346.GB2034@work-vm> From: Halil Pasic Date: Tue, 25 Oct 2016 15:33:14 +0200 MIME-Version: 1.0 In-Reply-To: <20161025101346.GB2034@work-vm> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Message-Id: Subject: Re: [Qemu-devel] [RFC PATCH 3/4] migration/vmstate: fix array of pointers to struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert" Cc: qemu-devel@nongnu.org, Amit Shah , Juan Quintela , Guenther Hutzl On 10/25/2016 12:13 PM, Dr. David Alan Gilbert wrote: > * Halil Pasic (pasic@linux.vnet.ibm.com) wrote: >> > Make VMS_ARRAY_OF_POINTER cope with null pointers. Previously the reward >> > for trying to migrate an array with some null pointers in it was an >> > illegal memory access, that is a swift and painless death of the >> > process. Let's make vmstate cope with this scenario at least for >> > pointers to structs. The general approach is when we encounter a null >> > pointer (element) instead of following the pointer to save/load the data >> > behind it we save/load a placeholder. This way we can detect if we >> > expected a null pointer at the load side but not null data was saved >> > instead. Sadly all other error scenarios are not detected by this scheme >> > (and would require the usage of the JSON meta data). >> > >> > Limitations: Does not work for pointers to primitives. > Hmm is this needed - I mean could you do this just by giving the vmsd > that defines the children of the array a '.needed' that tests if their > pointer is NULL? > > I do not think so: .needed is basically for subsections (also used in migration/savevm.c via the exported vmstate_save_needed function), and .field_exists is also no use for this (AFAIU). Have also tried just to be sure, it did not work for me. If I did not convince you, a bit of a code proving me wrong would be highly appreciated. Thanks for the comment! Halil