libqblock qemu block layer library
v9 cover libqblock qemu block layer library
These patches introduce libqblock API, make libqblock.la and make
check-libqblock could build this library. Functionalities:
1 create a new image.
2 sync access of an image.
3 basic image information retrieving such as backing file. 4 detect if a sector is allocated in an image.
Supported Formats:
ALL using file protocols.
Patch 1 to 4 is independent with libqblock which fix and adjust
qemu to prepare for getting libqblock onboard.
v2:
Insert reserved bytes into union.
Use uint64_t instead of size_t, offset.
Use const char * in filename pointer.
Initialization function removed and it was automatically executed when
library is loaded.
Added compile flag visibility=hidden, to avoid name space pollution. Structure naming style changed.
Using byte unit instead of sector for every API.
Added a member in image static information structure, to report logical
sector size, which is always 512 now.
Read and write API can take request not aligned to 512 now. It returns the
byte number that have succeed in operation, but now either negative value or the number requested would be returned, because qemu block sync I/O API would not return such number.
Typo fix due to comments and improved documents.
v3:
Removed the code about OOM error, introduced GError.
Used a table to map from string to enum types about format.
Use typedef for every structure.
Improved the gcc compiler macro to warn if gcc was not used. Global variable name changed with prefix libqb_.
The struct QBlockStaticInfo was changed to folder full format related
information inside, and a new member with pointers pointing to the mostly used members, such as backing file, virt size, was added. This would allow the user to get full information about how it is created in the future.
Each patch in the serial can work with qemu now.
Typo fixes.
v4:
Renamed QBroker to QBlockContext.
Removed tool objs out of libqblock.
Added a check in initialization about structure size for ABI. Added a new helper API to duplicate protocol information, helps to open files
in a backing file chain.
Check-libqblock will not rebuild libqblock every time now.
Test case file renamed to "libqblock-[FMT].c".
Test use gtest framework now.
Test do random creation of test file now, added check for information API in
it.
Test do random sync io instead of fixed offset io now.
Test accept one parameter about where to place the test image, now it is
./tests/libqblock/test_images.
v5:
Makefile of libqblock was adjusted to be similar as libcacard, added spec
file and install section.
Removed warning when GCC was not found.
Structure names were changed to better ones.
Removed the union typedef that contain reserved bytes to reduce the folder
depth.
Some format related enum options was changed to better name. Added accessors about image static information, hide indirect accessing
member detail in the structure.
Test Makefile do not create diretory now, test case create it themself. Test build system do not use libtool now, and removed qtest-obj-y in its
dependency, make check will automatically execute test anyway now.
Removed "ifeq ($(LIBTOOL),)" in Makefile.
v6:
Remove address pointer member in image static info structure.
v7:
Support out of tree building.
v8:
Fix a bug in out of tree building.
v9:
Rebase and splitted out small fix patch for qemu.
Wenchao Xia (8):
Buildsystem fix distclean error in pixman Buildsystem clean tests directory clearly Buildsystem move qapi generation to Makefile.objs block export function path_has_protocol libqblock build system
libqblock type defines
libqblock API
libqblock test example
.gitignore | 2 + Makefile | 41 +- Makefile.objs | 22 + block.c | 2 +- block.h | 2 + configure | 6 +- libqblock/Makefile | 72 +++ libqblock/libqblock-error.c | 57 ++ libqblock/libqblock-error.h | 49 ++ libqblock/libqblock-internal.h | 75 +++ libqblock/libqblock-types.h | 252 ++++++++ libqblock/libqblock.c | 1191 +++++++++++++++++++++++++++++++++++++ libqblock/libqblock.h | 341 +++++++++++ libqblock/libqblock.pc.in | 13 + tests/Makefile | 36 ++- tests/libqblock/libqblock-qcow2.c | 392 ++++++++++++ 16 files changed, 2524 insertions(+), 29 deletions(-) create mode 100644 libqblock/Makefile create mode 100644 libqblock/libqblock-error.c create mode 100644 libqblock/libqblock-error.h create mode 100644 libqblock/libqblock-internal.h create mode 100644 libqblock/libqblock-types.h create mode 100644 libqblock/libqblock.c create mode 100644 libqblock/libqblock.h create mode 100644 libqblock/libqblock.pc.in create mode 100644 tests/libqblock/libqblock-qcow2.c
PATCH v9 1/8 Buildsystem fix distclean error in pixman
Currently if pixman have no config.log inside, make file still
try to clean it resulting error. This patch fix it.
--- Makefile | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
Makefile +4 -1
@@ -278,7 +278,10 @@ distclean: clean for d in $(TARGET_DIRS) $(QEMULIBS); do \ rm -rf $$d || exit 1 ; \ done - test -f pixman/config.log && make -C pixman distclean + @if test -f pixman/config.log; \ + then \ + make -C pixman distclean;\ + fi KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \ ar de en-us fi fr-be hr it lv nl pl ru th \
Signature · 1 line
1.7.1
PATCH v9 2/8 Buildsystem clean tests directory clearly
In reply to Wenchao Xia Currently make clean only clean tests/tcg and hard to extend.
This patch added command make check-clean, which clean all generated files used in tests. With this command root Makefile do not care tests clean method any more, it simply calls the command to do it, so any more clean script could be added in tests/Makefile make it easier to extend.
--- Makefile | 2 +- configure | 2 +- tests/Makefile | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-)
Makefile +1 -1
@@ -251,7 +251,7 @@ clean: rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp) rm -rf qapi-generated rm -rf qga/qapi-generated - $(MAKE) -C tests/tcg clean + MAKEFILES=./tests/Makefile $(MAKE) check-clean for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \
configure +1 -1
@@ -4163,7 +4163,7 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" -FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" +FILES="Makefile tests/Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"
tests/Makefile +7 -0
@@ -94,6 +94,7 @@ check-help: @echo " make check-unit Run qobject tests" @echo " make check-block Run block tests" @echo " make check-report.html Generates an HTML test report" + @echo " make check-clean Clean the tests" @echo @echo "Please note that HTML reports do not regenerate if the unit tests" @echo "has not changed."
@@ -148,4 +149,10 @@ check-unit: $(patsubst %,check-%, $(check-unit-y)) check-block: $(patsubst %,check-%, $(check-block-y)) check: check-unit check-qtest +check-clean: + $(MAKE) -C tests/tcg clean + rm -f $(check-unit-y) + rm -f $(check-qtest-i386-y) $(check-qtest-x86_64-y) $(check-qtest-sparc64-y) $(check-qtest-sparc-y) + rm -f tests/*.o + -include $(wildcard tests/*.d)
Signature · 1 line
1.7.1
PATCH v9 3/8 Buildsystem move qapi generation to Makefile.objs
In reply to Wenchao Xia Sub Makefile may need qapi generated files, so move them to Makefile.objs,
In this way Makfile.objs control file auto generation.
--- Makefile | 22 ---------------------- Makefile.objs | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-)
Makefile +0 -22
@@ -207,28 +207,6 @@ ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/tests/Makefile endif -qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py - -qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ -$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") -qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ -$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") -qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\ -$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") - -qapi-types.c qapi-types.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." < $<, " GEN $@") -qapi-visit.c qapi-visit.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." < $<, " GEN $@") -qmp-commands.h qmp-marshal.c :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@") - QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)
Makefile.objs +22 -0
@@ -224,6 +224,28 @@ common-obj-y += qmp.o hmp.o universal-obj-y += $(qapi-obj-y) +qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py + +qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") +qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") +qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") + +qapi-types.c qapi-types.h :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." < $<, " GEN $@") +qapi-visit.c qapi-visit.h :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." < $<, " GEN $@") +qmp-commands.h qmp-marshal.c :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@") + ###################################################################### # guest agent
Signature · 1 line
1.7.1
PATCH v9 4/8 block export function path_has_protocol
In reply to Wenchao Xia This function is needed in other module, so export it. There is
already some patch on mail-list try export it, If that patch was applied, pls ignore this one.
--- block.c | 2 +- block.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletions(-)
block.c +1 -1
@@ -199,7 +199,7 @@ static void bdrv_io_limits_intercept(BlockDriverState *bs, }/* check if the path starts with "<protocol>:" */ -static int path_has_protocol (const char *path) +int path_has_protocol (const char *path) {const char *p;
block.h +2 -0
@@ -428,6 +428,8 @@ typedef enum {BLKDBG_EVENT_MAX , } BlkDebugEvent; +int path_has_protocol (const char *path); +#define BLKDBG_EVENT (bs, evt) bdrv_debug_event(bs, evt)void bdrv_debug_event (BlockDriverState *bs,BlkDebugEvent event);
Signature · 1 line
1.7.1
PATCH v9 5/8 libqblock build system
In reply to Wenchao Xia Libqblock was placed in new directory ./libqblock, libtool will build
dynamic library there, source files of block layer remains in ./block. So block related source code will generate 3 sets of binary, first is old ones used in qemu, second and third are non PIC and PIC ones in ./libqblock.
GCC compiler flag visibility=hidden was used with special macro, to export
only symbols that was marked as PUBLIC.
For testing, make check-libqblock will build binaries and execute it, make
clean or make check-clean will delete generated binaries.
By default this library will be built and tested, out of tree building is
supported.
Header files added in configure due to install-libqblock from out of tree
build need these them.
--- .gitignore | 2 + Makefile | 12 ++++++- configure | 4 ++- libqblock/Makefile | 72 +++++++++++++++++++++++++++++++++++++ libqblock/libqblock.pc.in | 13 +++++++ tests/Makefile | 29 ++++++++++++++- tests/libqblock/libqblock-qcow2.c | 4 ++ 7 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 libqblock/Makefile create mode 100644 libqblock/libqblock-error.c create mode 100644 libqblock/libqblock-error.h create mode 100644 libqblock/libqblock-types.h create mode 100644 libqblock/libqblock.c create mode 100644 libqblock/libqblock.h create mode 100644 libqblock/libqblock.pc.in create mode 100644 tests/libqblock/libqblock-qcow2.c
.gitignore +2 -0
@@ -93,3 +93,5 @@ cscope.* tags TAGS *~ +tests/libqblock/check-* +tests/libqblock/test_images
Makefile +11 -1
@@ -189,6 +189,16 @@ qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y) qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o +###################################################################### +# Support building shared library libqblock +libqblock.la: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" libqblock.la,) + +install-libqblock: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" install-libqblock,) + +########################################################################### + vscclient$(EXESUF): $(libcacard-y) $(oslib-obj-y) $(trace-obj-y) libcacard/vscclient.o $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(libcacard_libs) $(LIBS)," LINK $@")
@@ -230,7 +240,7 @@ clean: rm -rf qapi-generated rm -rf qga/qapi-generated MAKEFILES=./tests/Makefile $(MAKE) check-clean - for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ + for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard libqblock; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \ done
configure +3 -1
@@ -3099,7 +3099,7 @@ tools="" if test "$want_tools" = "yes" ; then tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools" if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then - tools="qemu-nbd\$(EXESUF) $tools" + tools="libqblock.la qemu-nbd\$(EXESUF) $tools" fi fi if test "$softmmu" = yes ; then
@@ -4163,12 +4163,14 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" +DIRS="$DIRS libqblock tests/libqblock" FILES="Makefile tests/Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps" FILES="$FILES pc-bios/spapr-rtas/Makefile" FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile" +FILES="$FILES libqblock/Makefile libqblock/libqblock.h libqblock/libqblock-error.h libqblock/libqblock-types.h" for bios_file in \ $source_path/pc-bios/*.bin \ $source_path/pc-bios/*.rom \
libqblock/Makefile new file +72 -0
72 lines not on this page · raw message
libqblock/libqblock-error.c new file +0 -0
libqblock/libqblock-error.h new file +0 -0
libqblock/libqblock-types.h new file +0 -0
libqblock/libqblock.c new file +0 -0
libqblock/libqblock.h new file +0 -0
libqblock/libqblock.pc.in new file +13 -0
@@ -0,0 +1,13 @@ +prefix=@PREFIX@ +exec_prefix=${prefix} +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: qblock +Description: QEMU block layer library +Version: @VERSION@ + +Requires: rt gthread-2.0 glib-2.0 z curl cap-ng uuid +Libs: -L${libdir} -lqblock +Libs.private: +Cflags: -I${includedir}
tests/Makefile +28 -1
@@ -84,6 +84,22 @@ check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET) qtest-obj-y = tests/libqtest.o $(oslib-obj-y) $(check-qtest-y): $(qtest-obj-y) +#libqblock test rules + +LIBQBLOCK_TEST_DIR= tests/libqblock/test_images +LIBQBLOCK_DIR = libqblock +LIBQBLOCK_SO = $(LIBQBLOCK_DIR)/.libs/libqblock.so +LIBQBLOCK_SO_LINK_FLAG= -Wl,-rpath,$(LIBQBLOCK_DIR)/.libs + +tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -fPIE,-fPIC, $(QEMU_CFLAGS)) +tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -DPIE,-DPIC, $(QEMU_CFLAGS)) +tests/libqblock/%.o: QEMU_INCLUDES += -I$(SRC_PATH)/tests -I$(SRC_PATH)/$(LIBQBLOCK_DIR) + +check-libqblock-y = tests/libqblock/check-libqblock-qcow2$(EXESUF) + +tests/libqblock/check-libqblock-qcow2$(EXESUF): tests/libqblock/libqblock-qcow2.o $(LIBQBLOCK_SO) + $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(LIBQBLOCK_SO_LINK_FLAG)," LINK $@") + .PHONY: check-help check-help: @echo "Regression testing targets:"
@@ -94,6 +110,7 @@ check-help: @echo " make check-unit Run qobject tests" @echo " make check-block Run block tests" @echo " make check-report.html Generates an HTML test report" + @echo " make check-libqblock Run libqblock tests" @echo " make check-clean Clean the tests" @echo @echo "Please note that HTML reports do not regenerate if the unit tests"
@@ -126,6 +143,12 @@ $(patsubst %, check-report-qtest-%.xml, $(QTEST_TARGETS)): check-report-qtest-%. check-report-unit.xml: $(check-unit-y) $(call quiet-command,gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $^, "GTESTER $@") +# gtester tests with libqblock + +.PHONY: $(patsubst %, check-%, $(check-libqblock-y)) +$(patsubst %, check-%, $(check-libqblock-y)): check-%: % + $(call quiet-command, LIBQBLOCK_TEST_DIR=$(LIBQBLOCK_TEST_DIR) gtester $(GTESTER_OPTIONS) -m=$(SPEED) $*,"GTESTER $*") + # Reports and overall runs check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_TARGETS)) check-report-unit.xml
@@ -147,12 +170,16 @@ check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS)) check-unit: $(patsubst %,check-%, $(check-unit-y)) check-block: $(patsubst %,check-%, $(check-block-y)) -check: check-unit check-qtest +check-libqblock: $(patsubst %,check-%, $(check-libqblock-y)) +check: check-unit check-qtest check-libqblock check-clean: $(MAKE) -C tests/tcg clean rm -f $(check-unit-y) rm -f $(check-qtest-i386-y) $(check-qtest-x86_64-y) $(check-qtest-sparc64-y) $(check-qtest-sparc-y) rm -f tests/*.o + rm -f tests/libqblock/*.o + rm -f $(check-libqblock-y) + rm -rf $(LIBQBLOCK_TEST_DIR) -include $(wildcard tests/*.d)
tests/libqblock/libqblock-qcow2.c new file +4 -0
@@ -0,0 +1,4 @@ +int main (int argc,char **argv) +{ +return 0 ; +}
Signature · 1 line
1.7.1
PATCH v9 6/8 libqblock type defines
In reply to Wenchao Xia This patch contains type and macro defines used in APIs, one file for public
usage, one for libqblock internal usage.
--- libqblock/libqblock-internal.h | 75 ++++++++++++ libqblock/libqblock-types.h | 252 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 327 insertions(+), 0 deletions(-) create mode 100644 libqblock/libqblock-internal.h
libqblock/libqblock-internal.h new file +75 -0
@@ -0,0 +1,75 @@ +/* +* QEMU block layer library +* +* Copyright IBM, Corp. 2012 +* +* Authors: +* Wenchao Xia <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#ifndef LIBQBLOCK_INTERNAL +#define LIBQBLOCK_INTERNAL + +#include "glib.h" + +#include "block.h" +#include "block_int.h" +#include "libqblock-types.h" + +/* this file contains defines and types used inside the library. */ + +#define FUNC_FREE (p) g_free((p)) +#define FUNC_MALLOC (size) g_malloc((size)) +#define FUNC_CALLOC (nmemb, size) g_malloc0((nmemb)*(size)) +#define FUNC_STRDUP (p) g_strdup((p)) + +#define CLEAN_FREE (p) { \ + FUNC_FREE(p); \ + (p) = NULL; \ +} + +/* details should be hidden to user */ +struct QBlockState { +BlockDriverState *bdrvs; +/* internal used file name now, if it is not NULL, it means +image was opened. +*/ +char *filename; +}; + +struct QBlockContext { +/* last error */ +GError *g_error; +int err_ret;/* 1st level of error, the libqblock error number */ +int err_no;/* 2nd level of error, errno what below reports */ +}; + +/** +* QBlockStaticInfoAddr: a structure contains a set of pointer. +* +* this struct contains a set of pointer pointing to some +* property related to format or protocol. If a property is not available, +* it will be set as NULL. User could use this to get properties directly. +* +* @virt_size: virtual size, it is always not NULL. +* @backing_loc: backing file location. +* @encrypt: encryption flag. +*/ + +typedef struct QBlockStaticInfoAddr { +uint64_t *virt_size; +QBlockLocationInfo *backing_loc; +bool *encrypt; +}QBlockStaticInfoAddr ; + +#define G_LIBQBLOCK_ERROR g_libqbock_error_quark() + +static inline GQuark g_libqbock_error_quark (void ) +{ +return g_quark_from_static_string ("g-libqblock-error-quark" ); +} +#endif
libqblock/libqblock-types.h +252 -0
252 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v9 7/8 libqblock API
In reply to Wenchao Xia This patch contains the major APIs in the library. For ABI some reserved
members were used.
Important APIs:
1 QBlockContext. This structure was used to retrieve errors, every thread
must create one first.
2 QBlockState. It stands for an block image object.
3 QBlockStaticInfo. It contains static information such as location, backing
file, size.
4 Sync I/O. It is similar to C file open, read, write and close operations.
--- libqblock/libqblock-error.c | 57 ++ libqblock/libqblock-error.h | 49 ++ libqblock/libqblock.c | 1191 +++++++++++++++++++++++++++++++++++++++++++ libqblock/libqblock.h | 341 +++++++++++++ 4 files changed, 1638 insertions(+), 0 deletions(-)
libqblock/libqblock-error.c +57 -0
@@ -0,0 +1,57 @@ +/* +* QEMU block layer library +* +* Copyright IBM, Corp. 2012 +* +* Authors: +* Wenchao Xia <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2 or later. +* See the COPYING.LIB file in the top-level directory. +* +*/ + +#include "libqblock-error.h" +#include "libqblock-internal.h" + +void qb_error_get_human_str (QBlockContext *context, +char *buf,size_t buf_size) +{ +const char *err_ret_str; +switch (context->err_ret) { +case QB_ERR_INTERNAL_ERR : + err_ret_str ="Internal error." ; +break ; +case QB_ERR_INVALID_PARAM : + err_ret_str ="Invalid param." ; +break ; +case QB_ERR_BLOCK_OUT_OF_RANGE : + err_ret_str ="request is out of image's range." ; +break ; +default : + err_ret_str ="Unknown error." ; +break ; + } +if (context ==NULL ) { +snprintf (buf, buf_size,"%s" , err_ret_str); +return ; + } + +if (context->err_ret ==QB_ERR_INTERNAL_ERR ) { +snprintf (buf, buf_size,"%s %s errno [%d]. strerror [%s]." , + err_ret_str, context->g_error->message, + context->err_no,strerror (-context->err_no)); + }else { +snprintf (buf, buf_size,"%s %s" , + err_ret_str, context->g_error->message); + } +return ; +} + +int qb_error_get_errno (QBlockContext *context) +{ +if (context->err_ret ==QB_ERR_INTERNAL_ERR ) { +return context->err_no; + } +return 0 ; +}
libqblock/libqblock-error.h +49 -0
49 lines not on this page · raw message
libqblock/libqblock.c +1191 -0
1,191 lines not on this page · raw message
libqblock/libqblock.h +341 -0
341 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v9 8/8 libqblock test example
In reply to Wenchao Xia In this example, first it will create some qcow2 images, then try get
information including backing file relationship, then it will do sync IO on the image.
--- tests/libqblock/libqblock-qcow2.c | 390 ++++++++++++++++++++++++++++++++++++- 1 files changed, 389 insertions(+), 1 deletions(-)
tests/libqblock/libqblock-qcow2.c +389 -1
@@ -1,4 +1,392 @@ +/* +* QEMU block layer library test +* +* Copyright IBM, Corp. 2012 +* +* Authors: +* Wenchao Xia <[email protected]> +* +* This work is licensed under the terms of the GNU LGPL, version 2 or later. +* See the COPYING.LIB file in the top-level directory. +* +* Limitation: +* 1 filename do not support relative path, to save trouble in creating +* backing files. +*/ + +#include <glib.h> +#include <stdarg.h> +#include <stdio.h> +#include <unistd.h> +#include <inttypes.h> +#include <string.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <sys/types.h> + + +#include "libqblock.h" +#include "libqtest.h" + +#define LIBQB_TEST_ENV_DIR "LIBQBLOCK_TEST_DIR" +#define LIBQB_TEST_DEFAULT_DIR "/tmp" +#define LIBQB_TEST_DEFAULT_FILENAME "libqblock_qcow2_test_img" + +typedef struct LibqbTestSettings { +const char *image_filename; +uint64_t image_size; +unsigned int num_backings; +unsigned int io_buf_size; +uint64_t io_offset; +int print_flag; +}LibqbTestSettings ; + +LibqbTestSettings libqb_test_settings; + +static void print_loc (const QBlockLocationInfo *loc) +{ +if (loc ==NULL ) { +printf ("loc is NULL." ); +return ; + } +switch (loc->prot_type) { +case QB_PROTO_NONE : +printf ("protocol type [none]." ); +break ; +case QB_PROTO_FILE : +printf ("protocol type [file], filename [%s]." , + loc->o_file.filename); +break ; +default : +printf ("protocol type not supported." ); +break ; + } +} + +static void print_info_image_static (QBlockStaticInfo *info) +{ +const uint64_t *virt_size =qb_get_virt_size (info); +const QBlockLocationInfo *backing_loc =qb_get_backing_loc (info); +g_assert (virt_size !=NULL ); + +printf ("=======image location:\n" ); +print_loc (&info->loc); +printf ("\nvirtual_size %" PRId64", format type %d [%s]" , + *(virt_size), + info->fmt.fmt_type,qb_fmttype2str (info->fmt.fmt_type)); +printf ("\nbacking image location:\n" ); +print_loc (backing_loc); +printf ("\n" ); +} + +static char *generate_backing_filename (const char *filename,int index) +{ +char *backing_filename =NULL ; + + backing_filename =g_strdup_printf ("%s_backing_%d" , filename, index); +return backing_filename; +} + +/* get filename in a full path */ +static const char *get_filename (const char *path) +{ +const char *filename; + filename =strrchr (path,'/' ); +if (filename ==NULL ) { + filename = path; + }else { + filename++; + } +return filename; +} + +/* create a chain of files, num_backings must >= 0. */ +static void files_create_qcow2 (const char *filename, +int num_backings, +uint64_t virt_size) +{ +QBlockContext *context =NULL ; +QBlockState *qbs =NULL ; +QBlockLocationInfo *loc_info =NULL ; +QBlockFormatInfo *fmt_info =NULL ; +int ret; +int index; +int flag; +char *backing_filename =NULL , *new_filename =NULL ; +const char *relative_filename =NULL ; + + ret =qb_context_new (&context); +g_assert (ret ==0 ); + + ret =qb_state_new (context, &qbs); +g_assert (ret ==0 ); + + ret =qb_loc_info_new (context, &loc_info); +g_assert (ret ==0 ); + + ret =qb_fmt_info_new (context, &fmt_info); +g_assert (ret ==0 ); + + loc_info->prot_type =QB_PROTO_FILE ; + fmt_info->fmt_type =QB_FMT_QCOW2 ; + fmt_info->o_qcow2.virt_size = virt_size; + flag =0 ; + + index =0 ; +while (index < num_backings) { + new_filename =generate_backing_filename (filename, index); + loc_info->o_file.filename = new_filename; +if (backing_filename !=NULL ) { + fmt_info->o_qcow2.backing_loc.prot_type =QB_PROTO_FILE ; + relative_filename =get_filename (backing_filename); + fmt_info->o_qcow2.backing_loc.o_file.filename = + relative_filename; + } + ret =qb_create (context, qbs, loc_info, fmt_info, flag); +g_assert (ret ==0 ); +free (backing_filename); + backing_filename = new_filename; + new_filename =NULL ; + index++; + } + + loc_info->o_file.filename = filename; +if (backing_filename !=NULL ) { + fmt_info->o_qcow2.backing_loc.prot_type =QB_PROTO_FILE ; + relative_filename =get_filename (backing_filename); + fmt_info->o_qcow2.backing_loc.o_file.filename = + relative_filename; + } + ret =qb_create (context, qbs, loc_info, fmt_info, flag); +g_assert (ret ==0 ); +free (backing_filename); + +qb_fmt_info_delete (context, &fmt_info); +qb_loc_info_delete (context, &loc_info); +qb_state_delete (context, &qbs); +qb_context_delete (&context); +return ; +} + +static void files_delete (const char *filename, +int num_backings, +uint64_t virt_size) +{ +char *new_filename =NULL ; +int index =0 ; +while (index < num_backings) { + new_filename =generate_backing_filename (filename, index); +unlink (new_filename); +free (new_filename); + index++; + } +unlink (filename); +} + +static void testcase_info_image_static (void ) +{ +const char *filename = libqb_test_settings.image_filename; +uint64_t image_size = libqb_test_settings.image_size; +int num_backings = libqb_test_settings.num_backings; +QBlockContext *context =NULL ; +QBlockState *qbs =NULL ; +QBlockLocationInfo *loc_info =NULL ; +int ret, flag; +QBlockStaticInfo *info_st =NULL ; +int i; +char *backing_filename =NULL ; +const uint64_t *virt_size =NULL ; +const QBlockLocationInfo *backing_loc =NULL ; + + ret =qb_context_new (&context); +g_assert (ret ==0 ); + + ret =qb_state_new (context, &qbs); +g_assert (ret ==0 ); + + ret =qb_loc_info_new (context, &loc_info); +g_assert (ret ==0 ); + + loc_info->prot_type =QB_PROTO_FILE ; + loc_info->o_file.filename = filename; + flag =LIBQBLOCK_O_NO_BACKING ; + ret =qb_open (context, qbs, loc_info,NULL , flag); +g_assert (ret ==0 ); + + i = num_backings -1 ; +while (1 ) { + ret =qb_info_image_static_get (context, qbs, &info_st); +g_assert (ret ==0 ); +if (libqb_test_settings.print_flag >0 ) { +print_info_image_static (info_st); + } +qb_close (context, qbs); + +/* checking the information */ +g_assert (info_st->loc.prot_type == loc_info->prot_type); + ret =strcmp (info_st->loc.o_file.filename, + loc_info->o_file.filename); + +g_assert (ret ==0 ); +g_assert (info_st->fmt.fmt_type ==QB_FMT_QCOW2 ); + virt_size =qb_get_virt_size (info_st); +g_assert (virt_size !=NULL ); +g_assert (*virt_size == image_size); + backing_loc =qb_get_backing_loc (info_st); +/* qcow2 have always backing file property */ +g_assert (backing_loc !=NULL ); +if (i >=0 ) { +/* it should have backing file */ +g_assert (backing_loc->prot_type ==QB_PROTO_FILE ); + backing_filename =generate_backing_filename (filename, i); + ret =strcmp (backing_filename, backing_loc->o_file.filename); +g_assert (ret ==0 ); +g_free (backing_filename); + }else { +g_assert (backing_loc->prot_type ==QB_FMT_NONE ); + } + i--; +/* see if there is backing file need to check. */ +if (backing_loc->prot_type ==QB_FMT_NONE ) { +g_assert (i <0 ); +break ; + } +qb_loc_info_delete (context, &loc_info); + loc_info =qb_loc_info_dup (backing_loc); + ret =qb_open (context, qbs, loc_info,NULL , flag); +g_assert (ret ==0 ); +qb_info_image_static_delete (context, &info_st); + } +qb_info_image_static_delete (context, &info_st); + +qb_loc_info_delete (context, &loc_info); +qb_state_delete (context, &qbs); +qb_context_delete (&context); +return ; +} + +/* assuming the image is new created */ +static void testcase_sync_io (void ) +{ +const char *filename = libqb_test_settings.image_filename; +uint64_t io_buf_size = libqb_test_settings.io_buf_size; +uint64_t io_offset = libqb_test_settings.io_offset;; +unsigned char *buf_r, *buf_w; +uint64_t i; +unsigned int rand_value; + + buf_r =g_malloc0 (io_buf_size); + buf_w =g_malloc0 (io_buf_size); +for (i =0 ; i < io_buf_size; i++) { + rand_value =g_test_rand_int_range (0 ,255 ); + buf_w[i] = (unsigned char )rand_value; + } + +QBlockContext *context =NULL ; +QBlockState *qbs =NULL ; +QBlockLocationInfo *loc_info =NULL ; +int ret, flag; + + ret =qb_context_new (&context); +g_assert (ret ==0 ); + + ret =qb_state_new (context, &qbs); +g_assert (ret ==0 ); + + ret =qb_loc_info_new (context, &loc_info); +g_assert (ret ==0 ); + + + loc_info->prot_type =QB_PROTO_FILE ; + loc_info->o_file.filename = filename; + flag =LIBQBLOCK_O_RDWR ; + ret =qb_open (context, qbs, loc_info,NULL , flag); +g_assert (ret ==0 ); + +int status; +int64_t len; + ret =qb_check_allocation (context, qbs, io_offset, io_buf_size, + &status, &len); +g_assert (ret ==0 ); +g_assert (status ==0 ); +g_assert (len == io_buf_size); + + ret =qb_write (context, qbs, buf_w, io_buf_size, io_offset); +g_assert (ret == io_buf_size); + + ret =qb_read (context, qbs, buf_r, io_buf_size, io_offset); +g_assert (ret == io_buf_size); + +int cmp =memcmp (buf_r, buf_w, io_buf_size); +g_assert (cmp ==0 ); + + ret =qb_check_allocation (context, qbs, io_offset, io_buf_size, + &status, &len); +g_assert (ret ==0 ); +g_assert (status ==1 ); +g_assert (len == io_buf_size); + +qb_close (context, qbs); + +qb_loc_info_delete (context, &loc_info); +qb_state_delete (context, &qbs); +qb_context_delete (&context); +g_free (buf_r); +g_free (buf_w); +return ; +} +int main (int argc,char **argv) { -return 0 ; +const char *root_dir; +const char *name =LIBQB_TEST_DEFAULT_FILENAME ; +int ret; +int dir_created =0 ; +char *filename; + + root_dir =getenv (LIBQB_TEST_ENV_DIR ); +if (root_dir ==NULL ) { + root_dir =LIBQB_TEST_DEFAULT_DIR ; + } + + ret =access (root_dir,F_OK ); +if (ret !=0 ) { +/*try mkdir */ + ret =mkdir (root_dir,0755 ); +g_assert (ret ==0 ); + dir_created =1 ; + } + + filename =g_strdup_printf ("%s/%s" , root_dir, name); + +g_test_init (&argc, &argv,NULL ); +g_test_rand_int (); + + libqb_test_settings.image_filename = filename; + libqb_test_settings.image_size = +1024 *1024 *g_test_rand_int_range (1 ,1024 ); + libqb_test_settings.num_backings =g_test_rand_int_range (0 ,10 ); + libqb_test_settings.io_buf_size =g_test_rand_int_range (1 ,1024 *1024 ); + libqb_test_settings.io_offset =g_test_rand_int_range (0 , + libqb_test_settings.image_size - libqb_test_settings.io_buf_size); + +files_create_qcow2 (libqb_test_settings.image_filename, + libqb_test_settings.num_backings, + libqb_test_settings.image_size); + +g_test_add_func ("/libqblock/sync_info_image_static" , + testcase_info_image_static); +g_test_add_func ("/libqblock/sync_io" , testcase_sync_io); + + ret =g_test_run (); +files_delete (libqb_test_settings.image_filename, + libqb_test_settings.num_backings, + libqb_test_settings.image_size); + +g_free (filename); +if (dir_created) { + ret =rmdir (root_dir); +g_assert (ret ==0 ); + } +return ret; }
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
In reply to Wenchao XiaQuoted 19 lines · Wenchao Xia
Currently make clean only clean tests/tcg and hard to extend.
This patch added command make check-clean, which clean all generated files used in tests. With this command rootMakefiledo not care tests clean method any more, it simply calls the command to do it, so any more clean script could be added in tests/Makefile make it easier to extend.Signed-off-by Wenchao Xia <[email protected]>--- Makefile | 2 +- configure | 2 +- tests/Makefile | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-)Makefile +0
-0
Makefile clean: · line 254
Quoted 5 lines
Makefile +1
-1@@ -251,7 +251,7 @@ clean: rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp) rm -rf qapi-generated rm -rf qga/qapi-generated - $(MAKE) -C tests/tcg clean + MAKEFILES=./tests/Makefile $(MAKE) check-clean
tests/Makefile is directly included by the top level makefile, so there's no need to reinvoke make here. You should be able to just make check-clean a dependency of the clean target here.
Quoted 29 lines
Makefile +0
-0for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \configure +1
-1@@ -4163,7 +4163,7 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" -FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" +FILES="Makefile tests/Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"tests/Makefile +1
-0@@ -94,6 +94,7 @@ check-help: @echo " make check-unit Run qobject tests" @echo " make check-block Run block tests" @echo " make check-report.html Generates an HTML test report" + @echo " make check-clean Clean the tests" @echo @echo "Please note that HTML reports do not regenerate if the unit tests" @echo "has not changed."
tests/Makefile check-unit: $(patsubst %,check-%, $(check-unit-y)) · line 155
Quoted 7 lines
tests/Makefile +4
-0@@ -148,4 +149,10 @@ check-unit: $(patsubst %,check-%, $(check-unit-y)) check-block: $(patsubst %,check-%, $(check-block-y)) check: check-unit check-qtest +check-clean: + $(MAKE) -C tests/tcg clean + rm -f $(check-unit-y) + rm -f $(check-qtest-i386-y) $(check-qtest-x86_64-y) $(check-qtest-sparc64-y) $(check-qtest-sparc-y)
Overlong line.
-- PMM
Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Wenchao Xia
Currently make clean only clean tests/tcg and hard to extend.
This patch added command make check-clean, which clean all generated files used in tests. With this command rootMakefiledo not care tests clean method any more, it simply calls the command to do it, so any more clean script could be added in tests/Makefile make it easier to extend.Signed-off-by Wenchao Xia <[email protected]>--- Makefile | 2 +- configure | 2 +- tests/Makefile | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-)
Quoted 15 lines
Makefile clean: · line 254
Quoted 10 lines
Makefile +1
-1@@ -251,7 +251,7 @@ clean: rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp) rm -rf qapi-generated rm -rf qga/qapi-generated - $(MAKE) -C tests/tcg clean + MAKEFILES=./tests/Makefile $(MAKE) check-cleantests/Makefile is directly included by the top level makefile, so there's no need to reinvoke make here. You should be able to just make check-clean a dependency of the clean target here.
if make destclean is executed, that tests/Makefile is not include
any more for a condition in root Makefile, change that condition may bring extra trouble, MAKEFILES= is added to work around it.
Quoted 32 lines
Quoted 32 lines
Makefile +0
-0for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \configure +1
-1@@ -4163,7 +4163,7 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" -FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" +FILES="Makefile tests/Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"tests/Makefile +1
-0@@ -94,6 +94,7 @@ check-help: @echo " make check-unit Run qobject tests" @echo " make check-block Run block tests" @echo " make check-report.html Generates an HTML test report" + @echo " make check-clean Clean the tests" @echo @echo "Please note that HTML reports do not regenerate if the unit tests" @echo "has not changed."@@ -148,4 +149,10 @@ check-unit: $(patsubst %,check-%, $(check-unit-y)) check-block: $(patsubst %,check-%, $(check-block-y)) check: check-unit check-qtest
Quoted 9 lines
tests/Makefile check-unit: $(patsubst %,check-%, $(check-unit-y)) · line 155
Quoted 4 lines
tests/Makefile +4
-0+check-clean: + $(MAKE) -C tests/tcg clean + rm -f $(check-unit-y) + rm -f $(check-qtest-i386-y) $(check-qtest-x86_64-y) $(check-qtest-sparc64-y) $(check-qtest-sparc-y)Overlong line.
-- PMM
ok.
Signature · 3 lines
Best Regards Wenchao Xia
Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
In reply to Wenchao XiaIl 16/11/2012 11:12, Wenchao Xia ha scritto:
Quoted 2 lines
Sub
Makefilemay need qapi generated files, so move them to Makefile.objs,
In this way Makfile.objs control file auto generation.
No objection in principle, but why are you doing this? Does it fix anything?
Paolo
Quoted 73 lines
Signed-off-by Wenchao Xia <[email protected]>--- Makefile | 22 ---------------------- Makefile.objs | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-)Makefile +0
-22@@ -207,28 +207,6 @@ ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/tests/Makefile endif -qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py - -qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ -$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") -qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ -$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") -qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\ -$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") - -qapi-types.c qapi-types.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." < $<, " GEN $@") -qapi-visit.c qapi-visit.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." < $<, " GEN $@") -qmp-commands.h qmp-marshal.c :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@") - QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)Makefile.objs +22
-0@@ -224,6 +224,28 @@ common-obj-y += qmp.o hmp.o universal-obj-y += $(qapi-obj-y) +qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py + +qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") +qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") +qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") + +qapi-types.c qapi-types.h :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." < $<, " GEN $@") +qapi-visit.c qapi-visit.h :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." < $<, " GEN $@") +qmp-commands.h qmp-marshal.c :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@") + ###################################################################### # guest agent
Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
In reply to Wenchao XiaIl 16/11/2012 11:31, Wenchao Xia ha scritto:
Quoted 32 lines
Quoted 16 lines · Peter Maydell
Quoted 14 lines · Wenchao Xia
Currently make clean only clean tests/tcg and hard to extend.
This patch added command make check-clean, which clean all generated files used in tests. With this command rootMakefiledo not care tests clean method any more, it simply calls the command to do it, so any more clean script could be added in tests/Makefile make it easier to extend.Signed-off-by Wenchao Xia <[email protected]>--- Makefile | 2 +- configure | 2 +- tests/Makefile | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-)Quoted 15 lines
Makefile clean: · line 254
Quoted 10 lines
Makefile +1
-1@@ -251,7 +251,7 @@ clean: rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp) rm -rf qapi-generated rm -rf qga/qapi-generated - $(MAKE) -C tests/tcg clean + MAKEFILES=./tests/Makefile $(MAKE) check-cleantests/Makefile is directly included by the top level makefile, so there's no need to reinvoke make here. You should be able to just make check-clean a dependency of the clean target here.
Quoted 3 lines
if make destclean is executed, that tests/Makefile is not include
any more for a condition in rootMakefile, change that condition may bring extra trouble, MAKEFILES= is added to work around it.
Does it work if you change
ifneq ($(wildcard config-host.mak),)
include $(SRC_PATH)/tests/Makefile
endif
to
-include $(SRC_PATH)/tests/Makefile
?
Paolo
Quoted 49 lines
Quoted 43 lines
Quoted 32 lines
Makefile +0
-0for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \configure +1
-1@@ -4163,7 +4163,7 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" -FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" +FILES="Makefile tests/Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"tests/Makefile +0
-0@@ -94,6 +94,7 @@ check-help: @echo " make check-unit Run qobject tests" @echo " make check-block Run block tests" @echo " make check-report.html Generates an HTML testreport"
+ @echo " make check-clean Clean the tests"
@echo
@echo "Please note that HTML reports do not regenerate if
the unit tests"
@echo "has not changed."tests/Makefile check-unit: $(patsubst %,check-%, $(check-unit-y)) · line 156
Quoted 8 lines
tests/Makefile +4
-0@@ -148,4 +149,10 @@ check-unit: $(patsubst %,check-%, $(check-unit-y)) check-block: $(patsubst %,check-%, $(check-block-y)) check: check-unit check-qtest +check-clean: + $(MAKE) -C tests/tcg clean + rm -f $(check-unit-y) + rm -f $(check-qtest-i386-y) $(check-qtest-x86_64-y) $(check-qtest-sparc64-y) $(check-qtest-sparc-y)Overlong line.
Quoted 2 lines
-- PMM
ok.
Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
In reply to Paolo BonziniQuoted 9 lines · Paolo Bonzini
Il 16/11/2012 11:12, Wenchao Xia ha scritto:
Quoted 2 lines
Sub
Makefilemay need qapi generated files, so move them to Makefile.objs,
In this way Makfile.objs control file auto generation.No objection in principle, but why are you doing this? Does it fix anything?
Paolo
It seems tools or block objects files are depending on qapi files,
and libqblock needs tools. So without it out of tree build of libqblock would fail.
Quoted 74 lines
Quoted 73 lines
Signed-off-by Wenchao Xia <[email protected]>--- Makefile | 22 ---------------------- Makefile.objs | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-)Makefile +0
-22@@ -207,28 +207,6 @@ ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/tests/Makefile endif -qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py - -qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ -$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") -qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ -$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") -qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\ -$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") - -qapi-types.c qapi-types.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." < $<, " GEN $@") -qapi-visit.c qapi-visit.h :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." < $<, " GEN $@") -qmp-commands.h qmp-marshal.c :\ -$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@") - QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN)Makefile.objs +22
-0@@ -224,6 +224,28 @@ common-obj-y += qmp.o hmp.o universal-obj-y += $(qapi-obj-y) +qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py + +qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") +qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") +qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o qga/qapi-generated -p "qga-" < $<, " GEN $@") + +qapi-types.c qapi-types.h :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." < $<, " GEN $@") +qapi-visit.c qapi-visit.h :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." < $<, " GEN $@") +qmp-commands.h qmp-marshal.c :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." < $<, " GEN $@") + ###################################################################### # guest agent
Signature · 3 lines
Best Regards Wenchao Xia
Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
In reply to Paolo BonziniQuoted 43 lines · Paolo Bonzini
Il 16/11/2012 11:31, Wenchao Xia ha scritto:
Quoted 32 lines
Quoted 16 lines · Peter Maydell
Quoted 14 lines · Wenchao Xia
Currently make clean only clean tests/tcg and hard to extend.
This patch added command make check-clean, which clean all generated files used in tests. With this command rootMakefiledo not care tests clean method any more, it simply calls the command to do it, so any more clean script could be added in tests/Makefile make it easier to extend.Signed-off-by Wenchao Xia <[email protected]>--- Makefile | 2 +- configure | 2 +- tests/Makefile | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-)Quoted 15 lines
Makefile clean: · line 254
Quoted 10 lines
Makefile +1
-1@@ -251,7 +251,7 @@ clean: rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp) rm -rf qapi-generated rm -rf qga/qapi-generated - $(MAKE) -C tests/tcg clean + MAKEFILES=./tests/Makefile $(MAKE) check-cleantests/Makefile is directly included by the top level makefile, so there's no need to reinvoke make here. You should be able to just make check-clean a dependency of the clean target here.
Quoted 3 lines
if make destclean is executed, that tests/Makefile is not include
any more for a condition in rootMakefile, change that condition may bring extra trouble, MAKEFILES= is added to work around it.Does it work if you change
ifneq ($(wildcard config-host.mak),)
include $(SRC_PATH)/tests/Makefile
endif
Quoted 8 lines
to
-include $(SRC_PATH)/tests/Makefile
?
Paolo
yes, but original author seems not include tests/Makefile in
this condition on purpose, so using MAKEFILES to keep it unchanged.
Quoted 50 lines
Quoted 49 lines
Quoted 43 lines
Quoted 32 lines
Makefile +0
-0for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \configure +1
-1@@ -4163,7 +4163,7 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" -FILES="Makefile tests/tcg/Makefile qdict-test-data.txt" +FILES="Makefile tests/Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps"tests/Makefile +0
-0@@ -94,6 +94,7 @@ check-help: @echo " make check-unit Run qobject tests" @echo " make check-block Run block tests" @echo " make check-report.html Generates an HTML testreport"
+ @echo " make check-clean Clean the tests"
@echo
@echo "Please note that HTML reports do not regenerate if
the unit tests"
@echo "has not changed."tests/Makefile check-unit: $(patsubst %,check-%, $(check-unit-y)) · line 156
Quoted 8 lines
tests/Makefile +4
-0@@ -148,4 +149,10 @@ check-unit: $(patsubst %,check-%, $(check-unit-y)) check-block: $(patsubst %,check-%, $(check-block-y)) check: check-unit check-qtest +check-clean: + $(MAKE) -C tests/tcg clean + rm -f $(check-unit-y) + rm -f $(check-qtest-i386-y) $(check-qtest-x86_64-y) $(check-qtest-sparc64-y) $(check-qtest-sparc-y)Overlong line.
Quoted 2 lines
-- PMM
ok.
Signature · 3 lines
Best Regards Wenchao Xia
Re: [Qemu-devel] [PATCH V9 5/8] libqblock build system
In reply to Wenchao XiaIl 16/11/2012 11:12, Wenchao Xia ha scritto:
Quoted 4 lines
Libqblock was placed in new directory ./libqblock, libtool will build
dynamic library there, source files of block layer remains in ./block. So block related source code will generate 3 sets of binary, first is old ones used in qemu, second and third are non PIC and PIC ones in ./libqblock.
Quoted 8 lines
GCC compiler flag visibility=hidden was used with special macro, to export
only symbols that was marked as PUBLIC.
For testing, make check-libqblock will build binaries and execute it, make
clean or make check-clean will delete generated binaries.
By default this library will be built and tested, out of tree building is
supported.
Header files added in configure due to install-libqblock from out of tree
build need these them.
Use $(SRC_PATH) instead in the install rules.
Quoted 35 lines
Signed-off-by Wenchao Xia <[email protected]>--- .gitignore | 2 + Makefile | 12 ++++++- configure | 4 ++- libqblock/Makefile | 72 +++++++++++++++++++++++++++++++++++++ libqblock/libqblock.pc.in | 13 +++++++ tests/Makefile | 29 ++++++++++++++- tests/libqblock/libqblock-qcow2.c | 4 ++ 7 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 libqblock/Makefile create mode 100644 libqblock/libqblock-error.c create mode 100644 libqblock/libqblock-error.h create mode 100644 libqblock/libqblock-types.h create mode 100644 libqblock/libqblock.c create mode 100644 libqblock/libqblock.h create mode 100644 libqblock/libqblock.pc.in create mode 100644 tests/libqblock/libqblock-qcow2.c.gitignore +2
-0@@ -93,3 +93,5 @@ cscope.* tags TAGS *~ +tests/libqblock/check-* +tests/libqblock/test_imagesMakefile +0
-0
Makefile qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y) · line 198
Quoted 10 lines
Makefile +7
-0@@ -189,6 +189,16 @@ qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y) qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o +###################################################################### +# Support building shared library libqblock +libqblock.la: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" libqblock.la,) + +install-libqblock: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" install-libqblock,)
Who calls install-libqblock?
Quoted 19 lines
Makefile +3
-1+########################################################################### + vscclient$(EXESUF): $(libcacard-y) $(oslib-obj-y) $(trace-obj-y) libcacard/vscclient.o $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(libcacard_libs) $(LIBS)," LINK $@")@@ -230,7 +240,7 @@ clean: rm -rf qapi-generated rm -rf qga/qapi-generated MAKEFILES=./tests/Makefile $(MAKE) check-clean - for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ + for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard libqblock; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \ doneconfigure +0
-0
configure tools="" · line 3102
Quoted 5 lines
configure +1
-1@@ -3099,7 +3099,7 @@ tools="" if test "$want_tools" = "yes" ; then tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools" if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then - tools="qemu-nbd\$(EXESUF) $tools" + tools="libqblock.la qemu-nbd\$(EXESUF) $tools"
Why make this conditional? (Rather, it should be conditional on the presence of libtool).
Also, perhaps a separate --enable/disable-libqblock switch is better. It simplifies testing, at least.
Quoted 5 lines
configure +0
-0fi fi if test "$softmmu" = yes ; then@@ -4163,12 +4163,14 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios"
configure DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" · line 4173
Quoted 10 lines
configure +2
-0DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" +DIRS="$DIRS libqblock tests/libqblock" FILES="Makefile tests/Makefile tests/tcg/Makefile qdict-test-data.txt" FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps" FILES="$FILES pc-bios/spapr-rtas/Makefile" FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile" +FILES="$FILES libqblock/Makefile libqblock/libqblock.h libqblock/libqblock-error.h libqblock/libqblock-types.h"
See above.
Quoted 16 lines
configure +0
-0for bios_file in \ $source_path/pc-bios/*.bin \ $source_path/pc-bios/*.rom \libqblock/Makefile new file +7
-0@@ -0,0 +1,72 @@ +########################################################################### +# libqblock Makefile +# Todo: +# 1 trace related files is generated in this directory, move +# them to the root directory. +########################################################################## +-include ../config-host.mak
libqblock/Makefile line 17
Quoted 10 lines
libqblock/Makefile new file +10
-0+-include $(SRC_PATH)/Makefile.objs +-include $(SRC_PATH)/rules.mak + +############################################################################# +# Library settings +############################################################################# +$(call set-vpath, $(SRC_PATH)) + +#expand the foldered vars,especially ./block +dummy := $(call unnest-vars)
This should be done by Makefile.objs already.
libqblock/Makefile line 24
Quoted 6 lines
libqblock/Makefile new file +6
-0+#library objects +libqblock-y=libqblock/libqblock.o libqblock/libqblock-error.o +tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \ + qemu-timer-common.o main-loop.o notify.o \ + iohandler.o cutils.o iov.o async.o +tools-obj-$(CONFIG_POSIX) += compatfd.o
Are all of these really needed? (In fact, after some of the recent changes none of these should be needed).
Quoted 86 lines
libqblock/Makefile new file +47
-0+ +QEMU_OBJS= $(libqblock-y) $(block-obj-y) $(tools-obj-y) +QEMU_OBJS_LIB=$(patsubst %.o, %.lo, $(QEMU_OBJS)) + +QEMU_CFLAGS+= -I$(SRC_PATH) -I$(SRC_PATH)/include -I../ +#adding magic macro define for symbol hiding and exposing +QEMU_CFLAGS+= -fvisibility=hidden -D LIBQB_BUILD + +#dependency libraries +LIBS+=-lz $(LIBS_TOOLS) + +#header files to be installed +libqblock-pub-headers=libqblock.h libqblock-types.h libqblock-error.h +libqblock_includedir=$(includedir)/qblock +libqblock_srcpath=$(SRC_PATH)/libqblock + +################################################################# +# Runtime rules +################################################################# +clean: + rm -f *.lo *.o *.d *.la libqblock-test trace.c trace.c-timestamp *.pc + rm -rf .libs block trace audio fsdev hw net qapi qga qom slirp ui libqblock + +all: libqblock.la libqblock.pc +# Dummy command so that make thinks it has done something + @true + +libqblock.la: $(QEMU_OBJS_LIB) + $(call quiet-command,$(LIBTOOL) --mode=link --quiet --tag=CC $(CC) -rpath $(libdir) -o $@ $^ $(LIBS)," lt LINK $@") + +libqblock.pc: $(libqblock_srcpath)/libqblock.pc.in + $(call quiet-command,sed -e 's|@LIBDIR@|$(libdir)|' \ + -e 's|@INCLUDEDIR@|$(libqblock_includedir)|' \ + -e 's|@VERSION@|$(shell cat $(SRC_PATH)/VERSION)|' \ + -e 's|@PREFIX@|$(prefix)|' \ + < $(libqblock_srcpath)/libqblock.pc.in > libqblock.pc,\ + " GEN $@") + +.PHONY: install-libqblock + +install-libqblock: libqblock.la libqblock.pc + $(INSTALL_DIR) "$(DESTDIR)$(libdir)" + $(INSTALL_DIR) "$(DESTDIR)$(libdir)/pkgconfig" + $(INSTALL_DIR) "$(DESTDIR)$(libqblock_includedir)" + $(LIBTOOL) --mode=install $(INSTALL_DATA) libqblock.la "$(DESTDIR)$(libdir)" + $(LIBTOOL) --mode=install $(INSTALL_DATA) libqblock.pc "$(DESTDIR)$(libdir)/pkgconfig" + $(LIBTOOL) --mode=install $(INSTALL_DATA) $(libqblock-pub-headers) "$(DESTDIR)$(libqblock_includedir)"libqblock/libqblock-error.c new file +0
-0libqblock/libqblock-error.h new file +0
-0libqblock/libqblock-types.h new file +0
-0libqblock/libqblock.c new file +0
-0libqblock/libqblock.h new file +0
-0libqblock/libqblock.pc.in new file +13
-0@@ -0,0 +1,13 @@ +prefix=@PREFIX@ +exec_prefix=${prefix} +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: qblock +Description: QEMU block layer library +Version: @VERSION@ + +Requires: rt gthread-2.0 glib-2.0 z curl cap-ng uuid +Libs: -L${libdir} -lqblock +Libs.private: +Cflags: -I${includedir}tests/Makefile +0
-0
tests/Makefile check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET) · line 92
Quoted 9 lines
tests/Makefile +6
-0@@ -84,6 +84,22 @@ check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET) qtest-obj-y = tests/libqtest.o $(oslib-obj-y) $(check-qtest-y): $(qtest-obj-y) +#libqblock test rules + +LIBQBLOCK_TEST_DIR= tests/libqblock/test_images +LIBQBLOCK_DIR = libqblock +LIBQBLOCK_SO = $(LIBQBLOCK_DIR)/.libs/libqblock.so +LIBQBLOCK_SO_LINK_FLAG= -Wl,-rpath,$(LIBQBLOCK_DIR)/.libs
Not portable. Please use libtool to link the program:
LTLINK = $(call quiet-command,$(LIBTOOL) --mode=link --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(sort $(1)) $(LIBS),"lt LINK $(TARGET_DIR)$@")
and then
$(check-libqblock-y): %$(EXESUF): %.o
$(call LTLINK,$^)
tests/Makefile check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET) · line 95
Quoted 2 lines
tests/Makefile +2
-0+tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -fPIE,-fPIC, $(QEMU_CFLAGS)) +tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -DPIE,-DPIC, $(QEMU_CFLAGS))
Why?
A hint: if you have to do something that is not done anywhere else in the tree, do not do it.
tests/Makefile check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET) · line 98
Quoted 3 lines
tests/Makefile +3
-0+tests/libqblock/%.o: QEMU_INCLUDES += -I$(SRC_PATH)/tests -I$(SRC_PATH)/$(LIBQBLOCK_DIR) + +check-libqblock-y = tests/libqblock/check-libqblock-qcow2$(EXESUF)
Please use something like check-libqblock-$(CONFIG_LIBQBLOCK) so that it works even if libqblock is not compiled in.
Also, I'm not sure we need a completely separate subdirectory for one file only. You can just use
$(check-libqblock-y): QEMU_INCLUDES += ...
Paolo
Quoted 56 lines
tests/Makefile +15
-1+tests/libqblock/check-libqblock-qcow2$(EXESUF): tests/libqblock/libqblock-qcow2.o $(LIBQBLOCK_SO) + $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(LIBQBLOCK_SO_LINK_FLAG)," LINK $@") + .PHONY: check-help check-help: @echo "Regression testing targets:"@@ -94,6 +110,7 @@ check-help: @echo " make check-unit Run qobject tests" @echo " make check-block Run block tests" @echo " make check-report.html Generates an HTML test report" + @echo " make check-libqblock Run libqblock tests" @echo " make check-clean Clean the tests" @echo @echo "Please note that HTML reports do not regenerate if the unit tests"@@ -126,6 +143,12 @@ $(patsubst %, check-report-qtest-%.xml, $(QTEST_TARGETS)): check-report-qtest-%. check-report-unit.xml: $(check-unit-y) $(call quiet-command,gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $^, "GTESTER $@") +# gtester tests with libqblock + +.PHONY: $(patsubst %, check-%, $(check-libqblock-y)) +$(patsubst %, check-%, $(check-libqblock-y)): check-%: % + $(call quiet-command, LIBQBLOCK_TEST_DIR=$(LIBQBLOCK_TEST_DIR) gtester $(GTESTER_OPTIONS) -m=$(SPEED) $*,"GTESTER $*") + # Reports and overall runs check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_TARGETS)) check-report-unit.xml@@ -147,12 +170,16 @@ check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS)) check-unit: $(patsubst %,check-%, $(check-unit-y)) check-block: $(patsubst %,check-%, $(check-block-y)) -check: check-unit check-qtest +check-libqblock: $(patsubst %,check-%, $(check-libqblock-y)) +check: check-unit check-qtest check-libqblock check-clean: $(MAKE) -C tests/tcg clean rm -f $(check-unit-y) rm -f $(check-qtest-i386-y) $(check-qtest-x86_64-y) $(check-qtest-sparc64-y) $(check-qtest-sparc-y) rm -f tests/*.o + rm -f tests/libqblock/*.o + rm -f $(check-libqblock-y) + rm -rf $(LIBQBLOCK_TEST_DIR) -include $(wildcard tests/*.d)tests/libqblock/libqblock-qcow2.c new file +4
-0@@ -0,0 +1,4 @@ +int main (int argc,char **argv) +{ +return 0 ; +}
Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
In reply to Wenchao XiaIl 16/11/2012 11:58, Wenchao Xia ha scritto:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Sub
Makefilemay need qapi generated files, so move them to
Makefile.objs,
In this way Makfile.objs control file auto generation.No objection in principle, but why are you doing this? Does it fix anything?
It seems tools or block objects files are depending on qapi files,
Yes, block files are.
Quoted 2 lines
and libqblock needs tools. So without it out of tree build of libqblock would fail.
The effect of this patch is to include the rules in libqblock's own Makefile.
libqblock indeed needs to compile these files to .lo. However, regeneration of the C source code and header shouldn't be needed there.
I think you're missing a dependency in the toplevel Makefile's
"libqblock.la" rule.
By the way, do not name that rule "libqblock.la". It doesn't build libqblock.la, it builds libqblock/libqblock.la. Instead, name it subdir-libqblock.
Paolo
Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
In reply to Wenchao XiaIl 16/11/2012 12:01, Wenchao Xia ha scritto:
Quoted 6 lines
Quoted 6 lines
ifneq ($(wildcard config-host.mak),)
include $(SRC_PATH)/tests/Makefile
endif
Quoted 8 lines
Quoted 6 lines
to
-include $(SRC_PATH)/tests/Makefile
?
yes, but original author seems not include tests/Makefile in
this condition on purpose, so using MAKEFILES to keep it unchanged.
git blame tells you that the ifneq was added by commit e454e2e (Makefile: Exclude tests/Makefile in unconfigured tree, 2012-01-17).
Instead of the ifneq, I proposed to use a minus in front of the include directive. It will avoid failures if tests/Makefile does not exist. However, it is not very good because it will cause /tests/Makefile to be opened (see the commit message of e454e2e).
Perhaps an even better way to avoid the problem would be this: just move the removal of makefile fragments to the _end_ of "make distclean":
Makefile +2 -4
@@ -203,9 +203,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated gen-out-type = $(subst .,-,$(suffix $@)) -ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/tests/Makefile -endif qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
@@ -265,8 +263,7 @@ qemu-%.tar.bz2: $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)" distclean: clean - rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi - rm -f config-all-devices.mak + rm -f config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi rm -f roms/seabios/config.mak roms/vgabios/config.mak rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps qemu-doc.dvi rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
@@ -279,6 +276,7 @@ distclean: clean rm -rf $$d || exit 1 ; \ done test -f pixman/config.log && make -C pixman distclean + rm -f config-host.mak rm -f config-all-devices.mak KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \ ar de en-us fi fr-be hr it lv nl pl ru th \
With this change, no need for MAKEFILES anymore.
Paolo
Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
Quoted 61 lines · Paolo Bonzini
Il 16/11/2012 12:01, Wenchao Xia ha scritto:
Quoted 6 lines
Quoted 6 lines
ifneq ($(wildcard config-host.mak),)
include $(SRC_PATH)/tests/Makefile
endifQuoted 8 lines
Quoted 6 lines
to
-include $(SRC_PATH)/tests/Makefile
?
yes, but original author seems not include tests/Makefile in
this condition on purpose, so using MAKEFILES to keep it unchanged.git blame tells you that the ifneq was added by commit e454e2e (
Makefile: Exclude tests/Makefile in unconfigured tree, 2012-01-17).Instead of the ifneq, I proposed to use a minus in front of the include directive. It will avoid failures if tests/Makefile does not exist. However, it is not very good because it will cause /tests/Makefile to be opened (see the commit message of e454e2e).
Perhaps an even better way to avoid the problem would be this: just move the removal of makefile fragments to the _end_ of "make distclean":
Makefile +2
-4@@ -203,9 +203,7 @@ qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated gen-out-type = $(subst .,-,$(suffix $@)) -ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/tests/Makefile -endif qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py@@ -265,8 +263,7 @@ qemu-%.tar.bz2: $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)" distclean: clean - rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi - rm -f config-all-devices.mak + rm -f config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi rm -f roms/seabios/config.mak roms/vgabios/config.mak rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps qemu-doc.dvi rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys@@ -279,6 +276,7 @@ distclean: clean rm -rf $$d || exit 1 ; \ done test -f pixman/config.log && make -C pixman distclean + rm -f config-host.mak rm -f config-all-devices.mak KEYMAPS=da en-gb et fr fr-ch is lt modifiers no pt-br sv \ ar de en-us fi fr-be hr it lv nl pl ru th \
Quoted 4 lines
With this change, no need for MAKEFILES anymore.
Paolo
I guess "make distclean" for second time would fail in this case,
because $(SRC_PATH) is not set. I found a better way to do it without MAKEFILES:
-ifneq ($(wildcard config-host.mak),)
- include $(SRC_PATH)/tests/Makefile
+ include tests/Makefile
-endif
due to tests/Makefile is added in configure in this patch so it is
always soft linked then include always succeed.
Signature · 3 lines
Best Regards Wenchao Xia
Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
Il 16/11/2012 13:40, Wenchao Xia ha scritto:
Quoted 11 lines
I guess "make distclean" for second time would fail in this case,
because $(SRC_PATH) is not set. I found a better way to do it without MAKEFILES:Makefile +1
-3-ifneq ($(wildcard config-host.mak),) - include $(SRC_PATH)/tests/Makefile + include tests/Makefile -endif due to tests/Makefile is added in configure in this patch so it isalways soft linked then include always succeed.
Whatever, this seems to be ok. Please post the complete patch so we can review it.
Paolo
Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
In reply to Paolo BonziniQuoted 15 lines · Paolo Bonzini
Il 16/11/2012 11:58, Wenchao Xia ha scritto:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Sub
Makefilemay need qapi generated files, so move them to
Makefile.objs,
In this way Makfile.objs control file auto generation.No objection in principle, but why are you doing this? Does it fix anything?
It seems tools or block objects files are depending on qapi files,
Yes, block files are.
Quoted 2 lines
and libqblock needs tools. So without it out of tree build of libqblock would fail.
Quoted 8 lines
The effect of this patch is to include the rules in libqblock's own
Makefile.libqblock indeed needs to compile these files to .lo. However, regeneration of the C source code and header shouldn't be needed there.
I think you're missing a dependency in the toplevel Makefile's
"libqblock.la" rule.
yes, I'll try avoid generation of those C files in sub directory.
Still moving generation rules all into Makefile.obs seems right to me.
Quoted 3 lines
By the way, do not name that rule "libqblock.la". It doesn't build libqblock.la, it builds libqblock/libqblock.la. Instead, name it subdir-libqblock.
OK.
Quoted 3 lines
Paolo
Signature · 3 lines
Best Regards Wenchao Xia
Re: [Qemu-devel] [PATCH V9 5/8] libqblock build system
In reply to Paolo BonziniQuoted 14 lines · Paolo Bonzini
Il 16/11/2012 11:12, Wenchao Xia ha scritto:
Quoted 4 lines
Libqblock was placed in new directory ./libqblock, libtool will build
dynamic library there, source files of block layer remains in ./block. So block related source code will generate 3 sets of binary, first is old ones used in qemu, second and third are non PIC and PIC ones in ./libqblock.Quoted 8 lines
GCC compiler flag visibility=hidden was used with special macro, to export
only symbols that was marked as PUBLIC.
For testing, make check-libqblock will build binaries and execute it, make
clean or make check-clean will delete generated binaries.
By default this library will be built and tested, out of tree building is
supported.
Header files added in configure due to install-libqblock from out of tree
build need these them.
Quoted 2 lines
Use $(SRC_PATH) instead in the install rules.
OK.
Quoted 38 lines
Quoted 38 lines
Signed-off-by Wenchao Xia <[email protected]>--- .gitignore | 2 + Makefile | 12 ++++++- configure | 4 ++- libqblock/Makefile | 72 +++++++++++++++++++++++++++++++++++++ libqblock/libqblock.pc.in | 13 +++++++ tests/Makefile | 29 ++++++++++++++- tests/libqblock/libqblock-qcow2.c | 4 ++ 7 files changed, 133 insertions(+), 3 deletions(-)create mode 100644 libqblock/Makefile create mode 100644
libqblock/libqblock-error.ccreate mode 100644libqblock/libqblock-error.hcreate mode 100644libqblock/libqblock-types.hcreate mode 100644libqblock/libqblock.ccreate mode 100644libqblock/libqblock.hcreate mode 100644 libqblock/libqblock.pc.in create mode 100644tests/libqblock/libqblock-qcow2.c.gitignore +2
-0@@ -93,3 +93,5 @@ cscope.* tags TAGS *~ +tests/libqblock/check-* +tests/libqblock/test_imagesMakefile +0
-0@@ -189,6 +189,16 @@ qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y) qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o
Quoted 10 lines
Makefile qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y) · line 198
Quoted 7 lines
Makefile +7
-0+###################################################################### +# Support building shared library libqblock +libqblock.la: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" libqblock.la,) + +install-libqblock: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" install-libqblock,)Who calls install-libqblock?
No one now, just provided an install rules similar to libcacard.
Quoted 28 lines
Quoted 19 lines
Makefile +3
-1+########################################################################### + vscclient$(EXESUF): $(libcacard-y) $(oslib-obj-y) $(trace-obj-y) libcacard/vscclient.o $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(libcacard_libs) $(LIBS)," LINK $@")@@ -230,7 +240,7 @@ clean: rm -rf qapi-generated rm -rf qga/qapi-generated MAKEFILES=./tests/Makefile $(MAKE) check-clean - for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ + for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard libqblock; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \ doneconfigure +0
-0configure tools="" · line 3102
Quoted 5 lines
configure +1
-1@@ -3099,7 +3099,7 @@ tools="" if test "$want_tools" = "yes" ; then tools="qemu-img\$(EXESUF) qemu-io\$(EXESUF) $tools" if [ "$linux" = "yes" -o "$bsd" = "yes" -o "$solaris" = "yes" ] ; then - tools="qemu-nbd\$(EXESUF) $tools" + tools="libqblock.la qemu-nbd\$(EXESUF) $tools"Why make this conditional? (Rather, it should be conditional on the presence of libtool).
Quoted 3 lines
Also, perhaps a separate --enable/disable-libqblock switch is better. It simplifies testing, at least.
OK.
Quoted 9 lines
Quoted 9 lines
configure +1
-0fi fi if test "$softmmu" = yes ; then@@ -4163,12 +4163,14 @@ DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" DIRS="$DIRS libcacard libcacard/libcacard libcacard/trace" +DIRS="$DIRS libqblock tests/libqblock" FILES="Makefile tests/Makefile tests/tcg/Makefile qdict-test-data.txt"
Quoted 9 lines
configure DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" · line 4173
Quoted 6 lines
configure +1
-0FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile libcacard/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps" FILES="$FILES pc-bios/spapr-rtas/Makefile" FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile" +FILES="$FILES libqblock/Makefile libqblock/libqblock.h libqblock/libqblock-error.h libqblock/libqblock-types.h"See above.
will remove.
Quoted 20 lines
Quoted 20 lines
configure +0
-0for bios_file in \ $source_path/pc-bios/*.bin \ $source_path/pc-bios/*.rom \libqblock/Makefile new file +11
-0@@ -0,0 +1,72 @@ +########################################################################### +# libqblock Makefile +# Todo: +# 1 trace related files is generated in this directory, move +# them to the root directory. +########################################################################## +-include ../config-host.mak +-include $(SRC_PATH)/Makefile.objs +-include $(SRC_PATH)/rules.mak + +#############################################################################
Quoted 9 lines
libqblock/Makefile line 17
Quoted 6 lines
libqblock/Makefile new file +6
-0+# Library settings +############################################################################# +$(call set-vpath, $(SRC_PATH)) + +#expand the foldered vars,especially ./block +dummy := $(call unnest-vars)This should be done by Makefile.objs already.
OK.
Quoted 10 lines
libqblock/Makefile line 24
Quoted 6 lines
libqblock/Makefile new file +6
-0+#library objects +libqblock-y=libqblock/libqblock.o libqblock/libqblock-error.o +tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \ + qemu-timer-common.o main-loop.o notify.o \ + iohandler.o cutils.o iov.o async.o +tools-obj-$(CONFIG_POSIX) += compatfd.oAre all of these really needed? (In fact, after some of the recent changes none of these should be needed).
OK, I'll try remove tools-objs.
Quoted 98 lines
Quoted 86 lines
libqblock/Makefile new file +47
-0+ +QEMU_OBJS= $(libqblock-y) $(block-obj-y) $(tools-obj-y) +QEMU_OBJS_LIB=$(patsubst %.o, %.lo, $(QEMU_OBJS)) + +QEMU_CFLAGS+= -I$(SRC_PATH) -I$(SRC_PATH)/include -I../ +#adding magic macro define for symbol hiding and exposing +QEMU_CFLAGS+= -fvisibility=hidden -D LIBQB_BUILD + +#dependency libraries +LIBS+=-lz $(LIBS_TOOLS) + +#header files to be installed +libqblock-pub-headers=libqblock.h libqblock-types.h libqblock-error.h +libqblock_includedir=$(includedir)/qblock +libqblock_srcpath=$(SRC_PATH)/libqblock + +################################################################# +# Runtime rules +################################################################# +clean: + rm -f *.lo *.o *.d *.la libqblock-test trace.c trace.c-timestamp *.pc + rm -rf .libs block trace audio fsdev hw net qapi qga qom slirp ui libqblock + +all: libqblock.la libqblock.pc +# Dummy command so that make thinks it has done something + @true + +libqblock.la: $(QEMU_OBJS_LIB) + $(call quiet-command,$(LIBTOOL) --mode=link --quiet --tag=CC $(CC) -rpath $(libdir) -o $@ $^ $(LIBS)," lt LINK $@") + +libqblock.pc: $(libqblock_srcpath)/libqblock.pc.in + $(call quiet-command,sed -e 's|@LIBDIR@|$(libdir)|' \ + -e 's|@INCLUDEDIR@|$(libqblock_includedir)|' \ + -e 's|@VERSION@|$(shell cat $(SRC_PATH)/VERSION)|' \ + -e 's|@PREFIX@|$(prefix)|' \ + < $(libqblock_srcpath)/libqblock.pc.in > libqblock.pc,\ + " GEN $@") + +.PHONY: install-libqblock + +install-libqblock: libqblock.la libqblock.pc + $(INSTALL_DIR) "$(DESTDIR)$(libdir)" + $(INSTALL_DIR) "$(DESTDIR)$(libdir)/pkgconfig" + $(INSTALL_DIR) "$(DESTDIR)$(libqblock_includedir)" + $(LIBTOOL) --mode=install $(INSTALL_DATA) libqblock.la "$(DESTDIR)$(libdir)" + $(LIBTOOL) --mode=install $(INSTALL_DATA) libqblock.pc "$(DESTDIR)$(libdir)/pkgconfig" + $(LIBTOOL) --mode=install $(INSTALL_DATA) $(libqblock-pub-headers) "$(DESTDIR)$(libqblock_includedir)"libqblock/libqblock-error.c new file +0
-0libqblock/libqblock-error.h new file +0
-0libqblock/libqblock-types.h new file +0
-0libqblock/libqblock.c new file +0
-0libqblock/libqblock.h new file +0
-0libqblock/libqblock.pc.in new file +13
-0@@ -0,0 +1,13 @@ +prefix=@PREFIX@ +exec_prefix=${prefix} +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: qblock +Description: QEMU block layer library +Version: @VERSION@ + +Requires: rt gthread-2.0 glib-2.0 z curl cap-ng uuid +Libs: -L${libdir} -lqblock +Libs.private: +Cflags: -I${includedir}tests/Makefile +0
-0tests/Makefile check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET) · line 92
Quoted 9 lines
tests/Makefile +6
-0@@ -84,6 +84,22 @@ check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET) qtest-obj-y = tests/libqtest.o $(oslib-obj-y) $(check-qtest-y): $(qtest-obj-y) +#libqblock test rules + +LIBQBLOCK_TEST_DIR= tests/libqblock/test_images +LIBQBLOCK_DIR = libqblock +LIBQBLOCK_SO = $(LIBQBLOCK_DIR)/.libs/libqblock.so +LIBQBLOCK_SO_LINK_FLAG= -Wl,-rpath,$(LIBQBLOCK_DIR)/.libsNot portable. Please use libtool to link the program:
Quoted 9 lines
LTLINK = $(call quiet-command,$(LIBTOOL) --mode=link --quiet --tag=CC $(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(sort $(1)) $(LIBS),"lt LINK $(TARGET_DIR)$@")
and then
$(check-libqblock-y): %$(EXESUF): %.o
$(call LTLINK,$^)
ok.
Quoted 8 lines
tests/Makefile check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET) · line 95
Quoted 2 lines
tests/Makefile +2
-0+tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -fPIE,-fPIC, $(QEMU_CFLAGS)) +tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -DPIE,-DPIC, $(QEMU_CFLAGS))Why?
A hint: if you have to do something that is not done anywhere else in the tree, do not do it.
not sure whether PIE objs can be linked with dynamic library, let me
try remove it.
Quoted 7 lines
tests/Makefile check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET) · line 98
Quoted 3 lines
tests/Makefile +3
-0+tests/libqblock/%.o: QEMU_INCLUDES += -I$(SRC_PATH)/tests -I$(SRC_PATH)/$(LIBQBLOCK_DIR) + +check-libqblock-y = tests/libqblock/check-libqblock-qcow2$(EXESUF)Please use something like check-libqblock-$(CONFIG_LIBQBLOCK) so that it works even if libqblock is not compiled in.
OK.
Quoted 7 lines
Also, I'm not sure we need a completely separate subdirectory for one file only. You can just use
$(check-libqblock-y):
QEMU_INCLUDES+= ...Paolo
A separate directory will allow more test cases come in easily,
I thought to added more test cases before.
Quoted 58 lines
Quoted 56 lines
tests/Makefile +15
-1+tests/libqblock/check-libqblock-qcow2$(EXESUF): tests/libqblock/libqblock-qcow2.o $(LIBQBLOCK_SO) + $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(LIBQBLOCK_SO_LINK_FLAG)," LINK $@") + .PHONY: check-help check-help: @echo "Regression testing targets:"@@ -94,6 +110,7 @@ check-help: @echo " make check-unit Run qobject tests" @echo " make check-block Run block tests" @echo " make check-report.html Generates an HTML test report" + @echo " make check-libqblock Run libqblock tests" @echo " make check-clean Clean the tests" @echo @echo "Please note that HTML reports do not regenerate if the unit tests"@@ -126,6 +143,12 @@ $(patsubst %, check-report-qtest-%.xml, $(QTEST_TARGETS)): check-report-qtest-%. check-report-unit.xml: $(check-unit-y) $(call quiet-command,gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $^, "GTESTER $@") +# gtester tests with libqblock + +.PHONY: $(patsubst %, check-%, $(check-libqblock-y)) +$(patsubst %, check-%, $(check-libqblock-y)): check-%: % + $(call quiet-command, LIBQBLOCK_TEST_DIR=$(LIBQBLOCK_TEST_DIR) gtester $(GTESTER_OPTIONS) -m=$(SPEED) $*,"GTESTER $*") + # Reports and overall runs check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_TARGETS)) check-report-unit.xml@@ -147,12 +170,16 @@ check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS)) check-unit: $(patsubst %,check-%, $(check-unit-y)) check-block: $(patsubst %,check-%, $(check-block-y)) -check: check-unit check-qtest +check-libqblock: $(patsubst %,check-%, $(check-libqblock-y)) +check: check-unit check-qtest check-libqblock check-clean: $(MAKE) -C tests/tcg clean rm -f $(check-unit-y) rm -f $(check-qtest-i386-y) $(check-qtest-x86_64-y) $(check-qtest-sparc64-y) $(check-qtest-sparc-y) rm -f tests/*.o + rm -f tests/libqblock/*.o + rm -f $(check-libqblock-y) + rm -rf $(LIBQBLOCK_TEST_DIR) -include $(wildcard tests/*.d)tests/libqblock/libqblock-qcow2.c new file +4
-0@@ -0,0 +1,4 @@ +int main (int argc,char **argv) +{ +return 0 ; +}
Signature · 3 lines
Best Regards Wenchao Xia
Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
In reply to Paolo BonziniQuoted 10 lines · Paolo Bonzini
Il 16/11/2012 13:40, Wenchao Xia ha scritto:
Quoted 9 lines
I guess "make distclean" for second time would fail in this case,
because $(SRC_PATH) is not set. I found a better way to do it without MAKEFILES:Makefile +1
-3-ifneq ($(wildcard config-host.mak),) - include $(SRC_PATH)/tests/Makefile + include tests/Makefile -endif
Quoted 8 lines
Quoted 2 lines
due to tests/Makefile is added in configure in this patch so it is
always soft linked then include always succeed.Whatever, this seems to be ok. Please post the complete patch so we can review it.
Paolo
OK, reposted build system patches without libqblock. 4th patch of it
is exporting a function in block.c, which have been posted by others but not upstream yet, pls ignore it.
Signature · 3 lines
Best Regards Wenchao Xia
Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
In reply to Wenchao XiaIl 18/11/2012 13:56, Wenchao Xia ha scritto:
Quoted 19 lines
Quoted 18 lines · Paolo Bonzini
Il 16/11/2012 11:58, Wenchao Xia ha scritto:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Sub
Makefilemay need qapi generated files, so move them to
Makefile.objs,
In this way Makfile.objs control file auto generation.No objection in principle, but why are you doing this? Does it fix anything?
It seems tools or block objects files are depending on qapi files,
Yes, block files are.
Quoted 2 lines
and libqblock needs tools. So without it out of tree build of libqblock would fail.
The effect of this patch is to include the rules in libqblock's own
Makefile.
Quoted 7 lines
Quoted 5 lines
libqblock indeed needs to compile these files to .lo. However, regeneration of the C source code and header shouldn't be needed there.
I think you're missing a dependency in the toplevel Makefile's
"libqblock.la" rule.yes, I'll try avoid generation of those C files in sub directory.
Still moving generation rules all into Makefile.obs seems right to me.
Makefile.objs rules are common to all subdirectories, including *-softmmu and *-linux-user. This is not what you want in this case.
Paolo
Re: [Qemu-devel] [PATCH V9 5/8] libqblock build system
In reply to Wenchao XiaIl 18/11/2012 14:06, Wenchao Xia ha scritto:
Quoted 77 lines
Quoted 20 lines · Paolo Bonzini
Il 16/11/2012 11:12, Wenchao Xia ha scritto:
Quoted 10 lines
Libqblock was placed in new directory ./libqblock, libtool will build
dynamic library there, source files of block layer remains in ./block. So block related source code will generate 3 sets of binary, first is old
ones used in qemu, second and third are non PIC and PIC ones in ./libqblock.
GCC compiler flag visibility=hidden was used with special macro,
to export
only symbols that was marked as PUBLIC.
For testing, make check-libqblock will build binaries and executeQuoted 8 lines
it, make
clean or make check-clean will delete generated binaries.
By default this library will be built and tested, out of tree
building is
supported.
Header files added in configure due to install-libqblock from out
of tree
build need these them.Quoted 2 lines
Use $(SRC_PATH) instead in the install rules.
OK.
Quoted 40 lines
Quoted 40 lines
Signed-off-by Wenchao Xia <[email protected]>--- .gitignore | 2 + Makefile | 12 ++++++- configure | 4 ++- libqblock/Makefile | 72 +++++++++++++++++++++++++++++++++++++ libqblock/libqblock.pc.in | 13 +++++++ tests/Makefile | 29 ++++++++++++++- tests/libqblock/libqblock-qcow2.c | 4 ++ 7 files changed, 133 insertions(+), 3 deletions(-)create mode 100644 libqblock/Makefile create mode 100644
libqblock/libqblock-error.ccreate mode 100644libqblock/libqblock-error.hcreate mode 100644libqblock/libqblock-types.hcreate mode 100644libqblock/libqblock.ccreate mode 100644libqblock/libqblock.hcreate mode 100644 libqblock/libqblock.pc.in create mode 100644tests/libqblock/libqblock-qcow2.c.gitignore +2
-0@@ -93,3 +93,5 @@ cscope.* tags TAGS *~ +tests/libqblock/check-* +tests/libqblock/test_imagesMakefile +0
-0@@ -189,6 +189,16 @@ qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y) qemu-bridge-helper$(EXESUF): qemu-bridge-helper.oQuoted 12 lines
Makefile qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y)
Quoted 9 lines
Makefile +7
-0+###################################################################### +# Support building shared library libqblock +libqblock.la: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" libqblock.la,) + +install-libqblock: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" install-libqblock,)Who calls install-libqblock?
Quoted 1 line
No one now, just provided an install rules similar to libcacard.
Please call it from the install target (through a dependency). Also remember to make these targets phony.
Quoted 11 lines
Quoted 10 lines
Makefile qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y)
Quoted 6 lines
Makefile +6
-0+#library objects +libqblock-y=libqblock/libqblock.o libqblock/libqblock-error.o +tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \ + qemu-timer-common.o main-loop.o notify.o \ + iohandler.o cutils.o iov.o async.o +tools-obj-$(CONFIG_POSIX) += compatfd.oAre all of these really needed? (In fact, after some of the recent changes none of these should be needed).
OK, I'll try remove tools-objs.
Or perhaps just trim it down. Moving it to Makefile.objs is another idea, but please keep it as small as possible.
Quoted 10 lines
Quoted 8 lines
Makefile
Quoted 2 lines
Makefile +2
-0+tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -fPIE,-fPIC, $(QEMU_CFLAGS)) +tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -DPIE,-DPIC, $(QEMU_CFLAGS))Why?
A hint: if you have to do something that is not done anywhere else in the tree, do not do it.
not sure whether PIE objs can be linked with dynamic library, let me
try remove it.
They cannot be part of a dynamic library, but they sure can be linked with one. QEMU itself is PIE and linked with SDL, gnutls, etc.
Quoted 9 lines
Quoted 7 lines
Also, I'm not sure we need a completely separate subdirectory for one file only. You can just use
$(check-libqblock-y):
QEMU_INCLUDES+= ...Paolo
A separate directory will allow more test cases come in easily,
I thought to added more test cases before.
But you have one for now... :)
Paolo
Re: [Qemu-devel] [PATCH V9 5/8] libqblock build system
Quoted 78 lines · Paolo Bonzini
Il 18/11/2012 14:06, Wenchao Xia ha scritto:
Quoted 77 lines
Quoted 20 lines · Paolo Bonzini
Il 16/11/2012 11:12, Wenchao Xia ha scritto:
Quoted 10 lines
Libqblock was placed in new directory ./libqblock, libtool will build
dynamic library there, source files of block layer remains in ./block. So block related source code will generate 3 sets of binary, first is old
ones used in qemu, second and third are non PIC and PIC ones in ./libqblock.
GCC compiler flag visibility=hidden was used with special macro,
to export
only symbols that was marked as PUBLIC.
For testing, make check-libqblock will build binaries and executeQuoted 8 lines
it, make
clean or make check-clean will delete generated binaries.
By default this library will be built and tested, out of tree
building is
supported.
Header files added in configure due to install-libqblock from out
of tree
build need these them.Quoted 2 lines
Use $(SRC_PATH) instead in the install rules.
OK.
Quoted 52 lines
Quoted 39 lines
Signed-off-by Wenchao Xia <[email protected]>--- .gitignore | 2 + Makefile | 12 ++++++- configure | 4 ++- libqblock/Makefile | 72 +++++++++++++++++++++++++++++++++++++ libqblock/libqblock.pc.in | 13 +++++++ tests/Makefile | 29 ++++++++++++++- tests/libqblock/libqblock-qcow2.c | 4 ++ 7 files changed, 133 insertions(+), 3 deletions(-)create mode 100644 libqblock/Makefile create mode 100644
libqblock/libqblock-error.ccreate mode 100644libqblock/libqblock-error.hcreate mode 100644libqblock/libqblock-types.hcreate mode 100644libqblock/libqblock.ccreate mode 100644libqblock/libqblock.hcreate mode 100644 libqblock/libqblock.pc.in create mode 100644tests/libqblock/libqblock-qcow2.c.gitignore +2
-0@@ -93,3 +93,5 @@ cscope.* tags TAGS *~ +tests/libqblock/check-* +tests/libqblock/test_imagesMakefile +0
-0@@ -189,6 +189,16 @@ qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) $(block-obj-y) qemu-bridge-helper$(EXESUF): qemu-bridge-helper.oMakefile qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y) · line 201
Quoted 10 lines
Makefile +7
-0+###################################################################### +# Support building shared library libqblock +libqblock.la: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" libqblock.la,) + +install-libqblock: + $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C libqblock V="$(V)" TARGET_DIR="$*/" install-libqblock,)Who calls install-libqblock?
Quoted 5 lines
Quoted 1 line
No one now, just provided an install rules similar to libcacard.
Please call it from the install target (through a dependency). Also remember to make these targets phony.
right, phony is important, I forgot it before.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Makefile qemu-io$(EXESUF): qemu-io.o cmd.o $(tools-obj-y)
Quoted 7 lines
Makefile +6
-0+#library objects +libqblock-y=libqblock/libqblock.o libqblock/libqblock-error.o +tools-obj-y = $(oslib-obj-y) $(trace-obj-y) qemu-tool.o qemu-timer.o \ + qemu-timer-common.o main-loop.o notify.o \ + iohandler.o cutils.o iov.o async.o +tools-obj-$(CONFIG_POSIX) += compatfd.oAre all of these really needed? (In fact, after some of the recent changes none of these should be needed).
Quoted 6 lines
Quoted 1 line
OK, I'll try remove tools-objs.
Or perhaps just trim it down. Moving it to Makefile.objs is another idea, but please keep it as small as possible.
OK.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Makefile
Quoted 2 lines
Makefile +2
-0+tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -fPIE,-fPIC, $(QEMU_CFLAGS)) +tests/libqblock/%.o: QEMU_CFLAGS:= $(subst -DPIE,-DPIC, $(QEMU_CFLAGS))Why?
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
A hint: if you have to do something that is not done anywhere else in the tree, do not do it.
not sure whether PIE objs can be linked with dynamic library, let me
try remove it.They cannot be part of a dynamic library, but they sure can be linked with one. QEMU itself is PIE and linked with SDL, gnutls, etc.
Thanks, this extended my knowledge.
Quoted 12 lines
Quoted 9 lines
Quoted 7 lines
Also, I'm not sure we need a completely separate subdirectory for one file only. You can just use
$(check-libqblock-y):
QEMU_INCLUDES+= ...Paolo
A separate directory will allow more test cases come in easily,
I thought to added more test cases before.But you have one for now... :)
OK.
Quoted 2 lines
Paolo
Signature · 3 lines
Best Regards Wenchao Xia