On 2015-02-16 at 06:47, Ekaterina Tumanova wrote:
geometry: hd_geometry_guess function autodetects the drive geometry.
This patch adds a block backend call, that probes the backing device
geometry. If the inner driver method is implemented and succeeds
(currently only for DASDs), the blkconf_geometry will pass-through
the backing device geometry. Otherwise will fallback to old logic.

blocksize: This patch initializes blocksize properties to 0.
In order to set the property a blkconf_blocksizes was introduced.
If user didn't set physical or logical blocksize, it will
retrieve its value from a driver (only succeeds for DASD), otherwise
it will set default 512 value.

The blkconf_blocksizes call was added to all users of BlkConf.

Signed-off-by: Ekaterina Tumanova <tuman...@linux.vnet.ibm.com>
Reviewed-by: Markus Armbruster <arm...@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com>
---
  hw/block/block.c             | 24 ++++++++++++++++++++++++
  hw/block/hd-geometry.c       | 10 +++++++++-
  hw/block/nvme.c              |  1 +
  hw/block/virtio-blk.c        |  1 +
  hw/core/qdev-properties.c    |  3 ++-
  hw/ide/qdev.c                |  1 +
  hw/scsi/scsi-disk.c          |  2 ++
  hw/usb/dev-storage.c         |  1 +
  include/hw/block/block.h     |  5 +++--
  include/hw/qdev-properties.h |  4 ++--
  10 files changed, 46 insertions(+), 6 deletions(-)

This patch makes qemu segfault if the drive property is not set for a scsi-hd device:

$ x86_64-softmmu/qemu-system-x86_64 -device virtio-scsi-pci -device scsi-hd
[1] 13368 segmentation fault (core dumped) x86_64-softmmu/qemu-system-x86_64 -device virtio-scsi-pci -device scsi-hd

(gdb) bt
#0 0x00007f0a77620f50 in blk_probe_blocksizes (blk=0x0, bsz=0x7fffd989f110) at block/block-backend.c:898 #1 0x00007f0a774eb943 in blkconf_blocksizes (conf=conf@entry=0x7f0a7b1e71c0) at hw/block/block.c:34 #2 0x00007f0a7755e5a8 in scsi_hd_realize (dev=0x7f0a7b1e7130, errp=0x7fffd989f150) at hw/scsi/scsi-disk.c:2294 #3 0x00007f0a77564671 in scsi_qdev_realize (errp=0x7fffd989f150, s=0x7f0a7b1e7130) at hw/scsi/scsi-bus.c:50 #4 0x00007f0a77564671 in scsi_qdev_realize (qdev=<optimized out>, errp=0x7fffd989f190) at hw/scsi/scsi-bus.c:197 #5 0x00007f0a77502b71 in device_set_realized (obj=0x7f0a7b1e7130, value=<optimized out>, errp=0x7fffd989f2c8) at hw/core/qdev.c:1047 #6 0x00007f0a775b1e0e in property_set_bool (obj=0x7f0a7b1e7130, v=<optimized out>, opaque=0x7f0a7b1e73e0, name=<optimized out>, errp=0x7fffd989f2c8) at qom/object.c:1514 #7 0x00007f0a775b4707 in object_property_set_qobject (obj=0x7f0a7b1e7130, value=<optimized out>, name=0x7f0a7769e3cd "realized", errp=0x7fffd989f2c8) at qom/qom-qobject.c:24 #8 0x00007f0a775b32a0 in object_property_set_bool (obj=obj@entry=0x7f0a7b1e7130, value=value@entry=true, name=name@entry=0x7f0a7769e3cd "realized", errp=errp@entry=0x7fffd989f2c8)
    at qom/object.c:905
#9 0x00007f0a774a8ca5 in qdev_device_add (opts=0x7f0a799fa3f0) at qdev-monitor.c:574 #10 0x00007f0a774b1df9 in device_init_func (opts=<optimized out>, opaque=<optimized out>) at qemu/vl.c:2127 #11 0x00007f0a7766803b in qemu_opts_foreach (list=<optimized out>, func=0x7f0a774b1df0 <device_init_func>, opaque=0x0, abort_on_failure=<optimized out>) at util/qemu-option.c:1057 #12 0x00007f0a773b96ec in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4239

Before this patch:

$ x86_64-softmmu/qemu-system-x86_64 -device virtio-scsi-pci -device scsi-hd
qemu-system-x86_64: -device scsi-hd: drive property not set
qemu-system-x86_64: -device scsi-hd: Device 'scsi-hd' could not be initialized

Max

Reply via email to