hw/core/qdev-properties-system: Allow the 'slew' policy only on x86
The 'slew' tick policy is currently enforced to be only available on x86 via some "#ifdef TARGET_I386" statements in mc146818rtc.c. We want to get rid of those #ifdefs, so we need a different way of checking whether the policy is allowed or not. Using the setter function in hw/core/qdev-properties-system.c seems to be a good place, so let's add a check here. Suggested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Bernhard Beschow <shentey@gmail.com> Message-Id: <20230110095351.611724-3-thuth@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
parent
2b85e0cda4
commit
aae167211f
@ -33,6 +33,7 @@
|
|||||||
#include "net/net.h"
|
#include "net/net.h"
|
||||||
#include "hw/pci/pci.h"
|
#include "hw/pci/pci.h"
|
||||||
#include "hw/pci/pcie.h"
|
#include "hw/pci/pcie.h"
|
||||||
|
#include "hw/i386/x86.h"
|
||||||
#include "util/block-helpers.h"
|
#include "util/block-helpers.h"
|
||||||
|
|
||||||
static bool check_prop_still_unset(Object *obj, const char *name,
|
static bool check_prop_still_unset(Object *obj, const char *name,
|
||||||
@ -558,13 +559,38 @@ void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd)
|
|||||||
|
|
||||||
/* --- lost tick policy --- */
|
/* --- lost tick policy --- */
|
||||||
|
|
||||||
|
static void qdev_propinfo_set_losttickpolicy(Object *obj, Visitor *v,
|
||||||
|
const char *name, void *opaque,
|
||||||
|
Error **errp)
|
||||||
|
{
|
||||||
|
Property *prop = opaque;
|
||||||
|
int *ptr = object_field_prop_ptr(obj, prop);
|
||||||
|
int value;
|
||||||
|
|
||||||
|
if (!visit_type_enum(v, name, &value, prop->info->enum_table, errp)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value == LOST_TICK_POLICY_SLEW) {
|
||||||
|
MachineState *ms = MACHINE(qdev_get_machine());
|
||||||
|
|
||||||
|
if (!object_dynamic_cast(OBJECT(ms), TYPE_X86_MACHINE)) {
|
||||||
|
error_setg(errp,
|
||||||
|
"the 'slew' policy is only available for x86 machines");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*ptr = value;
|
||||||
|
}
|
||||||
|
|
||||||
QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int));
|
QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int));
|
||||||
|
|
||||||
const PropertyInfo qdev_prop_losttickpolicy = {
|
const PropertyInfo qdev_prop_losttickpolicy = {
|
||||||
.name = "LostTickPolicy",
|
.name = "LostTickPolicy",
|
||||||
.enum_table = &LostTickPolicy_lookup,
|
.enum_table = &LostTickPolicy_lookup,
|
||||||
.get = qdev_propinfo_get_enum,
|
.get = qdev_propinfo_get_enum,
|
||||||
.set = qdev_propinfo_set_enum,
|
.set = qdev_propinfo_set_losttickpolicy,
|
||||||
.set_default_value = qdev_propinfo_set_default_value_enum,
|
.set_default_value = qdev_propinfo_set_default_value_enum,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user