From patchwork Mon Apr 5 20:33:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 49460 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F4019B7CFA for ; Tue, 6 Apr 2010 08:10:04 +1000 (EST) Received: from localhost ([127.0.0.1]:49025 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NyuTw-0002ll-1U for incoming@patchwork.ozlabs.org; Mon, 05 Apr 2010 18:09:20 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NyuRn-0002hy-4r for qemu-devel@nongnu.org; Mon, 05 Apr 2010 18:07:07 -0400 Received: from [140.186.70.92] (port=35816 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NytL1-0006bI-5a for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nyt00-0001aT-J3 for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:34:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46822) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nyt00-0001aJ-8m for qemu-devel@nongnu.org; Mon, 05 Apr 2010 16:34:20 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o35KYJer029454 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Apr 2010 16:34:19 -0400 Received: from localhost (vpn-8-191.rdu.redhat.com [10.11.8.191]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o35KYHmE000911; Mon, 5 Apr 2010 16:34:18 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Mon, 5 Apr 2010 17:33:44 -0300 Message-Id: <1270499642-31543-4-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1270499642-31543-1-git-send-email-lcapitulino@redhat.com> References: <1270499642-31543-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Ryan Harper , qemu-devel@nongnu.org, Luiz Capitulino Subject: [Qemu-devel] [PATCH 03/21] Add qerror message if the 'change' target filename can't be opened X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Ryan Harper Currently when using the change command to switch the file in the cd drive the command doesn't complain if the file doesn't exit or can't be opened and the drive keeps the existing image. This patch adds a qerror_report call to print a message out indicating the failure. This error message can be used to catch failures. Current behavior: QEMU 0.12.50 monitor - type 'help' for more information (qemu) info block ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0 ide1-cd0: type=cdrom removable=1 locked=0 [not inserted] floppy0: type=floppy removable=1 locked=0 [not inserted] sd0: type=floppy removable=1 locked=0 [not inserted] (qemu) change ide1-cd0 /home/rharper/work/isos/Fedora-9-i386-DVD.iso (qemu) info block ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0 ide1-cd0: type=cdrom removable=1 locked=0 file=/home/rharper/work/isos/Fedora-9-i386-DVD.iso ro=0 drv=raw encrypted=0 floppy0: type=floppy removable=1 locked=0 [not inserted] sd0: type=floppy removable=1 locked=0 [not inserted] (qemu) change ide1-cd0 /tmp/non_existent_file.iso (qemu) info block ide0-hd0: type=hd removable=0 file=/dev/null ro=0 drv=host_device encrypted=0 ide1-cd0: type=cdrom removable=1 locked=0 [not inserted] floppy0: type=floppy removable=1 locked=0 [not inserted] sd0: type=floppy removable=1 locked=0 [not inserted] (qemu) With patch: QEMU 0.12.50 monitor - type 'help' for more information (qemu) change ide1-cd0 /tmp/non_existent_file.iso Could not open '/tmp/non_existent_file.iso' (qemu) Signed-off-by: Ryan Harper Signed-off-by: Luiz Capitulino --- monitor.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index 822dc27..89952e8 100644 --- a/monitor.c +++ b/monitor.c @@ -1097,6 +1097,7 @@ static int do_change_block(Monitor *mon, const char *device, return -1; } if (bdrv_open2(bs, filename, BDRV_O_RDWR, drv) < 0) { + qerror_report(QERR_OPEN_FILE_FAILED, filename); return -1; } return monitor_read_bdrv_key_start(mon, bs, NULL, NULL);