From: Kevin Wolf <kwolf@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com,
mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 3/4] fdc: Move qdev properties to FloppyDrive
Date: Mon, 17 Oct 2016 10:53:24 +0200 [thread overview]
Message-ID: <20161017085324.GB4821@noname.redhat.com> (raw)
In-Reply-To: <58a36fa8-41ad-1dc3-b9ff-c9f01ef5f73a@redhat.com>
Am 15.10.2016 um 00:32 hat John Snow geschrieben:
> On 09/30/2016 03:39 PM, Kevin Wolf wrote:
> >This makes the FloppyDrive qdev object actually useful: Now that it has
> >all properties that don't belong to the controller, you can actually
> >use '-device floppy' and get a working result.
> >
> >Command line semantics is consistent with CD-ROM drives: By default you
> >get a single empty floppy drive. You can override it with -drive and
> >using the same index, but if you use -drive to add a floppy to a
> >different index, you get both of them. However, as soon as you use any
> >'-device floppy', even to a different slot, the default drive is
> >disabled.
> >
> >Using '-device floppy' without specifying the unit will choose the first
> >free slot on the controller.
> >
> >Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> >---
> > hw/block/fdc.c | 112 ++++++++++++++++++++++++++++++++++++++++++---------------
> > vl.c | 1 +
> > 2 files changed, 85 insertions(+), 28 deletions(-)
> >
> >diff --git a/hw/block/fdc.c b/hw/block/fdc.c
> >index 5aa8e52..00c0ec6 100644
> >--- a/hw/block/fdc.c
> >+++ b/hw/block/fdc.c
> >@@ -35,6 +35,7 @@
> > #include "qemu/timer.h"
> > #include "hw/isa/isa.h"
> > #include "hw/sysbus.h"
> >+#include "hw/block/block.h"
> > #include "sysemu/block-backend.h"
> > #include "sysemu/blockdev.h"
> > #include "sysemu/sysemu.h"
> >@@ -487,12 +488,18 @@ static const BlockDevOps fd_block_ops = {
> > OBJECT_CHECK(FloppyDrive, (obj), TYPE_FLOPPY_DRIVE)
> >
> > typedef struct FloppyDrive {
> >- DeviceState qdev;
> >- uint32_t unit;
> >+ DeviceState qdev;
> >+ uint32_t unit;
> >+ BlockConf conf;
> >+ FloppyDriveType type;
> > } FloppyDrive;
> >
> > static Property floppy_drive_properties[] = {
> > DEFINE_PROP_UINT32("unit", FloppyDrive, unit, -1),
> >+ DEFINE_BLOCK_PROPERTIES(FloppyDrive, conf),
> >+ DEFINE_PROP_DEFAULT("drive-type", FloppyDrive, type,
> >+ FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
> >+ FloppyDriveType),
> > DEFINE_PROP_END_OF_LIST(),
> > };
> >
> >@@ -501,6 +508,7 @@ static int floppy_drive_init(DeviceState *qdev)
> > FloppyDrive *dev = FLOPPY_DRIVE(qdev);
> > FloppyBus *bus = DO_UPCAST(FloppyBus, bus, dev->qdev.parent_bus);
> > FDrive *drive;
> >+ int ret;
> >
> > if (dev->unit == -1) {
> > for (dev->unit = 0; dev->unit < MAX_FD; dev->unit++) {
> >@@ -517,29 +525,57 @@ static int floppy_drive_init(DeviceState *qdev)
> > return -1;
> > }
> >
> >- /* TODO Check whether unit is in use */
> >-
> > drive = get_drv(bus->fdc, dev->unit);
> >-
> > if (drive->blk) {
> >- if (blk_get_on_error(drive->blk, 0) != BLOCKDEV_ON_ERROR_ENOSPC) {
> >- error_report("fdc doesn't support drive option werror");
> >- return -1;
> >- }
> >- if (blk_get_on_error(drive->blk, 1) != BLOCKDEV_ON_ERROR_REPORT) {
> >- error_report("fdc doesn't support drive option rerror");
> >- return -1;
> >- }
> >- } else {
> >+ error_report("Floppy unit %d is in use", dev->unit);
> >+ return -1;
> >+ }
> >+
> >+ if (!dev->conf.blk) {
> > /* Anonymous BlockBackend for an empty drive */
> >- drive->blk = blk_new();
> >+ dev->conf.blk = blk_new();
> >+ ret = blk_attach_dev(dev->conf.blk, dev);
>
> Missing a 'q' here: ^
Yes. It has the same value, but after my last pull request we need a
DeviceState* here indeed rather than a void*.
> >@@ -2782,8 +2838,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_DRIVE("driveA", FDCtrlSysBus, state.qdev_for_drives[0].blk),
> >+ DEFINE_PROP_DRIVE("driveB", FDCtrlSysBus, state.qdev_for_drives[1].blk),
> > DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlSysBus, state.drives[0].drive,
> > FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type,
> > FloppyDriveType),
>
> ^ Does sysbus' type property not need updating ...?
Doing half of the properties here felt like a good transitional step
from fully converting the PC device to completely ignoring Sun.
Well, I guess, I should fix that...
Kevin
next prev parent reply other threads:[~2016-10-17 8:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-30 19:39 [Qemu-devel] [PATCH v2 0/4] fdc: Use separate qdev device for drives Kevin Wolf
2016-09-30 19:39 ` [Qemu-devel] [PATCH v2 1/4] fdc: Add a floppy qbus Kevin Wolf
2016-10-14 21:32 ` John Snow
2016-09-30 19:39 ` [Qemu-devel] [PATCH v2 2/4] fdc: Add a floppy drive qdev Kevin Wolf
2016-10-14 22:09 ` John Snow
2016-09-30 19:39 ` [Qemu-devel] [PATCH v2 3/4] fdc: Move qdev properties to FloppyDrive Kevin Wolf
2016-10-14 22:32 ` John Snow
2016-10-17 8:53 ` Kevin Wolf [this message]
2016-09-30 19:39 ` [Qemu-devel] [PATCH v2 4/4] qemu-iotests: Test creating floppy drives Kevin Wolf
2016-10-14 11:11 ` [Qemu-devel] [PATCH v2 0/4] fdc: Use separate qdev device for drives Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161017085324.GB4821@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=jsnow@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).