diff --git a/.gitignore b/.gitignore index 9a5b1c7b..5973b4b4 100644 --- a/.gitignore +++ b/.gitignore @@ -28,10 +28,6 @@ qemu/sparc-softmmu/ qemu/i386-softmmu/ qemu/x86_64-softmmu/ -qemu/qapi-types.h -qemu/qapi-visit.h -qemu/qapi-types.c -qemu/qapi-visit.c tags qemu/config-host.ld qemu/config.log diff --git a/CMakeLists.txt b/CMakeLists.txt index e1c5aa6c..1698f128 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,18 +135,6 @@ else() message(FATAL_ERROR "Unknown host compiler: ${CMAKE_C_COMPILER}.") endwhile(TRUE) -# check python - find_program(PYTHON_CMD python) - if (NOT PYTHON_CMD) - find_program(PYTHON_CMD python3) - if (NOT PYTHON_CMD) - find_program(PYTHON_CMD python2) - if (NOT PYTHON_CMD) - message(FATAL_ERROR "Please install python.") - endif() - endif() - endif() - set(EXTRA_CFLAGS "--extra-cflags=") if (UNICORN_HAS_X86) set (EXTRA_CFLAGS "${EXTRA_CFLAGS}-DUNICORN_HAS_X86 ") @@ -191,7 +179,6 @@ else() # GEN dynamic source files execute_process(COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/qemu/configure - --python=${PYTHON_CMD} ${EXTRA_CFLAGS} ${TARGET_LIST} ) @@ -259,18 +246,6 @@ else() OUTPUT_FILE ${CMAKE_BINARY_DIR}/sparc64-softmmu/config-target.h ) endif() - execute_process(COMMAND ${PYTHON_CMD} -B ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/qapi-types.py - -h -o ${CMAKE_BINARY_DIR} -b -i ${CMAKE_CURRENT_SOURCE_DIR}/qemu/qapi-schema.json - ) - execute_process(COMMAND ${PYTHON_CMD} -B ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/qapi-types.py - -c -o ${CMAKE_BINARY_DIR} -b -i ${CMAKE_CURRENT_SOURCE_DIR}/qemu/qapi-schema.json - ) - execute_process(COMMAND ${PYTHON_CMD} -B ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/qapi-visit.py - -h -o ${CMAKE_BINARY_DIR} -b -i ${CMAKE_CURRENT_SOURCE_DIR}/qemu/qapi-schema.json - ) - execute_process(COMMAND ${PYTHON_CMD} -B ${CMAKE_CURRENT_SOURCE_DIR}/qemu/scripts/qapi-visit.py - -c -o ${CMAKE_BINARY_DIR} -b -i ${CMAKE_CURRENT_SOURCE_DIR}/qemu/qapi-schema.json - ) add_compile_options( -I${CMAKE_CURRENT_SOURCE_DIR}/qemu/tcg/${UNICORN_TARGET_ARCH} -D_GNU_SOURCE @@ -847,8 +822,8 @@ else() ${UNICORN_SRCS_COMMON} qemu/util/oslib-posix.c qemu/util/qemu-thread-posix.c - ${CMAKE_BINARY_DIR}/qapi-types.c - ${CMAKE_BINARY_DIR}/qapi-visit.c + qemu/qapi-types.c + qemu/qapi-visit.c ) endif() diff --git a/Makefile b/Makefile index 9268ac81..5128a022 100644 --- a/Makefile +++ b/Makefile @@ -237,8 +237,6 @@ LIBRARY_SYMLINK = lib$(LIBNAME).$(EXT) endif endif -UNICORN_QEMU_FLAGS += --python=$(shell which /usr/bin/python || which python || which python2 || which python3) - ifeq ($(UNICORN_STATIC),yes) ifneq ($(filter MINGW%,$(UNAME_S)),) ARCHIVE = $(LIBNAME).$(AR_EXT) diff --git a/docs/COMPILE-CMAKE.md b/docs/COMPILE-CMAKE.md index 3e0594ad..6e8be6cc 100644 --- a/docs/COMPILE-CMAKE.md +++ b/docs/COMPILE-CMAKE.md @@ -6,7 +6,7 @@ This documentation explains how to compile Unicorn with CMake on Windows or Requirements: - Windows: MicroSoft Visual Studio(>=2013). -- *nix: GNU gcc and Python CLI to generate dynamic source files. +- *nix: GNU gcc or clang to generate dynamic source files. Get CMake for free from http://www.cmake.org. diff --git a/docs/COMPILE-WINDOWS.md b/docs/COMPILE-WINDOWS.md index 55262cde..94744bed 100644 --- a/docs/COMPILE-WINDOWS.md +++ b/docs/COMPILE-WINDOWS.md @@ -35,22 +35,19 @@ Unicorn can be compiled either on Ubuntu or Windows. - To compile for Windows 32-bit, run: - $ pacman -S python2 $ pacman -S make $ pacman -S mingw-w64-i686-toolchain - To compile for Windows 64-bit, run: - $ pacman -S python2 $ pacman -S make $ pacman -S mingw-w64-x86_64-toolchain -- For Cygwin, "make", "gcc-core", "libpcre-devel", "zlib-devel", "python2-setuptools" - are needed. +- For Cygwin, "make", "gcc-core", "libpcre-devel", "zlib-devel" are needed. If apt-cyg is available, you can install these with: - $ apt-cyg install make gcc-core libpcre-devel zlib-devel python2-setuptools + $ apt-cyg install make gcc-core libpcre-devel zlib-devel diff --git a/qemu/Makefile b/qemu/Makefile index 1749c641..8e5762e8 100644 --- a/qemu/Makefile +++ b/qemu/Makefile @@ -34,8 +34,6 @@ endif endif GENERATED_HEADERS = config-host.h -GENERATED_HEADERS += qapi-types.h qapi-visit.h -GENERATED_SOURCES += qapi-types.c qapi-visit.c # Don't try to regenerate Makefile or configure # We don't generate any of them @@ -91,29 +89,11 @@ recurse-all: $(SUBDIR_RULES) ###################################################################### -gen-out-type = $(subst .,-,$(suffix $@)) - -qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py - -qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json - -qapi-types.c qapi-types.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ - $(gen-out-type) -o "." -b -i $<, \ - " GEN $@") -qapi-visit.c qapi-visit.h :\ -$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ - $(gen-out-type) -o "." -b -i $<, \ - " GEN $@") - clean: find . \( -name '*.l[oa]' -o -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f -exec rm {} + rm -f TAGS *~ */*~ @# May not be present in GENERATED_HEADERS rm -f $(foreach f,$(GENERATED_HEADERS),$(f) $(f)-timestamp) - rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp) for d in $(TARGET_DIRS); do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ done diff --git a/qemu/configure b/qemu/configure index 09caef3d..b5d52d76 100755 --- a/qemu/configure +++ b/qemu/configure @@ -451,7 +451,6 @@ Haiku) esac : ${make=${MAKE-make}} -: ${python=${PYTHON-python}} # Default objcc to clang if available, otherwise use CC if has clang; then @@ -494,8 +493,6 @@ for opt do ;; --make=*) make="$optarg" ;; - --python=*) python="$optarg" - ;; --extra-cflags=*) ;; --extra-ldflags=*) @@ -544,24 +541,6 @@ for opt do esac done -if ! has $python; then - error_exit "Python not found. Use --python=/path/to/python" -fi - -# Note that if the Python conditional here evaluates True we will exit -# with status 1 which is a shell 'false' value. -if ! $python -c 'import sys; sys.exit(sys.version_info < (2,4))'; then - error_exit "Cannot use '$python', Python 2.4 or later is required." \ - "Use --python=/path/to/python to specify a supported Python." -fi - -# The -B switch was added in Python 2.6. -# If it is supplied, compiled files are not written. -# Use it for Python versions which support it. -if $python -B -c 'import sys; sys.exit(0)' 2>/dev/null; then - python="$python -B" -fi - case "$cpu" in ppc) CPU_CFLAGS="-m32" @@ -641,7 +620,6 @@ Advanced options (experts only): --extra-cflags=CFLAGS append extra C compiler flags QEMU_CFLAGS --extra-ldflags=LDFLAGS append extra linker flags LDFLAGS --make=MAKE use specified make [$make] - --python=PYTHON use specified python [$python] --static enable static build [$static] --enable-debug-tcg enable TCG debugging --disable-debug-tcg disable TCG debugging (default) @@ -1083,7 +1061,6 @@ echo "CFLAGS $CFLAGS" echo "QEMU_CFLAGS $QEMU_CFLAGS" echo "LDFLAGS $LDFLAGS" echo "make $make" -echo "python $python" echo "host CPU $cpu" echo "host big endian $bigendian" echo "target list $target_list" @@ -1185,7 +1162,6 @@ fi QEMU_INCLUDES="-I\$(SRC_PATH)/tcg $QEMU_INCLUDES" echo "MAKE=$make" >> $config_host_mak -echo "PYTHON=$python" >> $config_host_mak echo "CC=$cc" >> $config_host_mak echo "CC_I386=$cc_i386" >> $config_host_mak echo "HOST_CC=$host_cc" >> $config_host_mak diff --git a/qemu/qapi-types.c b/qemu/qapi-types.c new file mode 100644 index 00000000..173c654b --- /dev/null +++ b/qemu/qapi-types.c @@ -0,0 +1,293 @@ +/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ + +/* + * deallocation functions for schema-defined QAPI types + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * Michael Roth + * + * 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 "qapi/dealloc-visitor.h" +#include "qapi-types.h" +#include "qapi-visit.h" + +const char *ErrorClass_lookup[] = { + "GenericError", + "CommandNotFound", + "DeviceEncrypted", + "DeviceNotActive", + "DeviceNotFound", + "KVMMissingCap", + NULL, +}; + +const char *X86CPURegister32_lookup[] = { + "EAX", + "EBX", + "ECX", + "EDX", + "ESP", + "EBP", + "ESI", + "EDI", + NULL, +}; + + +#ifndef QAPI_TYPES_BUILTIN_CLEANUP_DEF_H +#define QAPI_TYPES_BUILTIN_CLEANUP_DEF_H + + +void qapi_free_strList(strList *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_strList(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_intList(intList *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_intList(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_numberList(numberList *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_numberList(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_boolList(boolList *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_boolList(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_int8List(int8List *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_int8List(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_int16List(int16List *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_int16List(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_int32List(int32List *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_int32List(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_int64List(int64List *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_int64List(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_uint8List(uint8List *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_uint8List(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_uint16List(uint16List *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_uint16List(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_uint32List(uint32List *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_uint32List(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +void qapi_free_uint64List(uint64List *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_uint64List(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + +#endif /* QAPI_TYPES_BUILTIN_CLEANUP_DEF_H */ + + +void qapi_free_ErrorClassList(ErrorClassList *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_ErrorClassList(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + + +void qapi_free_X86CPURegister32List(X86CPURegister32List *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_X86CPURegister32List(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + + +void qapi_free_X86CPUFeatureWordInfoList(X86CPUFeatureWordInfoList *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_X86CPUFeatureWordInfoList(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + + +void qapi_free_X86CPUFeatureWordInfo(X86CPUFeatureWordInfo *obj) +{ + QapiDeallocVisitor *md; + Visitor *v; + + if (!obj) { + return; + } + + md = qapi_dealloc_visitor_new(); + v = qapi_dealloc_get_visitor(md); + visit_type_X86CPUFeatureWordInfo(v, &obj, NULL, NULL); + qapi_dealloc_visitor_cleanup(md); +} + diff --git a/qemu/qapi-types.h b/qemu/qapi-types.h new file mode 100644 index 00000000..944e8825 --- /dev/null +++ b/qemu/qapi-types.h @@ -0,0 +1,228 @@ +/* AUTOMATICALLY GENERATED, DO NOT MODIFY */ + +/* + * schema-defined QAPI types + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * + * 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_TYPES_H +#define QAPI_TYPES_H + +#include "unicorn/platform.h" + + +#ifndef QAPI_TYPES_BUILTIN_STRUCT_DECL_H +#define QAPI_TYPES_BUILTIN_STRUCT_DECL_H + + +typedef struct strList +{ + union { + char *value; + uint64_t padding; + }; + struct strList *next; +} strList; + +typedef struct intList +{ + union { + int64_t value; + uint64_t padding; + }; + struct intList *next; +} intList; + +typedef struct numberList +{ + union { + double value; + uint64_t padding; + }; + struct numberList *next; +} numberList; + +typedef struct boolList +{ + union { + bool value; + uint64_t padding; + }; + struct boolList *next; +} boolList; + +typedef struct int8List +{ + union { + int8_t value; + uint64_t padding; + }; + struct int8List *next; +} int8List; + +typedef struct int16List +{ + union { + int16_t value; + uint64_t padding; + }; + struct int16List *next; +} int16List; + +typedef struct int32List +{ + union { + int32_t value; + uint64_t padding; + }; + struct int32List *next; +} int32List; + +typedef struct int64List +{ + union { + int64_t value; + uint64_t padding; + }; + struct int64List *next; +} int64List; + +typedef struct uint8List +{ + union { + uint8_t value; + uint64_t padding; + }; + struct uint8List *next; +} uint8List; + +typedef struct uint16List +{ + union { + uint16_t value; + uint64_t padding; + }; + struct uint16List *next; +} uint16List; + +typedef struct uint32List +{ + union { + uint32_t value; + uint64_t padding; + }; + struct uint32List *next; +} uint32List; + +typedef struct uint64List +{ + union { + uint64_t value; + uint64_t padding; + }; + struct uint64List *next; +} uint64List; + +#endif /* QAPI_TYPES_BUILTIN_STRUCT_DECL_H */ + + +extern const char *ErrorClass_lookup[]; +typedef enum ErrorClass +{ + ERROR_CLASS_GENERIC_ERROR = 0, + ERROR_CLASS_COMMAND_NOT_FOUND = 1, + ERROR_CLASS_DEVICE_ENCRYPTED = 2, + ERROR_CLASS_DEVICE_NOT_ACTIVE = 3, + ERROR_CLASS_DEVICE_NOT_FOUND = 4, + ERROR_CLASS_KVM_MISSING_CAP = 5, + ERROR_CLASS_MAX = 6, +} ErrorClass; + +typedef struct ErrorClassList +{ + union { + ErrorClass value; + uint64_t padding; + }; + struct ErrorClassList *next; +} ErrorClassList; + +extern const char *X86CPURegister32_lookup[]; +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; + +typedef struct X86CPURegister32List +{ + union { + X86CPURegister32 value; + uint64_t padding; + }; + struct X86CPURegister32List *next; +} X86CPURegister32List; + + +typedef struct X86CPUFeatureWordInfo X86CPUFeatureWordInfo; + +typedef struct X86CPUFeatureWordInfoList +{ + union { + X86CPUFeatureWordInfo *value; + uint64_t padding; + }; + struct X86CPUFeatureWordInfoList *next; +} X86CPUFeatureWordInfoList; + +#ifndef QAPI_TYPES_BUILTIN_CLEANUP_DECL_H +#define QAPI_TYPES_BUILTIN_CLEANUP_DECL_H + +void qapi_free_strList(strList *obj); +void qapi_free_intList(intList *obj); +void qapi_free_numberList(numberList *obj); +void qapi_free_boolList(boolList *obj); +void qapi_free_int8List(int8List *obj); +void qapi_free_int16List(int16List *obj); +void qapi_free_int32List(int32List *obj); +void qapi_free_int64List(int64List *obj); +void qapi_free_uint8List(uint8List *obj); +void qapi_free_uint16List(uint16List *obj); +void qapi_free_uint32List(uint32List *obj); +void qapi_free_uint64List(uint64List *obj); + +#endif /* QAPI_TYPES_BUILTIN_CLEANUP_DECL_H */ + + +void qapi_free_ErrorClassList(ErrorClassList *obj); + +void qapi_free_X86CPURegister32List(X86CPURegister32List *obj); + +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_X86CPUFeatureWordInfoList(X86CPUFeatureWordInfoList *obj); +void qapi_free_X86CPUFeatureWordInfo(X86CPUFeatureWordInfo *obj); + +#endif diff --git a/qemu/qapi-visit.c b/qemu/qapi-visit.c new file mode 100644 index 00000000..7733bb55 --- /dev/null +++ b/qemu/qapi-visit.c @@ -0,0 +1,428 @@ +/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */ + +/* + * schema-defined QAPI visitor functions + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * + * 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-common.h" +#include "qapi-visit.h" + +void visit_type_strList(Visitor *m, strList **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + strList *native_i = (strList *)i; + visit_type_str(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_intList(Visitor *m, intList **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + intList *native_i = (intList *)i; + visit_type_int(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_numberList(Visitor *m, numberList **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + numberList *native_i = (numberList *)i; + visit_type_number(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_boolList(Visitor *m, boolList **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + boolList *native_i = (boolList *)i; + visit_type_bool(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_int8List(Visitor *m, int8List **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + int8List *native_i = (int8List *)i; + visit_type_int8(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_int16List(Visitor *m, int16List **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + int16List *native_i = (int16List *)i; + visit_type_int16(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_int32List(Visitor *m, int32List **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + int32List *native_i = (int32List *)i; + visit_type_int32(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_int64List(Visitor *m, int64List **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + int64List *native_i = (int64List *)i; + visit_type_int64(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_uint8List(Visitor *m, uint8List **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + uint8List *native_i = (uint8List *)i; + visit_type_uint8(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_uint16List(Visitor *m, uint16List **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + uint16List *native_i = (uint16List *)i; + visit_type_uint16(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_uint32List(Visitor *m, uint32List **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + uint32List *native_i = (uint32List *)i; + visit_type_uint32(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_uint64List(Visitor *m, uint64List **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + uint64List *native_i = (uint64List *)i; + visit_type_uint64(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_ErrorClassList(Visitor *m, ErrorClassList **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + ErrorClassList *native_i = (ErrorClassList *)i; + visit_type_ErrorClass(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_ErrorClass(Visitor *m, ErrorClass *obj, const char *name, Error **errp) +{ + visit_type_enum(m, (int *)obj, ErrorClass_lookup, "ErrorClass", name, errp); +} + +void visit_type_X86CPURegister32List(Visitor *m, X86CPURegister32List **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + X86CPURegister32List *native_i = (X86CPURegister32List *)i; + visit_type_X86CPURegister32(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} + +void visit_type_X86CPURegister32(Visitor *m, X86CPURegister32 *obj, const char *name, Error **errp) +{ + visit_type_enum(m, (int *)obj, X86CPURegister32_lookup, "X86CPURegister32", name, errp); +} + +static void visit_type_X86CPUFeatureWordInfo_fields(Visitor *m, X86CPUFeatureWordInfo **obj, Error **errp) +{ + Error *err = NULL; + visit_type_int(m, &(*obj)->cpuid_input_eax, "cpuid-input-eax", &err); + if (err) { + goto out; + } + visit_optional(m, &(*obj)->has_cpuid_input_ecx, "cpuid-input-ecx", &err); + if (!err && (*obj)->has_cpuid_input_ecx) { + visit_type_int(m, &(*obj)->cpuid_input_ecx, "cpuid-input-ecx", &err); + } + if (err) { + goto out; + } + visit_type_X86CPURegister32(m, &(*obj)->cpuid_register, "cpuid-register", &err); + if (err) { + goto out; + } + visit_type_int(m, &(*obj)->features, "features", &err); + if (err) { + goto out; + } + +out: + error_propagate(errp, err); +} + +void visit_type_X86CPUFeatureWordInfo(Visitor *m, X86CPUFeatureWordInfo **obj, const char *name, Error **errp) +{ + Error *err = NULL; + + visit_start_struct(m, (void **)obj, "X86CPUFeatureWordInfo", name, sizeof(X86CPUFeatureWordInfo), &err); + if (!err) { + if (*obj) { + visit_type_X86CPUFeatureWordInfo_fields(m, obj, errp); + } + visit_end_struct(m, &err); + } + error_propagate(errp, err); +} + +void visit_type_X86CPUFeatureWordInfoList(Visitor *m, X86CPUFeatureWordInfoList **obj, const char *name, Error **errp) +{ + Error *err = NULL; + GenericList *i, **prev; + + visit_start_list(m, name, &err); + if (err) { + goto out; + } + + for (prev = (GenericList **)obj; + !err && (i = visit_next_list(m, prev, &err)) != NULL; + prev = &i) { + X86CPUFeatureWordInfoList *native_i = (X86CPUFeatureWordInfoList *)i; + visit_type_X86CPUFeatureWordInfo(m, &native_i->value, NULL, &err); + } + + error_propagate(errp, err); + err = NULL; + visit_end_list(m, &err); +out: + error_propagate(errp, err); +} diff --git a/qemu/qapi-visit.h b/qemu/qapi-visit.h new file mode 100644 index 00000000..51bd0887 --- /dev/null +++ b/qemu/qapi-visit.h @@ -0,0 +1,51 @@ +/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */ + +/* + * schema-defined QAPI visitor functions + * + * Copyright IBM, Corp. 2011 + * + * Authors: + * Anthony Liguori + * + * 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_VISIT_H +#define QAPI_VISIT_H + +#include "qapi/visitor.h" +#include "qapi-types.h" + + +#ifndef QAPI_VISIT_BUILTIN_VISITOR_DECL_H +#define QAPI_VISIT_BUILTIN_VISITOR_DECL_H + +void visit_type_strList(Visitor *m, strList **obj, const char *name, Error **errp); +void visit_type_intList(Visitor *m, intList **obj, const char *name, Error **errp); +void visit_type_numberList(Visitor *m, numberList **obj, const char *name, Error **errp); +void visit_type_boolList(Visitor *m, boolList **obj, const char *name, Error **errp); +void visit_type_int8List(Visitor *m, int8List **obj, const char *name, Error **errp); +void visit_type_int16List(Visitor *m, int16List **obj, const char *name, Error **errp); +void visit_type_int32List(Visitor *m, int32List **obj, const char *name, Error **errp); +void visit_type_int64List(Visitor *m, int64List **obj, const char *name, Error **errp); +void visit_type_uint8List(Visitor *m, uint8List **obj, const char *name, Error **errp); +void visit_type_uint16List(Visitor *m, uint16List **obj, const char *name, Error **errp); +void visit_type_uint32List(Visitor *m, uint32List **obj, const char *name, Error **errp); +void visit_type_uint64List(Visitor *m, uint64List **obj, const char *name, Error **errp); + +#endif /* QAPI_VISIT_BUILTIN_VISITOR_DECL_H */ + + +void visit_type_ErrorClass(Visitor *m, ErrorClass *obj, const char *name, Error **errp); +void visit_type_ErrorClassList(Visitor *m, ErrorClassList **obj, const char *name, Error **errp); + +void visit_type_X86CPURegister32(Visitor *m, X86CPURegister32 *obj, const char *name, Error **errp); +void visit_type_X86CPURegister32List(Visitor *m, X86CPURegister32List **obj, const char *name, Error **errp); + +void visit_type_X86CPUFeatureWordInfo(Visitor *m, X86CPUFeatureWordInfo **obj, const char *name, Error **errp); +void visit_type_X86CPUFeatureWordInfoList(Visitor *m, X86CPUFeatureWordInfoList **obj, const char *name, Error **errp); + +#endif diff --git a/qemu/qapi-schema.json b/qemu/scripts/qapi-schema.json similarity index 100% rename from qemu/qapi-schema.json rename to qemu/scripts/qapi-schema.json diff --git a/qemu/scripts/qapi.sh b/qemu/scripts/qapi.sh new file mode 100644 index 00000000..80fd573c --- /dev/null +++ b/qemu/scripts/qapi.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# Run this scripts to create qapi below files in root dir +# ../qapi-types.c +# ../qapi-types.h +# ../qapi-visit.c +# ../qapi-visit.h + +python scripts/qapi-types.py -h -o .. -b -i qapi-schema.json +python scripts/qapi-types.py -c -o .. -b -i qapi-schema.json + +python scripts/qapi-visit.py -h -o .. -b -i qapi-schema.json +python scripts/qapi-visit.py -c -o .. -b -i qapi-schema.json + diff --git a/qemu/qapi/common.json b/qemu/scripts/qapi/common.json similarity index 100% rename from qemu/qapi/common.json rename to qemu/scripts/qapi/common.json