qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library
@ 2012-11-16 10:12 Wenchao Xia
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 1/8] Buildsystem fix distclean error in pixman Wenchao Xia
                   ` (7 more replies)
  0 siblings, 8 replies; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, aliguori, stefanha, blauwirbel, pbonzini,
	Wenchao Xia

  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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH V9 1/8] Buildsystem fix distclean error in pixman
  2012-11-16 10:12 [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library Wenchao Xia
@ 2012-11-16 10:12 ` Wenchao Xia
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly Wenchao Xia
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, aliguori, stefanha, blauwirbel, pbonzini,
	Wenchao Xia

  Currently if pixman have no config.log inside, make file still
try to clean it resulting error. This patch fix it.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 Makefile |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 81c660f..f40885b 100644
--- a/Makefile
+++ b/Makefile
@@ -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 \
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
  2012-11-16 10:12 [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library Wenchao Xia
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 1/8] Buildsystem fix distclean error in pixman Wenchao Xia
@ 2012-11-16 10:12 ` Wenchao Xia
  2012-11-16 10:23   ` Peter Maydell
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs Wenchao Xia
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, aliguori, stefanha, blauwirbel, pbonzini,
	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.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 Makefile       |    2 +-
 configure      |    2 +-
 tests/Makefile |    7 +++++++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index f40885b..8201e80 100644
--- a/Makefile
+++ b/Makefile
@@ -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; \
diff --git a/configure b/configure
index f847ee2..a18e267 100755
--- a/configure
+++ b/configure
@@ -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"
diff --git a/tests/Makefile b/tests/Makefile
index 9bf0765..a286622 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -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)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
  2012-11-16 10:12 [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library Wenchao Xia
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 1/8] Buildsystem fix distclean error in pixman Wenchao Xia
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly Wenchao Xia
@ 2012-11-16 10:12 ` Wenchao Xia
  2012-11-16 10:54   ` Paolo Bonzini
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 4/8] block export function path_has_protocol Wenchao Xia
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, aliguori, stefanha, blauwirbel, pbonzini,
	Wenchao Xia

  Sub Makefile may need qapi generated files, so move them to Makefile.objs,
In this way Makfile.objs control file auto generation.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 Makefile      |   22 ----------------------
 Makefile.objs |   22 ++++++++++++++++++++++
 2 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/Makefile b/Makefile
index 8201e80..2cde430 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
 
diff --git a/Makefile.objs b/Makefile.objs
index 37be7e2..9da96ea 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -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
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH V9 4/8] block export function path_has_protocol
  2012-11-16 10:12 [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library Wenchao Xia
                   ` (2 preceding siblings ...)
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs Wenchao Xia
@ 2012-11-16 10:12 ` Wenchao Xia
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 5/8] libqblock build system Wenchao Xia
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, aliguori, stefanha, blauwirbel, pbonzini,
	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.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 block.c |    2 +-
 block.h |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/block.c b/block.c
index da1fdca..ced9018 100644
--- a/block.c
+++ b/block.c
@@ -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;
 
diff --git a/block.h b/block.h
index 722c620..6805245 100644
--- a/block.h
+++ b/block.h
@@ -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);
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH V9 5/8] libqblock build system
  2012-11-16 10:12 [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library Wenchao Xia
                   ` (3 preceding siblings ...)
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 4/8] block export function path_has_protocol Wenchao Xia
@ 2012-11-16 10:12 ` Wenchao Xia
  2012-11-16 11:08   ` Paolo Bonzini
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 6/8] libqblock type defines Wenchao Xia
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, aliguori, stefanha, blauwirbel, pbonzini,
	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.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 .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

diff --git a/.gitignore b/.gitignore
index bd6ba1c..76207fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -93,3 +93,5 @@ cscope.*
 tags
 TAGS
 *~
+tests/libqblock/check-*
+tests/libqblock/test_images
diff --git a/Makefile b/Makefile
index 2cde430..4b0755d 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/configure b/configure
index a18e267..b1a1722 100755
--- a/configure
+++ b/configure
@@ -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 \
diff --git a/libqblock/Makefile b/libqblock/Makefile
new file mode 100644
index 0000000..190ffb4
--- /dev/null
+++ b/libqblock/Makefile
@@ -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
+
+#############################################################################
+# Library settings
+#############################################################################
+$(call set-vpath, $(SRC_PATH))
+
+#expand the foldered vars,especially ./block
+dummy := $(call unnest-vars)
+
+#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
+
+
+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)"
diff --git a/libqblock/libqblock-error.c b/libqblock/libqblock-error.c
new file mode 100644
index 0000000..e69de29
diff --git a/libqblock/libqblock-error.h b/libqblock/libqblock-error.h
new file mode 100644
index 0000000..e69de29
diff --git a/libqblock/libqblock-types.h b/libqblock/libqblock-types.h
new file mode 100644
index 0000000..e69de29
diff --git a/libqblock/libqblock.c b/libqblock/libqblock.c
new file mode 100644
index 0000000..e69de29
diff --git a/libqblock/libqblock.h b/libqblock/libqblock.h
new file mode 100644
index 0000000..e69de29
diff --git a/libqblock/libqblock.pc.in b/libqblock/libqblock.pc.in
new file mode 100644
index 0000000..d2a7d06
--- /dev/null
+++ b/libqblock/libqblock.pc.in
@@ -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}
diff --git a/tests/Makefile b/tests/Makefile
index a286622..ee26ba5 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -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)
diff --git a/tests/libqblock/libqblock-qcow2.c b/tests/libqblock/libqblock-qcow2.c
new file mode 100644
index 0000000..c05c0c4
--- /dev/null
+++ b/tests/libqblock/libqblock-qcow2.c
@@ -0,0 +1,4 @@
+int main(int argc, char **argv)
+{
+    return 0;
+}
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH V9 6/8] libqblock type defines
  2012-11-16 10:12 [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library Wenchao Xia
                   ` (4 preceding siblings ...)
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 5/8] libqblock build system Wenchao Xia
@ 2012-11-16 10:12 ` Wenchao Xia
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 7/8] libqblock API Wenchao Xia
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 8/8] libqblock test example Wenchao Xia
  7 siblings, 0 replies; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, aliguori, stefanha, blauwirbel, pbonzini,
	Wenchao Xia

  This patch contains type and macro defines used in APIs, one file for public
usage, one for libqblock internal usage.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 libqblock/libqblock-internal.h |   75 ++++++++++++
 libqblock/libqblock-types.h    |  252 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 327 insertions(+), 0 deletions(-)
 create mode 100644 libqblock/libqblock-internal.h

diff --git a/libqblock/libqblock-internal.h b/libqblock/libqblock-internal.h
new file mode 100644
index 0000000..75c0452
--- /dev/null
+++ b/libqblock/libqblock-internal.h
@@ -0,0 +1,75 @@
+/*
+ * QEMU block layer library
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
+ *
+ * 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
diff --git a/libqblock/libqblock-types.h b/libqblock/libqblock-types.h
index e69de29..77ad325 100644
--- a/libqblock/libqblock-types.h
+++ b/libqblock/libqblock-types.h
@@ -0,0 +1,252 @@
+/*
+ * QEMU block layer library
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
+ *
+ * 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_TYPES_H
+#define LIBQBLOCK_TYPES_H
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#if defined(__GNUC__) && __GNUC__ >= 4
+    #ifdef LIBQB_BUILD
+        #define DLL_PUBLIC __attribute__((visibility("default")))
+    #else
+        #define DLL_PUBLIC
+    #endif
+#endif
+
+/* this library is designed around this core struct. */
+typedef struct QBlockState QBlockState;
+
+/* every thread should have a context. */
+typedef struct QBlockContext QBlockContext;
+
+/* flag used in open and create */
+#define LIBQBLOCK_O_RDWR        0x0002
+/* do not use the host page cache */
+#define LIBQBLOCK_O_NOCACHE     0x0020
+/* use write-back caching */
+#define LIBQBLOCK_O_CACHE_WB    0x0040
+/* don't open the backing file */
+#define LIBQBLOCK_O_NO_BACKING  0x0100
+/* disable flushing on this disk */
+#define LIBQBLOCK_O_NO_FLUSH    0x0200
+
+#define LIBQBLOCK_O_CACHE_MASK \
+   (LIBQBLOCK_O_NOCACHE | LIBQBLOCK_O_CACHE_WB | LIBQBLOCK_O_NO_FLUSH)
+
+#define LIBQBLOCK_O_VALID_MASK \
+   (LIBQBLOCK_O_RDWR | LIBQBLOCK_O_NOCACHE | LIBQBLOCK_O_CACHE_WB | \
+    LIBQBLOCK_O_NO_BACKING | LIBQBLOCK_O_NO_FLUSH)
+
+typedef enum QBlockProtocol {
+    QB_PROTO_NONE = 0,
+    QB_PROTO_FILE,
+    QB_PROTO_MAX
+} QBlockProtocol;
+
+typedef struct QBlockProtocolOptionsFile {
+    const char *filename;
+} QBlockProtocolOptionsFile;
+
+/**
+ * struct QBlockLocationInfo: contains information about how to find the image
+ *
+ * @prot_type: protocol type, now only support FILE.
+ * @o_file: file protocol related attributes.
+ * @reserved: reserved bytes for ABI.
+ */
+#define QBLOCK_PROT_OPTIONS_UNION_SIZE (512)
+typedef struct QBlockLocationInfo {
+    QBlockProtocol prot_type;
+    union {
+        QBlockProtocolOptionsFile o_file;
+        uint64_t reserved[QBLOCK_PROT_OPTIONS_UNION_SIZE/8];
+    };
+} QBlockLocationInfo;
+
+
+/* format related options */
+typedef enum QBlockFormat {
+    QB_FMT_NONE = 0,
+    QB_FMT_COW,
+    QB_FMT_QED,
+    QB_FMT_QCOW,
+    QB_FMT_QCOW2,
+    QB_FMT_RAW,
+    QB_FMT_RBD,
+    QB_FMT_SHEEPDOG,
+    QB_FMT_VDI,
+    QB_FMT_VMDK,
+    QB_FMT_VPC,
+    QB_FMT_MAX
+} QBlockFormat;
+
+typedef struct QBlockFormatOptionsCOW {
+    uint64_t virt_size;
+    QBlockLocationInfo backing_loc;
+} QBlockFormatOptionsCOW;
+
+typedef struct QBlockFormatOptionsQED {
+    uint64_t virt_size;
+    QBlockLocationInfo backing_loc;
+    QBlockFormat backing_fmt;
+    uint64_t cluster_size; /* unit is bytes */
+    uint64_t table_size; /* unit is clusters */
+} QBlockFormatOptionsQED;
+
+typedef struct QBlockFormatOptionsQCOW {
+    uint64_t virt_size;
+    QBlockLocationInfo backing_loc;
+    bool encrypt;
+} QBlockFormatOptionsQCOW;
+
+/* "Compatibility level (0.10 or 1.1)" */
+typedef enum QBlockFormatOptionsQCOW2CompatLv {
+    QB_FMT_QCOW2_COMPAT_DEFAULT = 0,
+    QB_FMT_QCOW2_COMPAT_V0_10,
+    QB_FMT_QCOW2_COMPAT_V1_10,
+} QBlockFormatOptionsQCOW2CompatLv;
+
+/* off or metadata */
+typedef enum QBlockFormatOptionsQCOW2PreAlloc {
+    QB_FMT_QCOW2_PREALLOC_DEFAULT = 0,
+    QB_FMT_QCOW2_PREALLOC_OFF,
+    QB_FMT_QCOW2_PREALLOC_METADATA,
+} QBlockFormatOptionsQCOW2PreAlloc;
+
+typedef struct QBlockFormatOptionsQCOW2 {
+    uint64_t virt_size;
+    QBlockLocationInfo backing_loc;
+    QBlockFormat backing_fmt;
+    bool encrypt;
+    uint64_t cluster_size; /* unit is bytes */
+    QBlockFormatOptionsQCOW2CompatLv cpt_lv;
+    QBlockFormatOptionsQCOW2PreAlloc pre_mode;
+} QBlockFormatOptionsQCOW2;
+
+typedef struct QBlockFormatOptionsRAW {
+    uint64_t virt_size;
+} QBlockFormatOptionsRAW;
+
+typedef struct QBlockFormatOptionsRBD {
+    uint64_t virt_size;
+    uint64_t cluster_size;
+} QBlockFormatOptionsRBD;
+
+/* off or full */
+typedef enum QBlockFormatOptionsSDPreAlloc {
+    QB_FMT_SD_PREALLOC_DEFAULT = 0,
+    QB_FMT_SD_PREALLOC_OFF,
+    QB_FMT_SD_PREALLOC_FULL,
+} QBlockFormatOptionsSDPreAlloc;
+
+typedef struct QBlockFormatOptionsSD {
+    uint64_t virt_size;
+    QBlockLocationInfo backing_loc;
+    QBlockFormatOptionsSDPreAlloc pre_mode;
+} QBlockFormatOptionsSD;
+
+typedef enum QBlockFormatOptionsVDIPreAlloc {
+    QB_FMT_VDI_PREALLOC_DEFAULT = 0,
+    QB_FMT_VDI_PREALLOC_OFF,
+    QB_FMT_VDI_PREALLOC_METADATA,
+} QBlockFormatOptionsVDIPreAlloc;
+
+typedef struct QBlockFormatOptionsVDI {
+    uint64_t virt_size;
+    uint64_t cluster_size;
+    QBlockFormatOptionsVDIPreAlloc pre_mode;
+} QBlockFormatOptionsVDI;
+
+/* whether compact to vmdk verion 6 */
+typedef enum QBlockFormatOptionsVMDKCompatLv {
+    QB_FMT_VMDK_COMPAT_DEFAULT = 0,
+    QB_FMT_VMDK_COMPAT_VMDKV6_FALSE,
+    QB_FMT_VMDK_COMPAT_VMDKV6_TRUE,
+} QBlockFormatOptionsVMDKCompatLv;
+
+/* vmdk flat extent format, values:
+"{monolithicSparse (default) | monolithicFlat | twoGbMaxExtentSparse |
+twoGbMaxExtentFlat | streamOptimized} */
+typedef enum QBlockFormatOptionsVMDKSubfmt {
+    QB_FMT_VMDK_SUBFMT_DEFAULT = 0,
+    QB_FMT_VMDK_SUBFMT_MONOLITHIC_SPARSE,
+    QB_FMT_VMDK_SUBFMT_MONOLITHIC_FLAT,
+    QB_FMT_VMDK_SUBFMT_TWOGBMAX_EXTENT_SPARSE,
+    QB_FMT_VMDK_SUBFMT_TWOGBMAX_EXTENT_FLAT,
+    QB_FMT_VMDK_SUBFMT_STREAM_OPTIMIZED,
+} QBlockFormatOptionsVMDKSubfmt;
+
+typedef struct QBlockFormatOptionsVMDK {
+    uint64_t virt_size;
+    QBlockLocationInfo backing_loc;
+    QBlockFormatOptionsVMDKCompatLv cpt_lv;
+    QBlockFormatOptionsVMDKSubfmt subfmt;
+} QBlockFormatOptionsVMDK;
+
+/* "{dynamic (default) | fixed} " */
+typedef enum QBlockFormatOptionsVPCSubfmt {
+    QB_FMT_VPC_SUBFMT_DEFAULT = 0,
+    QB_FMT_VPC_SUBFMT_DYNAMIC,
+    QB_FMT_VPC_SUBFMT_FIXED,
+} QBlockFormatOptionsVPCSubfmt;
+
+typedef struct QBlockFormatOptionsVPC {
+    uint64_t virt_size;
+    QBlockFormatOptionsVPCSubfmt subfmt;
+} QBlockFormatOptionsVPC;
+
+#define QBLOCK_FMT_OPTIONS_UNION_SIZE (QBLOCK_PROT_OPTIONS_UNION_SIZE*2)
+
+/**
+ * struct QBlockFormatInfo: contains information about how to retrieve data
+ *  from the image
+ *
+ * @fmt_type: format type.
+ * @o_cow~@o_vdi: format related attributes.
+ * @reserved: reserved bytes for ABI.
+ */
+typedef struct QBlockFormatInfo {
+    QBlockFormat fmt_type;
+    union {
+        QBlockFormatOptionsCOW       o_cow;
+        QBlockFormatOptionsQED       o_qed;
+        QBlockFormatOptionsQCOW      o_qcow;
+        QBlockFormatOptionsQCOW2     o_qcow2;
+        QBlockFormatOptionsRAW       o_raw;
+        QBlockFormatOptionsRBD       o_rbd;
+        QBlockFormatOptionsSD        o_sd;
+        QBlockFormatOptionsVDI       o_vdi;
+        QBlockFormatOptionsVMDK      o_vmdk;
+        QBlockFormatOptionsVPC       o_vpc;
+        uint64_t reserved[QBLOCK_FMT_OPTIONS_UNION_SIZE/8];
+    };
+} QBlockFormatInfo;
+
+/**
+ * QBlockStaticInfo: information about the block image.
+ *
+ * @loc: location information.
+ * @fmt: format information.
+ * @sector_size: how many bytes in a sector, it is 512 usually.
+ */
+typedef struct QBlockStaticInfo {
+    QBlockLocationInfo loc;
+    QBlockFormatInfo fmt;
+    int sector_size;
+} QBlockStaticInfo;
+
+
+#endif
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH V9 7/8] libqblock API
  2012-11-16 10:12 [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library Wenchao Xia
                   ` (5 preceding siblings ...)
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 6/8] libqblock type defines Wenchao Xia
@ 2012-11-16 10:12 ` Wenchao Xia
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 8/8] libqblock test example Wenchao Xia
  7 siblings, 0 replies; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, aliguori, stefanha, blauwirbel, pbonzini,
	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.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 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(-)

diff --git a/libqblock/libqblock-error.c b/libqblock/libqblock-error.c
index e69de29..2a59970 100644
--- a/libqblock/libqblock-error.c
+++ b/libqblock/libqblock-error.c
@@ -0,0 +1,57 @@
+/*
+ * QEMU block layer library
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
+ *
+ * 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;
+}
diff --git a/libqblock/libqblock-error.h b/libqblock/libqblock-error.h
index e69de29..4ffd1f1 100644
--- a/libqblock/libqblock-error.h
+++ b/libqblock/libqblock-error.h
@@ -0,0 +1,49 @@
+/*
+ * QEMU block layer library
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
+ *
+ * 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_ERROR
+#define LIBQBLOCK_ERROR
+
+#include "libqblock-types.h"
+
+#define QB_ERR_INTERNAL_ERR (-1)
+#define QB_ERR_INVALID_PARAM (-100)
+#define QB_ERR_BLOCK_OUT_OF_RANGE (-101)
+
+/* error handling */
+/**
+ * qb_error_get_human_str: get human readable error string.
+ *
+ * return a human readable string, it would be truncated if buf is not big
+ *  enough.
+ *
+ * @context: operation context, must be valid.
+ * @buf: buf to receive the string.
+ * @buf_size: the size of the string buf.
+ */
+DLL_PUBLIC
+void qb_error_get_human_str(QBlockContext *context,
+                            char *buf, size_t buf_size);
+
+/**
+ * qb_error_get_errno: get error number, only valid when err_ret is
+ *   QB_ERR_INTERNAL_ERR.
+ *
+ * return negative errno if last error is QB_ERR_INTERNAL_ERR, otherwise 0.
+ *
+ * @context: operation context.
+ */
+DLL_PUBLIC
+int qb_error_get_errno(QBlockContext *context);
+
+#endif
diff --git a/libqblock/libqblock.c b/libqblock/libqblock.c
index e69de29..0266d06 100644
--- a/libqblock/libqblock.c
+++ b/libqblock/libqblock.c
@@ -0,0 +1,1191 @@
+/*
+ * QEMU block layer library
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
+ *
+ * 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 <unistd.h>
+#include <stdarg.h>
+
+#include "libqblock.h"
+#include "libqblock-internal.h"
+
+#include "qemu-aio.h"
+
+#define LIBQB_FILENAME_MAX 4096
+
+typedef struct LibqblockGlobalData {
+    int init_flag;
+} LibqblockGlobalData;
+
+LibqblockGlobalData libqb_global_data;
+
+typedef struct LibqbFormatStrMapping {
+    const char *fmt_str;
+    QBlockFormat fmt_type;
+} LibqbFormatStrMapping;
+
+LibqbFormatStrMapping libqb_fmtstr_table[] = {
+    {"cow", QB_FMT_COW},
+    {"qed", QB_FMT_QED},
+    {"qcow", QB_FMT_QCOW},
+    {"qcow2", QB_FMT_QCOW2},
+    {"raw", QB_FMT_RAW},
+    {"rbd", QB_FMT_RBD},
+    {"sheepdog", QB_FMT_SHEEPDOG},
+    {"vdi", QB_FMT_VDI},
+    {"vmdk", QB_FMT_VMDK},
+    {"vpc", QB_FMT_VPC},
+    {NULL, 0},
+};
+
+__attribute__((constructor))
+static void libqblock_init(void)
+{
+    if (libqb_global_data.init_flag == 0) {
+        bdrv_init();
+        qemu_init_main_loop();
+    }
+    libqb_global_data.init_flag = 1;
+    /* Todo, add an assertion about the ABI */
+}
+
+const char *qb_fmttype2str(QBlockFormat fmt_type)
+{
+    int i = 0;
+    LibqbFormatStrMapping *tb = libqb_fmtstr_table;
+
+    while (tb[i].fmt_str != NULL) {
+        if (tb[i].fmt_type == fmt_type) {
+            return tb[i].fmt_str;
+        }
+        i++;
+    }
+    return NULL;
+}
+
+QBlockFormat qb_str2fmttype(const char *fmt_str)
+{
+    int i = 0;
+    LibqbFormatStrMapping *tb = libqb_fmtstr_table;
+
+    while (tb[i].fmt_str != NULL) {
+        if ((strcmp(fmt_str, tb[i].fmt_str) == 0)) {
+            return tb[i].fmt_type;
+        }
+        i++;
+    }
+    return QB_FMT_NONE;
+}
+
+static void set_context_err(QBlockContext *context, int err_ret,
+                            const char *fmt, ...)
+{
+    va_list ap;
+
+    if (context->g_error != NULL) {
+        g_error_free(context->g_error);
+    }
+
+    va_start(ap, fmt);
+    context->g_error = g_error_new_valist(G_LIBQBLOCK_ERROR, err_ret, fmt, ap);
+    va_end(ap);
+
+    context->err_ret = err_ret;
+    if (err_ret == QB_ERR_INTERNAL_ERR) {
+        context->err_no = -errno;
+    } else {
+        context->err_no = 0;
+    }
+}
+
+int qb_context_new(QBlockContext **context)
+{
+    *context = FUNC_CALLOC(1, sizeof(QBlockContext));
+    return 0;
+}
+
+void qb_context_delete(QBlockContext **context)
+{
+    if ((*context)->g_error != NULL) {
+        g_error_free((*context)->g_error);
+    }
+    CLEAN_FREE(*context);
+    return;
+}
+
+int qb_state_new(QBlockContext *context,
+                 QBlockState **qbs)
+{
+    *qbs = FUNC_CALLOC(1, sizeof(QBlockState));
+    (*qbs)->bdrvs = bdrv_new("hda");
+    if ((*qbs)->bdrvs == NULL) {
+        CLEAN_FREE(*qbs);
+        set_context_err(context, QB_ERR_INTERNAL_ERR,
+                       "failed to create the driver.");
+        return context->err_ret;
+    }
+    return 0;
+}
+
+void qb_state_delete(QBlockContext *context,
+                     QBlockState **qbs)
+{
+    if ((*qbs)->filename != NULL) {
+        qb_close(context, *qbs);
+    }
+    if ((*qbs)->bdrvs != NULL) {
+        bdrv_delete((*qbs)->bdrvs);
+        (*qbs)->bdrvs = NULL;
+    }
+    CLEAN_FREE(*qbs);
+    return;
+}
+
+int qb_loc_info_new(QBlockContext *context,
+                    QBlockLocationInfo **loc)
+{
+    *loc = FUNC_CALLOC(1, sizeof(QBlockLocationInfo));
+    return 0;
+}
+
+void qb_loc_info_delete(QBlockContext *context,
+                         QBlockLocationInfo **loc)
+{
+    CLEAN_FREE(*loc);
+}
+
+int qb_fmt_info_new(QBlockContext *context,
+                    QBlockFormatInfo **fmt)
+{
+    *fmt = FUNC_CALLOC(1, sizeof(QBlockFormatInfo));
+    return 0;
+}
+
+void qb_fmt_info_delete(QBlockContext *context,
+                        QBlockFormatInfo **fmt)
+{
+    CLEAN_FREE(*fmt);
+}
+
+/* return 0 if every thing is fine */
+static int loc_check_params(QBlockContext *context,
+                            QBlockLocationInfo *loc)
+{
+    context->err_ret = 0;
+
+    switch (loc->prot_type) {
+    case QB_PROTO_FILE:
+        if (loc->o_file.filename == NULL) {
+            set_context_err(context, QB_ERR_INVALID_PARAM,
+                           "Filename was not set.");
+            goto out;
+        }
+        if (path_has_protocol(loc->o_file.filename) > 0) {
+            set_context_err(context, QB_ERR_INVALID_PARAM,
+                           "filename [%s] had protocol.",
+                           loc->o_file.filename);
+            goto out;
+        }
+        break;
+    default:
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                       "Protocol type [%d] was not valid.",
+                       loc->prot_type);
+        break;
+    }
+
+ out:
+    return context->err_ret;
+}
+
+/* translate loc structure to internal filename, returned char* need free,
+ * assuming filename is not NULL. *filename would be set to NULL if no valid
+ * filename found. *filename must be freed later.
+ * return 0 if no error with *filename set.
+ */
+static int loc2filename(QBlockContext *context,
+                        QBlockLocationInfo *loc,
+                        char **filename)
+{
+    context->err_ret = 0;
+
+    if (*filename != NULL) {
+        CLEAN_FREE(*filename);
+    }
+    switch (loc->prot_type) {
+    case QB_PROTO_FILE:
+        *filename = FUNC_STRDUP(loc->o_file.filename);
+        break;
+    default:
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                 "protocol type [%d] is not supported.",
+                  loc->prot_type);
+        break;
+    }
+
+    return context->err_ret;
+}
+
+/* translate filename to location, loc->prot_type = NONE if fail, filename
+   must be valid. loc internal char pointer must be freed later.
+ * return 0 if no error.
+ */
+static int filename2loc(QBlockContext *context,
+                        QBlockLocationInfo *loc,
+                        const char *filename)
+{
+    context->err_ret = 0;
+
+    if (path_has_protocol(filename) > 0) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                     "Filename [%s] had protocol, not supported now.",
+                     filename);
+        goto out;
+    }
+
+    loc->prot_type = QB_PROTO_FILE;
+    switch (loc->prot_type) {
+    case QB_PROTO_FILE:
+        loc->o_file.filename = FUNC_STRDUP(filename);
+        break;
+    default:
+        break;
+    }
+
+ out:
+    return context->err_ret;
+}
+
+/* return 0 if OK, or qblock error number */
+static int set_backing_file_options(QBlockContext *context,
+                                    QEMUOptionParameter *param,
+                                    QBlockLocationInfo *loc,
+                                    QBlockFormat *fmt)
+{
+    char *backing_filename = NULL;
+    const char *fmtstr_backing = NULL;
+    int ret = 0;
+
+    if (loc == NULL) {
+        goto out;
+    }
+
+    ret = loc2filename(context, loc, &backing_filename);
+    /* ret can < 0 if loc have not been set, mean user did not specify backing
+       file, so need to check return value */
+
+    ret = 0;
+
+    if (backing_filename) {
+        ret = set_option_parameter(param,
+                            BLOCK_OPT_BACKING_FILE, backing_filename);
+        assert(ret == 0);
+        if (fmt == NULL) {
+            goto out;
+        }
+        fmtstr_backing = qb_fmttype2str(*fmt);
+        if (fmtstr_backing) {
+            ret = set_option_parameter(param,
+                                BLOCK_OPT_BACKING_FMT, fmtstr_backing);
+            assert(ret == 0);
+        }
+    }
+
+ out:
+    FUNC_FREE(backing_filename);
+    return ret;
+}
+
+int qb_create(QBlockContext *context,
+              QBlockState *qbs,
+              QBlockLocationInfo *loc,
+              QBlockFormatInfo *fmt,
+              int flag)
+{
+    int ret = 0, bd_ret;
+    char *filename = NULL;
+    BlockDriverState *bs = NULL;
+    BlockDriver *drv = NULL, *backing_drv = NULL;
+    bool tmp_bool;
+
+    const char *fmtstr = NULL, *tmp = NULL;
+    QEMUOptionParameter *param = NULL, *create_options = NULL;
+    QEMUOptionParameter *backing_fmt, *backing_file, *size;
+    QBlockFormatOptionsCOW *o_cow = NULL;
+    QBlockFormatOptionsQED *o_qed = NULL;
+    QBlockFormatOptionsQCOW *o_qcow = NULL;
+    QBlockFormatOptionsQCOW2 *o_qcow2 = NULL;
+    QBlockFormatOptionsRAW *o_raw = NULL;
+    QBlockFormatOptionsRBD *o_rbd = NULL;
+    QBlockFormatOptionsSD *o_sd = NULL;
+    QBlockFormatOptionsVDI *o_vdi = NULL;
+    QBlockFormatOptionsVMDK *o_vmdk = NULL;
+    QBlockFormatOptionsVPC *o_vpc = NULL;
+
+
+    /* check parameters */
+    if (flag & (~LIBQBLOCK_O_VALID_MASK)) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                           "invalid flag was set.");
+        ret = context->err_ret;
+        goto out;
+    }
+
+    if ((loc == NULL) || (qbs == NULL) || (fmt == NULL)) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                          "Got unexpected NULL pointer in parameters.");
+        ret = context->err_ret;
+        goto out;
+    }
+
+    ret = loc_check_params(context, loc);
+    if (ret != 0) {
+        goto out;
+    }
+
+    /* internal translate */
+    ret = loc2filename(context, loc, &filename);
+    if (ret != 0) {
+        goto out;
+    }
+
+    fmtstr = qb_fmttype2str(fmt->fmt_type);
+    if (fmtstr == NULL) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                 "Got unexpected NULL pointer in parameters.");
+        ret = context->err_ret;
+        goto out;
+    }
+
+    drv = bdrv_find_format(fmtstr);
+    assert(drv != NULL);
+
+    create_options = append_option_parameters(create_options,
+                                              drv->create_options);
+    param = parse_option_parameters("", create_options, param);
+
+    switch (fmt->fmt_type) {
+    case QB_FMT_COW:
+        o_cow = &(fmt->o_cow);
+        bd_ret = set_option_parameter_int(param,
+                                BLOCK_OPT_SIZE, o_cow->virt_size);
+        assert(bd_ret == 0);
+        /* do not need to check loc, it may be not set */
+        ret = set_backing_file_options(context, param,
+                                       &o_cow->backing_loc, NULL);
+        if (ret != 0) {
+            goto out;
+        }
+        break;
+    case QB_FMT_QED:
+        o_qed = &(fmt->o_qed);
+        bd_ret = set_option_parameter_int(param,
+                                BLOCK_OPT_SIZE, o_qed->virt_size);
+        assert(bd_ret == 0);
+        ret = set_backing_file_options(context, param,
+                                 &o_qed->backing_loc, &o_qed->backing_fmt);
+        if (ret != 0) {
+            goto out;
+        }
+        bd_ret = set_option_parameter_int(param,
+                                BLOCK_OPT_CLUSTER_SIZE, o_qed->cluster_size);
+        assert(bd_ret == 0);
+        bd_ret = set_option_parameter_int(param,
+                                BLOCK_OPT_TABLE_SIZE, o_qed->table_size);
+        assert(bd_ret == 0);
+        break;
+    case QB_FMT_QCOW:
+        o_qcow = &(fmt->o_qcow);
+        bd_ret = set_option_parameter_int(param,
+                                BLOCK_OPT_SIZE, o_qcow->virt_size);
+        assert(bd_ret == 0);
+        ret = set_backing_file_options(context, param,
+                                       &o_qcow->backing_loc, NULL);
+        if (ret != 0) {
+            goto out;
+        }
+        tmp = o_qcow->encrypt ? "on" : "off";
+        bd_ret = set_option_parameter(param, BLOCK_OPT_ENCRYPT, tmp);
+        assert(bd_ret == 0);
+        break;
+    case QB_FMT_QCOW2:
+        o_qcow2 = &(fmt->o_qcow2);
+        bd_ret = set_option_parameter_int(param,
+                              BLOCK_OPT_SIZE, o_qcow2->virt_size);
+        assert(bd_ret == 0);
+        ret = set_backing_file_options(context, param,
+                              &o_qcow2->backing_loc, &o_qcow2->backing_fmt);
+        if (ret != 0) {
+            goto out;
+        }
+        tmp = o_qcow2->encrypt ? "on" : "off";
+        bd_ret = set_option_parameter(param, BLOCK_OPT_ENCRYPT, tmp);
+        assert(bd_ret == 0);
+        bd_ret = set_option_parameter_int(param,
+                              BLOCK_OPT_CLUSTER_SIZE, o_qcow2->cluster_size);
+        assert(bd_ret == 0);
+
+        if (o_qcow2->cpt_lv != QB_FMT_QCOW2_COMPAT_DEFAULT) {
+            tmp = o_qcow2->cpt_lv == QB_FMT_QCOW2_COMPAT_V0_10 ? "0.10" : "1.1";
+            bd_ret = set_option_parameter(param,
+                              BLOCK_OPT_COMPAT_LEVEL, tmp);
+            assert(bd_ret == 0);
+        }
+
+        if (o_qcow2->pre_mode != QB_FMT_QCOW2_PREALLOC_DEFAULT) {
+            tmp = o_qcow2->pre_mode == QB_FMT_QCOW2_PREALLOC_OFF ?
+                                         "off" : "metadata";
+            bd_ret = set_option_parameter(param,
+                              BLOCK_OPT_PREALLOC, tmp);
+            assert(bd_ret == 0);
+        }
+        break;
+
+    case QB_FMT_RAW:
+        o_raw = &(fmt->o_raw);
+        bd_ret = set_option_parameter_int(param,
+                              BLOCK_OPT_SIZE, o_raw->virt_size);
+        assert(bd_ret == 0);
+        break;
+    case QB_FMT_RBD:
+        o_rbd = &(fmt->o_rbd);
+        bd_ret = set_option_parameter_int(param,
+                              BLOCK_OPT_SIZE, o_rbd->virt_size);
+        assert(bd_ret == 0);
+        bd_ret = set_option_parameter_int(param,
+                              BLOCK_OPT_CLUSTER_SIZE, o_rbd->cluster_size);
+        assert(bd_ret == 0);
+        break;
+    case QB_FMT_SHEEPDOG:
+        o_sd = &(fmt->o_sd);
+        bd_ret = set_option_parameter_int(param,
+                              BLOCK_OPT_SIZE, o_sd->virt_size);
+        assert(bd_ret == 0);
+        ret = set_backing_file_options(context, param,
+                                       &o_sd->backing_loc, NULL);
+        if (ret != 0) {
+            goto out;
+        }
+        if (o_sd->pre_mode != QB_FMT_SD_PREALLOC_DEFAULT) {
+            tmp = o_sd->pre_mode == QB_FMT_SD_PREALLOC_OFF ? "off" : "full";
+            bd_ret = set_option_parameter(param,
+                              BLOCK_OPT_PREALLOC, tmp);
+            assert(bd_ret == 0);
+        }
+        break;
+    case QB_FMT_VDI:
+        o_vdi = &(fmt->o_vdi);
+        bd_ret = set_option_parameter_int(param,
+                              BLOCK_OPT_SIZE, o_vdi->virt_size);
+        assert(bd_ret == 0);
+        /* following option is not always valid depends on configuration */
+        set_option_parameter_int(param,
+                              BLOCK_OPT_CLUSTER_SIZE, o_vdi->cluster_size);
+        if (o_vdi->pre_mode != QB_FMT_VDI_PREALLOC_DEFAULT) {
+            tmp_bool = o_sd->pre_mode == QB_FMT_VDI_PREALLOC_METADATA ?
+                                                     true : false;
+            set_option_parameter_int(param, "static", tmp_bool);
+        }
+        break;
+    case QB_FMT_VMDK:
+        o_vmdk = &(fmt->o_vmdk);
+        bd_ret = set_option_parameter_int(param,
+                              BLOCK_OPT_SIZE, o_vmdk->virt_size);
+        assert(bd_ret == 0);
+        ret = set_backing_file_options(context, param,
+                                       &o_vmdk->backing_loc, NULL);
+        if (ret != 0) {
+            goto out;
+        }
+
+        if (o_vmdk->cpt_lv != QB_FMT_VMDK_COMPAT_DEFAULT) {
+            tmp_bool = o_vmdk->cpt_lv == QB_FMT_VMDK_COMPAT_VMDKV6_TRUE ?
+                                                     true : false;
+            bd_ret = set_option_parameter_int(param, BLOCK_OPT_COMPAT6,
+                                                     tmp_bool);
+            assert(bd_ret == 0);
+        }
+        if (o_vmdk->subfmt != QB_FMT_VMDK_SUBFMT_DEFAULT) {
+            switch (o_vmdk->subfmt) {
+            case QB_FMT_VMDK_SUBFMT_MONOLITHIC_SPARSE:
+                tmp = "monolithicSparse";
+                break;
+            case QB_FMT_VMDK_SUBFMT_MONOLITHIC_FLAT:
+                tmp = "monolithicFlat";
+                break;
+            case QB_FMT_VMDK_SUBFMT_TWOGBMAX_EXTENT_SPARSE:
+                tmp = "twoGbMaxExtentSparse";
+                break;
+            case QB_FMT_VMDK_SUBFMT_TWOGBMAX_EXTENT_FLAT:
+                tmp = "twoGbMaxExtentFlat";
+                break;
+            case QB_FMT_VMDK_SUBFMT_STREAM_OPTIMIZED:
+                tmp = "streamOptimized";
+                break;
+            default:
+                set_context_err(context, QB_ERR_INVALID_PARAM,
+                    "invalid VMDK sumfmt type %d was set.", o_vmdk->subfmt);
+                ret = context->err_ret;
+                goto out;
+                break;
+            }
+            bd_ret = set_option_parameter(param,
+                              BLOCK_OPT_SUBFMT, tmp);
+            assert(bd_ret == 0);
+        }
+        break;
+    case QB_FMT_VPC:
+        o_vpc = &(fmt->o_vpc);
+        bd_ret = set_option_parameter_int(param,
+                               BLOCK_OPT_SIZE, o_vpc->virt_size);
+        assert(bd_ret == 0);
+        if (o_vpc->subfmt != QB_FMT_VPC_SUBFMT_DEFAULT) {
+            tmp = o_vpc->subfmt == QB_FMT_VPC_SUBFMT_DYNAMIC ?
+                                               "dynamic" : "fixed";
+            bd_ret = set_option_parameter(param,
+                               BLOCK_OPT_SUBFMT, tmp);
+            assert(bd_ret == 0);
+        }
+        break;
+    default:
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                        "invalid format type %d was set.", fmt->fmt_type);
+        ret = context->err_ret;
+        goto out;
+        break;
+    }
+
+    backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE);
+    if (backing_file && backing_file->value.s) {
+        if (!strcmp(filename, backing_file->value.s)) {
+            set_context_err(context, QB_ERR_INVALID_PARAM,
+                          "Backing file is the same with new file.");
+            ret = context->err_ret;
+            goto out;
+        }
+    }
+
+    backing_fmt = get_option_parameter(param, BLOCK_OPT_BACKING_FMT);
+    if (backing_fmt && backing_fmt->value.s) {
+        backing_drv = bdrv_find_format(backing_fmt->value.s);
+        assert(backing_drv != NULL);
+    }
+
+    size = get_option_parameter(param, BLOCK_OPT_SIZE);
+    if (size && size->value.n <= 0) {
+        if (backing_file && backing_file->value.s) {
+            uint64_t size;
+            char buf[32];
+            int back_flags;
+
+            /* backing files always opened read-only */
+            back_flags =
+                flag &
+                ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
+
+            bs = bdrv_new("");
+
+            ret = bdrv_open(bs, backing_file->value.s,
+                                back_flags, backing_drv);
+            if (ret < 0) {
+                set_context_err(context, QB_ERR_INVALID_PARAM,
+                               "Failed to open the backing file.");
+                ret = context->err_ret;
+                goto out;
+            }
+            bdrv_get_geometry(bs, &size);
+            size *= BDRV_SECTOR_SIZE;
+
+            snprintf(buf, sizeof(buf), "%" PRId64, size);
+            set_option_parameter(param, BLOCK_OPT_SIZE, buf);
+        } else {
+            set_context_err(context, QB_ERR_INTERNAL_ERR,
+                           "Neither size or backing file was not set.");
+            ret = context->err_ret;
+            goto out;
+        }
+    }
+
+    bd_ret = bdrv_create(drv, filename, param);
+
+
+    if (bd_ret < 0) {
+        const char *errstr;
+        if (bd_ret == -ENOTSUP) {
+            errstr = "formatting option not supported.";
+        } else if (bd_ret == -EFBIG) {
+            errstr = "The image size is too large.";
+        } else {
+            errstr = "Error in creating the image.";
+        }
+        set_context_err(context, QB_ERR_INTERNAL_ERR, errstr);
+        ret = context->err_ret;
+    }
+
+out:
+    free_option_parameters(create_options);
+    free_option_parameters(param);
+    FUNC_FREE(filename);
+    if (bs) {
+        bdrv_delete(bs);
+    }
+
+    return ret;
+}
+
+int qb_open(QBlockContext *context,
+            QBlockState *qbs,
+            QBlockLocationInfo *loc,
+            QBlockFormatInfo *fmt,
+            int flag)
+{
+    int ret = 0, bd_ret;
+    BlockDriverState *bs;
+    BlockDriver *bd;
+    const char *fmtstr;
+    char *filename = NULL;
+
+    /* take care of user settings */
+    /* do nothing now */
+
+    /* check parameters */
+    if (flag & (~LIBQBLOCK_O_VALID_MASK)) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                      "Invalid flag was set.");
+        ret = context->err_ret;
+        goto out;
+    }
+
+    if ((loc == NULL) || (qbs == NULL)) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                      "Got unexpected NULL pointer in parameters.");
+        ret = context->err_ret;
+        goto out;
+    }
+
+    ret = loc_check_params(context, loc);
+    if (ret != 0) {
+        goto out;
+    }
+
+    /* internal translate */
+    ret = loc2filename(context, loc, &filename);
+    if (ret != 0) {
+        goto out;
+    }
+
+    fmtstr = NULL;
+    bd = NULL;
+    if (fmt != NULL) {
+        fmtstr = qb_fmttype2str(fmt->fmt_type);
+    }
+
+    if (fmtstr != NULL) {
+        bd = bdrv_find_format(fmtstr);
+        assert(bd != NULL);
+    }
+
+    /* do real opening */
+    bs = qbs->bdrvs;
+    bd_ret = bdrv_open(bs, filename, flag, bd);
+    if (bd_ret < 0) {
+        set_context_err(context, QB_ERR_INTERNAL_ERR,
+                      "Failed in opening with driver, bd_ret is %d.", bd_ret);
+        ret = context->err_ret;
+        goto out;
+    }
+
+    if (qbs->filename != NULL) {
+        FUNC_FREE(qbs->filename);
+    }
+    qbs->filename = FUNC_STRDUP(filename);
+
+ out:
+    FUNC_FREE(filename);
+    return ret;
+}
+
+void qb_close(QBlockContext *context,
+              QBlockState *qbs)
+{
+    BlockDriverState *bs;
+
+    bs = qbs->bdrvs;
+
+    if (qbs->filename != NULL) {
+        CLEAN_FREE(qbs->filename);
+        bdrv_close(bs);
+    }
+    return;
+}
+
+int32_t qb_read(QBlockContext *context,
+                QBlockState *qbs,
+                uint8_t *buf,
+                uint32_t len,
+                uint64_t offset)
+{
+    int bd_ret;
+    BlockDriverState *bs;
+    uint8_t temp_buf[BDRV_SECTOR_SIZE], *p;
+    uint64_t sector_start;
+    int sector_num, byte_offset, cp_len;
+    uint32_t remains;
+
+    context->err_ret = 0;
+    bs = qbs->bdrvs;
+
+    if (len <= 0) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                      "Param len is less or equal to zero.");
+        return context->err_ret;
+    }
+
+    p = buf;
+    remains = len;
+
+    sector_start = offset >> BDRV_SECTOR_BITS;
+
+    byte_offset = offset & (~BDRV_SECTOR_MASK);
+    if (byte_offset != 0) {
+        /* the start sector is not alligned, need to read/write this sector. */
+        bd_ret = bdrv_read(bs, sector_start, temp_buf, 1);
+        if (bd_ret < 0) {
+            set_context_err(context, QB_ERR_INTERNAL_ERR,
+                           "QEMU internal block error.");
+            context->err_no = bd_ret;
+            return context->err_ret;
+        }
+        cp_len = BDRV_SECTOR_SIZE - byte_offset;
+        memcpy(p, temp_buf + byte_offset, cp_len);
+
+        remains -= cp_len;
+        p += cp_len;
+        sector_start++;
+    }
+
+    /* now start position is alligned. */
+    if (remains >= BDRV_SECTOR_SIZE) {
+        sector_num = remains >> BDRV_SECTOR_BITS;
+        bd_ret = bdrv_read(bs, sector_start, p, sector_num);
+        if (bd_ret < 0) {
+            set_context_err(context, QB_ERR_INTERNAL_ERR,
+                           "QEMU internal block error.");
+            context->err_no = bd_ret;
+            return context->err_ret;
+        }
+        remains -= sector_num << BDRV_SECTOR_BITS;
+        p += sector_num << BDRV_SECTOR_BITS;
+        sector_start += sector_num;
+    }
+
+    if (remains > 0) {
+        /* there is some request remains, less than 1 sector */
+        bd_ret = bdrv_read(bs, sector_start, temp_buf, 1);
+        if (bd_ret < 0) {
+            set_context_err(context, QB_ERR_INTERNAL_ERR,
+                           "QEMU internal block error.");
+            context->err_no = bd_ret;
+            return context->err_ret;
+        }
+        memcpy(p, temp_buf, remains);
+        remains -= remains;
+    }
+
+    return len-remains;
+}
+
+int32_t qb_write(QBlockContext *context,
+                 QBlockState *qbs,
+                 const uint8_t *buf,
+                 uint32_t len,
+                 uint64_t offset)
+{
+    int bd_ret;
+    BlockDriverState *bs;
+    uint8_t temp_buf[BDRV_SECTOR_SIZE];
+    const uint8_t *p;
+    uint64_t sector_start;
+    int sector_num, byte_offset, cp_len;
+    uint32_t remains;
+
+    context->err_ret = 0;
+    bs = qbs->bdrvs;
+
+    if (len <= 0) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                      "Param len is less or equal to zero.");
+        return context->err_ret;
+    }
+
+    p = buf;
+    remains = len;
+
+    sector_start = offset >> BDRV_SECTOR_BITS;
+
+    byte_offset = offset & (~BDRV_SECTOR_MASK);
+    if (byte_offset != 0) {
+        /* the start sector is not alligned, need to read/write this sector. */
+        bd_ret = bdrv_read(bs, sector_start, temp_buf, 1);
+        if (bd_ret < 0) {
+            set_context_err(context, QB_ERR_INTERNAL_ERR,
+                           "QEMU internal block error.");
+            context->err_no = bd_ret;
+            return context->err_ret;
+        }
+        cp_len = BDRV_SECTOR_SIZE - byte_offset;
+        memcpy(temp_buf + byte_offset, p, cp_len);
+        bd_ret = bdrv_write(bs, sector_start, temp_buf, 1);
+        if (bd_ret < 0) {
+            set_context_err(context, QB_ERR_INTERNAL_ERR,
+                           "QEMU internal block error.");
+            context->err_no = bd_ret;
+            return context->err_ret;
+        }
+        remains -= cp_len;
+        p += cp_len;
+        sector_start++;
+    }
+
+    /* now start position is alligned. */
+    if (remains >= BDRV_SECTOR_SIZE) {
+        sector_num = remains >> BDRV_SECTOR_BITS;
+        bd_ret = bdrv_write(bs, sector_start, p, sector_num);
+        if (bd_ret < 0) {
+            set_context_err(context, QB_ERR_INTERNAL_ERR,
+                           "QEMU internal block error.");
+            context->err_no = bd_ret;
+            return context->err_ret;
+        }
+        remains -= sector_num << BDRV_SECTOR_BITS;
+        p += sector_num << BDRV_SECTOR_BITS;
+        sector_start += sector_num;
+    }
+
+    if (remains > 0) {
+        /* there is some request remains, less than 1 sector */
+        bd_ret = bdrv_read(bs, sector_start, temp_buf, 1);
+        if (bd_ret < 0) {
+            set_context_err(context, QB_ERR_INTERNAL_ERR,
+                           "QEMU internal block error.");
+            context->err_no = bd_ret;
+            return context->err_ret;
+        }
+        memcpy(temp_buf, p, remains);
+        bd_ret = bdrv_write(bs, sector_start, temp_buf, 1);
+        if (bd_ret < 0) {
+            set_context_err(context, QB_ERR_INTERNAL_ERR,
+                           "QEMU internal block error.");
+            context->err_no = bd_ret;
+            return context->err_ret;
+        }
+        remains -= remains;
+    }
+
+    return len-remains;
+}
+
+int qb_flush(QBlockContext *context,
+             QBlockState *qbs)
+{
+    int bd_ret;
+    BlockDriverState *bs;
+
+    context->err_ret = 0;
+    bs = qbs->bdrvs;
+    bd_ret = bdrv_flush(bs);
+    if (bd_ret < 0) {
+        set_context_err(context, QB_ERR_INTERNAL_ERR,
+                       "Internal error.");
+    }
+    return context->err_ret;
+}
+
+int qb_check_allocation(QBlockContext *context,
+                        QBlockState *qbs,
+                        uint64_t start,
+                        int64_t length,
+                        int *pstatus,
+                        int64_t *plength)
+{
+    int ret;
+    int sector_start, sector_num, num;
+    BlockDriverState *bs;
+    unsigned int real_len, ret_len;
+
+    context->err_ret = 0;
+    bs = qbs->bdrvs;
+
+    if (length > 0x1000000000000) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                       "length is too big.");
+        goto out;
+    }
+
+    if (qbs->filename == NULL) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                       "Image was not opened first.");
+        goto out;
+    }
+
+    if (length <= 0) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                       "length is not valid.");
+        goto out;
+    }
+
+    /* translate to sector */
+    sector_start = start >> BDRV_SECTOR_BITS;
+    real_len = (start & (~BDRV_SECTOR_MASK)) + length;
+    sector_num = real_len >> BDRV_SECTOR_BITS;
+    if ((real_len & (~BDRV_SECTOR_MASK)) != 0) {
+        sector_num++;
+    }
+
+    ret = bdrv_is_allocated(bs, sector_start, sector_num, &num);
+    if ((ret == 0) && (num == 0)) {
+        set_context_err(context, QB_ERR_BLOCK_OUT_OF_RANGE,
+                       "Start position was bigger than the image's size.");
+        goto out;
+    }
+
+    *pstatus = ret;
+    ret_len = (num << BDRV_SECTOR_BITS) - (start & (~BDRV_SECTOR_MASK));
+    if (ret_len > length) {
+        ret_len = length;
+    }
+    *plength = ret_len;
+
+ out:
+    return context->err_ret;
+}
+
+static void qb_setup_info_addr(const QBlockStaticInfo *info,
+                               QBlockStaticInfoAddr *info_addr)
+{
+    const uint64_t *virt_size = NULL;
+    const QBlockLocationInfo *backing_loc = NULL;
+    const bool *encrypt = NULL;
+    const QBlockFormatInfo *fmt = &(info->fmt);
+
+    switch (fmt->fmt_type) {
+    case QB_FMT_COW:
+        virt_size = &(fmt->o_cow.virt_size);
+        backing_loc = &(fmt->o_cow.backing_loc);
+        break;
+    case QB_FMT_QED:
+        virt_size = &(fmt->o_qed.virt_size);
+        backing_loc = &(fmt->o_qed.backing_loc);
+        break;
+    case QB_FMT_QCOW:
+        virt_size = &(fmt->o_qcow.virt_size);
+        backing_loc = &(fmt->o_qcow.backing_loc);
+        encrypt = &(fmt->o_qcow.encrypt);
+        break;
+    case QB_FMT_QCOW2:
+        virt_size = &(fmt->o_qcow2.virt_size);
+        backing_loc = &(fmt->o_qcow2.backing_loc);
+        encrypt = &(fmt->o_qcow2.encrypt);
+        break;
+    case QB_FMT_RAW:
+        virt_size = &(fmt->o_raw.virt_size);
+        break;
+    case QB_FMT_RBD:
+        virt_size = &(fmt->o_rbd.virt_size);
+        break;
+    case QB_FMT_SHEEPDOG:
+        virt_size = &(fmt->o_sd.virt_size);
+        backing_loc = &(fmt->o_sd.backing_loc);
+        break;
+    case QB_FMT_VDI:
+        virt_size = &(fmt->o_vdi.virt_size);
+        break;
+    case QB_FMT_VMDK:
+        virt_size = &(fmt->o_vmdk.virt_size);
+        backing_loc = &(fmt->o_vmdk.backing_loc);
+        break;
+    case QB_FMT_VPC:
+        virt_size = &(fmt->o_vpc.virt_size);
+        break;
+    default:
+        break;
+    }
+
+    info_addr->virt_size = (uint64_t *)virt_size;
+    info_addr->backing_loc = (QBlockLocationInfo *)backing_loc;
+    info_addr->encrypt = (bool *)encrypt;
+    return;
+}
+
+const uint64_t *qb_get_virt_size(const QBlockStaticInfo *info)
+{
+    QBlockStaticInfoAddr addr;
+    memset(&addr, 0, sizeof(QBlockStaticInfoAddr));
+    qb_setup_info_addr(info, &addr);
+    return addr.virt_size;
+}
+
+const QBlockLocationInfo *qb_get_backing_loc(const QBlockStaticInfo *info)
+{
+    QBlockStaticInfoAddr addr;
+    memset(&addr, 0, sizeof(QBlockStaticInfoAddr));
+    qb_setup_info_addr(info, &addr);
+    return addr.backing_loc;
+}
+
+const bool *qb_get_encrypt(const QBlockStaticInfo *info)
+{
+    QBlockStaticInfoAddr addr;
+    memset(&addr, 0, sizeof(QBlockStaticInfoAddr));
+    qb_setup_info_addr(info, &addr);
+    return addr.encrypt;
+}
+
+int qb_info_image_static_get(QBlockContext *context,
+                             QBlockState *qbs,
+                             QBlockStaticInfo **info)
+{
+    int ret = 0;
+    BlockDriverState *bs;
+    QBlockStaticInfo *info_tmp;
+    QBlockStaticInfoAddr *member_addr, addr;
+    const char *fmt_str;
+    uint64_t total_sectors;
+    char backing_filename[LIBQB_FILENAME_MAX];
+
+    if (qbs->filename == NULL) {
+        set_context_err(context, QB_ERR_INVALID_PARAM,
+                       "Block Image was not openned.");
+        ret = context->err_ret;
+        goto out;
+    }
+
+    info_tmp = FUNC_CALLOC(1, sizeof(QBlockStaticInfo));
+
+    bs = qbs->bdrvs;
+
+    ret = filename2loc(context,
+                       &(info_tmp->loc),
+                       qbs->filename);
+    if (ret < 0) {
+        goto free;
+    }
+
+    fmt_str = bdrv_get_format_name(bs);
+    info_tmp->fmt.fmt_type = qb_str2fmttype(fmt_str);
+    /* we got the format type and basic location info now, setup the struct
+    pointer to the internal members */
+    memset(&addr, 0, sizeof(QBlockStaticInfoAddr));
+    member_addr = &addr;
+    qb_setup_info_addr(info_tmp, member_addr);
+
+    assert(member_addr->virt_size != NULL);
+    bdrv_get_geometry(bs, &total_sectors);
+    *(member_addr->virt_size) = total_sectors * BDRV_SECTOR_SIZE;
+
+    if (member_addr->encrypt != NULL) {
+        *(member_addr->encrypt) = bdrv_is_encrypted(bs);
+    }
+
+    bdrv_get_full_backing_filename(bs, backing_filename,
+                                   sizeof(backing_filename));
+    if (backing_filename[0] != '\0') {
+        assert(member_addr->backing_loc != NULL);
+        ret = filename2loc(context,
+                           member_addr->backing_loc,
+                           backing_filename);
+        if (ret < 0) {
+            goto free;
+        }
+    }
+
+    info_tmp->sector_size = BDRV_SECTOR_SIZE;
+    *info = info_tmp;
+
+ out:
+    return ret;
+ free:
+    qb_info_image_static_delete(context, &info_tmp);
+    return ret;
+}
+
+/* free locations if it has string allocated on heap. */
+static void loc_free(QBlockLocationInfo *loc)
+{
+    switch (loc->prot_type) {
+    case QB_PROTO_FILE:
+        FUNC_FREE((void *)(loc->o_file.filename));
+        loc->o_file.filename = NULL;
+        break;
+    default:
+        break;
+    }
+}
+
+/* free fmt related resoure. */
+static void fmt_free(QBlockFormatInfo *fmt)
+{
+    switch (fmt->fmt_type) {
+    case QB_FMT_COW:
+        loc_free(&(fmt->o_cow.backing_loc));
+        break;
+    case QB_FMT_QED:
+        loc_free(&(fmt->o_qed.backing_loc));
+        break;
+    case QB_FMT_QCOW:
+        loc_free(&(fmt->o_qcow.backing_loc));
+        break;
+    case QB_FMT_QCOW2:
+        loc_free(&(fmt->o_qcow2.backing_loc));
+        break;
+    case QB_FMT_RAW:
+        break;
+    case QB_FMT_RBD:
+        break;
+    case QB_FMT_SHEEPDOG:
+        loc_free(&(fmt->o_sd.backing_loc));
+        break;
+    case QB_FMT_VDI:
+        break;
+    case QB_FMT_VMDK:
+        loc_free(&(fmt->o_vmdk.backing_loc));
+        break;
+    case QB_FMT_VPC:
+        break;
+    default:
+        break;
+    }
+    return;
+}
+
+
+void qb_info_image_static_delete(QBlockContext *context,
+                                 QBlockStaticInfo **info)
+{
+    loc_free(&(*info)->loc);
+    fmt_free(&(*info)->fmt);
+    CLEAN_FREE(*info);
+}
+
+QBlockLocationInfo *qb_loc_info_dup(const QBlockLocationInfo *prot)
+{
+    QBlockLocationInfo *p = FUNC_CALLOC(1, sizeof(QBlockLocationInfo));
+    p->prot_type = prot->prot_type;
+    switch (p->prot_type) {
+    case QB_PROTO_FILE:
+        p->o_file.filename =
+                          FUNC_STRDUP(prot->o_file.filename);
+        break;
+    default:
+        break;
+    }
+    return p;
+}
diff --git a/libqblock/libqblock.h b/libqblock/libqblock.h
index e69de29..8ca7d28 100644
--- a/libqblock/libqblock.h
+++ b/libqblock/libqblock.h
@@ -0,0 +1,341 @@
+/*
+ * QEMU block layer library
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
+ *
+ * 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_H
+#define LIBQBLOCK_H
+
+#include "libqblock-types.h"
+#include "libqblock-error.h"
+
+/**
+ * qb_context_new: allocate a new context.
+ *
+ * Broker is used to pass operation to libqblock, and get feedback from it.
+ *
+ * Returns 0 on success, libqblock negative error value on fail.
+ *
+ * @context: used to receive the created struct.
+ */
+DLL_PUBLIC
+int qb_context_new(QBlockContext **context);
+
+/**
+ * qb_context_delete: delete context.
+ *
+ * Broker will be freed and set to NULL.
+ *
+ * @context: operation context to be deleted.
+ */
+DLL_PUBLIC
+void qb_context_delete(QBlockContext **context);
+
+/**
+ * qb_state_new: allocate a new QBlockState struct
+ *
+ * Subsequent qblock actions will use this struct
+ *
+ * Returns 0 if succeed, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @qbs: used to receive the created struct.
+ */
+DLL_PUBLIC
+int qb_state_new(QBlockContext *context,
+                 QBlockState **qbs);
+
+/**
+ * qb_state_delete: free a QBlockState struct
+ *
+ * if image was opened, qb_close should be called before delete, otherwise
+ *  it would be automatically closed.
+ *
+ * @context: operation context.
+ * @qbs: pointer to the struct's pointer.
+ */
+DLL_PUBLIC
+void qb_state_delete(QBlockContext *context,
+                     QBlockState **qbs);
+
+/**
+ * qb_loc_info_new: create a new QBlockLocationInfo object.
+ *
+ * return 0 on success, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @loc: pointer to receive the new created one.
+ */
+DLL_PUBLIC
+int qb_loc_info_new(QBlockContext *context,
+                    QBlockLocationInfo **loc);
+
+/**
+ * qb_loc_info_delete: free a QBlockLocationInfo.
+ *
+ * @context: operation context.
+ * @loc: pointer to the object, *loc would be set to NULL.
+ */
+DLL_PUBLIC
+void qb_loc_info_delete(QBlockContext *context,
+                        QBlockLocationInfo **loc);
+
+/**
+ * qb_fmt_info_new: create a new QBlockFormatInfo structure.
+ *
+ * return 0 on success, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @op: pointer that will receive created struct.
+ */
+DLL_PUBLIC
+int qb_fmt_info_new(QBlockContext *context,
+                    QBlockFormatInfo **fmt);
+
+/**
+ * qb_fmt_info_delete: free QBlockFormatInfo structure.
+ *
+ * @context: operation context.
+ * @fmt: pointer to the struct, *fmt would be set to NULL.
+ */
+DLL_PUBLIC
+void qb_fmt_info_delete(QBlockContext *context,
+                        QBlockFormatInfo **fmt);
+
+
+/**
+ * qb_open: open a block object.
+ *
+ * return 0 on success, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @qbs: pointer to QBlockState.
+ * @loc: location options for open, how to find the image.
+ * @fmt: format options, how to extract the data, only valid member now is
+ *    fmt->fmt_type, set to NULL if you want to auto discovery the format.
+ * @flag: behavior control flags, it is LIBQBLOCK_O_XXX's combination.
+ *
+ * Note: For raw image, there is a risk that it's content is changed to some
+ *  magic value resulting a wrong probing done by libqblock, so don't do
+ * probing on raw images.
+ */
+DLL_PUBLIC
+int qb_open(QBlockContext *context,
+            QBlockState *qbs,
+            QBlockLocationInfo *loc,
+            QBlockFormatInfo *fmt,
+            int flag);
+
+/**
+ * qb_close: close a block object.
+ *
+ * qb_flush is automatically done inside.
+ *
+ * @context: operation context.
+ * @qbs: pointer to QBlockState.
+ */
+DLL_PUBLIC
+void qb_close(QBlockContext *context,
+              QBlockState *qbs);
+
+/**
+ * qb_create: create a block image or object.
+ *
+ * Note: Create operation would not open the image automatically.
+ *
+ * return 0 on success, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @qbs: pointer to QBlockState.
+ * @loc: location options for open, how to find the image.
+ * @fmt: format options, how to extract the data.
+ * @flag: behavior control flags, LIBQBLOCK_O_XXX's combination.
+ */
+DLL_PUBLIC
+int qb_create(QBlockContext *context,
+              QBlockState *qbs,
+              QBlockLocationInfo *loc,
+              QBlockFormatInfo *fmt,
+              int flag);
+
+
+/* sync access */
+/**
+ * qb_read: block sync read.
+ *
+ * return number of bytes read, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @qbs: pointer to QBlockState.
+ * @buf: buffer that receive the content.
+ * @len: length to read.
+ * @offset: offset in the block data.
+ */
+DLL_PUBLIC
+int32_t qb_read(QBlockContext *context,
+                QBlockState *qbs,
+                uint8_t *buf,
+                uint32_t len,
+                uint64_t offset);
+
+/**
+ * qb_write: block sync write.
+ *
+ * return number of bytes written, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @qbs: pointer to QBlockState.
+ * @buf: buffer that receive the content.
+ * @len: length to write.
+ * @offset: offset in the block data.
+ */
+DLL_PUBLIC
+int32_t qb_write(QBlockContext *context,
+                 QBlockState *qbs,
+                 const uint8_t *buf,
+                 uint32_t len,
+                 uint64_t offset);
+
+/**
+ * qb_flush: block sync flush.
+ *
+ * return 0 on success, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @qbs: pointer to QBlockState.
+ */
+DLL_PUBLIC
+int qb_flush(QBlockContext *context,
+             QBlockState *qbs);
+
+
+/* advance image APIs */
+/**
+ * qb_check_allocation: check if [start, start+lenth-1] was allocated on the
+ *  image.
+ *
+ * return 0 on success, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @qbs: pointer to QBlockState.
+ * @start: start position, unit is byte.
+ * @length: length to check, unit is byte, max is 1TB, otherwise will return
+ *   QB_ERR_INVALID_PARAM.
+ * @pstatus: pointer to receive the status, 1 means allocated,
+ *  0 means unallocated.
+ * @plength: pointer to receive the length that all have the same status as
+ *  *pstatus.
+ *
+ * Note: after return, start+*plength may have the same status as
+ *  start+*plength-1.
+ */
+DLL_PUBLIC
+int qb_check_allocation(QBlockContext *context,
+                        QBlockState *qbs,
+                        uint64_t start,
+                        int64_t length,
+                        int *pstatus,
+                        int64_t *plength);
+
+/* image information */
+/**
+ * qb_get_image_info: get image info.
+ *
+ * return 0 on success, libqblock negative error value on fail.
+ *
+ * @context: operation context.
+ * @qbs: pointer to QBlockState.
+ * @info: pointer that would receive the information.
+ *
+ * *info must be not modified after return, qb_info_image_static_delete will
+ *   use the information in it.
+ */
+DLL_PUBLIC
+int qb_info_image_static_get(QBlockContext *context,
+                             QBlockState *qbs,
+                             QBlockStaticInfo **info);
+
+/**
+ * qb_delete_image_info: free image info.
+ *
+ * @context: operation context.
+ * @info: pointer to the information struct.
+ */
+DLL_PUBLIC
+void qb_info_image_static_delete(QBlockContext *context,
+                                 QBlockStaticInfo **info);
+
+/* helper functions */
+/**
+ * qb_str2fmttype: translate format string to libqblock format enum type.
+ *
+ * return the type, or QB_FMT_NONE if string matches none of supported types.
+ *
+ * @fmt: the format string.
+ */
+DLL_PUBLIC
+QBlockFormat qb_str2fmttype(const char *fmt_str);
+
+/**
+ * qb_fmttype2str: translate libqblock format enum type to a string.
+ *
+ * return a pointer to the string, or NULL if type is not supported, and
+ *  returned pointer must NOT be freed.
+ *
+ * @fmt: the format enum type.
+ */
+DLL_PUBLIC
+const char *qb_fmttype2str(QBlockFormat fmt_type);
+
+/**
+ * qb_loc_info_dup: duplicate a QBlockLocationInfo instance.
+ *
+ * return a pointer to new allocated one having the same values with input,
+ *  it need to be freed by qb_loc_info_delete later. Never fail except OOM.
+ *
+ * @loc: pointer to the source instance.
+ */
+DLL_PUBLIC
+QBlockLocationInfo *qb_loc_info_dup(const QBlockLocationInfo *loc);
+
+/**
+ * qb_get_virt_size: get virtual size.
+ *
+ * return a pointer, which pointer to a member in info, or NULL if info is
+ *  not valid.
+ *
+ * @info: pointer to the QBlockStaticInfo structure.
+ */
+DLL_PUBLIC
+const uint64_t *qb_get_virt_size(const QBlockStaticInfo *info);
+
+/**
+ * qb_get_backing_loc: get backing file location.
+ *
+ * return a pointer, which pointer to a member in info, or NULL if info is
+ *  not valid, or image have no such property.
+ *
+ * @info: pointer to the QBlockStaticInfo structure.
+ */
+DLL_PUBLIC
+const QBlockLocationInfo *qb_get_backing_loc(const QBlockStaticInfo *info);
+
+/**
+ * qb_get_encrypt: get encrytion flag.
+ *
+ * return a pointer, which pointer to a member in info, or NULL if info is
+ *  not valid, or image have no such property.
+ *
+ * @info: pointer to the QBlockStaticInfo structure.
+ */
+DLL_PUBLIC
+const bool *qb_get_encrypt(const QBlockStaticInfo *info);
+#endif
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH V9 8/8] libqblock test example
  2012-11-16 10:12 [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library Wenchao Xia
                   ` (6 preceding siblings ...)
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 7/8] libqblock API Wenchao Xia
@ 2012-11-16 10:12 ` Wenchao Xia
  7 siblings, 0 replies; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: kwolf, peter.maydell, aliguori, stefanha, blauwirbel, pbonzini,
	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.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 tests/libqblock/libqblock-qcow2.c |  390 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 389 insertions(+), 1 deletions(-)

diff --git a/tests/libqblock/libqblock-qcow2.c b/tests/libqblock/libqblock-qcow2.c
index c05c0c4..15e81b8 100644
--- a/tests/libqblock/libqblock-qcow2.c
+++ b/tests/libqblock/libqblock-qcow2.c
@@ -1,4 +1,392 @@
+/*
+ * QEMU block layer library test
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Wenchao Xia   <xiawenc@linux.vnet.ibm.com>
+ *
+ * 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;
 }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly Wenchao Xia
@ 2012-11-16 10:23   ` Peter Maydell
  2012-11-16 10:31     ` Wenchao Xia
  0 siblings, 1 reply; 26+ messages in thread
From: Peter Maydell @ 2012-11-16 10:23 UTC (permalink / raw)
  To: Wenchao Xia; +Cc: kwolf, aliguori, stefanha, qemu-devel, blauwirbel, pbonzini

On 16 November 2012 10:12, Wenchao Xia <xiawenc@linux.vnet.ibm.com> wrote:
>   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.
>
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  Makefile       |    2 +-
>  configure      |    2 +-
>  tests/Makefile |    7 +++++++
>  3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index f40885b..8201e80 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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.

>         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; \
> diff --git a/configure b/configure
> index f847ee2..a18e267 100755
> --- a/configure
> +++ b/configure
> @@ -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"
> diff --git a/tests/Makefile b/tests/Makefile
> index 9bf0765..a286622 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -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)

Overlong line.

-- PMM

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
  2012-11-16 10:23   ` Peter Maydell
@ 2012-11-16 10:31     ` Wenchao Xia
  2012-11-16 10:56       ` Paolo Bonzini
  0 siblings, 1 reply; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:31 UTC (permalink / raw)
  To: Peter Maydell; +Cc: kwolf, aliguori, stefanha, qemu-devel, blauwirbel, pbonzini

于 2012-11-16 18:23, Peter Maydell 写道:
> On 16 November 2012 10:12, Wenchao Xia <xiawenc@linux.vnet.ibm.com> wrote:
>>    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.
>>
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>   Makefile       |    2 +-
>>   configure      |    2 +-
>>   tests/Makefile |    7 +++++++
>>   3 files changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index f40885b..8201e80 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -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.
>
   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.

>>          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; \
>> diff --git a/configure b/configure
>> index f847ee2..a18e267 100755
>> --- a/configure
>> +++ b/configure
>> @@ -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"
>> diff --git a/tests/Makefile b/tests/Makefile
>> index 9bf0765..a286622 100644
>> --- a/tests/Makefile
>> +++ b/tests/Makefile
>> @@ -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)
>
> Overlong line.
>
> -- PMM
>
ok.



-- 
Best Regards

Wenchao Xia

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs Wenchao Xia
@ 2012-11-16 10:54   ` Paolo Bonzini
  2012-11-16 10:58     ` Wenchao Xia
  0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2012-11-16 10:54 UTC (permalink / raw)
  To: Wenchao Xia
  Cc: kwolf, peter.maydell, aliguori, stefanha, qemu-devel, blauwirbel

Il 16/11/2012 11:12, Wenchao Xia ha scritto:
>   Sub Makefile may 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

> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  Makefile      |   22 ----------------------
>  Makefile.objs |   22 ++++++++++++++++++++++
>  2 files changed, 22 insertions(+), 22 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 8201e80..2cde430 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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)
>  
> diff --git a/Makefile.objs b/Makefile.objs
> index 37be7e2..9da96ea 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -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
>  
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
  2012-11-16 10:31     ` Wenchao Xia
@ 2012-11-16 10:56       ` Paolo Bonzini
  2012-11-16 11:01         ` Wenchao Xia
  0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2012-11-16 10:56 UTC (permalink / raw)
  To: Wenchao Xia
  Cc: kwolf, Peter Maydell, aliguori, stefanha, qemu-devel, blauwirbel

Il 16/11/2012 11:31, Wenchao Xia ha scritto:
> 于 2012-11-16 18:23, Peter Maydell 写道:
>> On 16 November 2012 10:12, Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> wrote:
>>>    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.
>>>
>>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>>> ---
>>>   Makefile       |    2 +-
>>>   configure      |    2 +-
>>>   tests/Makefile |    7 +++++++
>>>   3 files changed, 9 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/Makefile b/Makefile
>>> index f40885b..8201e80 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -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.
>>
>   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.

Does it work if you change

ifneq ($(wildcard config-host.mak),)
include $(SRC_PATH)/tests/Makefile
endif

to

-include $(SRC_PATH)/tests/Makefile

?

Paolo

> 
>>>          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; \
>>> diff --git a/configure b/configure
>>> index f847ee2..a18e267 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -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"
>>> diff --git a/tests/Makefile b/tests/Makefile
>>> index 9bf0765..a286622 100644
>>> --- a/tests/Makefile
>>> +++ b/tests/Makefile
>>> @@ -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)
>>
>> Overlong line.
>>
>> -- PMM
>>
> ok.
> 
> 
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
  2012-11-16 10:54   ` Paolo Bonzini
@ 2012-11-16 10:58     ` Wenchao Xia
  2012-11-16 11:12       ` Paolo Bonzini
  0 siblings, 1 reply; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 10:58 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: kwolf, peter.maydell, aliguori, stefanha, qemu-devel, blauwirbel

于 2012-11-16 18:54, Paolo Bonzini 写道:
> Il 16/11/2012 11:12, Wenchao Xia ha scritto:
>>    Sub Makefile may 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.

>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>   Makefile      |   22 ----------------------
>>   Makefile.objs |   22 ++++++++++++++++++++++
>>   2 files changed, 22 insertions(+), 22 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 8201e80..2cde430 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -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)
>>
>> diff --git a/Makefile.objs b/Makefile.objs
>> index 37be7e2..9da96ea 100644
>> --- a/Makefile.objs
>> +++ b/Makefile.objs
>> @@ -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
>>
>>
>


-- 
Best Regards

Wenchao Xia

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
  2012-11-16 10:56       ` Paolo Bonzini
@ 2012-11-16 11:01         ` Wenchao Xia
  2012-11-16 11:16           ` Paolo Bonzini
  0 siblings, 1 reply; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 11:01 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: kwolf, Peter Maydell, aliguori, stefanha, qemu-devel, blauwirbel

于 2012-11-16 18:56, Paolo Bonzini 写道:
> Il 16/11/2012 11:31, Wenchao Xia ha scritto:
>> 于 2012-11-16 18:23, Peter Maydell 写道:
>>> On 16 November 2012 10:12, Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>>> wrote:
>>>>     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.
>>>>
>>>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>>>> ---
>>>>    Makefile       |    2 +-
>>>>    configure      |    2 +-
>>>>    tests/Makefile |    7 +++++++
>>>>    3 files changed, 9 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/Makefile b/Makefile
>>>> index f40885b..8201e80 100644
>>>> --- a/Makefile
>>>> +++ b/Makefile
>>>> @@ -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.
>>>
>>    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.
>
> Does it work if you change
>
> ifneq ($(wildcard config-host.mak),)
> include $(SRC_PATH)/tests/Makefile
> endif
>
> 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.

>>
>>>>           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; \
>>>> diff --git a/configure b/configure
>>>> index f847ee2..a18e267 100755
>>>> --- a/configure
>>>> +++ b/configure
>>>> @@ -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"
>>>> diff --git a/tests/Makefile b/tests/Makefile
>>>> index 9bf0765..a286622 100644
>>>> --- a/tests/Makefile
>>>> +++ b/tests/Makefile
>>>> @@ -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)
>>>
>>> Overlong line.
>>>
>>> -- PMM
>>>
>> ok.
>>
>>
>>
>


-- 
Best Regards

Wenchao Xia

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 5/8] libqblock build system
  2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 5/8] libqblock build system Wenchao Xia
@ 2012-11-16 11:08   ` Paolo Bonzini
  2012-11-18 13:06     ` Wenchao Xia
  0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2012-11-16 11:08 UTC (permalink / raw)
  To: Wenchao Xia
  Cc: kwolf, peter.maydell, aliguori, stefanha, qemu-devel, blauwirbel

Il 16/11/2012 11:12, Wenchao Xia ha scritto:
>   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.

Use $(SRC_PATH) instead in the install rules.

> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  .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
> 
> diff --git a/.gitignore b/.gitignore
> index bd6ba1c..76207fe 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -93,3 +93,5 @@ cscope.*
>  tags
>  TAGS
>  *~
> +tests/libqblock/check-*
> +tests/libqblock/test_images
> diff --git a/Makefile b/Makefile
> index 2cde430..4b0755d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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?

> +###########################################################################
> +
>  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
> diff --git a/configure b/configure
> index a18e267..b1a1722 100755
> --- a/configure
> +++ b/configure
> @@ -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.

>    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"

See above.

>  for bios_file in \
>      $source_path/pc-bios/*.bin \
>      $source_path/pc-bios/*.rom \
> diff --git a/libqblock/Makefile b/libqblock/Makefile
> new file mode 100644
> index 0000000..190ffb4
> --- /dev/null
> +++ b/libqblock/Makefile
> @@ -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
> +
> +#############################################################################
> +# 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.

> +#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).

> +
> +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)"
> diff --git a/libqblock/libqblock-error.c b/libqblock/libqblock-error.c
> new file mode 100644
> index 0000000..e69de29
> diff --git a/libqblock/libqblock-error.h b/libqblock/libqblock-error.h
> new file mode 100644
> index 0000000..e69de29
> diff --git a/libqblock/libqblock-types.h b/libqblock/libqblock-types.h
> new file mode 100644
> index 0000000..e69de29
> diff --git a/libqblock/libqblock.c b/libqblock/libqblock.c
> new file mode 100644
> index 0000000..e69de29
> diff --git a/libqblock/libqblock.h b/libqblock/libqblock.h
> new file mode 100644
> index 0000000..e69de29
> diff --git a/libqblock/libqblock.pc.in b/libqblock/libqblock.pc.in
> new file mode 100644
> index 0000000..d2a7d06
> --- /dev/null
> +++ b/libqblock/libqblock.pc.in
> @@ -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}
> diff --git a/tests/Makefile b/tests/Makefile
> index a286622..ee26ba5 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -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/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/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

> +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)
> diff --git a/tests/libqblock/libqblock-qcow2.c b/tests/libqblock/libqblock-qcow2.c
> new file mode 100644
> index 0000000..c05c0c4
> --- /dev/null
> +++ b/tests/libqblock/libqblock-qcow2.c
> @@ -0,0 +1,4 @@
> +int main(int argc, char **argv)
> +{
> +    return 0;
> +}
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
  2012-11-16 10:58     ` Wenchao Xia
@ 2012-11-16 11:12       ` Paolo Bonzini
  2012-11-18 12:56         ` Wenchao Xia
  0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2012-11-16 11:12 UTC (permalink / raw)
  To: Wenchao Xia
  Cc: kwolf, peter.maydell, aliguori, stefanha, qemu-devel, blauwirbel

Il 16/11/2012 11:58, Wenchao Xia ha scritto:
>>>    Sub Makefile may 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.

> 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
  2012-11-16 11:01         ` Wenchao Xia
@ 2012-11-16 11:16           ` Paolo Bonzini
  2012-11-16 12:40             ` Wenchao Xia
  0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2012-11-16 11:16 UTC (permalink / raw)
  To: Wenchao Xia
  Cc: kwolf, Peter Maydell, aliguori, stefanha, qemu-devel, blauwirbel

Il 16/11/2012 12:01, Wenchao Xia ha scritto:
>>
>>
>> ifneq ($(wildcard config-host.mak),)
>> include $(SRC_PATH)/tests/Makefile
>> endif
>>
>> 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":

diff --git a/Makefile b/Makefile
index 81c660f..b994109 100644
--- a/Makefile
+++ b/Makefile
@@ -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

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
  2012-11-16 11:16           ` Paolo Bonzini
@ 2012-11-16 12:40             ` Wenchao Xia
  2012-11-16 12:49               ` Paolo Bonzini
  0 siblings, 1 reply; 26+ messages in thread
From: Wenchao Xia @ 2012-11-16 12:40 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: kwolf, Peter Maydell, aliguori, stefanha, qemu-devel, blauwirbel

于 2012-11-16 19:16, Paolo Bonzini 写道:
> Il 16/11/2012 12:01, Wenchao Xia ha scritto:
>>>
>>>
>>> ifneq ($(wildcard config-host.mak),)
>>> include $(SRC_PATH)/tests/Makefile
>>> endif
>>>
>>> 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":
>
> diff --git a/Makefile b/Makefile
> index 81c660f..b994109 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -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
>

   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.
-- 
Best Regards

Wenchao Xia

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
  2012-11-16 12:40             ` Wenchao Xia
@ 2012-11-16 12:49               ` Paolo Bonzini
  2012-11-18 13:09                 ` Wenchao Xia
  0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2012-11-16 12:49 UTC (permalink / raw)
  To: Wenchao Xia
  Cc: kwolf, Peter Maydell, aliguori, stefanha, qemu-devel, blauwirbel

Il 16/11/2012 13:40, Wenchao Xia ha scritto:
>   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.

Whatever, this seems to be ok.  Please post the complete patch so we can
review it.

Paolo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
  2012-11-16 11:12       ` Paolo Bonzini
@ 2012-11-18 12:56         ` Wenchao Xia
  2012-11-18 14:55           ` Paolo Bonzini
  0 siblings, 1 reply; 26+ messages in thread
From: Wenchao Xia @ 2012-11-18 12:56 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: kwolf, peter.maydell, aliguori, stefanha, qemu-devel, blauwirbel

于 2012-11-16 19:12, Paolo Bonzini 写道:
> Il 16/11/2012 11:58, Wenchao Xia ha scritto:
>>>>     Sub Makefile may 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.
>
>> 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.
>
   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.

> 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.

>
> Paolo
>


-- 
Best Regards

Wenchao Xia

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 5/8] libqblock build system
  2012-11-16 11:08   ` Paolo Bonzini
@ 2012-11-18 13:06     ` Wenchao Xia
  2012-11-18 14:58       ` Paolo Bonzini
  0 siblings, 1 reply; 26+ messages in thread
From: Wenchao Xia @ 2012-11-18 13:06 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: kwolf, peter.maydell, aliguori, stefanha, qemu-devel, blauwirbel

于 2012-11-16 19:08, Paolo Bonzini 写道:
> Il 16/11/2012 11:12, Wenchao Xia ha scritto:
>>    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.
>
> Use $(SRC_PATH) instead in the install rules.
>
   OK.

>>
>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>> ---
>>   .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
>>
>> diff --git a/.gitignore b/.gitignore
>> index bd6ba1c..76207fe 100644
>> --- a/.gitignore
>> +++ b/.gitignore
>> @@ -93,3 +93,5 @@ cscope.*
>>   tags
>>   TAGS
>>   *~
>> +tests/libqblock/check-*
>> +tests/libqblock/test_images
>> diff --git a/Makefile b/Makefile
>> index 2cde430..4b0755d 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -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?
>
   No one now, just provided an install rules similar to libcacard.

>> +###########################################################################
>> +
>>   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
>> diff --git a/configure b/configure
>> index a18e267..b1a1722 100755
>> --- a/configure
>> +++ b/configure
>> @@ -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.
>
   OK.

>>     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"
>
> See above.
>
   will remove.

>>   for bios_file in \
>>       $source_path/pc-bios/*.bin \
>>       $source_path/pc-bios/*.rom \
>> diff --git a/libqblock/Makefile b/libqblock/Makefile
>> new file mode 100644
>> index 0000000..190ffb4
>> --- /dev/null
>> +++ b/libqblock/Makefile
>> @@ -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
>> +
>> +#############################################################################
>> +# 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.

>> +#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).
>
   OK, I'll try remove tools-objs.

>> +
>> +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)"
>> diff --git a/libqblock/libqblock-error.c b/libqblock/libqblock-error.c
>> new file mode 100644
>> index 0000000..e69de29
>> diff --git a/libqblock/libqblock-error.h b/libqblock/libqblock-error.h
>> new file mode 100644
>> index 0000000..e69de29
>> diff --git a/libqblock/libqblock-types.h b/libqblock/libqblock-types.h
>> new file mode 100644
>> index 0000000..e69de29
>> diff --git a/libqblock/libqblock.c b/libqblock/libqblock.c
>> new file mode 100644
>> index 0000000..e69de29
>> diff --git a/libqblock/libqblock.h b/libqblock/libqblock.h
>> new file mode 100644
>> index 0000000..e69de29
>> diff --git a/libqblock/libqblock.pc.in b/libqblock/libqblock.pc.in
>> new file mode 100644
>> index 0000000..d2a7d06
>> --- /dev/null
>> +++ b/libqblock/libqblock.pc.in
>> @@ -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}
>> diff --git a/tests/Makefile b/tests/Makefile
>> index a286622..ee26ba5 100644
>> --- a/tests/Makefile
>> +++ b/tests/Makefile
>> @@ -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,$^)
>
ok.

>> +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.

>> +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.

> 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.

>> +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)
>> diff --git a/tests/libqblock/libqblock-qcow2.c b/tests/libqblock/libqblock-qcow2.c
>> new file mode 100644
>> index 0000000..c05c0c4
>> --- /dev/null
>> +++ b/tests/libqblock/libqblock-qcow2.c
>> @@ -0,0 +1,4 @@
>> +int main(int argc, char **argv)
>> +{
>> +    return 0;
>> +}
>>
>
>


-- 
Best Regards

Wenchao Xia

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly
  2012-11-16 12:49               ` Paolo Bonzini
@ 2012-11-18 13:09                 ` Wenchao Xia
  0 siblings, 0 replies; 26+ messages in thread
From: Wenchao Xia @ 2012-11-18 13:09 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: kwolf, Peter Maydell, aliguori, stefanha, qemu-devel, blauwirbel

于 2012-11-16 20:49, Paolo Bonzini 写道:
> Il 16/11/2012 13:40, Wenchao Xia ha scritto:
>>    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.
>
> 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.

-- 
Best Regards

Wenchao Xia

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs
  2012-11-18 12:56         ` Wenchao Xia
@ 2012-11-18 14:55           ` Paolo Bonzini
  0 siblings, 0 replies; 26+ messages in thread
From: Paolo Bonzini @ 2012-11-18 14:55 UTC (permalink / raw)
  To: Wenchao Xia
  Cc: kwolf, peter.maydell, aliguori, stefanha, qemu-devel, blauwirbel

Il 18/11/2012 13:56, Wenchao Xia ha scritto:
> 于 2012-11-16 19:12, Paolo Bonzini 写道:
>> Il 16/11/2012 11:58, Wenchao Xia ha scritto:
>>>>>     Sub Makefile may 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.
>>
>>> 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.
>>
>   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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 5/8] libqblock build system
  2012-11-18 13:06     ` Wenchao Xia
@ 2012-11-18 14:58       ` Paolo Bonzini
  2012-11-19  7:47         ` Wenchao Xia
  0 siblings, 1 reply; 26+ messages in thread
From: Paolo Bonzini @ 2012-11-18 14:58 UTC (permalink / raw)
  To: Wenchao Xia
  Cc: kwolf, peter.maydell, aliguori, stefanha, qemu-devel, blauwirbel

Il 18/11/2012 14:06, Wenchao Xia ha scritto:
> 于 2012-11-16 19:08, Paolo Bonzini 写道:
>> Il 16/11/2012 11:12, Wenchao Xia ha scritto:
>>>    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.
>>
>> Use $(SRC_PATH) instead in the install rules.
>>
>   OK.
> 
>>>
>>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>>> ---
>>>   .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
>>>
>>> diff --git a/.gitignore b/.gitignore
>>> index bd6ba1c..76207fe 100644
>>> --- a/.gitignore
>>> +++ b/.gitignore
>>> @@ -93,3 +93,5 @@ cscope.*
>>>   tags
>>>   TAGS
>>>   *~
>>> +tests/libqblock/check-*
>>> +tests/libqblock/test_images
>>> diff --git a/Makefile b/Makefile
>>> index 2cde430..4b0755d 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -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?
>>
>   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.


>>> +#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).
>>
>   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.


>>> +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.

>> 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH V9 5/8] libqblock build system
  2012-11-18 14:58       ` Paolo Bonzini
@ 2012-11-19  7:47         ` Wenchao Xia
  0 siblings, 0 replies; 26+ messages in thread
From: Wenchao Xia @ 2012-11-19  7:47 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: kwolf, peter.maydell, aliguori, stefanha, qemu-devel, blauwirbel

于 2012-11-18 22:58, Paolo Bonzini 写道:
> Il 18/11/2012 14:06, Wenchao Xia ha scritto:
>> 于 2012-11-16 19:08, Paolo Bonzini 写道:
>>> Il 16/11/2012 11:12, Wenchao Xia ha scritto:
>>>>     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.
>>>
>>> Use $(SRC_PATH) instead in the install rules.
>>>
>>    OK.
>>
>>>>
>>>> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
>>>> ---
>>>>    .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
>>>>
>>>> diff --git a/.gitignore b/.gitignore
>>>> index bd6ba1c..76207fe 100644
>>>> --- a/.gitignore
>>>> +++ b/.gitignore
>>>> @@ -93,3 +93,5 @@ cscope.*
>>>>    tags
>>>>    TAGS
>>>>    *~
>>>> +tests/libqblock/check-*
>>>> +tests/libqblock/test_images
>>>> diff --git a/Makefile b/Makefile
>>>> index 2cde430..4b0755d 100644
>>>> --- a/Makefile
>>>> +++ b/Makefile
>>>> @@ -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?
>>>
>>    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.

>
>>>> +#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).
>>>
>>    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.


>>>> +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.
>
   Thanks, this extended my knowledge.

>>> 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.

> Paolo
>


-- 
Best Regards

Wenchao Xia

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2012-11-19  7:48 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-16 10:12 [Qemu-devel] [PATCH V9 0/8] libqblock qemu block layer library Wenchao Xia
2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 1/8] Buildsystem fix distclean error in pixman Wenchao Xia
2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 2/8] Buildsystem clean tests directory clearly Wenchao Xia
2012-11-16 10:23   ` Peter Maydell
2012-11-16 10:31     ` Wenchao Xia
2012-11-16 10:56       ` Paolo Bonzini
2012-11-16 11:01         ` Wenchao Xia
2012-11-16 11:16           ` Paolo Bonzini
2012-11-16 12:40             ` Wenchao Xia
2012-11-16 12:49               ` Paolo Bonzini
2012-11-18 13:09                 ` Wenchao Xia
2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 3/8] Buildsystem move qapi generation to Makefile.objs Wenchao Xia
2012-11-16 10:54   ` Paolo Bonzini
2012-11-16 10:58     ` Wenchao Xia
2012-11-16 11:12       ` Paolo Bonzini
2012-11-18 12:56         ` Wenchao Xia
2012-11-18 14:55           ` Paolo Bonzini
2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 4/8] block export function path_has_protocol Wenchao Xia
2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 5/8] libqblock build system Wenchao Xia
2012-11-16 11:08   ` Paolo Bonzini
2012-11-18 13:06     ` Wenchao Xia
2012-11-18 14:58       ` Paolo Bonzini
2012-11-19  7:47         ` Wenchao Xia
2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 6/8] libqblock type defines Wenchao Xia
2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 7/8] libqblock API Wenchao Xia
2012-11-16 10:12 ` [Qemu-devel] [PATCH V9 8/8] libqblock test example Wenchao Xia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).