From patchwork Wed Sep 5 09:55:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: dunrong huang X-Patchwork-Id: 181836 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 075372C009A for ; Wed, 5 Sep 2012 19:55:31 +1000 (EST) Received: from localhost ([::1]:59351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9CKX-0000ll-6j for incoming@patchwork.ozlabs.org; Wed, 05 Sep 2012 05:55:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9CKK-0000l9-VL for qemu-devel@nongnu.org; Wed, 05 Sep 2012 05:55:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9CKJ-0000f9-Vf for qemu-devel@nongnu.org; Wed, 05 Sep 2012 05:55:16 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:43599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9CKJ-0000dq-PC; Wed, 05 Sep 2012 05:55:15 -0400 Received: by pbbjt11 with SMTP id jt11so689540pbb.4 for ; Wed, 05 Sep 2012 02:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:mime-version :content-type:content-transfer-encoding; bh=G3pMZbsHa3ObcEqKK7SxdQdvxSyWLRR8aF6n1Ny5emw=; b=Vr1pfWRqEjH7pMX2d7nOh9R1YdZzxzH5a3srkyfJFFg15wD7k9PjryR4R04pjfZCuz tR5Sl73U7Rb0gR2Lz+nrjTYxYXFUtvW3zPWGTqp0JHkemK17Y0dUjuFDPxUleDOltoR2 UwQy7tSzDFQMjhZsFB8Oqs5qmMpwwPj03at7xkVDJ1WzTm2U1XZZMJxichouV/R1qAGq G96URKdmMy4Zs4KCF925Nuw8lqwfDGu1MxV5Jw7RaaU68bbGeNkdOCv5HjgBYa92z+/J jxcAIystY/yYSbiuon8KoPYlG3+NQGpTToTJ0ZI87WodZ6ucR4+tcob08x+Je7Sj8pmR nveA== Received: by 10.68.240.7 with SMTP id vw7mr52910696pbc.152.1346838914662; Wed, 05 Sep 2012 02:55:14 -0700 (PDT) Received: from localhost.localdomain ([221.122.32.18]) by mx.google.com with ESMTPS id th6sm1100985pbc.0.2012.09.05.02.55.10 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 02:55:13 -0700 (PDT) From: riegamaths@gmail.com To: qemu-devel Date: Wed, 5 Sep 2012 17:55:32 +0800 Message-Id: <1346838932-29658-1-git-send-email-riegamaths@gmail.com> X-Mailer: git-send-email 1.7.12 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: qemu-trivial , Dunrong Huang Subject: [Qemu-devel] =?utf-8?q?=5BPATCH_v2=5D_block=3A_output_more_error_?= =?utf-8?q?messages_if_failed_to_create_temporary_snapshot?= 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 From: Dunrong Huang If we failed to create temporary snapshot, the error message did not match with the error, for example: $ TMPDIR=/tmp/bad_path qemu-system-x86_64 -enable-kvm debian.qcow2 -snapshot qemu-system-x86_64: -enable-kvm: could not open disk image /home/mathslinux/Images/debian.qcow2: No such file or directory Indeed, the file which cant be created is /tmp/bad_path/vl.xxxxxx, not debian.qcow2. so the error message makes users feel confused. Signed-off-by: Dunrong Huang --- v1 -> v2: Output error message only if fd < 0 block.c | 7 ++++++- 1 个文件被修改,插入 6 行(+),删除 1 行(-) diff --git a/block.c b/block.c index 470bdcc..2dd0c5b 100644 --- a/block.c +++ b/block.c @@ -433,7 +433,12 @@ int get_tmp_filename(char *filename, int size) return -EOVERFLOW; } fd = mkstemp(filename); - if (fd < 0 || close(fd)) { + if (fd < 0) { + fprintf(stderr, "Could not create temporary snapshot in %s directory: " + "%s\n", tmpdir, strerror(errno)); + return -errno; + } + if (close(fd) != 0) { return -errno; } return 0;