From patchwork Fri Nov 2 17:50:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 196684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0F34E2C00C2 for ; Sat, 3 Nov 2012 04:51:48 +1100 (EST) Received: from localhost ([::1]:56502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TULPG-00024A-3L for incoming@patchwork.ozlabs.org; Fri, 02 Nov 2012 13:51:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TULOz-0001lV-Bi for qemu-devel@nongnu.org; Fri, 02 Nov 2012 13:51:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TULOq-0005PX-W6 for qemu-devel@nongnu.org; Fri, 02 Nov 2012 13:51:26 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:55021) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TULOq-0005PA-Pu for qemu-devel@nongnu.org; Fri, 02 Nov 2012 13:51:20 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so2539706pbb.4 for ; Fri, 02 Nov 2012 10:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=o01ac+JfF3qLUEv1MuW3T+xU3BAGOnfsbgYeBiPdCOs=; b=HycmhEUnmJCpRoktGKdhj1eyMvbe5xQ3ytejC2ui1Ywwd67Dt4pxLTk5Ztjx4S3+n+ pxh/SGoW8H5O++IUiAAxTYGooDvVWyPEMSY9ulJ7o2TZMz2OgMgkmo5Y2Km5/i6LvmxM E6CXhJbyId8fs+KGwaBWb2lTP6+4FQ5cXdAROGlrJqei+akUlGXYReHN4O1+nPg6+fd2 lgJYvkmp/VZgiWFhjxHaw2hForMqzwaK/yTzpA8mBppjx3DZlKoSyybUWMe1h59YjwR+ 4IXJm1T0uEv/k9xTHHWfVTvnON4eLsPaCps5+cgiygJzgIPaIj5sVNE/xtzG6gI/gu3g 6Slg== Received: by 10.68.137.228 with SMTP id ql4mr8283223pbb.125.1351878679886; Fri, 02 Nov 2012 10:51:19 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id a4sm6052116pax.12.2012.11.02.10.51.16 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 02 Nov 2012 10:51:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 2 Nov 2012 18:50:54 +0100 Message-Id: <1351878665-32413-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1351878665-32413-1-git-send-email-pbonzini@redhat.com> References: <1351878665-32413-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.160.45 Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 01/12] migration: unify stdio-based QEMUFile operations X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now that qemu_fseek does not exist anymore, there is no reason to do an fseek before fread/fwrite when operating on an stdio file. Thus, unify the get/put_buffer callbacks used by qemu_fopen with those used for pipes. Reviewed-by: Orit Wasserman Signed-off-by: Paolo Bonzini --- savevm.c | 19 ++----------------- 1 file modificato, 2 inserzioni(+), 17 rimozioni(-) diff --git a/savevm.c b/savevm.c index 43d3d1b..cfcf918 100644 --- a/savevm.c +++ b/savevm.c @@ -343,21 +343,6 @@ QEMUFile *qemu_fopen_socket(int fd) return s->file; } -static int file_put_buffer(void *opaque, const uint8_t *buf, - int64_t pos, int size) -{ - QEMUFileStdio *s = opaque; - fseek(s->stdio_file, pos, SEEK_SET); - return fwrite(buf, 1, size, s->stdio_file); -} - -static int file_get_buffer(void *opaque, uint8_t *buf, int64_t pos, int size) -{ - QEMUFileStdio *s = opaque; - fseek(s->stdio_file, pos, SEEK_SET); - return fread(buf, 1, size, s->stdio_file); -} - QEMUFile *qemu_fopen(const char *filename, const char *mode) { QEMUFileStdio *s; @@ -376,10 +361,10 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode) goto fail; if(mode[0] == 'w') { - s->file = qemu_fopen_ops(s, file_put_buffer, NULL, stdio_fclose, + s->file = qemu_fopen_ops(s, stdio_put_buffer, NULL, stdio_fclose, NULL, NULL, NULL); } else { - s->file = qemu_fopen_ops(s, NULL, file_get_buffer, stdio_fclose, + s->file = qemu_fopen_ops(s, NULL, stdio_get_buffer, stdio_fclose, NULL, NULL, NULL); } return s->file;