1. 23 6月, 2020 1 次提交
    • M
      fdc: Reject clash between -drive if=floppy and -global isa-fdc · 6172e067
      Markus Armbruster 提交于
      The floppy controller devices desugar their drive properties into
      floppy devices (since commit a92bd191 "fdc: Move qdev properties to
      FloppyDrive", v2.8.0).  This involves some bad magic in
      fdctrl_connect_drives(), and exists for backward compatibility.
      
      The functions for boards to create floppy controller devices
      fdctrl_init_isa(), fdctrl_init_sysbus(), and sun4m_fdctrl_init()
      desugar -drive if=floppy to these floppy controller drive properties.
      
      If you use both -drive if=floppy (or its -fda / -fdb sugar) and
      -global isa-fdc for the same floppy device, -global silently loses the
      conflict, and both backends involved end up with the floppy device
      frontend attached, as demonstrated by iotest 172 (see commit before
      previous).  This is wrong.
      
      Desugar -drive if=floppy straight to floppy devices instead, with
      helper fdctrl_init_drives().  The conflict now gets rejected cleanly:
      first, fdctrl_connect_drives() creates the floppy for the controller's
      property, then fdctrl_init_drives() attempts to create the floppy for
      -drive if=floppy, but fails because the unit is already in use.
      
      Output of iotest 172 changes in three ways:
      
      1. The clash gets rejected.
      
      2. In one test case, "info qtree" has the floppy devices swapped, and
         "info block" has their QOM paths swapped.  This is because the
         floppy device for -fda now gets created after the one for -global
         isa-fdc.driveB.
      
      3. The error message for -global floppy.drive=floppy0 changes.  Before
         the patch, we set isa-fdc.driveA to -fda's block backend, then
         create the floppy device for it, then move the backend from
         isa-fdc.driveA to floppy.drive.  Floppy creation fails when
         applying -global floppy.drive=floppy0, because floppy0 is still
         attached to isa-fdc.  After the patch, we create the floppy for
         -fda, then set its drive property to floppy0.  Now floppy creation
         succeeds, but setting the drive property fails, because -global
         already set it.  Yes, this is exasperatingly complicated.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20200622094227.1271650-5-armbru@redhat.com>
      6172e067
  2. 17 6月, 2020 1 次提交
  3. 16 6月, 2020 3 次提交
    • M
      sysbus: Convert to sysbus_realize() etc. with Coccinelle · 3c6ef471
      Markus Armbruster 提交于
      Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
      argument to sysbus_realize(), sysbus_realize_and_unref().
      
      Coccinelle script:
      
          @@
          expression dev, errp;
          @@
          -    qdev_realize(DEVICE(dev), NULL, errp);
          +    sysbus_realize(SYS_BUS_DEVICE(dev), errp);
      
          @@
          expression sysbus_dev, dev, errp;
          @@
          +    sysbus_dev = SYS_BUS_DEVICE(dev);
          -    qdev_realize_and_unref(dev, NULL, errp);
          +    sysbus_realize_and_unref(sysbus_dev, errp);
          -    sysbus_dev = SYS_BUS_DEVICE(dev);
      
          @@
          expression sysbus_dev, dev, errp;
          expression expr;
          @@
               sysbus_dev = SYS_BUS_DEVICE(dev);
               ... when != dev = expr;
          -    qdev_realize_and_unref(dev, NULL, errp);
          +    sysbus_realize_and_unref(sysbus_dev, errp);
      
          @@
          expression dev, errp;
          @@
          -    qdev_realize_and_unref(DEVICE(dev), NULL, errp);
          +    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
      
          @@
          expression dev, errp;
          @@
          -    qdev_realize_and_unref(dev, NULL, errp);
          +    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
      
      Whitespace changes minimized manually.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Acked-by: NAlistair Francis <alistair.francis@wdc.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
      [Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
      3c6ef471
    • M
      isa: Convert uses of isa_create(), isa_try_create() manually · c23e0561
      Markus Armbruster 提交于
      Same transformation as in the previous commit.  Manual, because
      convincing Coccinelle to transform these cases is not worthwhile.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200610053247.1583243-21-armbru@redhat.com>
      c23e0561
    • M
      qdev: Convert uses of qdev_create() with Coccinelle · 3e80f690
      Markus Armbruster 提交于
      This is the transformation explained in the commit before previous.
      Takes care of just one pattern that needs conversion.  More to come in
      this series.
      
      Coccinelle script:
      
          @ depends on !(file in "hw/arm/highbank.c")@
          expression bus, type_name, dev, expr;
          @@
          -    dev = qdev_create(bus, type_name);
          +    dev = qdev_new(type_name);
               ... when != dev = expr
          -    qdev_init_nofail(dev);
          +    qdev_realize_and_unref(dev, bus, &error_fatal);
      
          @@
          expression bus, type_name, dev, expr;
          identifier DOWN;
          @@
          -    dev = DOWN(qdev_create(bus, type_name));
          +    dev = DOWN(qdev_new(type_name));
               ... when != dev = expr
          -    qdev_init_nofail(DEVICE(dev));
          +    qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
      
          @@
          expression bus, type_name, expr;
          identifier dev;
          @@
          -    DeviceState *dev = qdev_create(bus, type_name);
          +    DeviceState *dev = qdev_new(type_name);
               ... when != dev = expr
          -    qdev_init_nofail(dev);
          +    qdev_realize_and_unref(dev, bus, &error_fatal);
      
          @@
          expression bus, type_name, dev, expr, errp;
          symbol true;
          @@
          -    dev = qdev_create(bus, type_name);
          +    dev = qdev_new(type_name);
               ... when != dev = expr
          -    object_property_set_bool(OBJECT(dev), true, "realized", errp);
          +    qdev_realize_and_unref(dev, bus, errp);
      
          @@
          expression bus, type_name, expr, errp;
          identifier dev;
          symbol true;
          @@
          -    DeviceState *dev = qdev_create(bus, type_name);
          +    DeviceState *dev = qdev_new(type_name);
               ... when != dev = expr
          -    object_property_set_bool(OBJECT(dev), true, "realized", errp);
          +    qdev_realize_and_unref(dev, bus, errp);
      
      The first rule exempts hw/arm/highbank.c, because it matches along two
      control flow paths there, with different @type_name.  Covered by the
      next commit's manual conversions.
      
      Missing #include "qapi/error.h" added manually.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
      [Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
      3e80f690
  4. 15 5月, 2020 1 次提交
  5. 29 4月, 2020 1 次提交
    • M
      fdc: Fix fallback=auto error handling · 07a978ef
      Markus Armbruster 提交于
      fdctrl_realize_common() rejects fallback=auto.  Used by devices
      "isa-fdc", "sysbus-fdc", "SUNW,fdtwo".  The error handling is broken:
      
          $ qemu-system-x86_64 -nodefaults -device isa-fdc,fallback=auto,driveA=fd0 -drive if=none,id=fd0
          **
          ERROR:/work/armbru/qemu/hw/block/fdc.c:434:pick_drive_type: assertion failed: (drv->drive != FLOPPY_DRIVE_TYPE_AUTO)
          Aborted (core dumped)
      
      Cause: fdctrl_realize_common() neglects to bail out after setting the
      error.  Fix that.
      
      Fixes: a73275dd
      Cc: John Snow <jsnow@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20200422130719.28225-7-armbru@redhat.com>
      07a978ef
  6. 28 3月, 2020 1 次提交
    • S
      fdc/i8257: implement verify transfer mode · 9e58f172
      Sven Schnelle 提交于
      While working on the Tulip driver i tried to write some Teledisk images to
      a floppy image which didn't work. Turned out that Teledisk checks the written
      data by issuing a READ command to the FDC but running the DMA controller
      in VERIFY mode. As we ignored the DMA request in that case, the DMA transfer
      never finished, and Teledisk reported an error.
      
      The i8257 spec says about verify transfers:
      
      3) DMA verify, which does not actually involve the transfer of data. When an
      8257 channel is in the DMA verify mode, it will respond the same as described
      for transfer operations, except that no memory or I/O read/write control signals
      will be generated.
      
      Hervé proposed to remove all the dma_mode_ok stuff from fdc to have a more
      clear boundary between DMA and FDC, so this patch also does that.
      Suggested-by: NHervé Poussineau <hpoussin@reactos.org>
      Signed-off-by: NSven Schnelle <svens@stackframe.org>
      Reviewed-by: NHervé Poussineau <hpoussin@reactos.org>
      9e58f172
  7. 25 1月, 2020 1 次提交
  8. 16 8月, 2019 5 次提交
  9. 30 7月, 2019 1 次提交
    • K
      fdc: Fix inserting read-only media in empty drive · 0b9e918f
      Kevin Wolf 提交于
      In order to insert a read-only medium (i.e. a read-only block node) to
      the BlockBackend of a floppy drive, we must not have taken write
      permissions on that BlockBackend, or the operation will fail with the
      error message "Block node is read-only".
      
      The device already takes care to remove all permissions when the medium
      is ejected, but the state isn't correct if the drive is initially empty:
      It uses blk_is_read_only() to check whether write permissions should be
      taken, but this function returns false for empty BlockBackends in the
      common case.
      
      Fix floppy_drive_realize() to avoid taking write permissions if the
      drive is empty.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NMax Reitz <mreitz@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      0b9e918f
  10. 14 6月, 2019 1 次提交
  11. 12 6月, 2019 1 次提交
  12. 04 6月, 2019 1 次提交
    • K
      block: Add BlockBackend.ctx · d861ab3a
      Kevin Wolf 提交于
      This adds a new parameter to blk_new() which requires its callers to
      declare from which AioContext this BlockBackend is going to be used (or
      the locks of which AioContext need to be taken anyway).
      
      The given context is only stored and kept up to date when changing
      AioContexts. Actually applying the stored AioContext to the root node
      is saved for another commit.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      d861ab3a
  13. 19 11月, 2018 1 次提交
  14. 29 6月, 2018 2 次提交
  15. 26 3月, 2018 1 次提交
  16. 19 12月, 2017 1 次提交
    • M
      hw/block: Use errp directly rather than local_err · ceff3e1f
      Mao Zhongyi 提交于
      [Drop virtio_blk_data_plane_create() change that misinterprets return
      value when the virtio transport does not support dataplane.
      --Stefan]
      
      Cc: John Snow <jsnow@redhat.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: Keith Busch <keith.busch@intel.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Signed-off-by: NMao Zhongyi <maozy.fnst@cn.fujitsu.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Message-id: e77848d3735ba590f23ffbf8094379c646c33d79.1511317952.git.maozy.fnst@cn.fujitsu.com
      Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
      ceff3e1f
  17. 27 9月, 2017 1 次提交
  18. 19 9月, 2017 1 次提交
  19. 04 9月, 2017 1 次提交
  20. 28 6月, 2017 1 次提交
  21. 20 6月, 2017 1 次提交
  22. 17 5月, 2017 2 次提交
    • E
      fdc: Remove user_creatable flag from sysbus-fdc & SUNW,fdtwo · 8ca97a1f
      Eduardo Habkost 提交于
      sysbus-fdc and SUNW,fdtwo devices need IRQs to be wired and mmio
      to be mapped, and can't be used with -device. Unset
      user_creatable on their device classes.
      
      Cc: John Snow <jsnow@redhat.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: qemu-block@nongnu.org
      Cc: Thomas Huth <thuth@redhat.com>
      Acked-by: NJohn Snow <jsnow@redhat.com>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Acked-by: NMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170503203604.31462-6-ehabkost@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      8ca97a1f
    • E
      sysbus: Set user_creatable=false by default on TYPE_SYS_BUS_DEVICE · e4f4fb1e
      Eduardo Habkost 提交于
      commit 33cd52b5 unset
      cannot_instantiate_with_device_add_yet in TYPE_SYSBUS, making all
      sysbus devices appear on "-device help" and lack the "no-user"
      flag in "info qdm".
      
      To fix this, we can set user_creatable=false by default on
      TYPE_SYS_BUS_DEVICE, but this requires setting
      user_creatable=true explicitly on the sysbus devices that
      actually work with -device.
      
      Fortunately today we have just a few has_dynamic_sysbus=1
      machines: virt, pc-q35-*, ppce500, and spapr.
      
      virt, ppce500, and spapr have extra checks to ensure just a few
      device types can be instantiated:
      
      * virt supports only TYPE_VFIO_CALXEDA_XGMAC, TYPE_VFIO_AMD_XGBE.
      * ppce500 supports only TYPE_ETSEC_COMMON.
      * spapr supports only TYPE_SPAPR_PCI_HOST_BRIDGE.
      
      This patch sets user_creatable=true explicitly on those 4 device
      classes.
      
      Now, the more complex cases:
      
      pc-q35-*: q35 has no sysbus device whitelist yet (which is a
      separate bug). We are in the process of fixing it and building a
      sysbus whitelist on q35, but in the meantime we can fix the
      "-device help" and "info qdm" bugs mentioned above. Also, despite
      not being strictly necessary for fixing the q35 bug, reducing the
      list of user_creatable=true devices will help us be more
      confident when building the q35 whitelist.
      
      xen: We also have a hack at xen_set_dynamic_sysbus(), that sets
      has_dynamic_sysbus=true at runtime when using the Xen
      accelerator. This hack is only used to allow xen-backend devices
      to be dynamically plugged/unplugged.
      
      This means today we can use -device with the following 22 device
      types, that are the ones compiled into the qemu-system-x86_64 and
      qemu-system-i386 binaries:
      
      * allwinner-ahci
      * amd-iommu
      * cfi.pflash01
      * esp
      * fw_cfg_io
      * fw_cfg_mem
      * generic-sdhci
      * hpet
      * intel-iommu
      * ioapic
      * isabus-bridge
      * kvmclock
      * kvm-ioapic
      * kvmvapic
      * SUNW,fdtwo
      * sysbus-ahci
      * sysbus-fdc
      * sysbus-ohci
      * unimplemented-device
      * virtio-mmio
      * xen-backend
      * xen-sysdev
      
      This patch adds user_creatable=true explicitly to those devices,
      temporarily, just to keep 100% compatibility with existing
      behavior of q35. Subsequent patches will remove
      user_creatable=true from the devices that are really not meant to
      user-creatable on any machine, and remove the FIXME comment from
      the ones that are really supposed to be user-creatable. This is
      being done in separate patches because we still don't have an
      obvious list of devices that will be whitelisted by q35, and I
      would like to get each device reviewed individually.
      
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Alistair Francis <alistair.francis@xilinx.com>
      Cc: Beniamino Galvani <b.galvani@gmail.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
      Cc: David Gibson <david@gibson.dropbear.id.au>
      Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Frank Blaschka <frank.blaschka@de.ibm.com>
      Cc: Gabriel L. Somlo <somlo@cmu.edu>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: John Snow <jsnow@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Laszlo Ersek <lersek@redhat.com>
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Pierre Morel <pmorel@linux.vnet.ibm.com>
      Cc: Prasad J Pandit <pjp@fedoraproject.org>
      Cc: qemu-arm@nongnu.org
      Cc: qemu-block@nongnu.org
      Cc: qemu-ppc@nongnu.org
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Shannon Zhao <zhaoshenglong@huawei.com>
      Cc: sstabellini@kernel.org
      Cc: Thomas Huth <thuth@redhat.com>
      Cc: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
      Acked-by: NJohn Snow <jsnow@redhat.com>
      Acked-by: NJuergen Gross <jgross@suse.com>
      Acked-by: NMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170503203604.31462-3-ehabkost@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      [ehabkost: Small changes at sysbus_device_class_init() comments]
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      e4f4fb1e
  23. 24 4月, 2017 1 次提交
  24. 01 3月, 2017 3 次提交
  25. 28 10月, 2016 3 次提交
    • K
      fdc: Move qdev properties to FloppyDrive · a92bd191
      Kevin Wolf 提交于
      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: NKevin Wolf <kwolf@redhat.com>
      Message-id: 1477386868-21826-4-git-send-email-kwolf@redhat.com
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      a92bd191
    • K
      fdc: Add a floppy drive qdev · 394ea2ca
      Kevin Wolf 提交于
      Floppy controllers automatically create two floppy drive devices in qdev
      now. (They always created two drives, but managed them only internally.)
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1477386868-21826-3-git-send-email-kwolf@redhat.com
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      394ea2ca
    • K
      fdc: Add a floppy qbus · 51e6e90e
      Kevin Wolf 提交于
      This adds a qbus to the floppy controller that should contain the floppy
      drives eventually. At the moment it just exists and is empty.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NJohn Snow <jsnow@redhat.com>
      Message-id: 1477386868-21826-2-git-send-email-kwolf@redhat.com
      Signed-off-by: NJohn Snow <jsnow@redhat.com>
      51e6e90e
  26. 08 9月, 2016 1 次提交
  27. 12 5月, 2016 1 次提交
  28. 23 3月, 2016 1 次提交
    • R
      Replaced get_tick_per_sec() by NANOSECONDS_PER_SECOND · 73bcb24d
      Rutuja Shah 提交于
      This patch replaces get_ticks_per_sec() calls with the macro
      NANOSECONDS_PER_SECOND. Also, as there are no callers, get_ticks_per_sec()
      is then removed.  This replacement improves the readability and
      understandability of code.
      
      For example,
      
          timer_mod(fdctrl->result_timer,
      	      qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (get_ticks_per_sec() / 50));
      
      NANOSECONDS_PER_SECOND makes it obvious that qemu_clock_get_ns
      matches the unit of the expression on the right side of the plus.
      Signed-off-by: NRutuja Shah <rutu.shah.26@gmail.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      73bcb24d