From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPXcY-0005SG-Mi for qemu-devel@nongnu.org; Tue, 09 Apr 2013 08:25:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPXcX-000416-3C for qemu-devel@nongnu.org; Tue, 09 Apr 2013 08:25:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPXcW-000410-R7 for qemu-devel@nongnu.org; Tue, 09 Apr 2013 08:25:52 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r39CPqct000929 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 9 Apr 2013 08:25:52 -0400 Message-ID: <516408C9.7060304@redhat.com> Date: Tue, 09 Apr 2013 14:25:45 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1365420597-5506-1-git-send-email-pbonzini@redhat.com> <1365420597-5506-4-git-send-email-pbonzini@redhat.com> <878v4sdj6q.fsf@elfo.elfo> <516401A5.1020707@redhat.com> <87sj2zdhjh.fsf@elfo.elfo> In-Reply-To: <87sj2zdhjh.fsf@elfo.elfo> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/4] migration: drop is_write complications List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: quintela@redhat.com Cc: kwolf@redhat.com, owasserm@redhat.com, qemu-devel@nongnu.org Il 09/04/2013 14:17, Juan Quintela ha scritto: >> > This test assumes that it makes sense to call qemu_get_byte on a >> > write-opened QEMUFile. This is not true anymore after this patch. >> > After eliminating is_write, the right thing to do is abort. > > But this would not abort, it would do a segmenation fault! > > I would not complain to a: > > assert(!f->ops->get_buffer); > > It would told us from where we got the "invalid" call, but this removal > will change a "silent fail" (that I don't like either) to a segmentation > fault (that is even worse). It would still assert if you open a file in the wrong mode: - if (!f->ops->get_buffer) - return; - - if (f->is_write) - abort(); + assert(!qemu_file_is_writable(f)); It would segfault if you declare the QEMUFileOps wrong (e.g. no *_buffer operation), but that's a bug in the QEMUFile implementation rather than the usage. I think a segfault is acceptable for that. Paolo