From patchwork Tue Jul 6 15:33:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 58035 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 5ADFDB6EFE for ; Wed, 7 Jul 2010 01:47:32 +1000 (EST) Received: from localhost ([127.0.0.1]:37879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWAMk-0005eK-Eu for incoming@patchwork.ozlabs.org; Tue, 06 Jul 2010 11:47:22 -0400 Received: from [140.186.70.92] (port=39353 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWA9Y-0006Lq-4E for qemu-devel@nongnu.org; Tue, 06 Jul 2010 11:33:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWA9X-00008G-15 for qemu-devel@nongnu.org; Tue, 06 Jul 2010 11:33:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64669) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWA9W-000088-Pz for qemu-devel@nongnu.org; Tue, 06 Jul 2010 11:33:43 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o66FXfRm004746 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 6 Jul 2010 11:33:41 -0400 Received: from localhost.localdomain (dhcp-5-217.str.redhat.com [10.32.5.217]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o66FXTso012071; Tue, 6 Jul 2010 11:33:40 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Tue, 6 Jul 2010 17:33:16 +0200 Message-Id: <1278430406-18667-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1278430406-18667-1-git-send-email-kwolf@redhat.com> References: <1278430406-18667-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 07/17] fdc: Reject unimplemented error actions 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: Markus Armbruster drive_init() doesn't permit them for if=floppy, but that's worthless: we get them via if=none and -global. This can make device initialization fail. Since all callers of fdctrl_init_isa() ignore its value, change it to die instead of returning failure. Without this, some callers would ignore the failure, and others would crash. Wart: unlike drive_init(), we don't reject the default action when it's explicitly specified. That's because we can't distinguish "no rerror option" from "rerror=report", or "no werror" from "rerror=enospc". Left for another day. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/fdc.c | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/hw/fdc.c b/hw/fdc.c index 6c74878..2d50bd6 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -29,6 +29,7 @@ #include "hw.h" #include "fdc.h" +#include "qemu-error.h" #include "qemu-timer.h" #include "isa.h" #include "sysbus.h" @@ -1844,7 +1845,7 @@ static void fdctrl_result_timer(void *opaque) } /* Init functions */ -static void fdctrl_connect_drives(FDCtrl *fdctrl) +static int fdctrl_connect_drives(FDCtrl *fdctrl) { unsigned int i; FDrive *drive; @@ -1852,12 +1853,24 @@ static void fdctrl_connect_drives(FDCtrl *fdctrl) for (i = 0; i < MAX_FD; i++) { drive = &fdctrl->drives[i]; + if (drive->bs) { + if (bdrv_get_on_error(drive->bs, 0) != BLOCK_ERR_STOP_ENOSPC) { + error_report("fdc doesn't support drive option werror"); + return -1; + } + if (bdrv_get_on_error(drive->bs, 1) != BLOCK_ERR_REPORT) { + error_report("fdc doesn't support drive option rerror"); + return -1; + } + } + fd_init(drive); fd_revalidate(drive); if (drive->bs) { bdrv_set_removable(drive->bs, 1); } } + return 0; } FDCtrl *fdctrl_init_isa(DriveInfo **fds) @@ -1871,8 +1884,7 @@ FDCtrl *fdctrl_init_isa(DriveInfo **fds) if (fds[1]) { qdev_prop_set_drive_nofail(&dev->qdev, "driveB", fds[1]->bdrv); } - if (qdev_init(&dev->qdev) < 0) - return NULL; + qdev_init_nofail(&dev->qdev); return &(DO_UPCAST(FDCtrlISABus, busdev, dev)->state); } @@ -1950,9 +1962,7 @@ static int fdctrl_init_common(FDCtrl *fdctrl) if (fdctrl->dma_chann != -1) DMA_register_channel(fdctrl->dma_chann, &fdctrl_transfer_handler, fdctrl); - fdctrl_connect_drives(fdctrl); - - return 0; + return fdctrl_connect_drives(fdctrl); } static int isabus_fdc_init1(ISADevice *dev)