qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kwolf@redhat.com, peter.maydell@linaro.org, aliguori@us.ibm.com,
	stefanha@gmail.com, qemu-devel@nongnu.org, blauwirbel@gmail.com
Subject: Re: [Qemu-devel] [PATCH V9 5/8] libqblock build system
Date: Sun, 18 Nov 2012 21:06:19 +0800	[thread overview]
Message-ID: <50A8DD4B.9030304@linux.vnet.ibm.com> (raw)
In-Reply-To: <50A61EB5.4060105@redhat.com>

于 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

  reply	other threads:[~2012-11-18 13:06 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50A8DD4B.9030304@linux.vnet.ibm.com \
    --to=xiawenc@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=blauwirbel@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).