mirror of
https://github.com/qemu/qemu.git
synced 2024-12-15 15:33:29 +08:00
spapr: Do TPM proxy hotplug sanity checks at pre-plug
There can be only one TPM proxy at a time. This is currently checked at plug time. But this can be detected at pre-plug in order to error out earlier. This allows to get rid of error handling in the plug handler. Signed-off-by: Greg Kurz <groug@kaod.org> Message-Id: <20201120234208.683521-9-groug@kaod.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
9a07069958
commit
ac96807b02
@ -3971,16 +3971,27 @@ static void spapr_phb_unplug_request(HotplugHandler *hotplug_dev,
|
||||
}
|
||||
}
|
||||
|
||||
static void spapr_tpm_proxy_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||||
Error **errp)
|
||||
static
|
||||
bool spapr_tpm_proxy_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
||||
Error **errp)
|
||||
{
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
|
||||
|
||||
if (spapr->tpm_proxy != NULL) {
|
||||
error_setg(errp, "Only one TPM proxy can be specified for this machine");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void spapr_tpm_proxy_plug(HotplugHandler *hotplug_dev, DeviceState *dev)
|
||||
{
|
||||
SpaprMachineState *spapr = SPAPR_MACHINE(OBJECT(hotplug_dev));
|
||||
SpaprTpmProxy *tpm_proxy = SPAPR_TPM_PROXY(dev);
|
||||
|
||||
if (spapr->tpm_proxy != NULL) {
|
||||
error_setg(errp, "Only one TPM proxy can be specified for this machine");
|
||||
return;
|
||||
}
|
||||
/* Already checked in spapr_tpm_proxy_pre_plug() */
|
||||
g_assert(spapr->tpm_proxy == NULL);
|
||||
|
||||
spapr->tpm_proxy = tpm_proxy;
|
||||
}
|
||||
@ -4004,7 +4015,7 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
|
||||
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE)) {
|
||||
spapr_phb_plug(hotplug_dev, dev);
|
||||
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) {
|
||||
spapr_tpm_proxy_plug(hotplug_dev, dev, errp);
|
||||
spapr_tpm_proxy_plug(hotplug_dev, dev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4067,6 +4078,8 @@ static void spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev,
|
||||
spapr_core_pre_plug(hotplug_dev, dev, errp);
|
||||
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE)) {
|
||||
spapr_phb_pre_plug(hotplug_dev, dev, errp);
|
||||
} else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) {
|
||||
spapr_tpm_proxy_pre_plug(hotplug_dev, dev, errp);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user