Received: from eggs.gnu.org ([2001:4830:134:3::10]:44492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpwh0-0001BA-16 for qemu-devel@nongnu.org; Fri, 30 Sep 2016 08:13:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpwgy-0007Qc-V1 for qemu-devel@nongnu.org; Fri, 30 Sep 2016 08:13:29 -0400 From: Fam Zheng Date: Fri, 30 Sep 2016 20:10:01 +0800 Message-Id: <1475237406-26917-32-git-send-email-famz@redhat.com> In-Reply-To: <1475237406-26917-1-git-send-email-famz@redhat.com> References: <1475237406-26917-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v8 31/36] fdc: Add lock-mode qdev properties List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: berrange@redhat.com, John Snow , qemu-block@nongnu.org, Kevin Wolf , rjones@redhat.com, Jeff Cody , Max Reitz , Markus Armbruster , stefanha@redhat.com, den@openvz.org, pbonzini@redhat.com, eblake@redhat.com Signed-off-by: Fam Zheng --- hw/block/fdc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index b79873a..20684b8 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -158,6 +158,7 @@ typedef enum FDiskFlags { typedef struct FDrive { FDCtrl *fdctrl; BlockBackend *blk; + ImageLockMode lock_mode; /* Drive status */ FloppyDriveType drive; /* CMOS drive type */ uint8_t perpendicular; /* 2.88 MB access mode */ @@ -2446,11 +2447,23 @@ static void fdctrl_realize_common(FDCtrl *fdctrl, Error **errp) { int i, j; static int command_tables_inited = 0; + Error *local_err = NULL; if (fdctrl->fallback == FLOPPY_DRIVE_TYPE_AUTO) { error_setg(errp, "Cannot choose a fallback FDrive type of 'auto'"); } + for (i = 0; i < 2; ++i) { + if (fdctrl->drives[i].blk) { + blk_lock_image(fdctrl->drives[i].blk, fdctrl->drives[i].lock_mode, + &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + } + } + /* Fill 'command_to_handler' lookup table */ if (!command_tables_inited) { command_tables_inited = 1; @@ -2495,7 +2508,6 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp) FDCtrlISABus *isa = ISA_FDC(dev); FDCtrl *fdctrl = &isa->state; Error *err = NULL; - isa_register_portio_list(isadev, &fdctrl->portio_list, isa->iobase, fdc_portio_list, fdctrl, "fdc"); @@ -2608,6 +2620,8 @@ static Property isa_fdc_properties[] = { DEFINE_PROP_UINT32("dma", FDCtrlISABus, dma, 2), DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.drives[0].blk), DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].blk), + DEFINE_PROP_LOCK_MODE("lock-modeA", FDCtrlISABus, state.drives[0].lock_mode), + DEFINE_PROP_LOCK_MODE("lock-modeB", FDCtrlISABus, state.drives[1].lock_mode), DEFINE_PROP_BIT("check_media_rate", FDCtrlISABus, state.check_media_rate, 0, true), DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlISABus, state.drives[0].drive, @@ -2667,6 +2681,8 @@ static const VMStateDescription vmstate_sysbus_fdc ={ static Property sysbus_fdc_properties[] = { DEFINE_PROP_DRIVE("driveA", FDCtrlSysBus, state.drives[0].blk), DEFINE_PROP_DRIVE("driveB", FDCtrlSysBus, state.drives[1].blk), + DEFINE_PROP_LOCK_MODE("lock-modeA", FDCtrlISABus, state.drives[0].lock_mode), + DEFINE_PROP_LOCK_MODE("lock-modeB", FDCtrlISABus, state.drives[1].lock_mode), DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlSysBus, state.drives[0].drive, FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, FloppyDriveType), @@ -2696,6 +2712,7 @@ static const TypeInfo sysbus_fdc_info = { static Property sun4m_fdc_properties[] = { DEFINE_PROP_DRIVE("drive", FDCtrlSysBus, state.drives[0].blk), + DEFINE_PROP_LOCK_MODE("lock-mode", FDCtrlISABus, state.drives[0].lock_mode), DEFINE_PROP_DEFAULT("fdtype", FDCtrlSysBus, state.drives[0].drive, FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, FloppyDriveType), -- 2.7.4