qapi: Empty out qapi-schema.json

The previous commit improved compile time by including less of the
generated QAPI headers. This is impossible for stuff defined directly
in qapi-schema.json, because that ends up in headers that that pull in
everything.

Move everything but include directives from qapi-schema.json to new
sub-module qapi/misc.json, then include just the "misc" shard where
possible.

It's possible everywhere, except:

* monitor.c needs qmp-command.h to get qmp_init_marshal()

* monitor.c, ui/vnc.c and the generated qapi-event-FOO.c need
qapi-event.h to get enum QAPIEvent

Perhaps we'll get rid of those some other day.

Adding a type to qapi/migration.json now recompiles some 120 instead
of 2300 out of 5100 objects.

Backports commit 112ed241f5d9a411dbca92bdf597151cb853c6a7 from qemu
This commit is contained in:
Markus Armbruster 2018-03-09 10:13:16 -05:00 committed by Lioncash
parent 5500a5e912
commit 311d659acf
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
17 changed files with 411 additions and 58 deletions

2
.gitignore vendored
View file

@ -31,9 +31,11 @@ qemu/x86_64-softmmu/
qemu/qapi-builtin-types.[ch]
qemu/qapi-builtin-visit.[ch]
qemu/qapi/qapi-types-common.[ch]
qemu/qapi/qapi-types-misc.[ch]
qemu/qapi/qapi-visit-common.[ch]
qemu/qapi-types.[ch]
qemu/qapi-visit.[ch]
qemu/qapi/qapi-visit-misc.[ch]
qemu/qapi-gen-timestamp
tags
qemu/config-host.ld

View file

@ -0,0 +1,69 @@
/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
/*
* Schema-defined QAPI types
*
* Copyright IBM, Corp. 2011
* Copyright (c) 2013-2018 Red Hat Inc.
*
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
* See the COPYING.LIB file in the top-level directory.
*/
#include "qemu/osdep.h"
#include "qapi/dealloc-visitor.h"
#include "qapi/qapi-types-misc.h"
#include "qapi/qapi-visit-misc.h"
const char *const X86CPURegister32_lookup[] = {
"EAX",
"EBX",
"ECX",
"EDX",
"ESP",
"EBP",
"ESI",
"EDI",
NULL,
};
void qapi_free_X86CPUFeatureWordInfo(X86CPUFeatureWordInfo *obj)
{
Visitor *v;
if (!obj) {
return;
}
v = qapi_dealloc_visitor_new();
visit_type_X86CPUFeatureWordInfo(v, NULL, &obj, NULL);
visit_free(v);
}
void qapi_free_X86CPUFeatureWordInfoList(X86CPUFeatureWordInfoList *obj)
{
Visitor *v;
if (!obj) {
return;
}
v = qapi_dealloc_visitor_new();
visit_type_X86CPUFeatureWordInfoList(v, NULL, &obj, NULL);
visit_free(v);
}
void qapi_free_DummyForceArrays(DummyForceArrays *obj)
{
Visitor *v;
if (!obj) {
return;
}
v = qapi_dealloc_visitor_new();
visit_type_DummyForceArrays(v, NULL, &obj, NULL);
visit_free(v);
}
/* Dummy declaration to prevent empty .o file */
char dummy_qapi_qapi_types_misc_c;

View file

@ -0,0 +1,61 @@
/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
/*
* Schema-defined QAPI types
*
* Copyright IBM, Corp. 2011
* Copyright (c) 2013-2018 Red Hat Inc.
*
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
* See the COPYING.LIB file in the top-level directory.
*/
#ifndef QAPI_QAPI_TYPES_MISC_H
#define QAPI_QAPI_TYPES_MISC_H
#include "qapi-builtin-types.h"
typedef enum X86CPURegister32 {
X86_CPU_REGISTER32_EAX = 0,
X86_CPU_REGISTER32_EBX = 1,
X86_CPU_REGISTER32_ECX = 2,
X86_CPU_REGISTER32_EDX = 3,
X86_CPU_REGISTER32_ESP = 4,
X86_CPU_REGISTER32_EBP = 5,
X86_CPU_REGISTER32_ESI = 6,
X86_CPU_REGISTER32_EDI = 7,
X86_CPU_REGISTER32__MAX = 8,
} X86CPURegister32;
extern const char *const X86CPURegister32_lookup[];
typedef struct X86CPUFeatureWordInfo X86CPUFeatureWordInfo;
typedef struct X86CPUFeatureWordInfoList X86CPUFeatureWordInfoList;
typedef struct DummyForceArrays DummyForceArrays;
struct X86CPUFeatureWordInfo {
int64_t cpuid_input_eax;
bool has_cpuid_input_ecx;
int64_t cpuid_input_ecx;
X86CPURegister32 cpuid_register;
int64_t features;
};
void qapi_free_X86CPUFeatureWordInfo(X86CPUFeatureWordInfo *obj);
struct X86CPUFeatureWordInfoList {
X86CPUFeatureWordInfoList *next;
X86CPUFeatureWordInfo *value;
};
void qapi_free_X86CPUFeatureWordInfoList(X86CPUFeatureWordInfoList *obj);
struct DummyForceArrays {
X86CPUFeatureWordInfoList *unused;
};
void qapi_free_DummyForceArrays(DummyForceArrays *obj);
#endif /* QAPI_QAPI_TYPES_MISC_H */

View file

@ -0,0 +1,149 @@
/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
/*
* Schema-defined QAPI visitors
*
* Copyright IBM, Corp. 2011
* Copyright (C) 2014-2018 Red Hat, Inc.
*
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
* See the COPYING.LIB file in the top-level directory.
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "qapi/qmp/qerror.h"
#include "qapi/qapi-visit-misc.h"
void visit_type_X86CPURegister32(Visitor *v, const char *name, X86CPURegister32 *obj, Error **errp)
{
int value = *obj;
visit_type_enum(v, name, &value, X86CPURegister32_lookup, errp);
*obj = value;
}
void visit_type_X86CPUFeatureWordInfo_members(Visitor *v, X86CPUFeatureWordInfo *obj, Error **errp)
{
Error *err = NULL;
visit_type_int(v, "cpuid-input-eax", &obj->cpuid_input_eax, &err);
if (err) {
goto out;
}
if (visit_optional(v, "cpuid-input-ecx", &obj->has_cpuid_input_ecx)) {
visit_type_int(v, "cpuid-input-ecx", &obj->cpuid_input_ecx, &err);
if (err) {
goto out;
}
}
visit_type_X86CPURegister32(v, "cpuid-register", &obj->cpuid_register, &err);
if (err) {
goto out;
}
visit_type_int(v, "features", &obj->features, &err);
if (err) {
goto out;
}
out:
error_propagate(errp, err);
}
void visit_type_X86CPUFeatureWordInfo(Visitor *v, const char *name, X86CPUFeatureWordInfo **obj, Error **errp)
{
Error *err = NULL;
visit_start_struct(v, name, (void **)obj, sizeof(X86CPUFeatureWordInfo), &err);
if (err) {
goto out;
}
if (!*obj) {
goto out_obj;
}
visit_type_X86CPUFeatureWordInfo_members(v, *obj, &err);
if (err) {
goto out_obj;
}
visit_check_struct(v, &err);
out_obj:
visit_end_struct(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_X86CPUFeatureWordInfo(*obj);
*obj = NULL;
}
out:
error_propagate(errp, err);
}
void visit_type_X86CPUFeatureWordInfoList(Visitor *v, const char *name, X86CPUFeatureWordInfoList **obj, Error **errp)
{
Error *err = NULL;
X86CPUFeatureWordInfoList *tail;
size_t size = sizeof(**obj);
visit_start_list(v, name, (GenericList **)obj, size, &err);
if (err) {
goto out;
}
for (tail = *obj; tail;
tail = (X86CPUFeatureWordInfoList *)visit_next_list(v, (GenericList *)tail, size)) {
visit_type_X86CPUFeatureWordInfo(v, NULL, &tail->value, &err);
if (err) {
break;
}
}
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_X86CPUFeatureWordInfoList(*obj);
*obj = NULL;
}
out:
error_propagate(errp, err);
}
void visit_type_DummyForceArrays_members(Visitor *v, DummyForceArrays *obj, Error **errp)
{
Error *err = NULL;
visit_type_X86CPUFeatureWordInfoList(v, "unused", &obj->unused, &err);
if (err) {
goto out;
}
out:
error_propagate(errp, err);
}
void visit_type_DummyForceArrays(Visitor *v, const char *name, DummyForceArrays **obj, Error **errp)
{
Error *err = NULL;
visit_start_struct(v, name, (void **)obj, sizeof(DummyForceArrays), &err);
if (err) {
goto out;
}
if (!*obj) {
goto out_obj;
}
visit_type_DummyForceArrays_members(v, *obj, &err);
if (err) {
goto out_obj;
}
visit_check_struct(v, &err);
out_obj:
visit_end_struct(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_DummyForceArrays(*obj);
*obj = NULL;
}
out:
error_propagate(errp, err);
}
/* Dummy declaration to prevent empty .o file */
char dummy_qapi_qapi_visit_misc_c;

View file

@ -0,0 +1,28 @@
/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
/*
* Schema-defined QAPI visitors
*
* Copyright IBM, Corp. 2011
* Copyright (C) 2014-2018 Red Hat, Inc.
*
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
* See the COPYING.LIB file in the top-level directory.
*/
#ifndef QAPI_QAPI_VISIT_MISC_H
#define QAPI_QAPI_VISIT_MISC_H
#include "qapi-builtin-visit.h"
#include "qapi/qapi-types-misc.h"
void visit_type_X86CPURegister32(Visitor *v, const char *name, X86CPURegister32 *obj, Error **errp);
void visit_type_X86CPUFeatureWordInfo_members(Visitor *v, X86CPUFeatureWordInfo *obj, Error **errp);
void visit_type_X86CPUFeatureWordInfo(Visitor *v, const char *name, X86CPUFeatureWordInfo **obj, Error **errp);
void visit_type_X86CPUFeatureWordInfoList(Visitor *v, const char *name, X86CPUFeatureWordInfoList **obj, Error **errp);
void visit_type_DummyForceArrays_members(Visitor *v, DummyForceArrays *obj, Error **errp);
void visit_type_DummyForceArrays(Visitor *v, const char *name, DummyForceArrays **obj, Error **errp);
#endif /* QAPI_QAPI_VISIT_MISC_H */

View file

@ -238,8 +238,10 @@ copy $(SolutionDir)..\include\unicorn\*.h $(SolutionDir)distro\include\unicorn\
<ClCompile Include="..\..\..\uc.c" />
<ClCompile Include="..\qapi-builtin-types.c" />
<ClCompile Include="..\qapi-builtin-visit.c" />
<ClCompile Include="..\qapi-types-common.c" />
<ClCompile Include="..\qapi-visit-common.c" />
<ClCompile Include="..\qapi\qapi-types-misc.c" />
<ClCompile Include="..\qapi\qapi-visit-misc.c" />
<ClCompile Include="..\qapi\qapi-types-common.c" />
<ClCompile Include="..\qapi\qapi-visit-common.c" />
<ClCompile Include="..\qapi-types.c" />
<ClCompile Include="..\qapi-visit.c" />
<ClCompile Include="dllmain.cpp">
@ -368,8 +370,10 @@ copy $(SolutionDir)..\include\unicorn\*.h $(SolutionDir)distro\include\unicorn\
<ClInclude Include="..\config-host.h" />
<ClInclude Include="..\qapi-builtin-types.h" />
<ClInclude Include="..\qapi-builtin-visit.h" />
<ClInclude Include="..\qapi-types-common.h" />
<ClInclude Include="..\qapi-visit-common.h" />
<ClInclude Include="..\qapi\qapi-types-common.h" />
<ClInclude Include="..\qapi\qapi-visit-common.h" />
<ClInclude Include="..\qapi\qapi-types-misc.h" />
<ClInclude Include="..\qapi\qapi-visit-misc.h" />
<ClInclude Include="..\qapi-types.h" />
<ClInclude Include="..\qapi-visit.h" />
</ItemGroup>

View file

@ -138,10 +138,16 @@
<ClCompile Include="..\qapi-builtin-visit.c">
<Filter>qemu</Filter>
</ClCompile>
<ClCompile Include="..\qapi-types-common.c">
<ClCompile Include="..\qapi\qapi-types-common.c">
<Filter>qemu</Filter>
</ClCompile>
<ClCompile Include="..\qapi-visit-common.c">
<ClCompile Include="..\qapi\qapi-visit-common.c">
<Filter>qemu</Filter>
</ClCompile>
<ClCompile Include="..\qapi\qapi-types-misc.c">
<Filter>qemu</Filter>
</ClCompile>
<ClCompile Include="..\qapi\qapi-visit-misc.c">
<Filter>qemu</Filter>
</ClCompile>
<ClCompile Include="..\qapi-visit.c">
@ -244,10 +250,16 @@
<ClInclude Include="..\qapi-builtin-visit.h">
<Filter>qemu</Filter>
</ClInclude>
<ClInclude Include="..\qapi-types-common.h">
<ClInclude Include="..\qapi\qapi-types-common.h">
<Filter>qemu</Filter>
</ClInclude>
<ClInclude Include="..\qapi-visit-common.h">
<ClInclude Include="..\qapi\qapi-visit-common.h">
<Filter>qemu</Filter>
</ClInclude>
<ClInclude Include="..\qapi\qapi-types-misc.h">
<Filter>qemu</Filter>
</ClInclude>
<ClInclude Include="..\qapi\qapi-visit-misc.h">
<Filter>qemu</Filter>
</ClInclude>
<ClInclude Include="..\qapi-visit.h">

View file

@ -66,6 +66,8 @@
<ClCompile Include="..\..\..\uc.c" />
<ClCompile Include="..\qapi-builtin-types.c" />
<ClCompile Include="..\qapi-builtin-visit.c" />
<ClCompile Include="..\qapi\qapi-types-misc.c" />
<ClCompile Include="..\qapi\qapi-visit-misc.c" />
<ClCompile Include="..\qapi-types.c" />
<ClCompile Include="..\qapi-visit.c" />
</ItemGroup>
@ -181,8 +183,10 @@
<ClInclude Include="..\config-host.h" />
<ClInclude Include="..\qapi-builtin-types.h" />
<ClInclude Include="..\qapi-builtin-visit.h" />
<ClInclude Include="..\qapi-types-common.h" />
<ClInclude Include="..\qapi-visit-common.h" />
<ClInclude Include="..\qapi\qapi-types-common.h" />
<ClInclude Include="..\qapi\qapi-visit-common.h" />
<ClInclude Include="..\qapi\qapi-types-misc.h" />
<ClInclude Include="..\qapi\qapi-visit-misc.h" />
<ClInclude Include="..\qapi-types.h" />
<ClInclude Include="..\qapi-visit.h" />
</ItemGroup>

View file

@ -211,10 +211,16 @@
<ClCompile Include="..\qapi-builtin-visit.c">
<Filter>qemu</Filter>
</ClCompile>
<ClCompile Include="..\qapi-types-common.c">
<ClCompile Include="..\qapi\qapi-types-common.c">
<Filter>qemu</Filter>
</ClCompile>
<ClCompile Include="..\qapi-visit-common.c">
<ClCompile Include="..\qapi\qapi-visit-common.c">
<Filter>qemu</Filter>
</ClCompile>
<ClCompile Include="..\qapi\qapi-types-misc.c">
<Filter>qemu</Filter>
</ClCompile>
<ClCompile Include="..\qapi\qapi-visit-misc.c">
<Filter>qemu</Filter>
</ClCompile>
</ItemGroup>
@ -536,10 +542,16 @@
<ClInclude Include="..\qapi-builtin-visit.h">
<Filter>qemu</Filter>
</ClInclude>
<ClInclude Include="..\qapi-types-common.h">
<ClInclude Include="..\qapi\qapi-types-common.h">
<Filter>qemu</Filter>
</ClInclude>
<ClInclude Include="..\qapi-visit-common.h">
<ClInclude Include="..\qapi\qapi-visit-common.h">
<Filter>qemu</Filter>
</ClInclude>
<ClInclude Include="..\qapi\qapi-types-misc.h">
<Filter>qemu</Filter>
</ClInclude>
<ClInclude Include="..\qapi\qapi-visit-misc.h">
<Filter>qemu</Filter>
</ClInclude>
</ItemGroup>

View file

@ -50,8 +50,10 @@ GENERATED_FILES = config-host.h
GENERATED_FILES += qapi-builtin-types.h qapi-builtin-types.c
GENERATED_FILES += qapi-types.h qapi-types.c
GENERATED_FILES += qapi/qapi-types-common.h qapi/qapi-types-common.c
GENERATED_FILES += qapi/qapi-types-misc.h qapi/qapi-types-misc.c
GENERATED_FILES += qapi-builtin-visit.h qapi-builtin-visit.c
GENERATED_FILES += qapi-visit.h qapi-visit.c
GENERATED_FILES += qapi/qapi-visit-misc.h qapi/qapi-visit-misc.c
GENERATED_FILES += qapi/qapi-visit-common.h qapi/qapi-visit-common.c
# Don't try to regenerate Makefile or configure
@ -153,14 +155,20 @@ $(SRC_PATH)/scripts/qapi/common.py \
$(SRC_PATH)/scripts/ordereddict.py \
$(SRC_PATH)/scripts/qapi-gen.py
qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json
qapi-modules = \
$(SRC_PATH)/qapi-schema.json \
$(SRC_PATH)/qapi/common.json \
$(SRC_PATH)/qapi/misc.json
qapi-builtin-types.c qapi-builtin-types.h \
qapi-types.c qapi-types.h \
qapi/qapi-types-common.c qapi/qapi-types-common.h \
qapi/qapi-types-misc.c qapi/qapi-types-misc.h \
qapi-builtin-visit.c qapi-builtin-visit.h \
qapi-visit.c qapi-visit.h \
qapi/qapi-visit-common.c qapi/qapi-visit-common.h \
qapi/qapi-visit-misc.c qapi/qapi-visit-misc.h \
qapi-doc.texi: \
qapi-gen-timestamp ;
qapi-gen-timestamp: $(qapi-modules) $(qapi-py)

View file

@ -3,6 +3,8 @@
util-obj-y = util/ qobject/ qapi/ qapi-types.o qapi-visit.o
util-obj-y += qapi-builtin-types.o
util-obj-y += qapi-builtin-visit.o
util-obj-y += qapi/qapi-types-misc.o
util-obj-y += qapi/qapi-visit-misc.o
#######################################################################
# block-obj-y is code used by both qemu system emulation and qemu-img

View file

@ -74,46 +74,4 @@
# QAPI common definitions
{ 'include': 'qapi/common.json' }
##
# @X86CPURegister32:
#
# A X86 32-bit register
#
# Since: 1.5
##
{ 'enum': 'X86CPURegister32',
'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ] }
##
# @X86CPUFeatureWordInfo:
#
# Information about a X86 CPU feature word
#
# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
#
# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
# feature word
#
# @cpuid-register: Output register containing the feature bits
#
# @features: value of output register, containing the feature bits
#
# Since: 1.5
##
{ 'struct': 'X86CPUFeatureWordInfo',
'data': { 'cpuid-input-eax': 'int',
'*cpuid-input-ecx': 'int',
'cpuid-register': 'X86CPURegister32',
'features': 'int' } }
##
# @DummyForceArrays:
#
# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally
#
# Since: 2.5
##
{ 'struct': 'DummyForceArrays',
'data': { 'unused': ['X86CPUFeatureWordInfo'] } }
{ 'include': 'qapi/misc.json' }

44
qemu/qapi/misc.json Normal file
View file

@ -0,0 +1,44 @@
# -*- Mode: Python -*-
#
##
# @X86CPURegister32:
#
# A X86 32-bit register
#
# Since: 1.5
##
{ 'enum': 'X86CPURegister32',
'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ] }
##
# @X86CPUFeatureWordInfo:
#
# Information about a X86 CPU feature word
#
# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
#
# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
# feature word
#
# @cpuid-register: Output register containing the feature bits
#
# @features: value of output register, containing the feature bits
#
# Since: 1.5
##
{ 'struct': 'X86CPUFeatureWordInfo',
'data': { 'cpuid-input-eax': 'int',
'*cpuid-input-ecx': 'int',
'cpuid-register': 'X86CPURegister32',
'features': 'int' } }
##
# @DummyForceArrays:
#
# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally
#
# Since: 2.5
##
{ 'struct': 'DummyForceArrays',
'data': { 'unused': ['X86CPUFeatureWordInfo'] } }