~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to hw/scsi/scsi-bus.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
    qemu_bh_delete(s->bh);
106
106
    s->bh = NULL;
107
107
 
 
108
    aio_context_acquire(blk_get_aio_context(s->conf.blk));
108
109
    QTAILQ_FOREACH_SAFE(req, &s->requests, next, next) {
109
110
        scsi_req_ref(req);
110
111
        if (req->retry) {
122
123
        }
123
124
        scsi_req_unref(req);
124
125
    }
 
126
    aio_context_release(blk_get_aio_context(s->conf.blk));
125
127
}
126
128
 
127
129
void scsi_req_retry(SCSIRequest *req)
261
263
    return SCSI_DEVICE(dev);
262
264
}
263
265
 
264
 
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, Error **errp)
 
266
void scsi_bus_legacy_handle_cmdline(SCSIBus *bus, bool deprecated)
265
267
{
266
268
    Location loc;
267
269
    DriveInfo *dinfo;
268
270
    int unit;
269
 
    Error *err = NULL;
270
271
 
271
272
    loc_push_none(&loc);
272
273
    for (unit = 0; unit <= bus->info->max_target; unit++) {
275
276
            continue;
276
277
        }
277
278
        qemu_opts_loc_restore(dinfo->opts);
 
279
        if (deprecated) {
 
280
            /* Handling -drive not claimed by machine initialization */
 
281
            if (blk_get_attached_dev(blk_by_legacy_dinfo(dinfo))) {
 
282
                continue;       /* claimed */
 
283
            }
 
284
            if (!dinfo->is_default) {
 
285
                error_report("warning: bus=%d,unit=%d is deprecated with this"
 
286
                             " machine type",
 
287
                             bus->busnr, unit);
 
288
            }
 
289
        }
278
290
        scsi_bus_legacy_add_drive(bus, blk_by_legacy_dinfo(dinfo),
279
 
                                  unit, false, -1, NULL, &err);
280
 
        if (err != NULL) {
281
 
            error_propagate(errp, err);
282
 
            break;
283
 
        }
 
291
                                  unit, false, -1, NULL, &error_fatal);
284
292
    }
285
293
    loc_pop(&loc);
286
294
}
287
295
 
 
296
static bool is_scsi_hba_with_legacy_magic(Object *obj)
 
297
{
 
298
    static const char *magic[] = {
 
299
        "am53c974", "dc390", "esp", "lsi53c810", "lsi53c895a",
 
300
        "megasas", "megasas-gen2", "mptsas1068", "spapr-vscsi",
 
301
        "virtio-scsi-device",
 
302
        NULL
 
303
    };
 
304
    const char *typename = object_get_typename(obj);
 
305
    int i;
 
306
 
 
307
    for (i = 0; magic[i]; i++)
 
308
        if (!strcmp(typename, magic[i])) {
 
309
            return true;
 
310
    }
 
311
 
 
312
    return false;
 
313
}
 
314
 
 
315
static int scsi_legacy_handle_cmdline_cb(Object *obj, void *opaque)
 
316
{
 
317
    SCSIBus *bus = (SCSIBus *)object_dynamic_cast(obj, TYPE_SCSI_BUS);
 
318
 
 
319
    if (bus && is_scsi_hba_with_legacy_magic(OBJECT(bus->qbus.parent))) {
 
320
        scsi_bus_legacy_handle_cmdline(bus, true);
 
321
    }
 
322
 
 
323
    return 0;
 
324
}
 
325
 
 
326
void scsi_legacy_handle_cmdline(void)
 
327
{
 
328
    object_child_foreach_recursive(object_get_root(),
 
329
                                   scsi_legacy_handle_cmdline_cb, NULL);
 
330
}
 
331
 
288
332
static int32_t scsi_invalid_field(SCSIRequest *req, uint8_t *buf)
289
333
{
290
334
    scsi_req_build_sense(req, SENSE_CODE(INVALID_FIELD));
1945
1989
 
1946
1990
/* SCSI request list.  For simplicity, pv points to the whole device */
1947
1991
 
1948
 
static void put_scsi_requests(QEMUFile *f, void *pv, size_t size)
 
1992
static int put_scsi_requests(QEMUFile *f, void *pv, size_t size,
 
1993
                             VMStateField *field, QJSON *vmdesc)
1949
1994
{
1950
1995
    SCSIDevice *s = pv;
1951
1996
    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, s->qdev.parent_bus);
1968
2013
        }
1969
2014
    }
1970
2015
    qemu_put_sbyte(f, 0);
 
2016
 
 
2017
    return 0;
1971
2018
}
1972
2019
 
1973
 
static int get_scsi_requests(QEMUFile *f, void *pv, size_t size)
 
2020
static int get_scsi_requests(QEMUFile *f, void *pv, size_t size,
 
2021
                             VMStateField *field)
1974
2022
{
1975
2023
    SCSIDevice *s = pv;
1976
2024
    SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, s->qdev.parent_bus);