Commit a6aebb38 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging



SCSI patches include bug fixes from Fam and Peter, improved error
reporting from Fam and a fix for DPRINTF bitrot.  Memory patches try
again to initialize name from the QOM name.

# gpg: Signature made Thu 28 Aug 2014 15:10:31 BST using RSA key ID 9B4D86F2
# gpg: Good signature from "Paolo Bonzini <pbonzini@redhat.com>"
# gpg:                 aka "Paolo Bonzini <bonzini@gnu.org>"

* remotes/bonzini/tags/for-upstream:
  memory: Lazy init name from QOM name as needed
  xen: hvm: Abstract away memory region name ref
  xen-hvm: Constify string
  virtio-scsi: Report error if num_queues is 0 or too large
  scsi-generic: remove superfluous DPRINTF avoid to break compiling
  block/iscsi: fix memory corruption on iscsi resize
  scsi-bus: Convert DeviceClass init to realize
  block: Pass errp in blkconf_geometry

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 38a01e55 d1dd32af
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -22,8 +22,9 @@ void blkconf_serial(BlockConf *conf, char **serial)
    }
}

int blkconf_geometry(BlockConf *conf, int *ptrans,
                     unsigned cyls_max, unsigned heads_max, unsigned secs_max)
void blkconf_geometry(BlockConf *conf, int *ptrans,
                      unsigned cyls_max, unsigned heads_max, unsigned secs_max,
                      Error **errp)
{
    DriveInfo *dinfo;

@@ -46,17 +47,16 @@ int blkconf_geometry(BlockConf *conf, int *ptrans,
    }
    if (conf->cyls || conf->heads || conf->secs) {
        if (conf->cyls < 1 || conf->cyls > cyls_max) {
            error_report("cyls must be between 1 and %u", cyls_max);
            return -1;
            error_setg(errp, "cyls must be between 1 and %u", cyls_max);
            return;
        }
        if (conf->heads < 1 || conf->heads > heads_max) {
            error_report("heads must be between 1 and %u", heads_max);
            return -1;
            error_setg(errp, "heads must be between 1 and %u", heads_max);
            return;
        }
        if (conf->secs < 1 || conf->secs > secs_max) {
            error_report("secs must be between 1 and %u", secs_max);
            return -1;
            error_setg(errp, "secs must be between 1 and %u", secs_max);
            return;
        }
    }
    return 0;
}
+3 −4
Original line number Diff line number Diff line
@@ -729,9 +729,7 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
    VirtIOBlock *s = VIRTIO_BLK(dev);
    VirtIOBlkConf *blk = &(s->blk);
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
    Error *err = NULL;
#endif
    static int virtio_blk_id;

    if (!blk->conf.bs) {
@@ -745,8 +743,9 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)

    blkconf_serial(&blk->conf, &blk->serial);
    s->original_wce = bdrv_enable_write_cache(blk->conf.bs);
    if (blkconf_geometry(&blk->conf, NULL, 65535, 255, 255) < 0) {
        error_setg(errp, "Error setting geometry");
    blkconf_geometry(&blk->conf, NULL, 65535, 255, 255, &err);
    if (err) {
        error_propagate(errp, err);
        return;
    }

+8 −3
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
{
    IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
    IDEState *s = bus->ifs + dev->unit;
    Error *err = NULL;

    if (dev->conf.discard_granularity == -1) {
        dev->conf.discard_granularity = 512;
@@ -161,10 +162,14 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
    }

    blkconf_serial(&dev->conf, &dev->serial);
    if (kind != IDE_CD
        && blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255) < 0) {
    if (kind != IDE_CD) {
        blkconf_geometry(&dev->conf, &dev->chs_trans, 65536, 16, 255, &err);
        if (err) {
            error_report("%s", error_get_pretty(err));
            error_free(err);
            return -1;
        }
    }

    if (ide_init_drive(s, dev->conf.bs, kind,
                       dev->version, dev->serial, dev->model, dev->wwn,
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "hw/pci/pci.h"
#include "hw/scsi/scsi.h"
#include "sysemu/dma.h"
#include "qemu/error-report.h"

//#define DEBUG_LSI
//#define DEBUG_LSI_REG
+34 −36
Original line number Diff line number Diff line
@@ -36,20 +36,19 @@ static const TypeInfo scsi_bus_info = {
};
static int next_scsi_bus;

static int scsi_device_init(SCSIDevice *s)
static void scsi_device_realize(SCSIDevice *s, Error **errp)
{
    SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(s);
    if (sc->init) {
        return sc->init(s);
    if (sc->realize) {
        sc->realize(s, errp);
    }
    return 0;
}

static void scsi_device_destroy(SCSIDevice *s)
static void scsi_device_unrealize(SCSIDevice *s, Error **errp)
{
    SCSIDeviceClass *sc = SCSI_DEVICE_GET_CLASS(s);
    if (sc->destroy) {
        sc->destroy(s);
    if (sc->unrealize) {
        sc->unrealize(s, errp);
    }
}

@@ -143,24 +142,24 @@ static void scsi_dma_restart_cb(void *opaque, int running, RunState state)
    }
}

static int scsi_qdev_init(DeviceState *qdev)
static void scsi_qdev_realize(DeviceState *qdev, Error **errp)
{
    SCSIDevice *dev = SCSI_DEVICE(qdev);
    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, dev->qdev.parent_bus);
    SCSIDevice *d;
    int rc = -1;
    Error *local_err = NULL;

    if (dev->channel > bus->info->max_channel) {
        error_report("bad scsi channel id: %d", dev->channel);
        goto err;
        error_setg(errp, "bad scsi channel id: %d", dev->channel);
        return;
    }
    if (dev->id != -1 && dev->id > bus->info->max_target) {
        error_report("bad scsi device id: %d", dev->id);
        goto err;
        error_setg(errp, "bad scsi device id: %d", dev->id);
        return;
    }
    if (dev->lun != -1 && dev->lun > bus->info->max_lun) {
        error_report("bad scsi device lun: %d", dev->lun);
        goto err;
        error_setg(errp, "bad scsi device lun: %d", dev->lun);
        return;
    }

    if (dev->id == -1) {
@@ -172,8 +171,8 @@ static int scsi_qdev_init(DeviceState *qdev)
            d = scsi_device_find(bus, dev->channel, ++id, dev->lun);
        } while (d && d->lun == dev->lun && id < bus->info->max_target);
        if (d && d->lun == dev->lun) {
            error_report("no free target");
            goto err;
            error_setg(errp, "no free target");
            return;
        }
        dev->id = id;
    } else if (dev->lun == -1) {
@@ -182,43 +181,41 @@ static int scsi_qdev_init(DeviceState *qdev)
            d = scsi_device_find(bus, dev->channel, dev->id, ++lun);
        } while (d && d->lun == lun && lun < bus->info->max_lun);
        if (d && d->lun == lun) {
            error_report("no free lun");
            goto err;
            error_setg(errp, "no free lun");
            return;
        }
        dev->lun = lun;
    } else {
        d = scsi_device_find(bus, dev->channel, dev->id, dev->lun);
        assert(d);
        if (d->lun == dev->lun && dev != d) {
            error_report("lun already used by '%s'", d->qdev.id);
            goto err;
            error_setg(errp, "lun already used by '%s'", d->qdev.id);
            return;
        }
    }

    QTAILQ_INIT(&dev->requests);
    rc = scsi_device_init(dev);
    if (rc == 0) {
    scsi_device_realize(dev, &local_err);
    if (local_err) {
        error_propagate(errp, local_err);
        return;
    }
    dev->vmsentry = qemu_add_vm_change_state_handler(scsi_dma_restart_cb,
                                                     dev);
    }

    if (bus->info->hotplug) {
        bus->info->hotplug(bus, dev);
    }

err:
    return rc;
}

static int scsi_qdev_exit(DeviceState *qdev)
static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp)
{
    SCSIDevice *dev = SCSI_DEVICE(qdev);

    if (dev->vmsentry) {
        qemu_del_vm_change_state_handler(dev->vmsentry);
    }
    scsi_device_destroy(dev);
    return 0;
    scsi_device_unrealize(dev, errp);
}

/* handle legacy '-drive if=scsi,...' cmd line args */
@@ -273,6 +270,7 @@ void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp)
        scsi_bus_legacy_add_drive(bus, dinfo->bdrv, unit, false, -1, NULL,
                                  &err);
        if (err != NULL) {
            error_report("%s", error_get_pretty(err));
            error_propagate(errp, err);
            break;
        }
@@ -1993,9 +1991,9 @@ static void scsi_device_class_init(ObjectClass *klass, void *data)
    DeviceClass *k = DEVICE_CLASS(klass);
    set_bit(DEVICE_CATEGORY_STORAGE, k->categories);
    k->bus_type  = TYPE_SCSI_BUS;
    k->init     = scsi_qdev_init;
    k->realize   = scsi_qdev_realize;
    k->unplug    = scsi_qdev_unplug;
    k->exit     = scsi_qdev_exit;
    k->unrealize = scsi_qdev_unrealize;
    k->props     = scsi_props;
}

Loading