static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { DeviceState *dev = DEVICE(obj); Error *local_err = NULL; Property *prop = opaque; TPMBackend *s, **be = qdev_get_prop_ptr(dev, prop); char *str; if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); return; } visit_type_str(v, name, &str, &local_err); if (local_err) { error_propagate(errp, local_err); return; } s = qemu_find_tpm_be(str); if (s == NULL) { error_setg(errp, "Property '%s.%s' can't find value '%s'", object_get_typename(obj), prop->name, str); } else if (tpm_backend_init(s, TPM_IF(obj), errp) == 0) { *be = s; /* weak reference, avoid cyclic ref */ } g_free(str); }
static void tpm_tis_realizefn(DeviceState *dev, Error **errp) { TPMState *s = TPM(dev); TPMTISEmuState *tis = &s->s.tis; s->be_driver = qemu_find_tpm(s->backend); if (!s->be_driver) { error_setg(errp, "tpm_tis: backend driver with id %s could not be " "found", s->backend); return; } s->be_driver->fe_model = TPM_MODEL_TPM_TIS; if (tpm_backend_init(s->be_driver, s, tpm_tis_receive_cb)) { error_setg(errp, "tpm_tis: backend driver with id %s could not be " "initialized", s->backend); return; } if (tis->irq_num > 15) { error_setg(errp, "tpm_tis: IRQ %d for TPM TIS is outside valid range " "of 0 to 15.\n", tis->irq_num); return; } tis->bh = qemu_bh_new(tpm_tis_receive_bh, s); isa_init_irq(&s->busdev, &tis->irq, tis->irq_num); }