@@ -146,8 +146,8 @@ typedef struct {
* @valid_accelerators:
* If this machine supports a specific set of virtualization accelerators,
* this contains a NULL-terminated list of the accelerators that can be
- * used. If this field is not set, any accelerator is valid. The QTest
- * accelerator is always valid.
+ * used. If this field is not set, a default list containing only the TCG
+ * accelerator is used. The QTest accelerator is always valid.
* @kvm_type:
* Return the type of KVM corresponding to the kvm-type string option or
* computed based on other criteria such as the host kernel capabilities
@@ -520,11 +520,11 @@ static void machine_set_nvdimm_persistence(Object *obj, const char *value,
bool machine_class_valid_for_accelerator(MachineClass *mc, const char *acc_name)
{
- const char *const *name = mc->valid_accelerators;
+ static const char *const default_accels[] = {
+ "tcg", NULL
+ };
+ const char *const *name = mc->valid_accelerators ? : default_accels;
- if (!name) {
- return true;
- }
if (strcmp(acc_name, "qtest") == 0) {
return true;
}
By default machines can only use the TCG and QTest accelerators. If a machine can use another accelerator, it has to explicitly list it in its MachineClass valid_accelerators[]. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- include/hw/boards.h | 4 ++-- hw/core/machine.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)