qapi: Update scripts to commit 01b2ffcedd94ad7b42bc870e4c6936c87ad03429

This commit is contained in:
Lioncash 2018-03-03 18:23:47 -05:00
parent dd77730d49
commit a6623ce754
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
8 changed files with 799 additions and 507 deletions

View file

@ -14,6 +14,7 @@
*
*/
#include "qemu/osdep.h"
#include "qapi/dealloc-visitor.h"
#include "qapi-types.h"
#include "qapi-visit.h"

View file

@ -16,8 +16,6 @@
#ifndef QAPI_TYPES_H
#define QAPI_TYPES_H
#include "qemu/typedefs.h"
#include "unicorn/platform.h"
#ifndef QAPI_TYPES_BUILTIN
#define QAPI_TYPES_BUILTIN
@ -33,104 +31,133 @@ typedef enum QType {
QTYPE_QBOOL = 6,
QTYPE__MAX = 7,
} QType;
extern const char *const QType_lookup[];
typedef struct anyList anyList;
struct anyList {
anyList *next;
QObject *value;
};
void qapi_free_anyList(anyList *obj);
typedef struct boolList boolList;
struct boolList {
boolList *next;
bool value;
};
void qapi_free_boolList(boolList *obj);
typedef struct int16List int16List;
struct int16List {
int16List *next;
int16_t value;
};
void qapi_free_int16List(int16List *obj);
typedef struct int32List int32List;
struct int32List {
int32List *next;
int32_t value;
};
void qapi_free_int32List(int32List *obj);
typedef struct int64List int64List;
struct int64List {
int64List *next;
int64_t value;
};
void qapi_free_int64List(int64List *obj);
typedef struct int8List int8List;
struct int8List {
int8List *next;
int8_t value;
};
void qapi_free_int8List(int8List *obj);
typedef struct intList intList;
struct intList {
intList *next;
int64_t value;
};
void qapi_free_intList(intList *obj);
typedef struct numberList numberList;
struct numberList {
numberList *next;
double value;
};
void qapi_free_numberList(numberList *obj);
typedef struct sizeList sizeList;
struct sizeList {
sizeList *next;
uint64_t value;
};
void qapi_free_sizeList(sizeList *obj);
typedef struct strList strList;
struct strList {
strList *next;
char *value;
};
void qapi_free_strList(strList *obj);
typedef struct uint16List uint16List;
struct uint16List {
uint16List *next;
uint16_t value;
};
void qapi_free_uint16List(uint16List *obj);
typedef struct uint32List uint32List;
struct uint32List {
uint32List *next;
uint32_t value;
};
void qapi_free_uint32List(uint32List *obj);
typedef struct uint64List uint64List;
struct uint64List {
uint64List *next;
uint64_t value;
};
void qapi_free_uint64List(uint64List *obj);
typedef struct uint8List uint8List;
struct uint8List {
uint8List *next;
uint8_t value;
};
void qapi_free_uint8List(uint8List *obj);
#endif /* QAPI_TYPES_BUILTIN */
@ -147,6 +174,7 @@ typedef enum QapiErrorClass {
QAPI_ERROR_CLASS_KVMMISSINGCAP = 5,
QAPI_ERROR_CLASS__MAX = 6,
} QapiErrorClass;
extern const char *const QapiErrorClass_lookup[];
typedef struct X86CPUFeatureWordInfo X86CPUFeatureWordInfo;
@ -164,11 +192,13 @@ typedef enum X86CPURegister32 {
X86_CPU_REGISTER32_EDI = 7,
X86_CPU_REGISTER32__MAX = 8,
} X86CPURegister32;
extern const char *const X86CPURegister32_lookup[];
struct DummyForceArrays {
X86CPUFeatureWordInfoList *unused;
};
void qapi_free_DummyForceArrays(DummyForceArrays *obj);
struct X86CPUFeatureWordInfo {
@ -178,11 +208,14 @@ struct X86CPUFeatureWordInfo {
X86CPURegister32 cpuid_register;
int64_t features;
};
void qapi_free_X86CPUFeatureWordInfo(X86CPUFeatureWordInfo *obj);
struct X86CPUFeatureWordInfoList {
X86CPUFeatureWordInfoList *next;
X86CPUFeatureWordInfo *value;
};
void qapi_free_X86CPUFeatureWordInfoList(X86CPUFeatureWordInfoList *obj);
#endif

View file

@ -13,6 +13,7 @@
*
*/
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "qapi-visit.h"
@ -142,8 +143,9 @@ void visit_type_X86CPUFeatureWordInfoList(Visitor *v, const char *name, X86CPUFe
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_X86CPUFeatureWordInfoList(*obj);
@ -179,8 +181,9 @@ void visit_type_anyList(Visitor *v, const char *name, anyList **obj, Error **err
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_anyList(*obj);
@ -209,8 +212,9 @@ void visit_type_boolList(Visitor *v, const char *name, boolList **obj, Error **e
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_boolList(*obj);
@ -239,8 +243,9 @@ void visit_type_int16List(Visitor *v, const char *name, int16List **obj, Error *
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_int16List(*obj);
@ -269,8 +274,9 @@ void visit_type_int32List(Visitor *v, const char *name, int32List **obj, Error *
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_int32List(*obj);
@ -299,8 +305,9 @@ void visit_type_int64List(Visitor *v, const char *name, int64List **obj, Error *
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_int64List(*obj);
@ -329,8 +336,9 @@ void visit_type_int8List(Visitor *v, const char *name, int8List **obj, Error **e
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_int8List(*obj);
@ -359,8 +367,9 @@ void visit_type_intList(Visitor *v, const char *name, intList **obj, Error **err
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_intList(*obj);
@ -389,8 +398,9 @@ void visit_type_numberList(Visitor *v, const char *name, numberList **obj, Error
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_numberList(*obj);
@ -419,8 +429,9 @@ void visit_type_sizeList(Visitor *v, const char *name, sizeList **obj, Error **e
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_sizeList(*obj);
@ -449,8 +460,9 @@ void visit_type_strList(Visitor *v, const char *name, strList **obj, Error **err
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_strList(*obj);
@ -479,8 +491,9 @@ void visit_type_uint16List(Visitor *v, const char *name, uint16List **obj, Error
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_uint16List(*obj);
@ -509,8 +522,9 @@ void visit_type_uint32List(Visitor *v, const char *name, uint32List **obj, Error
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_uint32List(*obj);
@ -539,8 +553,9 @@ void visit_type_uint64List(Visitor *v, const char *name, uint64List **obj, Error
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_uint64List(*obj);
@ -569,8 +584,9 @@ void visit_type_uint8List(Visitor *v, const char *name, uint8List **obj, Error *
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_uint8List(*obj);

View file

@ -1,6 +1,76 @@
# -*- Mode: Python -*-
##
# = Introduction
#
# QAPI Schema
# This document describes all commands currently supported by QMP.
#
# Most of the time their usage is exactly the same as in the user Monitor, this
# means that any other document which also describe commands (the manpage,
# QEMU's manual, etc) can and should be consulted.
#
# QMP has two types of commands: regular and query commands. Regular commands
# usually change the Virtual Machine's state someway, while query commands just
# return information. The sections below are divided accordingly.
#
# It's important to observe that all communication examples are formatted in
# a reader-friendly way, so that they're easier to understand. However, in real
# protocol usage, they're emitted as a single line.
#
# Also, the following notation is used to denote data flow:
#
# Example:
#
# | -> data issued by the Client
# | <- Server data response
#
# Please, refer to the QMP specification (docs/qmp-spec.txt) for
# detailed information on the Server command and response formats.
#
# = Stability Considerations
#
# The current QMP command set (described in this file) may be useful for a
# number of use cases, however it's limited and several commands have bad
# defined semantics, specially with regard to command completion.
#
# These problems are going to be solved incrementally in the next QEMU releases
# and we're going to establish a deprecation policy for badly defined commands.
#
# If you're planning to adopt QMP, please observe the following:
#
# 1. The deprecation policy will take effect and be documented soon, please
# check the documentation of each used command as soon as a new release of
# QEMU is available
#
# 2. DO NOT rely on anything which is not explicit documented
#
# 3. Errors, in special, are not documented. Applications should NOT check
# for specific errors classes or data (it's strongly recommended to only
# check for the "error" key)
#
##
{ 'pragma': { 'doc-required': true } }
# Whitelists to permit QAPI rule violations; think twice before you
# add to them!
{ 'pragma': {
# Commands allowed to return a non-dictionary:
'returns-whitelist': [
'human-monitor-command',
'qom-get',
'query-migrate-cache-size',
'query-tpm-models',
'query-tpm-types',
'ringbuf-read' ],
'name-case-whitelist': [
'ACPISlotType', # DIMM, visible through query-acpi-ospm-status
'CpuInfoMIPS', # PC, visible through query-cpu
'CpuInfoTricore', # PC, visible through query-cpu
'QapiErrorClass', # all members, visible through errors
'UuidInfo', # UUID, visible through query-uuid
'X86CPURegister32', # all members, visible indirectly through qom-get
'q_obj_CpuInfo-base' # CPU, visible through query-cpu
] } }
# QAPI common definitions
{ 'include': 'qapi/common.json' }
@ -22,7 +92,7 @@
#
# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
#
# @cpuid-input-ecx: #optional Input ECX value for CPUID instruction for that
# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
# feature word
#
# @cpuid-register: Output register containing the feature bits

View file

@ -1,9 +1,11 @@
# -*- Mode: Python -*-
#
# QAPI common definitions
##
# @QapiErrorClass
# = QAPI common definitions
##
##
# @QapiErrorClass:
#
# QEMU error classes
#

View file

@ -13,6 +13,7 @@
from qapi import *
# variants must be emitted before their container; track what has already
# been output
objects_seen = set()
@ -25,8 +26,10 @@ typedef struct %(c_name)s %(c_name)s;
''',
c_name=c_name(name))
def gen_array(name, element_type):
return mcgen('''
struct %(c_name)s {
%(c_name)s *next;
%(c_type)s value;
@ -37,7 +40,6 @@ struct %(c_name)s {
def gen_struct_members(members):
ret = ''
for memb in members:
if memb.optional:
ret += mcgen('''
@ -114,39 +116,6 @@ static inline %(base)s *qapi_%(c_name)s_base(const %(c_name)s *obj)
c_name=c_name(name), base=base.c_name())
def gen_alternate_qtypes_decl(name):
return mcgen('''
extern const int %(c_name)s_qtypes[];
''',
c_name=c_name(name))
def gen_alternate_qtypes(name, variants):
ret = mcgen('''
const int %(c_name)s_qtypes[QTYPE__MAX] = {
''',
c_name=c_name(name))
for var in variants.variants:
qtype = var.type.alternate_qtype()
assert qtype
ret += mcgen('''
[%(qtype)s] = %(enum_const)s,
''',
qtype=qtype,
enum_const=c_enum_const(variants.tag_member.type.name,
var.name))
ret += mcgen('''
};
''')
return ret
def gen_variants(variants):
ret = mcgen('''
union { /* union tag is @%(c_name)s */
@ -169,6 +138,7 @@ def gen_variants(variants):
def gen_type_cleanup_decl(name):
ret = mcgen('''
void qapi_free_%(c_name)s(%(c_name)s *obj);
''',
c_name=c_name(name))
@ -208,7 +178,6 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
self.decl = ''
self.defn = ''
self._fwdecl = ''
self._fwdefn = ''
self._btin = guardstart('QAPI_TYPES_BUILTIN')
def visit_end(self):
@ -265,9 +234,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
def visit_alternate_type(self, name, info, variants):
self._fwdecl += gen_fwd_object_or_array(name)
self._fwdefn += gen_alternate_qtypes(name, variants)
self.decl += gen_object(name, None, [variants.tag_member], variants)
self.decl += gen_alternate_qtypes_decl(name)
self._gen_type_cleanup(name)
# If you link code generated from multiple schemata, you want only one
@ -277,10 +244,10 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
do_builtins = False
(input_file, output_dir, do_c, do_h, prefix, opts) = \
parse_command_line("b", ["builtins"])
parse_command_line('b', ['builtins'])
for o, a in opts:
if o in ("-b", "--builtins"):
if o in ('-b', '--builtins'):
do_builtins = True
c_comment = '''
@ -312,23 +279,19 @@ h_comment = '''
*
*/
'''
(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
'qapi-types.c', 'qapi-types.h',
c_comment, h_comment)
fdef.write(mcgen('''
#include "qemu/osdep.h"
#include "qapi/dealloc-visitor.h"
#include "%(prefix)sqapi-types.h"
#include "%(prefix)sqapi-visit.h"
''',
prefix=prefix))
# To avoid circular headers, use only typedefs.h here, not qobject.h
fdecl.write(mcgen('''
#include "qemu/typedefs.h"
#include "unicorn/platform.h"
'''))
schema = QAPISchema(input_file)
gen = QAPISchemaGenTypeVisitor()
schema.visit(gen)

View file

@ -13,7 +13,7 @@
# See the COPYING file in the top-level directory.
from qapi import *
import re
def gen_visit_decl(name, scalar=False):
c_type = c_name(name) + ' *'
@ -89,6 +89,7 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **errp)
var.name,
variants.tag_member.type.prefix),
c_type=var.type.c_name(), c_name=c_name(var.name))
ret += mcgen('''
default:
abort();
@ -131,8 +132,9 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj, Error
}
}
error_propagate(errp, err);
err = NULL;
if (!err) {
visit_check_list(v, &err);
}
visit_end_list(v, (void **)obj);
if (err && visit_is_input(v)) {
qapi_free_%(c_name)s(*obj);
@ -159,8 +161,8 @@ void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, Error
def gen_visit_alternate(name, variants):
ret = ''
promote_int = 'true'
ret = ''
for var in variants.variants:
if var.type.alternate_qtype() == 'QTYPE_QNUM':
promote_int = 'false'
@ -332,10 +334,10 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
do_builtins = False
(input_file, output_dir, do_c, do_h, prefix, opts) = \
parse_command_line("b", ["builtins"])
parse_command_line('b', ['builtins'])
for o, a in opts:
if o in ("-b", "--builtins"):
if o in ('-b', '--builtins'):
do_builtins = True
c_comment = '''
@ -372,6 +374,7 @@ h_comment = '''
c_comment, h_comment)
fdef.write(mcgen('''
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "qapi/error.h"
#include "%(prefix)sqapi-visit.h"

File diff suppressed because it is too large Load diff