Re: [Qemu-devel] [RFC PATCH v3 1/5] make.rule: fix $(obj) to a real relative path
Il 10/09/2013 03:02, Fam Zheng ha scritto: Makefile.target includes rule.mak and unnested common-obj-y, then prefix them with '../', this will ignore object specific QEMU_CFLAGS in subdir Makefile.objs: $(obj)/curl.o: QEMU_CFLAGS += $(CURL_CFLAGS) Because $(obj) here is './block', instead of '../block'. This doesn't hurt compiling because we basically build all .o from top Makefile, before entering Makefile.target, but it will affact arriving per-object libs support. The starting point of $(obj) is fixed in $(obj-base) before including ./Makefile.objs, to get consistency with nested Makefile rules in target rule and variable definition. Signed-off-by: Fam Zheng f...@redhat.com Glad this worked. ) -dummy := $(call unnest-vars) diff --git a/Makefile.target b/Makefile.target index 9a49852..381022d 100644 --- a/Makefile.target +++ b/Makefile.target @@ -143,13 +143,15 @@ endif # CONFIG_SOFTMMU # Workaround for http://gcc.gnu.org/PR55489, see configure. %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS) -nested-vars += obj-y +nested-vars += obj-y block-obj-y common-obj-y # This resolves all nested paths, so it must come last This comment is now obsolete. include $(SRC_PATH)/Makefile.objs +obj-base := .. Strictly speaking obj-base=.. is incorrect for obj-y, isn't it? Does it work if you do block-obj-y = ../ common-obj-y = ../ instead of including $(SRC_PATH)/Makefile.objs? Then obj-base can be empty and is not needed. But the patch looks good already, I'm asking mostly to get a better understanding of the system. Paolo +dummy := $(call unnest-vars) all-obj-y = $(obj-y) -all-obj-y += $(addprefix ../, $(common-obj-y)) +all-obj-y += $(addprefix ../, $(common-obj-y) $(block-obj-y)) ifndef CONFIG_HAIKU LIBS+=-lm diff --git a/configure b/configure index e989609..cc3cd4d 100755 --- a/configure +++ b/configure @@ -2251,6 +2251,7 @@ fi if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then glib_cflags=`$pkg_config --cflags gthread-2.0` glib_libs=`$pkg_config --libs gthread-2.0` +CFLAGS=$glib_cflags $CFLAGS LIBS=$glib_libs $LIBS libs_qga=$glib_libs $libs_qga else diff --git a/rules.mak b/rules.mak index 4499745..3ff7d7a 100644 --- a/rules.mak +++ b/rules.mak @@ -103,7 +103,7 @@ clean: clean-timestamp # magic to descend into other directories -obj := . +obj = $(obj-base) old-nested-dirs := define push-var @@ -119,9 +119,11 @@ endef define unnest-dir $(foreach var,$(nested-vars),$(call push-var,$(var),$1/)) -$(eval obj := $(obj)/$1) +$(eval obj-parent-$1 := $(obj)) +$(eval obj := $(if $(obj),$(obj)/$1,$1)) $(eval include $(SRC_PATH)/$1/Makefile.objs) -$(eval obj := $(patsubst %/$1,%,$(obj))) +$(eval obj := $(obj-parent-$1)) +$(eval obj-parent-$1 := ) $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/)) endef diff --git a/tests/Makefile b/tests/Makefile index baba9e9..15ef039 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -110,6 +110,10 @@ test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o $(test-obj-y): QEMU_INCLUDES += -Itests QEMU_CFLAGS += -I$(SRC_PATH)/tests +nested-vars := block-obj-y +obj-base := .. +dummy := $(call unnest-vars) + tests/test-x86-cpuid.o: QEMU_INCLUDES += -I$(SRC_PATH)/target-i386 tests/check-qint$(EXESUF): tests/check-qint.o libqemuutil.a
Re: [Qemu-devel] [RFC PATCH v3 3/5] Makefile: introduce common-obj-m and block-obj-m for DSO
Il 10/09/2013 03:02, Fam Zheng ha scritto: -all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all +# static linked mods are expanded to .o list +dummy := $(call expand-mod-obj,common-obj-y) +dummy := $(call expand-mod-obj,block-obj-y) + +modules-m = $(patsubst %.o,%$(DSOSUF),$(filter %.o,$(block-obj-m) $(common-obj-m))) \ +$(patsubst %.mo,%$(DSOSUF),$(filter %.mo,$(block-obj-m) $(common-obj-m))) + +all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all $(modules-m) + +# Generate rules for single file modules (%.so: %.o). +$(foreach o,$(filter %.o,$(block-obj-m) $(common-obj-m)),$(eval \ + $(patsubst %.o,%.so,$o): $o)) + +# For multi file modules, dependencies should be listed explicitly in +# Makefile.objs as +# foo.mo-objs := bar.o biz.o +$(foreach o,$(filter %.mo,$(block-obj-m) $(common-obj-m)),$(eval \ + $(patsubst %.mo,%.so,$o): $($o-objs))) I agree that this foo.mo-objs variable is homogeneous with how you handle libraries and cflags. I like it now. However, I don't like the many places in which you have to special-case modules (expand-mod-obj, modules-m, etc.), and the duplication between Makefile and Makefile.target. I would prefer if you try doing this patch along the lines I suggested in my review of v2, using .mo files as a placeholder and then doing the final link either into the .so or in the executable. This should remove the need for at least expand-mod-obj, and probably for more of the duplicated constructs you have. In particular, I would like modules-m to be simply $(block-obj-m) $(common-obj-m). In the medium term, we need to find a way to avoid the duplication: block-obj-y = block/ block-obj-m = block/ Perhaps by introducing a dirs variable that automatically triggers recursion on all nested variables. But this can be the topic of a separate patch series, if you prefer. Paolo vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) @@ -251,6 +270,9 @@ clean: rm -f qemu-options.def find . -name '*.[oda]' -type f -exec rm -f {} + find . -name '*.l[oa]' -type f -exec rm -f {} + + find . -name '*.so' -type f -exec rm -f {} + + find . -name '*.dll' -type f -exec rm -f {} + + rm -f $(TOOLS) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ rm -Rf .libs rm -f qemu-img-cmds.h diff --git a/Makefile.objs b/Makefile.objs index efd5b0f..abf59e6 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -19,6 +19,8 @@ block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o block-obj-y += qemu-coroutine-sleep.o block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o +block-obj-m = block/ + ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) # Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add. # only pull in the actual virtio-9p device if we also enabled virtio. @@ -83,6 +85,9 @@ common-obj-$(CONFIG_SMARTCARD_NSS) += $(libcacard-y) common-obj-y += qmp-marshal.o common-obj-y += qmp.o hmp.o + +common-obj-m = $(block-obj-m) + endif ## diff --git a/Makefile.target b/Makefile.target index 381022d..8d70560 100644 --- a/Makefile.target +++ b/Makefile.target @@ -150,6 +150,10 @@ include $(SRC_PATH)/Makefile.objs obj-base := .. dummy := $(call unnest-vars) +# static linked mods are expanded to .o list +dummy := $(call expand-mod-obj,common-obj-y) +dummy := $(call expand-mod-obj,block-obj-y) + all-obj-y = $(obj-y) all-obj-y += $(addprefix ../, $(common-obj-y) $(block-obj-y)) diff --git a/configure b/configure index cc3cd4d..c6d4a62 100755 --- a/configure +++ b/configure @@ -190,6 +190,8 @@ mingw32=no gcov=no gcov_tool=gcov EXESUF= +DSOSUF=.so +LDFLAGS_SHARED=-shared prefix=/usr/local mandir=\${prefix}/share/man datadir=\${prefix}/share @@ -485,6 +487,7 @@ OpenBSD) Darwin) bsd=yes darwin=yes + LDFLAGS_SHARED=-bundle if [ $cpu = x86_64 ] ; then QEMU_CFLAGS=-arch x86_64 $QEMU_CFLAGS LDFLAGS=-arch x86_64 $LDFLAGS @@ -584,6 +587,7 @@ fi if test $mingw32 = yes ; then EXESUF=.exe + DSOSUF=.dll QEMU_CFLAGS=-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) QEMU_CFLAGS=-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS @@ -4175,6 +4179,8 @@ echo LIBTOOLFLAGS=$LIBTOOLFLAGS $config_host_mak echo LIBS+=$LIBS $config_host_mak echo LIBS_TOOLS+=$libs_tools $config_host_mak echo EXESUF=$EXESUF $config_host_mak +echo DSOSUF=$DSOSUF $config_host_mak +echo LDFLAGS_SHARED=$LDFLAGS_SHARED $config_host_mak echo LIBS_QGA+=$libs_qga $config_host_mak echo POD2MAN=$POD2MAN $config_host_mak echo TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS $config_host_mak diff --git a/rules.mak b/rules.mak index 84ed998..b88ac75 100644 --- a/rules.mak +++ b/rules.mak @@ -58,6 +58,10 @@ endif %.o: %.dtrace $(call quiet-command,dtrace -o $@ -G -s
Re: [Qemu-devel] [RFC PATCH v3 5/5] block: build qed and curl as shared library
Il 10/09/2013 03:02, Fam Zheng ha scritto: Curl and qed block drivers are built as shared object module. We have per object cflags and libs support now, move CURL_CFLAGS and CURL_LIBS from global option variables to a per object basis. make install is not installing them yet, manually copy it to ${prefix}/qemu/block/ to make it loaded. Signed-off-by: Fam Zheng f...@redhat.com --- block/Makefile.objs | 7 --- configure | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/Makefile.objs b/block/Makefile.objs index 3bb85b5..741b92f 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -1,7 +1,6 @@ block-obj-y += raw_bsd.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-cache.o -block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o -block-obj-y += qed-check.o +block-obj-m += qed.mo block-obj-y += vhdx.o block-obj-y += parallels.o blkdebug.o blkverify.o block-obj-y += snapshot.o qapi.o @@ -23,4 +22,6 @@ common-obj-y += commit.o common-obj-y += mirror.o common-obj-y += backup.o -$(obj)/curl.o: QEMU_CFLAGS+=$(CURL_CFLAGS) +curl.o-cflags := $(CURL_CFLAGS) +curl.o-libs := $(CURL_LIBS) +qed.mo-objs := qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o qed-check.o diff --git a/configure b/configure index a2858c2..136ac1a 100755 --- a/configure +++ b/configure @@ -2213,8 +2213,6 @@ EOF curl_libs=`$curlconfig --libs 2/dev/null` if compile_prog $curl_cflags $curl_libs ; then curl=yes -libs_tools=$curl_libs $libs_tools -libs_softmmu=$curl_libs $libs_softmmu else if test $curl = yes ; then feature_not_found curl @@ -3893,8 +3891,9 @@ if test $bswap_h = yes ; then echo CONFIG_MACHINE_BSWAP_H=y $config_host_mak fi if test $curl = yes ; then - echo CONFIG_CURL=y $config_host_mak + echo CONFIG_CURL=m $config_host_mak echo CURL_CFLAGS=$curl_cflags $config_host_mak + echo CURL_LIBS=$curl_libs $config_host_mak fi if test $brlapi = yes ; then echo CONFIG_BRLAPI=y $config_host_mak Looks good. For v4, however, please introduce --enable-modules so we get closer to the final picture. The implementation can be as simple as if ($(CONFIG_MODULES),y) modules-m = $(block-obj-m) $(common-obj-m) else block-obj-y += $(block-obj-m) common-obj-y += $(common-obj-m) block-obj-m = common-obj-m endif Paolo
Re: [Qemu-devel] [PATCH v3 0/3] vfio: fixes for better support for 128 bit memory section sizes
Il 10/09/2013 06:23, Alexey Kardashevskiy ha scritto: On 08/29/2013 12:29 AM, Paolo Bonzini wrote: Il 28/08/2013 16:10, Alex Williamson ha scritto: On Wed, 2013-08-28 at 13:09 +0200, Paolo Bonzini wrote: Il 28/08/2013 11:46, Alexey Kardashevskiy ha scritto: On 08/22/2013 09:29 PM, Alexey Kardashevskiy wrote: I made a couple of small patches while debugging VFIO on SPAPR which uses IOMMU MemoryRegion 2^64 bytes long. Changes: v3: * int128: add int128_exts64() updated v2: * added int128_exts64() function as a separate patch and used in vfio: Fix 128 bit handling Alexey Kardashevskiy (3): int128: add int128_exts64() vfio: Fix debug output for int128 values vfio: Fix 128 bit handling hw/misc/vfio.c| 19 +-- include/qemu/int128.h | 5 + 2 files changed, 18 insertions(+), 6 deletions(-) Ping? I fixed everything I was told to, is there anything left? Or we need to decide through which tree this should go? :) Thanks! I think it should go through Alex's tree, but he may be busy due to the impending opening of the Linux merge window. I can take it if you could ACK the first patch. Thanks, Sure, consider it acked. :) S, Alex, can I consider them (first two I guess) taken by you to your tree? I cannot find them in any tree... See http://article.gmane.org/gmane.comp.emulators.qemu/232179 Paolo
Re: [Qemu-devel] [PATCH v2 0/7] tcg-ppc qemu_ldst improvements
Il 10/09/2013 02:28, Richard Henderson ha scritto: I'm not 100% sure what was wrong with v1 -- possibly some silly typo fixed during rebasing on top of Paolo's patches. I did that since at minimum his patches are necessary for AIX fixes. Great, thank you very much! Paolo
Re: [Qemu-devel] [PATCH 0/4] Define default CPU at configure time
Le 9 septembre 2013 à 21:23, Richard Henderson r...@twiddle.net a écrit : On 09/07/2013 02:19 AM, Peter Maydell wrote: On 7 September 2013 10:13, Laurent Vivier laur...@vivier.eu wrote: Le 07/09/2013 10:43, Peter Maydell a écrit : In fact, I don't understand why a given CPU id has been chosen to be the default value. I think there is a default value not because this is the best/most used value but because we need a default. The default for ARM is any, which is specifically for linux-user and means enable all possible user-visible instruction set options. That means it should be able to run any guest binary OK. Some other target CPU types do this, but not all; I think that ideally we should convert them to do similarly. For mips this is impossible. There are multiple isa extensions that are mutually exclusive. But for everyone else that ought to work. It doesn't work for m68k, too. It's why I need to define the default I want to use... Regards, Laurent
Re: [Qemu-devel] [RFC PATCH v3 1/5] make.rule: fix $(obj) to a real relative path
On Tue, 09/10 08:34, Paolo Bonzini wrote: Il 10/09/2013 03:02, Fam Zheng ha scritto: Makefile.target includes rule.mak and unnested common-obj-y, then prefix them with '../', this will ignore object specific QEMU_CFLAGS in subdir Makefile.objs: $(obj)/curl.o: QEMU_CFLAGS += $(CURL_CFLAGS) Because $(obj) here is './block', instead of '../block'. This doesn't hurt compiling because we basically build all .o from top Makefile, before entering Makefile.target, but it will affact arriving per-object libs support. The starting point of $(obj) is fixed in $(obj-base) before including ./Makefile.objs, to get consistency with nested Makefile rules in target rule and variable definition. Signed-off-by: Fam Zheng f...@redhat.com Glad this worked. ) -dummy := $(call unnest-vars) diff --git a/Makefile.target b/Makefile.target index 9a49852..381022d 100644 --- a/Makefile.target +++ b/Makefile.target @@ -143,13 +143,15 @@ endif # CONFIG_SOFTMMU # Workaround for http://gcc.gnu.org/PR55489, see configure. %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS) -nested-vars += obj-y +nested-vars += obj-y block-obj-y common-obj-y # This resolves all nested paths, so it must come last This comment is now obsolete. include $(SRC_PATH)/Makefile.objs +obj-base := .. Strictly speaking obj-base=.. is incorrect for obj-y, isn't it? Does it You are right, I'd do it respectively, since... work if you do block-obj-y = ../ common-obj-y = ../ instead of including $(SRC_PATH)/Makefile.objs? Then obj-base can be empty and is not needed. But the patch looks good already, I'm asking mostly to get a better understanding of the system. it's not working. The base point of unnesting is fixed to SRC_PATH: define unnest-dir ... $(eval include $(SRC_PATH)/$1/Makefile.objs) ... endef So it can't unnest ../. block-obj-y = ./ makes a little more sense, but $(obj) can be messed, again. Do you think two calls of unnest-vars OK? nested-vars = obj-y dummy := $(call unnest-vars) include $(SRC_PATH)/Makefile.objs obj-base := .. nested-vars = block-obj-y common-obj-y dummy := $(call unnest-vars) +dummy := $(call unnest-vars) all-obj-y = $(obj-y) -all-obj-y += $(addprefix ../, $(common-obj-y)) +all-obj-y += $(addprefix ../, $(common-obj-y) $(block-obj-y)) ifndef CONFIG_HAIKU LIBS+=-lm diff --git a/configure b/configure index e989609..cc3cd4d 100755 --- a/configure +++ b/configure @@ -2251,6 +2251,7 @@ fi if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then glib_cflags=`$pkg_config --cflags gthread-2.0` glib_libs=`$pkg_config --libs gthread-2.0` +CFLAGS=$glib_cflags $CFLAGS LIBS=$glib_libs $LIBS libs_qga=$glib_libs $libs_qga else diff --git a/rules.mak b/rules.mak index 4499745..3ff7d7a 100644 --- a/rules.mak +++ b/rules.mak @@ -103,7 +103,7 @@ clean: clean-timestamp # magic to descend into other directories -obj := . +obj = $(obj-base) old-nested-dirs := define push-var @@ -119,9 +119,11 @@ endef define unnest-dir $(foreach var,$(nested-vars),$(call push-var,$(var),$1/)) -$(eval obj := $(obj)/$1) +$(eval obj-parent-$1 := $(obj)) +$(eval obj := $(if $(obj),$(obj)/$1,$1)) $(eval include $(SRC_PATH)/$1/Makefile.objs) -$(eval obj := $(patsubst %/$1,%,$(obj))) +$(eval obj := $(obj-parent-$1)) +$(eval obj-parent-$1 := ) $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/)) endef diff --git a/tests/Makefile b/tests/Makefile index baba9e9..15ef039 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -110,6 +110,10 @@ test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o $(test-obj-y): QEMU_INCLUDES += -Itests QEMU_CFLAGS += -I$(SRC_PATH)/tests +nested-vars := block-obj-y +obj-base := .. +dummy := $(call unnest-vars) + tests/test-x86-cpuid.o: QEMU_INCLUDES += -I$(SRC_PATH)/target-i386 tests/check-qint$(EXESUF): tests/check-qint.o libqemuutil.a
Re: [Qemu-devel] [PATCH v2 2/6] block: Add ImageInfoSpecific to BlockDriverInfo
On 2013-09-10 05:26, Fam Zheng wrote: On Fri, 09/06 15:12, Max Reitz wrote: Add the new ImageInfoSpecific type also to BlockDriverInfo. To prevent memory leaks, this field has to be initialized to NULL every time before calling bdrv_get_info and qapi_free_ImageInfoSpecific has to be called on it when the BlockDriverInfo object is no longer required. I don't understand here. I think bdi is always passed into bdrv_get_info() uninitialized and in bdrv_get_info() there is: memset(bdi, 0, sizeof(*bdi)); before passing it on to driver, so it's always set to NULL. Oh, you're right, I missed that. Thanks! And why pointer, not a member to save a free() call? As far as I understand it (and if I don't miss anything again), ImageInfoSpecific is a auto-generated QAPI type, so it may contain pointers to other types anyway (as it does in the case of QCow2, which is the only driver where I have implemented this new field at all; in that case, the compatiblity level is a string), therefore we always need some function to clean up the data referenced by ImageInfoSpecific; qapi_free_ImageInfoSpecific is the perfect one for this, but it takes a heap pointer. Hence, I think using a pointer (to a heap-allocated object) is easier in this case, since the QAPI clean-up function assumes this case. Signed-off-by: Max Reitz mre...@redhat.com --- block.c | 3 ++- block/mirror.c| 6 -- block/qapi.c | 6 +- include/block/block.h | 2 ++ qemu-img.c| 3 ++- qemu-io-cmds.c| 6 +- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 26639e8..1a5d2a4 100644 --- a/block.c +++ b/block.c @@ -1921,7 +1921,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, int64_t *cluster_sector_num, int *cluster_nb_sectors) { -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(bs, bdi) 0 || bdi.cluster_size == 0) { *cluster_sector_num = sector_num; @@ -1932,6 +1932,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, *cluster_nb_sectors = QEMU_ALIGN_UP(sector_num - *cluster_sector_num + nb_sectors, c); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } static bool tracked_request_overlaps(BdrvTrackedRequest *req, diff --git a/block/mirror.c b/block/mirror.c index 86de458..cfef7e9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -295,7 +295,7 @@ static void coroutine_fn mirror_run(void *opaque) BlockDriverState *bs = s-common.bs; int64_t sector_num, end, sectors_per_chunk, length; uint64_t last_pause_ns; -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; char backing_filename[1024]; int ret = 0; int n; @@ -325,6 +325,7 @@ static void coroutine_fn mirror_run(void *opaque) s-buf_size = MAX(s-buf_size, bdi.cluster_size); s-cow_bitmap = bitmap_new(length); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } end = s-common.len BDRV_SECTOR_BITS; @@ -544,13 +545,14 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, if (granularity == 0) { /* Choose the default granularity based on the target file's cluster * size, clamped between 4k and 64k. */ -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(target, bdi) = 0 bdi.cluster_size != 0) { granularity = MAX(4096, bdi.cluster_size); granularity = MIN(65536, granularity); } else { granularity = 65536; } +qapi_free_ImageInfoSpecific(bdi.format_specific); } assert ((granularity (granularity - 1)) == 0); diff --git a/block/qapi.c b/block/qapi.c index a4bc411..f13fbd5 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -110,7 +110,7 @@ void bdrv_query_image_info(BlockDriverState *bs, uint64_t total_sectors; const char *backing_filename; char backing_filename2[1024]; -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; int ret; Error *err = NULL; ImageInfo *info = g_new0(ImageInfo, 1); @@ -133,6 +133,10 @@ void bdrv_query_image_info(BlockDriverState *bs, } info-dirty_flag = bdi.is_dirty; info-has_dirty_flag = true; +if (bdi.format_specific) { +info-format_specific = bdi.format_specific; +info-has_format_specific = true; +} } backing_filename = bs-backing_file; if (backing_filename[0] != '\0') { diff --git a/include/block/block.h b/include/block/block.h index e6b391c..85e9703 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -18,6 +18,8 @@ typedef struct BlockDriverInfo { /* offset at
Re: [Qemu-devel] [PATCH v2 3/6] block/qapi: Human-readable ImageInfoSpecific dump
On 2013-09-10 06:04, Fam Zheng wrote: On Fri, 09/06 15:12, Max Reitz wrote: Add a function for generically dumping the ImageInfoSpecific information in a human-readable format to block/qapi.c. Use this function in bdrv_image_info_dump and qemu-io-cmds.c:info_f to allow qemu-img info resp. qemu-io -c info to print that format specific information. Signed-off-by: Max Reitz mre...@redhat.com --- block/qapi.c | 121 +++ include/block/qapi.h | 2 + qemu-io-cmds.c | 3 ++ 3 files changed, 126 insertions(+) diff --git a/block/qapi.c b/block/qapi.c index f13fbd5..4fe45d5 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -25,6 +25,9 @@ #include block/qapi.h #include block/block_int.h #include qmp-commands.h +#include qapi-visit.h +#include qapi/qmp-output-visitor.h +#include qapi/qmp/types.h /* * Returns 0 on success, with *p_list either set to describe snapshot @@ -401,6 +404,119 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, } } +static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, + QDict *dict); +static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, + QList *list); + +static void dump_qobject(fprintf_function func_fprintf, void *f, + int comp_indent, QObject *obj) +{ +switch (qobject_type(obj)) { +case QTYPE_QINT: { +QInt *value = qobject_to_qint(obj); +func_fprintf(f, % PRId64, qint_get_int(value)); +break; +} +case QTYPE_QSTRING: { +QString *value = qobject_to_qstring(obj); +func_fprintf(f, %s, qstring_get_str(value)); +break; +} +case QTYPE_QDICT: { +QDict *value = qobject_to_qdict(obj); +dump_qdict(func_fprintf, f, comp_indent, value); +break; +} +case QTYPE_QLIST: { +QList *value = qobject_to_qlist(obj); +dump_qlist(func_fprintf, f, comp_indent, value); +break; +} +case QTYPE_QFLOAT: { +QFloat *value = qobject_to_qfloat(obj); +func_fprintf(f, %g, qfloat_get_double(value)); +break; +} +case QTYPE_QBOOL: { +QBool *value = qobject_to_qbool(obj); +func_fprintf(f, %s, qbool_get_int(value) ? true : false); +break; +} +case QTYPE_QERROR: { +QString *value = qerror_human((QError *)obj); +func_fprintf(f, %s, qstring_get_str(value)); +break; +} +case QTYPE_NONE: +break; +case QTYPE_MAX: +default: +abort(); +} +} + +static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, + QList *list) +{ +const QListEntry *entry; +int i = 0; + +for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) { +qtype_code type = qobject_type(entry-value); +bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST); +const char *format = composite ? %*s[%i]:\n : %*s[%i]: ; + +func_fprintf(f, format, indentation * 4, , i); +dump_qobject(func_fprintf, f, indentation + 1, entry-value); +if (!composite) { +func_fprintf(f, \n); +} +} +} + +static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, + QDict *dict) +{ +const QDictEntry *entry; + +for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) { +qtype_code type = qobject_type(entry-value); +bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST); +const char *format = composite ? %*s%s:\n : %*s%s: ; +char key[strlen(entry-key) + 1]; +int i; + +/* replace dashes with spaces in key (variable) names */ +for (i = 0; entry-key[i]; i++) { +key[i] = entry-key[i] == '-' ? ' ' : entry-key[i]; +} +key[i] = 0; + +func_fprintf(f, format, indentation * 4, , key); +dump_qobject(func_fprintf, f, indentation + 1, entry-value); +if (!composite) { +func_fprintf(f, \n); +} +} +} + +void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, + ImageInfoSpecific *info_spec) +{ +Error *local_err = NULL; +QmpOutputVisitor *ov = qmp_output_visitor_new(); +QObject *obj, *data; + +visit_type_ImageInfoSpecific(qmp_output_get_visitor(ov), info_spec, NULL, + local_err); +obj = qmp_output_get_qobject(ov); +assert(qobject_type(obj) == QTYPE_QDICT); +data = qdict_get(qobject_to_qdict(obj), data); +dump_qobject(func_fprintf, f, 0, data); +qmp_output_visitor_cleanup(ov); +} + void
[Qemu-devel] Disabling IRQ error
hi everyone, I`m getting the nobody cared disabling IRQ error, when i raised external interrupts IRQ3 to the Openpic in QEMU. (Actually, any external interrupts irq i raised can reproduce this error, but internal interrupts work fine) And this IRQ3 is sharing irq with usb card. I have tried to resolve this issue as follows, but nothing changed. 1)tried to boot with irqpoll option. 2)tried to stop raising the irq for usb card. 3)tried to boot with kernel_irqchip option Related log from dmesg: [ 2079.800787] irq 19: nobody cared (try booting with the irqpoll option) [ 2079.800891] Call Trace: [ 2079.801303] [d7ff3f40] [c0007780] show_stack+0x7c/0x1a0 (unreliable) [ 2079.801398] [d7ff3f80] [c007ad48] __report_bad_irq+0x5c/0xe0 [ 2079.801439] [d7ff3fa0] [c007af58] note_interrupt+0x18c/0x240 [ 2079.801466] [d7ff3fd0] [c007be04] handle_fasteoi_irq+0xf8/0x158 [ 2079.801492] [d7ff3ff0] [c000d9d4] call_handle_irq+0x18/0x28 [ 2079.801582] [d7ff5ec0] [c0004df0] do_IRQ+0xf0/0x16c [ 2079.801609] [d7ff5ee0] [c000e9bc] ret_from_except+0x0/0x18 [ 2079.801652] --- Exception: 501 at __do_softirq+0x94/0x18c [ 2079.801664] LR = __do_softirq+0x54/0x18c [ 2079.801698] [d7ff5ff0] [c000d9ac] call_do_softirq+0x14/0x24 [ 2079.801725] [d788fc50] [c0004bc0] do_softirq+0x74/0xa0 [ 2079.801751] [d788fc70] [c004350c] irq_exit+0x3c/0x8c [ 2079.801775] [d788fc80] [c0004e3c] do_IRQ+0x13c/0x16c [ 2079.801800] [d788fca0] [c000e9bc] ret_from_except+0x0/0x18 [ 2079.802566] --- Exception: 501 at bbc_dma_exec+0xa08/0xef4 [bbc_driver] [ 2079.802580] LR = bbc_dma_exec+0x970/0xef4 [bbc_driver] [ 2079.802620] [d788fdf0] [d94d4f28] bbc_ioctl_dma_read_write+0x2bc/0x464 [bbc_driver] [ 2079.802661] [d788fe70] [d94cae84] bbc_ioctl+0x2a0/0x36c [bbc_driver] [ 2079.802754] [d788feb0] [c00d1f04] do_vfs_ioctl+0x6b8/0x760 [ 2079.802782] [d788ff10] [c00d2014] sys_ioctl+0x68/0xa8 [ 2079.802807] [d788ff40] [c000e368] ret_from_syscall+0x0/0x3c [ 2079.802891] --- Exception: c01 at 0xfaffda8 [ 2079.802901] LR = 0xfb8ec20 [ 2079.802936] handlers: [ 2079.803034] [c0268d70] (usb_hcd_irq+0x0/0xac) [ 2079.803120] [d94cc1bc] (bbc_interrupt_handler+0x0/0x65c [bbc_driver]) [ 2079.803181] Disabling IRQ #19 And interrupt information from /proc/interrupts and stat: # cat /proc/interrupts CPU0 18: 6923OpenPIC Levelohci_hcd:usb2, ohci_hcd:usb3, drvbbc_ldc 19: 11OpenPIC Levelehci_hcd:usb1, drvbbc 20: 0OpenPIC Edge internal_error 21: 0OpenPIC LevelNMI 22: 0OpenPIC LevelSP_I2C_Handler 42: 1148OpenPIC Levelserial 43:174OpenPIC Leveli2c-mpc, i2c-mpc 59: 0OpenPIC Levelfsl_espi 72: 51888OpenPIC Levelmmc0 LOC: 143330 Local timer interrupts SPU: 0 Spurious interrupts CNT: 0 Performance monitoring interrupts MCE: 0 Machine check exceptions #cat /proc/stat cpu 4929 0 5784 353692 736 0 460 0 0 0 cpu0 4929 0 5784 353692 736 0 460 0 0 0 intr 394342 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6929 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1574 174 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 53202 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ctxt 357415 btime 1378108122 processes 1648 procs_running 1 procs_blocked 0 softirq 329977 0 154040 0 0 1145 0 17497 0 337 156958 I`ve no idea what the problem is and how to fix it. Do you have experience to this? Thanks in advance for any advice. Simen
Re: [Qemu-devel] [PATCH v2 2/6] block: Add ImageInfoSpecific to BlockDriverInfo
On Tue, 09/10 09:22, Max Reitz wrote: On 2013-09-10 05:26, Fam Zheng wrote: On Fri, 09/06 15:12, Max Reitz wrote: Add the new ImageInfoSpecific type also to BlockDriverInfo. To prevent memory leaks, this field has to be initialized to NULL every time before calling bdrv_get_info and qapi_free_ImageInfoSpecific has to be called on it when the BlockDriverInfo object is no longer required. I don't understand here. I think bdi is always passed into bdrv_get_info() uninitialized and in bdrv_get_info() there is: memset(bdi, 0, sizeof(*bdi)); before passing it on to driver, so it's always set to NULL. Oh, you're right, I missed that. Thanks! And why pointer, not a member to save a free() call? As far as I understand it (and if I don't miss anything again), ImageInfoSpecific is a auto-generated QAPI type, so it may contain pointers to other types anyway (as it does in the case of QCow2, which is the only driver where I have implemented this new field at all; in that case, the compatiblity level is a string), therefore we always need some function to clean up the data referenced by ImageInfoSpecific; qapi_free_ImageInfoSpecific is the perfect one for this, but it takes a heap pointer. Hence, I think using a pointer (to a heap-allocated object) is easier in this case, since the QAPI clean-up function assumes this case. OK, learning this from you. Since this is allocated in bdrv_get_info() (from the caller PoV), and, the info requires releasing after use, a bdrv_put_info() may be a good function to do it, instead of directly operate on the field everywhere. Signed-off-by: Max Reitz mre...@redhat.com --- block.c | 3 ++- block/mirror.c| 6 -- block/qapi.c | 6 +- include/block/block.h | 2 ++ qemu-img.c| 3 ++- qemu-io-cmds.c| 6 +- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 26639e8..1a5d2a4 100644 --- a/block.c +++ b/block.c @@ -1921,7 +1921,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, int64_t *cluster_sector_num, int *cluster_nb_sectors) { -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(bs, bdi) 0 || bdi.cluster_size == 0) { *cluster_sector_num = sector_num; @@ -1932,6 +1932,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, *cluster_nb_sectors = QEMU_ALIGN_UP(sector_num - *cluster_sector_num + nb_sectors, c); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } static bool tracked_request_overlaps(BdrvTrackedRequest *req, diff --git a/block/mirror.c b/block/mirror.c index 86de458..cfef7e9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -295,7 +295,7 @@ static void coroutine_fn mirror_run(void *opaque) BlockDriverState *bs = s-common.bs; int64_t sector_num, end, sectors_per_chunk, length; uint64_t last_pause_ns; -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; char backing_filename[1024]; int ret = 0; int n; @@ -325,6 +325,7 @@ static void coroutine_fn mirror_run(void *opaque) s-buf_size = MAX(s-buf_size, bdi.cluster_size); s-cow_bitmap = bitmap_new(length); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } end = s-common.len BDRV_SECTOR_BITS; @@ -544,13 +545,14 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, if (granularity == 0) { /* Choose the default granularity based on the target file's cluster * size, clamped between 4k and 64k. */ -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(target, bdi) = 0 bdi.cluster_size != 0) { granularity = MAX(4096, bdi.cluster_size); granularity = MIN(65536, granularity); } else { granularity = 65536; } +qapi_free_ImageInfoSpecific(bdi.format_specific); } assert ((granularity (granularity - 1)) == 0); diff --git a/block/qapi.c b/block/qapi.c index a4bc411..f13fbd5 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -110,7 +110,7 @@ void bdrv_query_image_info(BlockDriverState *bs, uint64_t total_sectors; const char *backing_filename; char backing_filename2[1024]; -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; int ret; Error *err = NULL; ImageInfo *info = g_new0(ImageInfo, 1); @@ -133,6 +133,10 @@ void bdrv_query_image_info(BlockDriverState *bs, } info-dirty_flag = bdi.is_dirty; info-has_dirty_flag = true; +if (bdi.format_specific) { +info-format_specific =
Re: [Qemu-devel] [PATCH v2 05/10] raven: set a correct PCI I/O memory region
Il 09/09/2013 22:57, Hervé Poussineau ha scritto: Paolo, Peter, so, did we raise some consensus? Should I reuse get_system_io(), or having a separate MemoryRegion is acceptable? I think that creating a independant MemoryRegion is better, as I see no reason why QEMU should provide a global I/O region, which has some sense mostly on x86 architectures only. However, I can rework patches to use get_system_io() if that's what you prefer... Since alpha-softmmu and versatile have established a precedent, your patch is fine. Thanks! Paolo
Re: [Qemu-devel] [RFC] Policy for supported hosts/platforms
On Mon, Sep 09, 2013 at 02:15:57PM -0400, Ed Maste wrote: On 17 July 2013 20:07, Ed Maste ema...@freebsd.org wrote: On 8 July 2013 11:15, Ed Maste ema...@freebsd.org wrote: Ok, as soon as I can get a password (after the buildbot disk space issues are sorted out) I'll contribute a FreeBSD 9 amd64 builder. It seems the disk space / inode issue is resolved; is there anything further still in the way of adding a FreeBSD builder? Ping. Christian: Can you add a new buildslave account for FreeBSD 9 amd64 and send Ed the connection details? Stefan
Re: [Qemu-devel] [PATCH v2 2/6] block: Add ImageInfoSpecific to BlockDriverInfo
On 2013-09-10 09:37, Fam Zheng wrote: On Tue, 09/10 09:22, Max Reitz wrote: On 2013-09-10 05:26, Fam Zheng wrote: On Fri, 09/06 15:12, Max Reitz wrote: Add the new ImageInfoSpecific type also to BlockDriverInfo. To prevent memory leaks, this field has to be initialized to NULL every time before calling bdrv_get_info and qapi_free_ImageInfoSpecific has to be called on it when the BlockDriverInfo object is no longer required. I don't understand here. I think bdi is always passed into bdrv_get_info() uninitialized and in bdrv_get_info() there is: memset(bdi, 0, sizeof(*bdi)); before passing it on to driver, so it's always set to NULL. Oh, you're right, I missed that. Thanks! And why pointer, not a member to save a free() call? As far as I understand it (and if I don't miss anything again), ImageInfoSpecific is a auto-generated QAPI type, so it may contain pointers to other types anyway (as it does in the case of QCow2, which is the only driver where I have implemented this new field at all; in that case, the compatiblity level is a string), therefore we always need some function to clean up the data referenced by ImageInfoSpecific; qapi_free_ImageInfoSpecific is the perfect one for this, but it takes a heap pointer. Hence, I think using a pointer (to a heap-allocated object) is easier in this case, since the QAPI clean-up function assumes this case. OK, learning this from you. Since this is allocated in bdrv_get_info() (from the caller PoV), and, the info requires releasing after use, a bdrv_put_info() may be a good function to do it, instead of directly operate on the field everywhere. You mean a function for filling the ImageInfoSpecific field? Hm, we can't really use parameters, since every driver would then require its own function (which, imo, would defeat the purpose); the only thing I can imagine right now is a function which converts a JSON description to the object; however, this would again require proper escaping for strings and conversion to strings for non-string types, so I doubt whether this would really help... Signed-off-by: Max Reitz mre...@redhat.com --- block.c | 3 ++- block/mirror.c| 6 -- block/qapi.c | 6 +- include/block/block.h | 2 ++ qemu-img.c| 3 ++- qemu-io-cmds.c| 6 +- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 26639e8..1a5d2a4 100644 --- a/block.c +++ b/block.c @@ -1921,7 +1921,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, int64_t *cluster_sector_num, int *cluster_nb_sectors) { -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(bs, bdi) 0 || bdi.cluster_size == 0) { *cluster_sector_num = sector_num; @@ -1932,6 +1932,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, *cluster_nb_sectors = QEMU_ALIGN_UP(sector_num - *cluster_sector_num + nb_sectors, c); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } static bool tracked_request_overlaps(BdrvTrackedRequest *req, diff --git a/block/mirror.c b/block/mirror.c index 86de458..cfef7e9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -295,7 +295,7 @@ static void coroutine_fn mirror_run(void *opaque) BlockDriverState *bs = s-common.bs; int64_t sector_num, end, sectors_per_chunk, length; uint64_t last_pause_ns; -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; char backing_filename[1024]; int ret = 0; int n; @@ -325,6 +325,7 @@ static void coroutine_fn mirror_run(void *opaque) s-buf_size = MAX(s-buf_size, bdi.cluster_size); s-cow_bitmap = bitmap_new(length); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } end = s-common.len BDRV_SECTOR_BITS; @@ -544,13 +545,14 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, if (granularity == 0) { /* Choose the default granularity based on the target file's cluster * size, clamped between 4k and 64k. */ -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(target, bdi) = 0 bdi.cluster_size != 0) { granularity = MAX(4096, bdi.cluster_size); granularity = MIN(65536, granularity); } else { granularity = 65536; } +qapi_free_ImageInfoSpecific(bdi.format_specific); } assert ((granularity (granularity - 1)) == 0); diff --git a/block/qapi.c b/block/qapi.c index a4bc411..f13fbd5 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -110,7 +110,7 @@ void bdrv_query_image_info(BlockDriverState *bs, uint64_t total_sectors; const char *backing_filename; char backing_filename2[1024]; -BlockDriverInfo bdi; +
Re: [Qemu-devel] [PATCH] pcnet-pci: mark I/O and MMIO as LITTLE_ENDIAN
On Wed, Aug 28, 2013 at 02:17:39PM +0200, Aurelien Jarno wrote: Now that the memory subsystem is propagating the endianness correctly, the pcnet-pci device should have its I/O ports and MMIO memory marked as LITTLE_ENDIAN, as PCI devices are little endian. This makes the pcnet-pci NIC to work again on big endian MIPS Malta (default NIC). Cc: qemu-sta...@nongnu.org Signed-off-by: Aurelien Jarno aurel...@aurel32.net --- hw/net/pcnet-pci.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Thanks, applied to my net-next tree: https://github.com/stefanha/qemu/commits/net-next Stefan
Re: [Qemu-devel] [PULL 0/4] Net patches
On Mon, Sep 09, 2013 at 04:49:06PM +0200, Aurelien Jarno wrote: On Fri, Sep 06, 2013 at 04:59:06PM +0200, Stefan Hajnoczi wrote: On Fri, Sep 06, 2013 at 08:03:27AM +0200, Paolo Bonzini wrote: Il 05/09/2013 23:02, Aurelien Jarno ha scritto: It would be nice if you can get the pcnet fix in your tree. For the ne2k patch, as reported it might break the non-PCI version. I have to look at that more in details, probably this week-end. No, that's fine. The non-PCI version is also little endian. Good. I just wanted confirmation because I'm not up-to-speed on device endianness. I'll merge the patch. Thanks. Would it be possible to also merge the following patch: http://patchwork.ozlabs.org/patch/270487/ Merged onto my net-next tree. I'll send a pull request at the end of the week. Stefan
Re: [Qemu-devel] [PATCH v2 2/6] block: Add ImageInfoSpecific to BlockDriverInfo
On Tue, 09/10 09:45, Max Reitz wrote: On 2013-09-10 09:37, Fam Zheng wrote: On Tue, 09/10 09:22, Max Reitz wrote: On 2013-09-10 05:26, Fam Zheng wrote: On Fri, 09/06 15:12, Max Reitz wrote: Add the new ImageInfoSpecific type also to BlockDriverInfo. To prevent memory leaks, this field has to be initialized to NULL every time before calling bdrv_get_info and qapi_free_ImageInfoSpecific has to be called on it when the BlockDriverInfo object is no longer required. I don't understand here. I think bdi is always passed into bdrv_get_info() uninitialized and in bdrv_get_info() there is: memset(bdi, 0, sizeof(*bdi)); before passing it on to driver, so it's always set to NULL. Oh, you're right, I missed that. Thanks! And why pointer, not a member to save a free() call? As far as I understand it (and if I don't miss anything again), ImageInfoSpecific is a auto-generated QAPI type, so it may contain pointers to other types anyway (as it does in the case of QCow2, which is the only driver where I have implemented this new field at all; in that case, the compatiblity level is a string), therefore we always need some function to clean up the data referenced by ImageInfoSpecific; qapi_free_ImageInfoSpecific is the perfect one for this, but it takes a heap pointer. Hence, I think using a pointer (to a heap-allocated object) is easier in this case, since the QAPI clean-up function assumes this case. OK, learning this from you. Since this is allocated in bdrv_get_info() (from the caller PoV), and, the info requires releasing after use, a bdrv_put_info() may be a good function to do it, instead of directly operate on the field everywhere. You mean a function for filling the ImageInfoSpecific field? Hm, we can't really use parameters, since every driver would then require its own function (which, imo, would defeat the purpose); the only thing I can imagine right now is a function which converts a JSON description to the object; however, this would again require proper escaping for strings and conversion to strings for non-string types, so I doubt whether this would really help... No, I mean freeing it. Maybe I should suggest bdrv_free_info() or something else. It's just that too many qapi_free_ImageInfoSpecific(bdi.format_specific); lines after all the bdrv_get_info() calls don't look very clean. Signed-off-by: Max Reitz mre...@redhat.com --- block.c | 3 ++- block/mirror.c| 6 -- block/qapi.c | 6 +- include/block/block.h | 2 ++ qemu-img.c| 3 ++- qemu-io-cmds.c| 6 +- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 26639e8..1a5d2a4 100644 --- a/block.c +++ b/block.c @@ -1921,7 +1921,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, int64_t *cluster_sector_num, int *cluster_nb_sectors) { -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(bs, bdi) 0 || bdi.cluster_size == 0) { *cluster_sector_num = sector_num; @@ -1932,6 +1932,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, *cluster_nb_sectors = QEMU_ALIGN_UP(sector_num - *cluster_sector_num + nb_sectors, c); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } static bool tracked_request_overlaps(BdrvTrackedRequest *req, diff --git a/block/mirror.c b/block/mirror.c index 86de458..cfef7e9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -295,7 +295,7 @@ static void coroutine_fn mirror_run(void *opaque) BlockDriverState *bs = s-common.bs; int64_t sector_num, end, sectors_per_chunk, length; uint64_t last_pause_ns; -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; char backing_filename[1024]; int ret = 0; int n; @@ -325,6 +325,7 @@ static void coroutine_fn mirror_run(void *opaque) s-buf_size = MAX(s-buf_size, bdi.cluster_size); s-cow_bitmap = bitmap_new(length); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } end = s-common.len BDRV_SECTOR_BITS; @@ -544,13 +545,14 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, if (granularity == 0) { /* Choose the default granularity based on the target file's cluster * size, clamped between 4k and 64k. */ -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(target, bdi) = 0 bdi.cluster_size != 0) { granularity = MAX(4096, bdi.cluster_size); granularity = MIN(65536, granularity); } else { granularity = 65536; } +qapi_free_ImageInfoSpecific(bdi.format_specific); }
Re: [Qemu-devel] [PATCH v2 0/5] Do not set SO_REUSEADDR on Windows
On Mon, Sep 09, 2013 at 02:15:20PM +0200, Sebastian Ottlik wrote: On 09.09.2013 14:05, Stefan Hajnoczi wrote: On Thu, Sep 05, 2013 at 03:48:16PM +0200, Sebastian Ottlik wrote: On 04.09.2013 19:08, Sebastian Ottlik wrote: This patchset disabels all use of SO_REUSEADDR on Windows. On Windows systems the default behaviour is equivalent to SO_REUSEADDR on other operating systems. SO_REUSEADDR can still be set but results in undesired behaviour instead. It may even lead to situations were system behaviour is unspecified. More information on this can be found at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspx I originally encountered this issue when accidentally launching two QEMU instances with identical GDB ports at the same time. In which case QEMU won't fail as one might expect. v2 Changes: - Introduce a function with os specific implementation instead of using #ifdef I named it socket_set_fast_reuse instead of the suggested qemu_set_reuseaddr so the name better reflects what the function actually does. gdbstub.c |6 ++ include/qemu/sockets.h |1 + net/socket.c | 19 +++ slirp/misc.c |3 +-- slirp/socket.c |4 +--- slirp/tcp_subr.c |6 ++ slirp/udp.c|4 ++-- util/oslib-posix.c | 14 ++ util/oslib-win32.c | 10 ++ util/qemu-sockets.c|6 +++--- 10 files changed, 43 insertions(+), 30 deletions(-) util: add socket_set_fast_reuse function gdbstub: call socket_set_fast_reuse instead of setting SO_REUSEADDR net: call socket_set_fast_reuse instead of setting SO_REUSEADDR slirp: call socket_set_fast_reuse instead of setting SO_REUSEADDR util: call socket_set_fast_reuse instead of setting SO_REUSEADDR Pinging this patch, as I think it is still an appropriate approach to the issue: I did some research and apparently there is a valid use case for SO_REUSEADDR on windows when multiple clients need to listen to the same port for the same multicast group. IMHO making qemu_setsockopt ignore SO_REUSEADDR on windows might be confusing for some use cases. Actually net_socket_mcast_create in net/socket.c should probably set SO_REUSEADDR on windows. This is also an issue with patch 3 I supplied that I will address in a new version of this patch set if there is an agreement on a general approach. Sounds like a good idea. The patch series overall looks good. Stefan Thanks for the feedback. I will resubmit the patch series including the change for net_socket_mcast_create and fixes for the style issues you pointed out soon. When I submitted this new version of the patch set I think I was a little early as there was still some discussion in the thread of the original version. In general, what is a good period to wait before submitting a new version? Sending an extra revision is not a problem. In fact, I think that's better than waiting too long and forgetting about the series. If you want to wait for discussion to end, two business days seems like a safe period of time. By being responsive you will also spur reviewers to be responsive :). Stefan
Re: [Qemu-devel] [PATCH v2 2/6] block: Add ImageInfoSpecific to BlockDriverInfo
On 2013-09-10 09:50, Fam Zheng wrote: On Tue, 09/10 09:45, Max Reitz wrote: On 2013-09-10 09:37, Fam Zheng wrote: On Tue, 09/10 09:22, Max Reitz wrote: On 2013-09-10 05:26, Fam Zheng wrote: On Fri, 09/06 15:12, Max Reitz wrote: Add the new ImageInfoSpecific type also to BlockDriverInfo. To prevent memory leaks, this field has to be initialized to NULL every time before calling bdrv_get_info and qapi_free_ImageInfoSpecific has to be called on it when the BlockDriverInfo object is no longer required. I don't understand here. I think bdi is always passed into bdrv_get_info() uninitialized and in bdrv_get_info() there is: memset(bdi, 0, sizeof(*bdi)); before passing it on to driver, so it's always set to NULL. Oh, you're right, I missed that. Thanks! And why pointer, not a member to save a free() call? As far as I understand it (and if I don't miss anything again), ImageInfoSpecific is a auto-generated QAPI type, so it may contain pointers to other types anyway (as it does in the case of QCow2, which is the only driver where I have implemented this new field at all; in that case, the compatiblity level is a string), therefore we always need some function to clean up the data referenced by ImageInfoSpecific; qapi_free_ImageInfoSpecific is the perfect one for this, but it takes a heap pointer. Hence, I think using a pointer (to a heap-allocated object) is easier in this case, since the QAPI clean-up function assumes this case. OK, learning this from you. Since this is allocated in bdrv_get_info() (from the caller PoV), and, the info requires releasing after use, a bdrv_put_info() may be a good function to do it, instead of directly operate on the field everywhere. You mean a function for filling the ImageInfoSpecific field? Hm, we can't really use parameters, since every driver would then require its own function (which, imo, would defeat the purpose); the only thing I can imagine right now is a function which converts a JSON description to the object; however, this would again require proper escaping for strings and conversion to strings for non-string types, so I doubt whether this would really help... No, I mean freeing it. Maybe I should suggest bdrv_free_info() or something else. It's just that too many qapi_free_ImageInfoSpecific(bdi.format_specific); lines after all the bdrv_get_info() calls don't look very clean. Sounds nice. I'll do it; thanks for the suggestion. Signed-off-by: Max Reitz mre...@redhat.com --- block.c | 3 ++- block/mirror.c| 6 -- block/qapi.c | 6 +- include/block/block.h | 2 ++ qemu-img.c| 3 ++- qemu-io-cmds.c| 6 +- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 26639e8..1a5d2a4 100644 --- a/block.c +++ b/block.c @@ -1921,7 +1921,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, int64_t *cluster_sector_num, int *cluster_nb_sectors) { -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(bs, bdi) 0 || bdi.cluster_size == 0) { *cluster_sector_num = sector_num; @@ -1932,6 +1932,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs, *cluster_nb_sectors = QEMU_ALIGN_UP(sector_num - *cluster_sector_num + nb_sectors, c); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } static bool tracked_request_overlaps(BdrvTrackedRequest *req, diff --git a/block/mirror.c b/block/mirror.c index 86de458..cfef7e9 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -295,7 +295,7 @@ static void coroutine_fn mirror_run(void *opaque) BlockDriverState *bs = s-common.bs; int64_t sector_num, end, sectors_per_chunk, length; uint64_t last_pause_ns; -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; char backing_filename[1024]; int ret = 0; int n; @@ -325,6 +325,7 @@ static void coroutine_fn mirror_run(void *opaque) s-buf_size = MAX(s-buf_size, bdi.cluster_size); s-cow_bitmap = bitmap_new(length); } +qapi_free_ImageInfoSpecific(bdi.format_specific); } end = s-common.len BDRV_SECTOR_BITS; @@ -544,13 +545,14 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, if (granularity == 0) { /* Choose the default granularity based on the target file's cluster * size, clamped between 4k and 64k. */ -BlockDriverInfo bdi; +BlockDriverInfo bdi = { .format_specific = NULL }; if (bdrv_get_info(target, bdi) = 0 bdi.cluster_size != 0) { granularity = MAX(4096, bdi.cluster_size); granularity = MIN(65536, granularity); } else { granularity = 65536; } +qapi_free_ImageInfoSpecific(bdi.format_specific); } assert
Re: [Qemu-devel] [RFC PATCH v3 1/5] make.rule: fix $(obj) to a real relative path
Il 10/09/2013 09:16, Fam Zheng ha scritto: The base point of unnesting is fixed to SRC_PATH: define unnest-dir ... $(eval include $(SRC_PATH)/$1/Makefile.objs) ... endef So it can't unnest ../. block-obj-y = ./ makes a little more sense, but $(obj) can be messed, again. Right. I was confusing the object directory with the source directory. Do you think two calls of unnest-vars OK? nested-vars = obj-y dummy := $(call unnest-vars) include $(SRC_PATH)/Makefile.objs obj-base := .. nested-vars = block-obj-y common-obj-y dummy := $(call unnest-vars) Yeah, that's fine. Perhaps nested-vars and obj-base could become arguments to unnest-vars, too. Paolo +dummy := $(call unnest-vars) all-obj-y = $(obj-y) -all-obj-y += $(addprefix ../, $(common-obj-y)) +all-obj-y += $(addprefix ../, $(common-obj-y) $(block-obj-y)) ifndef CONFIG_HAIKU LIBS+=-lm diff --git a/configure b/configure index e989609..cc3cd4d 100755 --- a/configure +++ b/configure @@ -2251,6 +2251,7 @@ fi if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then glib_cflags=`$pkg_config --cflags gthread-2.0` glib_libs=`$pkg_config --libs gthread-2.0` +CFLAGS=$glib_cflags $CFLAGS LIBS=$glib_libs $LIBS libs_qga=$glib_libs $libs_qga else diff --git a/rules.mak b/rules.mak index 4499745..3ff7d7a 100644 --- a/rules.mak +++ b/rules.mak @@ -103,7 +103,7 @@ clean: clean-timestamp # magic to descend into other directories -obj := . +obj = $(obj-base) old-nested-dirs := define push-var @@ -119,9 +119,11 @@ endef define unnest-dir $(foreach var,$(nested-vars),$(call push-var,$(var),$1/)) -$(eval obj := $(obj)/$1) +$(eval obj-parent-$1 := $(obj)) +$(eval obj := $(if $(obj),$(obj)/$1,$1)) $(eval include $(SRC_PATH)/$1/Makefile.objs) -$(eval obj := $(patsubst %/$1,%,$(obj))) +$(eval obj := $(obj-parent-$1)) +$(eval obj-parent-$1 := ) $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/)) endef diff --git a/tests/Makefile b/tests/Makefile index baba9e9..15ef039 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -110,6 +110,10 @@ test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o $(test-obj-y): QEMU_INCLUDES += -Itests QEMU_CFLAGS += -I$(SRC_PATH)/tests +nested-vars := block-obj-y +obj-base := .. +dummy := $(call unnest-vars) + tests/test-x86-cpuid.o: QEMU_INCLUDES += -I$(SRC_PATH)/target-i386 tests/check-qint$(EXESUF): tests/check-qint.o libqemuutil.a
Re: [Qemu-devel] [PATCH v4 02/12] vfio: Create VFIOAddressSpace objects as needed
On 09/06/2013 04:24 AM, Alex Williamson wrote: On Fri, 2013-08-30 at 20:15 +1000, Alexey Kardashevskiy wrote: From: David Gibson da...@gibson.dropbear.id.au So far, VFIO has a notion of different logical DMA address spaces, but only ever uses one (system memory). This patch extends this, creating new VFIOAddressSpace objects as necessary, according to the AddressSpace reported by the PCI subsystem for this device's DMAs. This isn't enough yet to support guest side IOMMUs with VFIO, but it does mean we could now support VFIO devices on, for example, a guest side PCI host bridge which maps system memory at somewhere other than 0 in PCI space. Signed-off-by: David Gibson da...@gibson.dropbear.id.au Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- hw/misc/vfio.c | 43 +++ 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 93a316e..c16f41b 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -133,9 +133,10 @@ enum { typedef struct VFIOAddressSpace { AddressSpace *as; QLIST_HEAD(, VFIOContainer) containers; +QLIST_ENTRY(VFIOAddressSpace) list; } VFIOAddressSpace; -static VFIOAddressSpace vfio_address_space_memory; +QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces; struct VFIOGroup; @@ -2611,10 +2612,34 @@ static int vfio_load_rom(VFIODevice *vdev) return 0; } -static void vfio_address_space_init(VFIOAddressSpace *space, AddressSpace *as) +static VFIOAddressSpace *vfio_get_address_space(AddressSpace *as) { +VFIOAddressSpace *space; + +QLIST_FOREACH(space, vfio_address_spaces, list) { +if (space-as == as) { +return space; +} +} + +/* No suitable VFIOAddressSpace, create a new one */ +space = g_malloc0(sizeof(*space)); space-as = as; QLIST_INIT(space-containers); + +QLIST_INSERT_HEAD(vfio_address_spaces, space, list); + +return space; +} + +static void vfio_put_address_space(VFIOAddressSpace *space) +{ +if (!QLIST_EMPTY(space-containers)) { +return; +} + +QLIST_REMOVE(space, list); +g_free(space); } static int vfio_connect_container(VFIOGroup *group, VFIOAddressSpace *space) @@ -2699,6 +2724,8 @@ static void vfio_disconnect_container(VFIOGroup *group) group-container = NULL; if (QLIST_EMPTY(container-group_list)) { +VFIOAddressSpace *space = container-space; + if (container-iommu_data.release) { container-iommu_data.release(container); } @@ -2706,6 +2733,8 @@ static void vfio_disconnect_container(VFIOGroup *group) DPRINTF(vfio_disconnect_container: close container-fd\n); close(container-fd); g_free(container); + +vfio_put_address_space(space); } } @@ -3076,6 +3105,7 @@ static int vfio_initfn(PCIDevice *pdev) { VFIODevice *pvdev, *vdev = DO_UPCAST(VFIODevice, pdev, pdev); VFIOGroup *group; +VFIOAddressSpace *space; char path[PATH_MAX], iommu_group_path[PATH_MAX], *group_name; ssize_t len; struct stat st; @@ -3111,14 +3141,12 @@ static int vfio_initfn(PCIDevice *pdev) DPRINTF(%s(%04x:%02x:%02x.%x) group %d\n, __func__, vdev-host.domain, vdev-host.bus, vdev-host.slot, vdev-host.function, groupid); -if (pci_device_iommu_address_space(pdev) != address_space_memory) { -error_report(vfio: DMA address space must be system memory); -return -EINVAL; -} +space = vfio_get_address_space(pci_device_iommu_address_space(pdev)); -group = vfio_get_group(groupid, vfio_address_space_memory); +group = vfio_get_group(groupid, space); if (!group) { error_report(vfio: failed to get group %d, groupid); +vfio_put_address_space(space); return -ENOENT; } Kind of a code flow issue here, on teardown we have: vfio_put_group vfio_disconnect_container vfio_put_address_space On setup we do: vfio_get_address_space vfio_get_group vfio_connect_container We could easily move vfio_get_address_space into vfio_get_group to make things a little more balanced. It doesn't seem like too much additional to pass the address space through vfio_get_group into vfio_connect_container so that we could have a completely symmetric flow though. I can do that. I will just need to call vfio_put_address_space() on every branch which returns NULL. Or rework a bit more. So I ended up with this: (not a patch, just cut-n-paste). === -static VFIOGroup *vfio_get_group(int groupid, VFIOAddressSpace *space) +static VFIOGroup *vfio_get_group(int groupid, AddressSpace *as) { +VFIOAddressSpace *space; VFIOGroup *group; char path[32]; struct vfio_group_status status = { .argsz = sizeof(status) }; +space = vfio_get_address_space(as); + QLIST_FOREACH(group, group_list,
Re: [Qemu-devel] [PATCH v4 03/12] vfio: Add guest side IOMMU support
On 09/06/2013 04:49 AM, Alex Williamson wrote: On Fri, 2013-08-30 at 20:15 +1000, Alexey Kardashevskiy wrote: From: David Gibson da...@gibson.dropbear.id.au This patch uses the new IOMMU notifiers to allow VFIO pass through devices to work with guest side IOMMUs, as long as the host-side VFIO iommu has sufficient capability and granularity to match the guest side. This works by tracking all map and unmap operations on the guest IOMMU using the notifiers, and mirroring them into VFIO. There are a number of FIXMEs, and the scheme involves rather more notifier structures than I'd like, but it should make for a reasonable proof of concept. Signed-off-by: David Gibson da...@gibson.dropbear.id.au Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- Changes: v4: * fixed list objects naming * vfio_listener_region_add() reworked to call memory_region_ref() from one place only, it is also easier to review the changes * fixes boundary check not to fail on sections == 2^64 bytes, the vfio: Fix debug output for int128 values patch is required; this obsoletes the [PATCH v3 0/3] vfio: fixes for better support for 128 bit memory section sizes patch proposal --- hw/misc/vfio.c | 137 + 1 file changed, 128 insertions(+), 9 deletions(-) diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index c16f41b..53791fb 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -150,10 +150,18 @@ typedef struct VFIOContainer { }; void (*release)(struct VFIOContainer *); } iommu_data; +QLIST_HEAD(, VFIOGuestIOMMU) giommu_list; QLIST_HEAD(, VFIOGroup) group_list; QLIST_ENTRY(VFIOContainer) next; } VFIOContainer; +typedef struct VFIOGuestIOMMU { +VFIOContainer *container; +MemoryRegion *iommu; +Notifier n; +QLIST_ENTRY(VFIOGuestIOMMU) giommu_next; +} VFIOGuestIOMMU; + /* Cache of MSI-X setup plus extra mmap and memory region for split BAR map */ typedef struct VFIOMSIXInfo { uint8_t table_bar; @@ -1917,7 +1925,63 @@ static int vfio_dma_map(VFIOContainer *container, hwaddr iova, static bool vfio_listener_skipped_section(MemoryRegionSection *section) { -return !memory_region_is_ram(section-mr); +return !memory_region_is_ram(section-mr) +!memory_region_is_iommu(section-mr); +} + +static void vfio_iommu_map_notify(Notifier *n, void *data) +{ +VFIOGuestIOMMU *giommu = container_of(n, VFIOGuestIOMMU, n); +VFIOContainer *container = giommu-container; +IOMMUTLBEntry *iotlb = data; +MemoryRegion *mr; +hwaddr xlat; +hwaddr len = iotlb-addr_mask + 1; +void *vaddr; +int ret; + +DPRINTF(iommu map @ %HWADDR_PRIx - %HWADDR_PRIx\n, +iotlb-iova, iotlb-iova + iotlb-addr_mask); + +/* + * The IOMMU TLB entry we have just covers translation through + * this IOMMU to its immediate target. We need to translate + * it the rest of the way through to memory. + */ +mr = address_space_translate(address_space_memory, + iotlb-translated_addr, + xlat, len, iotlb-perm IOMMU_WO); +if (!memory_region_is_ram(mr)) { +DPRINTF(iommu map to non memory area %HWADDR_PRIx\n, +xlat); +return; +} +if (len iotlb-addr_mask) { +DPRINTF(iommu has granularity incompatible with target AS\n); +return; +} + +vaddr = memory_region_get_ram_ptr(mr) + xlat; + +if (iotlb-perm != IOMMU_NONE) { +ret = vfio_dma_map(container, iotlb-iova, + iotlb-addr_mask + 1, vaddr, + !(iotlb-perm IOMMU_WO) || mr-readonly); +if (ret) { +error_report(vfio_dma_map(%p, 0x%HWADDR_PRIx, + 0x%HWADDR_PRIx, %p) = %d (%m), + container, iotlb-iova, + iotlb-addr_mask + 1, vaddr, ret); +} +} else { +ret = vfio_dma_unmap(container, iotlb-iova, iotlb-addr_mask + 1); +if (ret) { +error_report(vfio_dma_unmap(%p, 0x%HWADDR_PRIx, + 0x%HWADDR_PRIx) = %d (%m), + container, iotlb-iova, + iotlb-addr_mask + 1, ret); +} +} } static void vfio_listener_region_add(MemoryListener *listener, @@ -1926,11 +1990,10 @@ static void vfio_listener_region_add(MemoryListener *listener, VFIOContainer *container = container_of(listener, VFIOContainer, iommu_data.listener); hwaddr iova, end; +Int128 llend; void *vaddr; int ret; -assert(!memory_region_is_iommu(section-mr)); - if (vfio_listener_skipped_section(section)) { DPRINTF(SKIPPING region_add %HWADDR_PRIx - %PRIx64\n,
Re: [Qemu-devel] Disabling IRQ error
On Tue, Sep 10, 2013 at 11:25 AM, Xie Xianshan xi...@cn.fujitsu.com wrote: hi everyone, I`m getting the nobody cared disabling IRQ error, when i raised external interrupts IRQ3 to the Openpic in QEMU. (Actually, any external interrupts irq i raised can reproduce this error, but internal interrupts work fine) And this IRQ3 is sharing irq with usb card. Could you please explain what you mean by I raised external interrupt, what you generally try to achieve and what behaviour you expected? Your description reminds me of this thread: https://lists.gnu.org/archive/html/qemu-devel/2013-08/msg04063.html -- Thanks. -- Max
Re: [Qemu-devel] [PATCH v3 00/29] tcg-aarch64 improvements
On 09.09.2013 17:07, Richard Henderson wrote: On 09/09/2013 08:02 AM, Claudio Fontana wrote: On 09.09.2013 16:08, Richard Henderson wrote: On 09/09/2013 01:13 AM, Claudio Fontana wrote: after carefully reading and testing your patches, this is how I suggest to proceed: first do the implementation of the new functionality (tcg opcodes, jit) in a way that is consistent with the existing code. No type changes, no refactoring, no beautification. Once we agree on those, introduce the meaningful restructuring you want to do, like the new INSN type, the don't handle mov/movi in tcg_out_op, the TCG_OPF_64BIT thing, etc. Last do the cosmetic stuff if you really want to do it, like the change all ext to bool (note that there is no point if the callers still use 1 and 0: adapt them as well) etc. No, I don't agree. Especially with respect to the insn type. I'd much rather do all the cosmetic stuff, as you put it, first. It makes all of the real changes much easier to understand. r~ I guess we are stuck then. With the cosmetic and restructuring stuff coming before, I cannot cherry pick the good parts later. Have you tested the first 9 patches on their own? I.e. tcg-aarch64: Set ext based on TCG_OPF_64BIT tcg-aarch64: Change all ext variables to bool tcg-aarch64: Don't handle mov/movi in tcg_out_op tcg-aarch64: Hoist common argument loads in tcg_out_op tcg-aarch64: Change enum aarch64_arith_opc to AArch64Insn tcg-aarch64: Merge enum aarch64_srr_opc with AArch64Insn tcg-aarch64: Introduce tcg_fmt_* functions tcg-aarch64: Introduce tcg_fmt_Rdn_aimm tcg-aarch64: Implement mov with tcg_fmt_* functions yes. There should be no functional change to the backend, producing 100% identical output code. There should even be little or no change in tcg.o itself. There are two aspects. On one side, although some changes do not break anything, I see some problems in them. Putting them as a prerequisite for the rest forces us to agreeing on everything before moving forward, instead of being able to agree on separate chunks (meat first, rest later). In my view, this makes the process longer. On another side, I end up having to manually revert some parts of these which you put as prerequisites, during bisection when landing after them, which is a huge time drain when tracking regressions introduced in the later part of the series. This should make it trivial to verify that these patches are not at fault. r~ They don't break the targets, no. Claudio
Re: [Qemu-devel] [PATCH] e1000: NetClientInfo.receive_iov implemented
On Mon, Sep 09, 2013 at 02:51:42PM +0200, Vincenzo Maffione wrote: Just two small style comments: @@ -834,11 +837,14 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) unsigned int n, rdt; uint32_t rdh_start; uint16_t vlan_special = 0; -uint8_t vlan_status = 0, vlan_offset = 0; +uint8_t vlan_status = 0; uint8_t min_buf[MIN_BUF_SIZE]; size_t desc_offset; size_t desc_size; size_t total_size; +size_t size = iov_size(iov, iovcnt), iov_ofs = 0; Please keep these initializers on separate lines (not a hard rule, but I find it clearer especially when calling functions): size_t size = iov_size(iov, iovcnt); size_t iov_ofs = 0; +struct iovec iv; This iovec is for min_buf[]. I suggest moving it below the min_buf[] declaration and renaming it to make its purpose clearer: struct iovec min_iovec; Stefan
Re: [Qemu-devel] [PATCH v4 04/12] spapr vfio: add vfio_container_spapr_get_info()
On 09/06/2013 05:01 AM, Alex Williamson wrote: On Fri, 2013-08-30 at 20:15 +1000, Alexey Kardashevskiy wrote: As sPAPR platform supports DMA windows on a PCI bus, the information about their location and size should be passed into the guest via the device tree. The patch adds a helper to read this info from the container fd. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- Changes: v4: * fixed possible leaks on error paths --- hw/misc/vfio.c | 45 + include/hw/misc/vfio.h | 11 +++ 2 files changed, 56 insertions(+) create mode 100644 include/hw/misc/vfio.h diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 53791fb..4210471 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -39,6 +39,7 @@ #include qemu/range.h #include sysemu/kvm.h #include sysemu/sysemu.h +#include hw/misc/vfio.h /* #define DEBUG_VFIO */ #ifdef DEBUG_VFIO @@ -3490,3 +3491,47 @@ static void register_vfio_pci_dev_type(void) } type_init(register_vfio_pci_dev_type) + +int vfio_container_spapr_get_info(AddressSpace *as, int32_t groupid, + struct vfio_iommu_spapr_tce_info *info, + int *group_fd) +{ +VFIOAddressSpace *space; +VFIOGroup *group; +VFIOContainer *container; +int ret, fd; + +space = vfio_get_address_space(as); +if (!space) { +return -1; +} +group = vfio_get_group(groupid, space); +if (!group) { +goto put_as_exit; +} +container = group-container; +if (!group-container) { +goto put_group_exit; +} +fd = container-fd; +if (!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU)) { +goto put_group_exit; +} +ret = ioctl(fd, VFIO_IOMMU_SPAPR_TCE_GET_INFO, info); +if (ret) { +error_report(vfio: failed to get iommu info for container: %s, + strerror(errno)); +goto put_group_exit; +} +*group_fd = group-fd; The above gets don't actually increment a reference count, so copying the fd seems risky here. If fd is gone while I am carrying it to my external VFIO user to call kvmppc_vfio_group_get_external_user() on it, then the guest just shut itself in a foot, no? And I do not see how I would make it no risky, do you? + +return 0; + +put_group_exit: +vfio_put_group(group); + +put_as_exit: +vfio_put_address_space(space); But put_group calls disconnect_container which calls put_address_space... so it get's put twice. The lack of symmetry already bites us with a bug. True. This will be fixed by moving vfio_get_address_space() into vfio_get_group(). -- Alexey
Re: [Qemu-devel] [PATCH 0/4] Define default CPU at configure time
On 10 September 2013 08:13, Laurent Vivier laur...@vivier.eu wrote: Le 9 septembre 2013 à 21:23, Richard Henderson r...@twiddle.net a écrit : For mips this is impossible. There are multiple isa extensions that are mutually exclusive. But for everyone else that ought to work. It doesn't work for m68k, too. It's why I need to define the default I want to use... Where the instruction set options conflict I really don't think we should have a default selectable at configure time. Having different people with different qemu-m68k or qemu-mips being able to run or not run different programs sounds very confusing. At least if there's a command line option or a wrapper to set environment then it's reasonably clear that the config is different. Also if these different variants are properly represented by different ELF information you can then register several different wrappers to handle different flavours of m68k or mips binary correctly. -- PMM
Re: [Qemu-devel] [PATCH v3 00/29] tcg-aarch64 improvements
On 10 September 2013 09:27, Claudio Fontana claudio.font...@huawei.com wrote: On another side, I end up having to manually revert some parts of these which you put as prerequisites, during bisection when landing after them, which is a huge time drain when tracking regressions introduced in the later part of the series. I don't understand this; can you explain? If these early refactoring patches have bugs then we should just identify them and fix them. If they don't have bugs why would you need to manually revert parts of them? thanks -- PMM
Re: [Qemu-devel] [PATCH v4 11/12] spapr vfio: enable for spapr
On 09/06/2013 05:05 AM, Alex Williamson wrote: On Fri, 2013-08-30 at 20:15 +1000, Alexey Kardashevskiy wrote: This turns the sPAPR support on and enables VFIO container use in the kernel. Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru --- Changes: v4: * fixed format string to use %m which is a glibc extension: Print output of strerror(errno). No argument is required. --- hw/misc/vfio.c | 30 ++ 1 file changed, 30 insertions(+) diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 4210471..882da70 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -2815,6 +2815,36 @@ static int vfio_connect_container(VFIOGroup *group, VFIOAddressSpace *space) memory_listener_register(container-iommu_data.listener, container-space-as); +} else if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_SPAPR_TCE_IOMMU)) { +ret = ioctl(group-fd, VFIO_GROUP_SET_CONTAINER, fd); +if (ret) { +error_report(vfio: failed to set group container: %m); +g_free(container); +close(fd); +return -errno; +} + +ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_SPAPR_TCE_IOMMU); +if (ret) { +error_report(vfio: failed to set iommu for container: %m); +g_free(container); +close(fd); +return -errno; +} + +ret = ioctl(fd, VFIO_IOMMU_ENABLE); +if (ret) { +error_report(vfio: failed to enable container: %m); +g_free(container); +close(fd); +return -errno; These (and the copies that already exist in this function) are screaming for a goto. Heh. So. There should be 2 patches then - one adding gotos to the existing code and another one adding new functionality-with-gotos-already. I can do that, is it what you suggest? What about the rest of the series? Next time I will split [Qemu-devel] [PATCH v4 05/12] spapr_pci: convert init to realize but the rest will be still the same. I have understanding that Alex Graf is expecting you to review the whole thing (ack/sob? not sure how this all works) before he pulls it into his tree. And thanks for comments. -- Alexey
[Qemu-devel] [PATCH v3 3/6] block/qapi: Human-readable ImageInfoSpecific dump
Add a function for generically dumping the ImageInfoSpecific information in a human-readable format to block/qapi.c. Use this function in bdrv_image_info_dump and qemu-io-cmds.c:info_f to allow qemu-img info resp. qemu-io -c info to print that format specific information. Signed-off-by: Max Reitz mre...@redhat.com --- block/qapi.c | 121 +++ include/block/qapi.h | 2 + qemu-io-cmds.c | 6 +++ 3 files changed, 129 insertions(+) diff --git a/block/qapi.c b/block/qapi.c index 86c399c..3e33b7f 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -25,6 +25,9 @@ #include block/qapi.h #include block/block_int.h #include qmp-commands.h +#include qapi-visit.h +#include qapi/qmp-output-visitor.h +#include qapi/qmp/types.h /* * Returns 0 on success, with *p_list either set to describe snapshot @@ -401,6 +404,119 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, } } +static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, + QDict *dict); +static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, + QList *list); + +static void dump_qobject(fprintf_function func_fprintf, void *f, + int comp_indent, QObject *obj) +{ +switch (qobject_type(obj)) { +case QTYPE_QINT: { +QInt *value = qobject_to_qint(obj); +func_fprintf(f, % PRId64, qint_get_int(value)); +break; +} +case QTYPE_QSTRING: { +QString *value = qobject_to_qstring(obj); +func_fprintf(f, %s, qstring_get_str(value)); +break; +} +case QTYPE_QDICT: { +QDict *value = qobject_to_qdict(obj); +dump_qdict(func_fprintf, f, comp_indent, value); +break; +} +case QTYPE_QLIST: { +QList *value = qobject_to_qlist(obj); +dump_qlist(func_fprintf, f, comp_indent, value); +break; +} +case QTYPE_QFLOAT: { +QFloat *value = qobject_to_qfloat(obj); +func_fprintf(f, %g, qfloat_get_double(value)); +break; +} +case QTYPE_QBOOL: { +QBool *value = qobject_to_qbool(obj); +func_fprintf(f, %s, qbool_get_int(value) ? true : false); +break; +} +case QTYPE_QERROR: { +QString *value = qerror_human((QError *)obj); +func_fprintf(f, %s, qstring_get_str(value)); +break; +} +case QTYPE_NONE: +break; +case QTYPE_MAX: +default: +abort(); +} +} + +static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, + QList *list) +{ +const QListEntry *entry; +int i = 0; + +for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) { +qtype_code type = qobject_type(entry-value); +bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST); +const char *format = composite ? %*s[%i]:\n : %*s[%i]: ; + +func_fprintf(f, format, indentation * 4, , i); +dump_qobject(func_fprintf, f, indentation + 1, entry-value); +if (!composite) { +func_fprintf(f, \n); +} +} +} + +static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, + QDict *dict) +{ +const QDictEntry *entry; + +for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) { +qtype_code type = qobject_type(entry-value); +bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST); +const char *format = composite ? %*s%s:\n : %*s%s: ; +char key[strlen(entry-key) + 1]; +int i; + +/* replace dashes with spaces in key (variable) names */ +for (i = 0; entry-key[i]; i++) { +key[i] = entry-key[i] == '-' ? ' ' : entry-key[i]; +} +key[i] = 0; + +func_fprintf(f, format, indentation * 4, , key); +dump_qobject(func_fprintf, f, indentation + 1, entry-value); +if (!composite) { +func_fprintf(f, \n); +} +} +} + +void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, + ImageInfoSpecific *info_spec) +{ +Error *local_err = NULL; +QmpOutputVisitor *ov = qmp_output_visitor_new(); +QObject *obj, *data; + +visit_type_ImageInfoSpecific(qmp_output_get_visitor(ov), info_spec, NULL, + local_err); +obj = qmp_output_get_qobject(ov); +assert(qobject_type(obj) == QTYPE_QDICT); +data = qdict_get(qobject_to_qdict(obj), data); +dump_qobject(func_fprintf, f, 0, data); +qmp_output_visitor_cleanup(ov); +} + void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, ImageInfo *info) { @@ -471,4
[Qemu-devel] [PATCH v3 1/6] qapi: Add ImageInfoSpecific type
Add a new type ImageInfoSpecific as a union for image format specific information in ImageInfo. Signed-off-by: Max Reitz mre...@redhat.com --- qapi-schema.json | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/qapi-schema.json b/qapi-schema.json index a51f7d2..eebf851 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -210,6 +210,18 @@ 'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } } ## +# @ImageInfoSpecific: +# +# A discriminated record of image format specific information structures. +# +# Since: 1.7 +## + +{ 'union': 'ImageInfoSpecific', + 'data': { + } } + +## # @ImageInfo: # # Information about a QEMU image file @@ -238,6 +250,9 @@ # # @backing-image: #optional info of the backing image (since 1.6) # +# @info-string: #optional string supplying additional format-specific +# information (since 1.7) +# # Since: 1.3 # ## @@ -248,7 +263,8 @@ '*cluster-size': 'int', '*encrypted': 'bool', '*backing-filename': 'str', '*full-backing-filename': 'str', '*backing-filename-format': 'str', '*snapshots': ['SnapshotInfo'], - '*backing-image': 'ImageInfo' } } + '*backing-image': 'ImageInfo', + '*format-specific': 'ImageInfoSpecific' } } ## # @ImageCheck: -- 1.8.3.1
[Qemu-devel] [PATCH v3 4/6] qcow2: Add support for ImageInfoSpecific
Add a new ImageInfoSpecificQCow2 type as a subtype of ImageInfoSpecific. This contains the compatibility level as a string and an optional lazy_refcounts boolean (optional means mandatory for compat = 1.1 and not available for compat == 0.10). In qcow2_get_info, fill the BlockDriverInfo.format_specific field with that information. Signed-off-by: Max Reitz mre...@redhat.com --- block/qcow2.c| 12 qapi-schema.json | 16 2 files changed, 28 insertions(+) diff --git a/block/qcow2.c b/block/qcow2.c index 4bc679a..e088c0a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1755,8 +1755,20 @@ static int64_t qcow2_vm_state_offset(BDRVQcowState *s) static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { BDRVQcowState *s = bs-opaque; + bdi-cluster_size = s-cluster_size; bdi-vm_state_offset = qcow2_vm_state_offset(s); + +bdi-format_specific = g_new0(ImageInfoSpecific, 1); +bdi-format_specific-kind = IMAGE_INFO_SPECIFIC_KIND_QCOW2; +bdi-format_specific-qcow2 = g_new0(ImageInfoSpecificQCow2, 1); +if (s-qcow_version == 2) { +bdi-format_specific-qcow2-compat = g_strdup(0.10); +} else if (s-qcow_version == 3) { +bdi-format_specific-qcow2-compat = g_strdup(1.1); +bdi-format_specific-qcow2-lazy_refcounts = s-use_lazy_refcounts; +bdi-format_specific-qcow2-has_lazy_refcounts = true; +} return 0; } diff --git a/qapi-schema.json b/qapi-schema.json index eebf851..cadf40b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -210,6 +210,21 @@ 'vm-clock-sec': 'int', 'vm-clock-nsec': 'int' } } ## +# @ImageInfoSpecificQCow2: +# +# @compat: compatibility level +# +# @lazy-refcounts: #optional on or off; only valid for compat = 1.1 +# +# Since: 1.7 +## +{ 'type': 'ImageInfoSpecificQCow2', + 'data': { + 'compat': 'str', + '*lazy-refcounts': 'bool' + } } + +## # @ImageInfoSpecific: # # A discriminated record of image format specific information structures. @@ -219,6 +234,7 @@ { 'union': 'ImageInfoSpecific', 'data': { + 'qcow2': 'ImageInfoSpecificQCow2' } } ## -- 1.8.3.1
[Qemu-devel] [PATCH v3 0/6] Provide additional info through qemu-img info
qemu-img info provides only pretty general information about an image. For any image format, there might be specific options which cannot be represented in a universal way; for instance, qcow2 provides the compatibility and lazy_refcount options whose values are certainly interesting but currently cannot be output by qemu-img info. Therefore, this series adds a new ImageInfoSpecific union type to ImageInfo and BlockDriverInfo which may be used by block drivers as a template for new types dedicated to the specific information they can provide. It also adds support to qemu-img info and qemu-io -c info to print the content of these specific structures. v3: - implemented Fam's remarks: - bdrv_get_info already initializes all fields to NULL, no need to do this manually (patch 2) - implemented bdrv_put_info as a wrapper to qapi_free_ImageInfoSpecific, though this may change with further extensions to BlockDriverInfo (patch 2) - changed one occurence of puts(foo) to printf(foo\n) in order to be consistent with the surrounding code (patch 3) - other patches (1, 4, 5, 6) remain unmodified v2: - following Eric's recommendation: changed the representation of the format specific information from an uninterpreted blobbed string to a union of format specific types Max Reitz (6): qapi: Add ImageInfoSpecific type block: Add ImageInfoSpecific to BlockDriverInfo block/qapi: Human-readable ImageInfoSpecific dump qcow2: Add support for ImageInfoSpecific qemu-iotests: Discard specific info in _img_info qemu-iotests: Additional info from qemu-img info block.c | 16 +- block/mirror.c | 16 -- block/qapi.c | 125 +++ block/qcow2.c| 12 + include/block/block.h| 3 ++ include/block/qapi.h | 2 + qapi-schema.json | 34 +++- qemu-img.c | 1 + qemu-io-cmds.c | 8 +++ tests/qemu-iotests/064 | 72 + tests/qemu-iotests/064.out | 22 tests/qemu-iotests/common.rc | 19 ++- tests/qemu-iotests/group | 1 + 13 files changed, 323 insertions(+), 8 deletions(-) create mode 100755 tests/qemu-iotests/064 create mode 100644 tests/qemu-iotests/064.out -- 1.8.3.1
[Qemu-devel] [PATCH v3 2/6] block: Add ImageInfoSpecific to BlockDriverInfo
Add the new ImageInfoSpecific type also to BlockDriverInfo, as well as a bdrv_put_info function which releases all data allocated by bdrv_get_info from BlockDriverInfo (such as the new ImageInfoSpecific field). To prevent memory leaks, bdrv_put_info has to be called on every BlockDriverInfo object when it is no longer required (and bdrv_get_info has been successful). Signed-off-by: Max Reitz mre...@redhat.com --- block.c | 16 +++- block/mirror.c| 16 +++- block/qapi.c | 4 include/block/block.h | 3 +++ qemu-img.c| 1 + qemu-io-cmds.c| 2 ++ 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/block.c b/block.c index 26639e8..2e74fc0 100644 --- a/block.c +++ b/block.c @@ -1922,8 +1922,10 @@ void bdrv_round_to_clusters(BlockDriverState *bs, int *cluster_nb_sectors) { BlockDriverInfo bdi; +int ret; -if (bdrv_get_info(bs, bdi) 0 || bdi.cluster_size == 0) { +ret = bdrv_get_info(bs, bdi); +if (ret 0 || bdi.cluster_size == 0) { *cluster_sector_num = sector_num; *cluster_nb_sectors = nb_sectors; } else { @@ -1932,6 +1934,9 @@ void bdrv_round_to_clusters(BlockDriverState *bs, *cluster_nb_sectors = QEMU_ALIGN_UP(sector_num - *cluster_sector_num + nb_sectors, c); } +if (ret = 0) { +bdrv_put_info(bs, bdi); +} } static bool tracked_request_overlaps(BdrvTrackedRequest *req, @@ -3229,6 +3234,15 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) return drv-bdrv_get_info(bs, bdi); } +/** + * Releases all data which has been allocated through bdrv_get_info. This + * function should be called if and only if bdrv_get_info was successful. + */ +void bdrv_put_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ +qapi_free_ImageInfoSpecific(bdi-format_specific); +} + int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int64_t pos, int size) { diff --git a/block/mirror.c b/block/mirror.c index 86de458..9549add 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -320,10 +320,12 @@ static void coroutine_fn mirror_run(void *opaque) bdrv_get_backing_filename(s-target, backing_filename, sizeof(backing_filename)); if (backing_filename[0] !s-target-backing_hd) { -bdrv_get_info(s-target, bdi); -if (s-granularity bdi.cluster_size) { -s-buf_size = MAX(s-buf_size, bdi.cluster_size); -s-cow_bitmap = bitmap_new(length); +if (bdrv_get_info(s-target, bdi) = 0) { +if (s-granularity bdi.cluster_size) { +s-buf_size = MAX(s-buf_size, bdi.cluster_size); +s-cow_bitmap = bitmap_new(length); +} +bdrv_put_info(s-target, bdi); } } @@ -545,12 +547,16 @@ void mirror_start(BlockDriverState *bs, BlockDriverState *target, /* Choose the default granularity based on the target file's cluster * size, clamped between 4k and 64k. */ BlockDriverInfo bdi; -if (bdrv_get_info(target, bdi) = 0 bdi.cluster_size != 0) { +int ret = bdrv_get_info(target, bdi); +if (ret = 0 bdi.cluster_size != 0) { granularity = MAX(4096, bdi.cluster_size); granularity = MIN(65536, granularity); } else { granularity = 65536; } +if (ret = 0) { +bdrv_put_info(target, bdi); +} } assert ((granularity (granularity - 1)) == 0); diff --git a/block/qapi.c b/block/qapi.c index a4bc411..86c399c 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -133,6 +133,10 @@ void bdrv_query_image_info(BlockDriverState *bs, } info-dirty_flag = bdi.is_dirty; info-has_dirty_flag = true; +if (bdi.format_specific) { +info-format_specific = bdi.format_specific; +info-has_format_specific = true; +} } backing_filename = bs-backing_file; if (backing_filename[0] != '\0') { diff --git a/include/block/block.h b/include/block/block.h index e6b391c..20f17a1 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -18,6 +18,8 @@ typedef struct BlockDriverInfo { /* offset at which the VM state can be saved (0 if not possible) */ int64_t vm_state_offset; bool is_dirty; +/* additional information; NULL if none */ +ImageInfoSpecific *format_specific; } BlockDriverInfo; typedef struct BlockFragInfo { @@ -312,6 +314,7 @@ int bdrv_get_flags(BlockDriverState *bs); int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors); int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); +void bdrv_put_info(BlockDriverState *bs, BlockDriverInfo *bdi); void bdrv_round_to_clusters(BlockDriverState *bs,
Re: [Qemu-devel] [PATCH 3/6] range: add min/max operations on ranges
On Wed, 4 Sep 2013 13:48:35 +0300 Michael S. Tsirkin m...@redhat.com wrote: Signed-off-by: Michael S. Tsirkin m...@redhat.com --- include/qemu/range.h | 17 + 1 file changed, 17 insertions(+) diff --git a/include/qemu/range.h b/include/qemu/range.h index 4a0780d..1c688ca 100644 --- a/include/qemu/range.h +++ b/include/qemu/range.h @@ -17,6 +17,23 @@ struct Range { uint64_t end; /* 1 + the last byte. 0 if range empty or ends at ~0x0LL. */ }; +static inline void range_extend(Range *range, Range *extend_by) doc comment what it does pls. +{ +if (!extend_by-begin !extend_by-end) { +return; +} +if (!range-begin !range-end) { +*range = *extend_by; +return; +} +if (range-begin extend_by-begin) { +range-begin = extend_by-begin; +} +if (range-end - 1 extend_by-end - 1) { (foo)-end could be 0 at this point leading to overflow when subtracted, is it intended to be so? +range-end = extend_by-end; +} +} + /* Get last byte of a range from offset + length. * Undefined for ranges that wrap around 0. */ static inline uint64_t range_get_last(uint64_t offset, uint64_t len)
[Qemu-devel] [PATCH v3 6/6] qemu-iotests: Additional info from qemu-img info
Add a test for the additional information now provided by qemu-img info when used on qcow2 images. Signed-off-by: Max Reitz mre...@redhat.com --- tests/qemu-iotests/064 | 72 ++ tests/qemu-iotests/064.out | 22 ++ tests/qemu-iotests/group | 1 + 3 files changed, 95 insertions(+) create mode 100755 tests/qemu-iotests/064 create mode 100644 tests/qemu-iotests/064.out diff --git a/tests/qemu-iotests/064 b/tests/qemu-iotests/064 new file mode 100755 index 000..4979db5 --- /dev/null +++ b/tests/qemu-iotests/064 @@ -0,0 +1,72 @@ +#!/bin/bash +# +# Test for additional information emitted by qemu-img info on qcow2 +# images +# +# Copyright (C) 2013 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# + +# creator +owner=mre...@redhat.com + +seq=`basename $0` +echo QA output created by $seq + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap _cleanup; exit \$status 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +# This tests qocw2-specific low-level functionality +_supported_fmt qcow2 +_supported_proto generic +_supported_os Linux + +IMG_SIZE=64M + +echo +echo === Testing qcow2 image with -o compat=0.10 === +echo +IMGOPTS=compat=0.10 _make_test_img $IMG_SIZE +# don't use _img_info, since that function will filter out the +# additional information we're about to test for +$QEMU_IMG info $TEST_IMG | grep Format specific information: -A 42 + +echo +echo === Testing qcow2 image with -o compat=1.1,lazy_refcounts=off === +echo +IMGOPTS=compat=1.1,lazy_refcounts=off _make_test_img $IMG_SIZE +$QEMU_IMG info $TEST_IMG | grep Format specific information: -A 42 + +echo +echo === Testing qcow2 image with -o compat=1.1,lazy_refcounts=on === +echo +IMGOPTS=compat=1.1,lazy_refcounts=on _make_test_img $IMG_SIZE +$QEMU_IMG info $TEST_IMG | grep Format specific information: -A 42 + +# success, all done +echo *** done +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/064.out b/tests/qemu-iotests/064.out new file mode 100644 index 000..6ce5b43 --- /dev/null +++ b/tests/qemu-iotests/064.out @@ -0,0 +1,22 @@ +QA output created by 064 + +=== Testing qcow2 image with -o compat=0.10 === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +Format specific information: +compat: 0.10 + +=== Testing qcow2 image with -o compat=1.1,lazy_refcounts=off === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +Format specific information: +compat: 1.1 +lazy refcounts: false + +=== Testing qcow2 image with -o compat=1.1,lazy_refcounts=on === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +Format specific information: +compat: 1.1 +lazy refcounts: true +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index b696242..740cd84 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -66,3 +66,4 @@ 059 rw auto 060 rw auto 062 rw auto +064 rw auto -- 1.8.3.1
[Qemu-devel] [PATCH v3 5/6] qemu-iotests: Discard specific info in _img_info
In _img_info, filter out additional information specific to the image format provided by qemu-img info, since tests designed for multiple image formats would produce different outputs for every image format else. Signed-off-by: Max Reitz mre...@redhat.com --- tests/qemu-iotests/common.rc | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 5e077c3..13f62d8 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -181,12 +181,29 @@ _check_test_img() _img_info() { +discard=0 $QEMU_IMG info $@ $TEST_IMG 21 | \ sed -e s#$IMGPROTO:$TEST_DIR#TEST_DIR#g \ -e s#$TEST_DIR#TEST_DIR#g \ -e s#$IMGFMT#IMGFMT#g \ -e /^disk size:/ D \ --e /actual-size/ D +-e /actual-size/ D | \ +while IFS='' read line; do +if [ $line == Format specific information: ]; then +discard=1 +elif [ `echo $line | sed -e 's/^ *//'` == 'format-specific: {' ]; then +discard=2 +json_indent=`echo $line | sed -e 's/^\( *\).*$/\1/'` +fi +if [ $discard == 0 ]; then +echo $line +elif [ $discard == 1 -a -z $line ]; then +echo +discard=0 +elif [ $discard == 2 -a `echo $line | sed -e 's/ *$//'` == ${json_indent}}, ]; then +discard=0 +fi +done } _get_pids_by_name() -- 1.8.3.1
[Qemu-devel] [PATCH 1/4] usb: sanity check setup_index+setup_len in post_load
Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb/bus.c | 4 1 file changed, 4 insertions(+) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 82ca6a1..72d5b92 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -47,6 +47,10 @@ static int usb_device_post_load(void *opaque, int version_id) } else { dev-attached = 1; } +if (dev-setup_index = sizeof(dev-data_buf) || +dev-setup_len = sizeof(dev-data_buf)) { +return -EINVAL; +} return 0; } -- 1.8.3.1
[Qemu-devel] [PULL 0/4] usb patch queue
Hi, Here comes the usb patch queue, bringing little fixes and making usb bluetooth support a compile time option. please pull, Gerd The following changes since commit 94c2b6aff43cdfcfdfb552773a6b6b973a72ef0b: mips_malta: support up to 2GiB RAM (2013-09-09 18:42:22 +0200) are available in the git repository at: git://git.kraxel.org/qemu usb.89 for you to fetch changes up to adbecc89731cf3e0ae656d50ea9fa58c589c4bdc: ehci: save device pointer in EHCIState (2013-09-10 11:14:42 +0200) Gerd Hoffmann (2): usb: sanity check setup_index+setup_len in post_load ehci: save device pointer in EHCIState Miroslav Rezanina (2): Preparation for usb-bt-dongle conditional build Remove dev-bluetooth.c dependency from vl.c hw/bt/core.c | 23 ++ hw/bt/hci.c| 48 + hw/usb/Makefile.objs | 3 -- hw/usb/bus.c | 4 +++ hw/usb/dev-bluetooth.c | 10 +- hw/usb/hcd-ehci.c | 7 ++--- hw/usb/hcd-ehci.h | 1 + include/hw/bt.h| 3 ++ include/hw/usb.h | 3 -- vl.c | 82 +++--- 10 files changed, 95 insertions(+), 89 deletions(-)
[Qemu-devel] [PATCH 4/4] ehci: save device pointer in EHCIState
We'll need a pointer to the actual pci/sysbus device, stick a pointer to it into the EHCIState struct. https://bugzilla.redhat.com/show_bug.cgi?id=1005495 Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb/hcd-ehci.c | 7 +++ hw/usb/hcd-ehci.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 137e200..22bdbf4 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -1241,13 +1241,11 @@ static int ehci_init_transfer(EHCIPacket *p) { uint32_t cpage, offset, bytes, plen; dma_addr_t page; -USBBus *bus = p-queue-ehci-bus; -BusState *qbus = BUS(bus); cpage = get_field(p-qtd.token, QTD_TOKEN_CPAGE); bytes = get_field(p-qtd.token, QTD_TOKEN_TBYTES); offset = p-qtd.bufptr[0] ~QTD_BUFPTR_MASK; -qemu_sglist_init(p-sgl, qbus-parent, 5, p-queue-ehci-as); +qemu_sglist_init(p-sgl, p-queue-ehci-device, 5, p-queue-ehci-as); while (bytes 0) { if (cpage 4) { @@ -1486,7 +1484,7 @@ static int ehci_process_itd(EHCIState *ehci, return -1; } -qemu_sglist_init(ehci-isgl, DEVICE(ehci), 2, ehci-as); +qemu_sglist_init(ehci-isgl, ehci-device, 2, ehci-as); if (off + len 4096) { /* transfer crosses page border */ uint32_t len2 = off + len - 4096; @@ -2529,6 +2527,7 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp) s-frame_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ehci_frame_timer, s); s-async_bh = qemu_bh_new(ehci_frame_timer, s); +s-device = dev; qemu_register_reset(ehci_reset, s); qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s); diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index 15a28e8..065c9fa 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -255,6 +255,7 @@ typedef QTAILQ_HEAD(EHCIQueueHead, EHCIQueue) EHCIQueueHead; struct EHCIState { USBBus bus; +DeviceState *device; qemu_irq irq; MemoryRegion mem; AddressSpace *as; -- 1.8.3.1
[Qemu-devel] [PATCH 2/4] Preparation for usb-bt-dongle conditional build
From: Miroslav Rezanina mreza...@redhat.com To allow disable usb-bt-dongle device using CONFIG_BLUETOOTH option, some of functions in vl.c file has to be made accessible in dev-bluetooth.c. This is pure code moving. Signed-off-by: Miroslav Rezanina mreza...@redhat.com Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/bt/core.c| 23 +++ hw/bt/hci.c | 48 +++ include/hw/bt.h | 3 +++ vl.c| 69 - 4 files changed, 74 insertions(+), 69 deletions(-) diff --git a/hw/bt/core.c b/hw/bt/core.c index 49012e0..0ffc948 100644 --- a/hw/bt/core.c +++ b/hw/bt/core.c @@ -119,3 +119,26 @@ void bt_device_done(struct bt_device_s *dev) *p = dev-next; } + +static struct bt_vlan_s { +struct bt_scatternet_s net; +int id; +struct bt_vlan_s *next; +} *first_bt_vlan; + +/* find or alloc a new bluetooth VLAN */ +struct bt_scatternet_s *qemu_find_bt_vlan(int id) +{ +struct bt_vlan_s **pvlan, *vlan; +for (vlan = first_bt_vlan; vlan != NULL; vlan = vlan-next) { +if (vlan-id == id) +return vlan-net; +} +vlan = g_malloc0(sizeof(struct bt_vlan_s)); +vlan-id = id; +pvlan = first_bt_vlan; +while (*pvlan != NULL) +pvlan = (*pvlan)-next; +*pvlan = vlan; +return vlan-net; +} diff --git a/hw/bt/hci.c b/hw/bt/hci.c index d1c0604..7ea3dc6 100644 --- a/hw/bt/hci.c +++ b/hw/bt/hci.c @@ -429,6 +429,24 @@ static const uint8_t bt_event_reserved_mask[8] = { 0xff, 0x9f, 0xfb, 0xff, 0x07, 0x18, 0x00, 0x00, }; + +static void null_hci_send(struct HCIInfo *hci, const uint8_t *data, int len) +{ +} + +static int null_hci_addr_set(struct HCIInfo *hci, const uint8_t *bd_addr) +{ +return -ENOTSUP; +} + +struct HCIInfo null_hci = { +.cmd_send = null_hci_send, +.sco_send = null_hci_send, +.acl_send = null_hci_send, +.bdaddr_set = null_hci_addr_set, +}; + + static inline uint8_t *bt_hci_event_start(struct bt_hci_s *hci, int evt, int len) { @@ -2176,6 +2194,36 @@ struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net) return s-info; } +struct HCIInfo *hci_init(const char *str) +{ +char *endp; +struct bt_scatternet_s *vlan = 0; + +if (!strcmp(str, null)) +/* null */ +return null_hci; +else if (!strncmp(str, host, 4) (str[4] == '\0' || str[4] == ':')) +/* host[:hciN] */ +return bt_host_hci(str[4] ? str + 5 : hci0); +else if (!strncmp(str, hci, 3)) { +/* hci[,vlan=n] */ +if (str[3]) { +if (!strncmp(str + 3, ,vlan=, 6)) { +vlan = qemu_find_bt_vlan(strtol(str + 9, endp, 0)); +if (*endp) +vlan = 0; +} +} else +vlan = qemu_find_bt_vlan(0); +if (vlan) + return bt_new_hci(vlan); +} + +fprintf(stderr, qemu: Unknown bluetooth HCI `%s'.\n, str); + +return 0; +} + static void bt_hci_done(struct HCIInfo *info) { struct bt_hci_s *hci = hci_from_info(info); diff --git a/include/hw/bt.h b/include/hw/bt.h index 3f365bc..cb2a7e6 100644 --- a/include/hw/bt.h +++ b/include/hw/bt.h @@ -108,12 +108,15 @@ struct bt_device_s { uint16_t clkoff; /* Note: Always little-endian */ }; +extern struct HCIInfo null_hci; /* bt.c */ void bt_device_init(struct bt_device_s *dev, struct bt_scatternet_s *net); void bt_device_done(struct bt_device_s *dev); +struct bt_scatternet_s *qemu_find_bt_vlan(int id); /* bt-hci.c */ struct HCIInfo *bt_new_hci(struct bt_scatternet_s *net); +struct HCIInfo *hci_init(const char *str); /* bt-vhci.c */ void bt_vhci_init(struct HCIInfo *info); diff --git a/vl.c b/vl.c index b4b119a..faefd9f 100644 --- a/vl.c +++ b/vl.c @@ -843,45 +843,6 @@ static int nb_hcis; static int cur_hci; static struct HCIInfo *hci_table[MAX_NICS]; -static struct bt_vlan_s { -struct bt_scatternet_s net; -int id; -struct bt_vlan_s *next; -} *first_bt_vlan; - -/* find or alloc a new bluetooth VLAN */ -static struct bt_scatternet_s *qemu_find_bt_vlan(int id) -{ -struct bt_vlan_s **pvlan, *vlan; -for (vlan = first_bt_vlan; vlan != NULL; vlan = vlan-next) { -if (vlan-id == id) -return vlan-net; -} -vlan = g_malloc0(sizeof(struct bt_vlan_s)); -vlan-id = id; -pvlan = first_bt_vlan; -while (*pvlan != NULL) -pvlan = (*pvlan)-next; -*pvlan = vlan; -return vlan-net; -} - -static void null_hci_send(struct HCIInfo *hci, const uint8_t *data, int len) -{ -} - -static int null_hci_addr_set(struct HCIInfo *hci, const uint8_t *bd_addr) -{ -return -ENOTSUP; -} - -static struct HCIInfo null_hci = { -.cmd_send = null_hci_send, -.sco_send = null_hci_send, -.acl_send = null_hci_send, -.bdaddr_set = null_hci_addr_set, -}; - struct HCIInfo *qemu_next_hci(void) { if (cur_hci == nb_hcis) @@ -890,36 +851,6 @@ struct HCIInfo
[Qemu-devel] [PATCH 3/4] Remove dev-bluetooth.c dependency from vl.c
From: Miroslav Rezanina mreza...@redhat.com Use usb_legacy_register handling to create bt-dongle device and remove code dependency from vl.c so CONFIG_USB_BLUETOOTH can be disabled. Signed-off-by: Miroslav Rezanina mreza...@redhat.com Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/usb/Makefile.objs | 3 --- hw/usb/dev-bluetooth.c | 10 +- include/hw/usb.h | 3 --- vl.c | 13 - 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/hw/usb/Makefile.objs b/hw/usb/Makefile.objs index f9695e7..a3eac3e 100644 --- a/hw/usb/Makefile.objs +++ b/hw/usb/Makefile.objs @@ -18,9 +18,6 @@ common-obj-$(CONFIG_USB_STORAGE_UAS) += dev-uas.o common-obj-$(CONFIG_USB_AUDIO)+= dev-audio.o common-obj-$(CONFIG_USB_SERIAL) += dev-serial.o common-obj-$(CONFIG_USB_NETWORK) += dev-network.o - -# FIXME: make configurable too -CONFIG_USB_BLUETOOTH := y common-obj-$(CONFIG_USB_BLUETOOTH)+= dev-bluetooth.o ifeq ($(CONFIG_USB_SMARTCARD),y) diff --git a/hw/usb/dev-bluetooth.c b/hw/usb/dev-bluetooth.c index f2fc2a8..7f292b1 100644 --- a/hw/usb/dev-bluetooth.c +++ b/hw/usb/dev-bluetooth.c @@ -511,10 +511,17 @@ static int usb_bt_initfn(USBDevice *dev) return 0; } -USBDevice *usb_bt_init(USBBus *bus, HCIInfo *hci) +static USBDevice *usb_bt_init(USBBus *bus, const char *cmdline) { USBDevice *dev; struct USBBtState *s; +HCIInfo *hci; + +if (*cmdline) { +hci = hci_init(cmdline); +} else { +hci = bt_new_hci(qemu_find_bt_vlan(0)); +} if (!hci) return NULL; @@ -566,6 +573,7 @@ static const TypeInfo bt_info = { static void usb_bt_register_types(void) { type_register_static(bt_info); +usb_legacy_register(usb-bt-dongle, bt, usb_bt_init); } type_init(usb_bt_register_types) diff --git a/include/hw/usb.h b/include/hw/usb.h index 1b8acba..a7680d4 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -442,9 +442,6 @@ int set_usb_string(uint8_t *buf, const char *str); USBDevice *usb_host_device_open(USBBus *bus, const char *devname); void usb_host_info(Monitor *mon, const QDict *qdict); -/* usb-bt.c */ -USBDevice *usb_bt_init(USBBus *bus, HCIInfo *hci); - /* usb ports of the VM */ #define VM_USB_HUB_SIZE 8 diff --git a/vl.c b/vl.c index faefd9f..4e709d5 100644 --- a/vl.c +++ b/vl.c @@ -1457,8 +1457,10 @@ static void configure_msg(QemuOpts *opts) static int usb_device_add(const char *devname) { -const char *p; USBDevice *dev = NULL; +#ifndef CONFIG_LINUX +const char *p; +#endif if (!usb_enabled(false)) { return -1; @@ -1474,15 +1476,8 @@ static int usb_device_add(const char *devname) /* only the linux version is qdev-ified, usb-bsd still needs this */ if (strstart(devname, host:, p)) { dev = usb_host_device_open(usb_bus_find(-1), p); -} else -#endif -if (!strcmp(devname, bt) || strstart(devname, bt:, p)) { -dev = usb_bt_init(usb_bus_find(-1), - devname[2] ? hci_init(p) - : bt_new_hci(qemu_find_bt_vlan(0))); -} else { -return -1; } +#endif if (!dev) return -1; -- 1.8.3.1
Re: [Qemu-devel] [RFC PATCH v3 3/5] Makefile: introduce common-obj-m and block-obj-m for DSO
On Tue, 09/10 08:45, Paolo Bonzini wrote: Il 10/09/2013 03:02, Fam Zheng ha scritto: -all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all +# static linked mods are expanded to .o list +dummy := $(call expand-mod-obj,common-obj-y) +dummy := $(call expand-mod-obj,block-obj-y) + +modules-m = $(patsubst %.o,%$(DSOSUF),$(filter %.o,$(block-obj-m) $(common-obj-m))) \ +$(patsubst %.mo,%$(DSOSUF),$(filter %.mo,$(block-obj-m) $(common-obj-m))) + +all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all $(modules-m) + +# Generate rules for single file modules (%.so: %.o). +$(foreach o,$(filter %.o,$(block-obj-m) $(common-obj-m)),$(eval \ + $(patsubst %.o,%.so,$o): $o)) + +# For multi file modules, dependencies should be listed explicitly in +# Makefile.objs as +# foo.mo-objs := bar.o biz.o +$(foreach o,$(filter %.mo,$(block-obj-m) $(common-obj-m)),$(eval \ + $(patsubst %.mo,%.so,$o): $($o-objs))) I agree that this foo.mo-objs variable is homogeneous with how you handle libraries and cflags. I like it now. However, I don't like the many places in which you have to special-case modules (expand-mod-obj, modules-m, etc.), and the duplication between Makefile and Makefile.target. I would prefer if you try doing this patch along the lines I suggested in my review of v2, using .mo files as a placeholder and then doing the final link either into the .so or in the executable. This should remove the need for at least expand-mod-obj, and probably for more of the duplicated constructs you have. OK. I'll try. In particular, I would like modules-m to be simply $(block-obj-m) $(common-obj-m). There need to be some variable with %.o and %.mo subst to %.so, to become dependency of target all. In the medium term, we need to find a way to avoid the duplication: block-obj-y = block/ block-obj-m = block/ Perhaps by introducing a dirs variable that automatically triggers recursion on all nested variables. But this can be the topic of a separate patch series, if you prefer. Agree but prefer to do it in a separate series. Thanks, Fam vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) @@ -251,6 +270,9 @@ clean: rm -f qemu-options.def find . -name '*.[oda]' -type f -exec rm -f {} + find . -name '*.l[oa]' -type f -exec rm -f {} + + find . -name '*.so' -type f -exec rm -f {} + + find . -name '*.dll' -type f -exec rm -f {} + + rm -f $(TOOLS) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ rm -Rf .libs rm -f qemu-img-cmds.h diff --git a/Makefile.objs b/Makefile.objs index efd5b0f..abf59e6 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -19,6 +19,8 @@ block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o block-obj-y += qemu-coroutine-sleep.o block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o +block-obj-m = block/ + ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) # Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add. # only pull in the actual virtio-9p device if we also enabled virtio. @@ -83,6 +85,9 @@ common-obj-$(CONFIG_SMARTCARD_NSS) += $(libcacard-y) common-obj-y += qmp-marshal.o common-obj-y += qmp.o hmp.o + +common-obj-m = $(block-obj-m) + endif ## diff --git a/Makefile.target b/Makefile.target index 381022d..8d70560 100644 --- a/Makefile.target +++ b/Makefile.target @@ -150,6 +150,10 @@ include $(SRC_PATH)/Makefile.objs obj-base := .. dummy := $(call unnest-vars) +# static linked mods are expanded to .o list +dummy := $(call expand-mod-obj,common-obj-y) +dummy := $(call expand-mod-obj,block-obj-y) + all-obj-y = $(obj-y) all-obj-y += $(addprefix ../, $(common-obj-y) $(block-obj-y)) diff --git a/configure b/configure index cc3cd4d..c6d4a62 100755 --- a/configure +++ b/configure @@ -190,6 +190,8 @@ mingw32=no gcov=no gcov_tool=gcov EXESUF= +DSOSUF=.so +LDFLAGS_SHARED=-shared prefix=/usr/local mandir=\${prefix}/share/man datadir=\${prefix}/share @@ -485,6 +487,7 @@ OpenBSD) Darwin) bsd=yes darwin=yes + LDFLAGS_SHARED=-bundle if [ $cpu = x86_64 ] ; then QEMU_CFLAGS=-arch x86_64 $QEMU_CFLAGS LDFLAGS=-arch x86_64 $LDFLAGS @@ -584,6 +587,7 @@ fi if test $mingw32 = yes ; then EXESUF=.exe + DSOSUF=.dll QEMU_CFLAGS=-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) QEMU_CFLAGS=-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS @@ -4175,6 +4179,8 @@ echo LIBTOOLFLAGS=$LIBTOOLFLAGS $config_host_mak echo LIBS+=$LIBS $config_host_mak echo LIBS_TOOLS+=$libs_tools $config_host_mak echo EXESUF=$EXESUF $config_host_mak +echo DSOSUF=$DSOSUF $config_host_mak +echo LDFLAGS_SHARED=$LDFLAGS_SHARED $config_host_mak echo
[Qemu-devel] [RFC qom-cpu v2 2/8] x86: add x86_cpu_unrealizefn() for cpu apic remove
Implement x86_cpu_unrealizefn() for corresponding x86_cpu_realizefn(), which is mostly used to clear the apic related information at here. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/cpu/icc_bus.c| 11 +++ hw/i386/kvm/apic.c | 6 ++ hw/intc/apic.c | 7 +++ hw/intc/apic_common.c | 11 +++ include/hw/cpu/icc_bus.h| 1 + include/hw/i386/apic_internal.h | 1 + target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 35 +++ 8 files changed, 73 insertions(+) diff --git a/hw/cpu/icc_bus.c b/hw/cpu/icc_bus.c index 8748cc5..45e87d1 100644 --- a/hw/cpu/icc_bus.c +++ b/hw/cpu/icc_bus.c @@ -54,11 +54,22 @@ static void icc_device_realize(DeviceState *dev, Error **errp) } } +static void icc_device_unrealize(DeviceState *dev, Error **errp) +{ +ICCDevice *id = ICC_DEVICE(dev); +ICCDeviceClass *idc = ICC_DEVICE_GET_CLASS(id); + +if (idc-exit) { +idc-exit(id); +} +} + static void icc_device_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); dc-realize = icc_device_realize; +dc-unrealize = icc_device_unrealize; dc-bus_type = TYPE_ICC_BUS; } diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c index 5609063..8f028a1 100644 --- a/hw/i386/kvm/apic.c +++ b/hw/i386/kvm/apic.c @@ -181,11 +181,17 @@ static void kvm_apic_init(APICCommonState *s) } } +static void kvm_apic_exit(APICCommonState *s) +{ +memory_region_destroy(s-io_memory); +} + static void kvm_apic_class_init(ObjectClass *klass, void *data) { APICCommonClass *k = APIC_COMMON_CLASS(klass); k-init = kvm_apic_init; +k-exit = kvm_apic_exit; k-set_base = kvm_apic_set_base; k-set_tpr = kvm_apic_set_tpr; k-get_tpr = kvm_apic_get_tpr; diff --git a/hw/intc/apic.c b/hw/intc/apic.c index a913186..23488b4 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -882,11 +882,18 @@ static void apic_init(APICCommonState *s) msi_supported = true; } +static void apic_uninit(APICCommonState *s) +{ +memory_region_destroy(s-io_memory); +local_apics[s-idx] = NULL; +} + static void apic_class_init(ObjectClass *klass, void *data) { APICCommonClass *k = APIC_COMMON_CLASS(klass); k-init = apic_init; +k-exit = apic_uninit; k-set_base = apic_set_base; k-set_tpr = apic_set_tpr; k-get_tpr = apic_get_tpr; diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 5568621..32c2f74 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -316,6 +316,16 @@ static int apic_init_common(ICCDevice *dev) return 0; } +static void apic_exit_common(ICCDevice *dev) +{ +APICCommonState *s = APIC_COMMON(dev); +APICCommonClass *info; + +info = APIC_COMMON_GET_CLASS(s); +if (info-exit) +info-exit(s); +} + static void apic_dispatch_pre_save(void *opaque) { APICCommonState *s = APIC_COMMON(opaque); @@ -387,6 +397,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data) dc-no_user = 1; dc-props = apic_properties_common; idc-init = apic_init_common; +idc-exit = apic_exit_common; } static const TypeInfo apic_common_type = { diff --git a/include/hw/cpu/icc_bus.h b/include/hw/cpu/icc_bus.h index b550070..15d5374 100644 --- a/include/hw/cpu/icc_bus.h +++ b/include/hw/cpu/icc_bus.h @@ -67,6 +67,7 @@ typedef struct ICCDeviceClass { /* public */ int (*init)(ICCDevice *dev); /* TODO replace with QOM realize */ +void (*exit)(ICCDevice *dev); } ICCDeviceClass; #define TYPE_ICC_DEVICE icc-device diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h index 1b0a7fb..87d5248 100644 --- a/include/hw/i386/apic_internal.h +++ b/include/hw/i386/apic_internal.h @@ -81,6 +81,7 @@ typedef struct APICCommonClass ICCDeviceClass parent_class; void (*init)(APICCommonState *s); +void (*exit)(APICCommonState *s); void (*set_base)(APICCommonState *s, uint64_t val); void (*set_tpr)(APICCommonState *s, uint8_t val); uint8_t (*get_tpr)(APICCommonState *s); diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index c4447c2..1e520be 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -50,6 +50,7 @@ typedef struct X86CPUClass { /* public */ DeviceRealize parent_realize; +DeviceUnrealize parent_unrealize; void (*parent_reset)(CPUState *cpu); } X86CPUClass; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 2b99683..6f9154d 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2339,10 +2339,31 @@ static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) return; } } + +static void x86_cpu_apic_unrealize(X86CPU *cpu, Error **errp) +{ +CPUX86State *env = cpu-env; +Error *local_err = NULL; + +if (env-apic_state == NULL) { +return; +} + +
[Qemu-devel] [RFC qom-cpu v2 1/8] apic: remove apic_no from apic_init_common()
the 'apic_no' is increased by one when initialize/create a vCPU each time, which causes APICCommonState s-idx always is increased. but if we want to re-add a vCPU after removing a vCPU, we need to re-use the vacant s-idx which the corresponding vCPU had been removed. so we could use the unique cpu apic_id instead of the progressive s-idx. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/intc/apic_common.c | 4 +--- target-i386/cpu.c | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index a0beb10..5568621 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -289,13 +289,11 @@ static int apic_init_common(ICCDevice *dev) APICCommonState *s = APIC_COMMON(dev); APICCommonClass *info; static DeviceState *vapic; -static int apic_no; static bool mmio_registered; -if (apic_no = MAX_APICS) { +if (s-idx = MAX_APICS) { return -1; } -s-idx = apic_no++; info = APIC_COMMON_GET_CLASS(s); info-init(s); diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 42c5de0..2b99683 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2322,6 +2322,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp) /* TODO: convert to link */ apic = APIC_COMMON(env-apic_state); apic-cpu = cpu; +apic-idx = env-cpuid_apic_id; } static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) -- 1.8.1.4
[Qemu-devel] [RFC qom-cpu v2 7/8] piix4: implement function cpu_status_write() for vcpu ejection
When OS eject a vcpu (like: echo 1 /sys/bus/acpi/devices/LNXCPUXX/eject), it will call acpi EJ0 method, the firmware will write the new cpumap, QEMU will know which vcpu need to be ejected. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/acpi/piix4.c | 37 - 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 2ddc9a8..0e9b5bd 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -61,6 +61,7 @@ struct pci_status { typedef struct CPUStatus { uint8_t sts[PIIX4_PROC_LEN]; +uint8_t old_sts[PIIX4_PROC_LEN]; } CPUStatus; typedef struct PIIX4PMState { @@ -610,6 +611,12 @@ static const MemoryRegionOps piix4_pci_ops = { }, }; +static void acpi_piix_eject_vcpu(int64_t cpuid) +{ +/* TODO: eject a vcpu, release allocated vcpu and exit the vcpu pthread. */ +PIIX4_DPRINTF(vcpu: % PRIu64 need to be ejected.\n, cpuid); +} + static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size) { PIIX4PMState *s = opaque; @@ -622,7 +629,27 @@ static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size) static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data, unsigned int size) { -/* TODO: implement VCPU removal on guest signal that CPU can be removed */ +PIIX4PMState *s = opaque; +CPUStatus *cpus = s-gpe_cpu; +uint8_t val; +int i; +int64_t cpuid = 0; + +val = cpus-old_sts[addr] ^ data; + +if (val == 0) { +return; +} + +for (i = 0; i 8; i++) { +if (val 1 i) { +cpuid = 8 * addr + i; +} +} + +if (cpuid != 0) { +acpi_piix_eject_vcpu(cpuid); +} } static const MemoryRegionOps cpu_hotplug_ops = { @@ -642,13 +669,20 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu, ACPIGPE *gpe = s-ar.gpe; CPUClass *k = CPU_GET_CLASS(cpu); int64_t cpu_id; +int i; assert(s != NULL); *gpe-sts = *gpe-sts | PIIX4_CPU_HOTPLUG_STATUS; cpu_id = k-get_arch_id(CPU(cpu)); + +for (i = 0; i PIIX4_PROC_LEN; i++) { +g-old_sts[i] = g-sts[i]; +} + if (action == PLUG) { g-sts[cpu_id / 8] |= (1 (cpu_id % 8)); +g-old_sts[cpu_id / 8] |= (1 (cpu_id % 8)); } else { g-sts[cpu_id / 8] = ~(1 (cpu_id % 8)); } @@ -687,6 +721,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, g_assert((id / 8) PIIX4_PROC_LEN); s-gpe_cpu.sts[id / 8] |= (1 (id % 8)); +s-gpe_cpu.old_sts[id / 8] |= (1 (id % 8)); } memory_region_init_io(s-io_cpu, OBJECT(s), cpu_hotplug_ops, s, acpi-cpu-hotplug, PIIX4_PROC_LEN); -- 1.8.1.4
[Qemu-devel] [RFC qom-cpu v2 4/8] qom cpu: rename variable 'cpu_added_notifier' to 'cpu_hotplug_notifier'
Rename variable 'cpu_added_notifier' to 'cpu_hotplug_notifier', for adding vcpu-remove notifier support. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/acpi/piix4.c | 10 +- hw/i386/pc.c| 2 +- include/sysemu/sysemu.h | 2 +- qom/cpu.c | 10 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 0b8d1d9..c8f4182 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -95,7 +95,7 @@ typedef struct PIIX4PMState { uint8_t s4_val; CPUStatus gpe_cpu; -Notifier cpu_added_notifier; +Notifier cpu_hotplug_notifier; } PIIX4PMState; #define TYPE_PIIX4_PM PIIX4_PM @@ -660,9 +660,9 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu, pm_update_sci(s); } -static void piix4_cpu_added_req(Notifier *n, void *opaque) +static void piix4_cpu_hotplug(Notifier *n, void *opaque) { -PIIX4PMState *s = container_of(n, PIIX4PMState, cpu_added_notifier); +PIIX4PMState *s = container_of(n, PIIX4PMState, cpu_hotplug_notifier); piix4_cpu_hotplug_req(s, CPU(opaque), PLUG); } @@ -695,8 +695,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, memory_region_init_io(s-io_cpu, OBJECT(s), cpu_hotplug_ops, s, acpi-cpu-hotplug, PIIX4_PROC_LEN); memory_region_add_subregion(parent, PIIX4_PROC_BASE, s-io_cpu); -s-cpu_added_notifier.notify = piix4_cpu_added_req; -qemu_register_cpu_added_notifier(s-cpu_added_notifier); +s-cpu_hotplug_notifier.notify = piix4_cpu_hotplug; +qemu_register_cpu_hotplug_notifier(s-cpu_hotplug_notifier); } static void enable_device(PIIX4PMState *s, int slot) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 3de9c51..f36903f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -407,7 +407,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, /* init CPU hotplug notifier */ cpu_hotplug_cb.rtc_state = s; cpu_hotplug_cb.cpu_added_notifier.notify = rtc_notify_cpu_added; -qemu_register_cpu_added_notifier(cpu_hotplug_cb.cpu_added_notifier); +qemu_register_cpu_hotplug_notifier(cpu_hotplug_cb.cpu_added_notifier); if (set_boot_dev(s, boot_device)) { exit(1); diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index b1aa059..e1c1120 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -153,7 +153,7 @@ void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict); void drive_hot_add(Monitor *mon, const QDict *qdict); /* CPU hotplug */ -void qemu_register_cpu_added_notifier(Notifier *notifier); +void qemu_register_cpu_hotplug_notifier(Notifier *notifier); /* pcie aer error injection */ void pcie_aer_inject_error_print(Monitor *mon, const QObject *data); diff --git a/qom/cpu.c b/qom/cpu.c index fa7ec6b..7992fe1 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -67,12 +67,12 @@ static void cpu_common_get_memory_mapping(CPUState *cpu, } /* CPU hot-plug notifiers */ -static NotifierList cpu_added_notifiers = -NOTIFIER_LIST_INITIALIZER(cpu_add_notifiers); +static NotifierList cpu_hotplug_notifiers = +NOTIFIER_LIST_INITIALIZER(cpu_hotplug_notifiers); -void qemu_register_cpu_added_notifier(Notifier *notifier) +void qemu_register_cpu_hotplug_notifier(Notifier *notifier) { -notifier_list_add(cpu_added_notifiers, notifier); +notifier_list_add(cpu_hotplug_notifiers, notifier); } void cpu_reset_interrupt(CPUState *cpu, int mask) @@ -218,7 +218,7 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) if (dev-hotplugged) { cpu_synchronize_post_init(cpu); -notifier_list_notify(cpu_added_notifiers, dev); +notifier_list_notify(cpu_hotplug_notifiers, dev); cpu_resume(cpu); } } -- 1.8.1.4
[Qemu-devel] [RFC qom-cpu v2 5/8] qom cpu: add UNPLUG cpu notifier support
Move struct HotplugEventType from file piix4.c to file qom/cpu.c, and add struct CPUNotifier for supporting UNPLUG cpu notifier. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/acpi/piix4.c | 8 ++-- include/qom/cpu.h | 10 ++ qom/cpu.c | 6 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index c8f4182..2ddc9a8 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -635,11 +635,6 @@ static const MemoryRegionOps cpu_hotplug_ops = { }, }; -typedef enum { -PLUG, -UNPLUG, -} HotplugEventType; - static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu, HotplugEventType action) { @@ -663,8 +658,9 @@ static void piix4_cpu_hotplug_req(PIIX4PMState *s, CPUState *cpu, static void piix4_cpu_hotplug(Notifier *n, void *opaque) { PIIX4PMState *s = container_of(n, PIIX4PMState, cpu_hotplug_notifier); +CPUNotifier *notifier = opaque; -piix4_cpu_hotplug_req(s, CPU(opaque), PLUG); +piix4_cpu_hotplug_req(s, CPU(notifier-dev), notifier-type); } static int piix4_device_hotplug(DeviceState *qdev, PCIDevice *dev, diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 7739e00..0238532 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -507,6 +507,16 @@ void qemu_init_vcpu(CPUState *cpu); */ void cpu_single_step(CPUState *cpu, int enabled); +typedef enum { +PLUG, +UNPLUG, +} HotplugEventType; + +typedef struct CPUNotifier { +DeviceState *dev; +HotplugEventType type; +} CPUNotifier; + #ifdef CONFIG_SOFTMMU extern const struct VMStateDescription vmstate_cpu_common; #else diff --git a/qom/cpu.c b/qom/cpu.c index 7992fe1..c6d7ebc 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -215,10 +215,14 @@ static ObjectClass *cpu_common_class_by_name(const char *cpu_model) static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu = CPU(dev); +CPUNotifier notifier; + +notifier.dev = dev; +notifier.type = PLUG; if (dev-hotplugged) { cpu_synchronize_post_init(cpu); -notifier_list_notify(cpu_hotplug_notifiers, dev); +notifier_list_notify(cpu_hotplug_notifiers, notifier); cpu_resume(cpu); } } -- 1.8.1.4
[Qemu-devel] [RFC qom-cpu v2 3/8] qmp: add 'cpu-del' command support
Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/i386/pc.c | 5 + hw/i386/pc_piix.c| 1 + include/hw/boards.h | 2 ++ include/hw/i386/pc.h | 1 + qapi-schema.json | 12 qmp-commands.hx | 23 +++ qmp.c| 9 + 7 files changed, 53 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0c313fe..3de9c51 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -957,6 +957,11 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp); } +void pc_hot_del_cpu(const int64_t id, Error **errp) +{ +/* TODO: hot remove vCPU. */ +} + void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge) { int i; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 6e1e654..d779b75 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -347,6 +347,7 @@ static QEMUMachine pc_i440fx_machine_v1_6 = { .desc = Standard PC (i440FX + PIIX, 1996), .init = pc_init_pci_1_6, .hot_add_cpu = pc_hot_add_cpu, +.hot_del_cpu = pc_hot_del_cpu, .max_cpus = 255, .is_default = 1, DEFAULT_MACHINE_OPTIONS, diff --git a/include/hw/boards.h b/include/hw/boards.h index fb7c6f1..fea3737 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -23,6 +23,7 @@ typedef void QEMUMachineInitFunc(QEMUMachineInitArgs *args); typedef void QEMUMachineResetFunc(void); typedef void QEMUMachineHotAddCPUFunc(const int64_t id, Error **errp); +typedef void QEMUMachineHotDelCPUFunc(const int64_t id, Error **errp); typedef struct QEMUMachine { const char *name; @@ -31,6 +32,7 @@ typedef struct QEMUMachine { QEMUMachineInitFunc *init; QEMUMachineResetFunc *reset; QEMUMachineHotAddCPUFunc *hot_add_cpu; +QEMUMachineHotDelCPUFunc *hot_del_cpu; BlockInterfaceType block_default_type; int max_cpus; unsigned int no_serial:1, diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f79d478..b7e66f4 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -96,6 +96,7 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level); void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge); void pc_hot_add_cpu(const int64_t id, Error **errp); +void pc_hot_del_cpu(const int64_t id, Error **errp); void pc_acpi_init(const char *default_dsdt); PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size, diff --git a/qapi-schema.json b/qapi-schema.json index a51f7d2..6052aa9 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1432,6 +1432,18 @@ ## { 'command': 'cpu-add', 'data': {'id': 'int'} } +# @cpu-del + +# Deletes CPU with specified ID +# +# @id: ID of CPU to be deleted, valid values [0..max_cpus) +# +# Returns: Nothing on success +# +# Since 1.7 +## +{ 'command': 'cpu-del', 'data': {'id': 'int'} } + ## # @memsave: # diff --git a/qmp-commands.hx b/qmp-commands.hx index cf47e3f..16b54fd 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -411,6 +411,29 @@ Example: EQMP { +.name = cpu-del, +.args_type = id:i, +.mhandler.cmd_new = qmp_marshal_input_cpu_del, +}, + +SQMP +cpu-del +--- + +Deletes virtual cpu + +Arguments: + +- id: cpu id (json-int) + +Example: + +- { execute: cpu-del, arguments: { id: 2 } } +- { return: {} } + +EQMP + +{ .name = memsave, .args_type = val:l,size:i,filename:s,cpu:i?, .mhandler.cmd_new = qmp_marshal_input_memsave, diff --git a/qmp.c b/qmp.c index 4c149b3..84dc873 100644 --- a/qmp.c +++ b/qmp.c @@ -118,6 +118,15 @@ void qmp_cpu_add(int64_t id, Error **errp) } } +void qmp_cpu_del(int64_t id, Error **errp) +{ +if (current_machine-hot_del_cpu) { +current_machine-hot_del_cpu(id, errp); +} else { +error_setg(errp, Not supported); +} +} + #ifndef CONFIG_VNC /* If VNC support is enabled, the true query-vnc command is defined in the VNC subsystem */ -- 1.8.1.4
[Qemu-devel] [RFC qom-cpu v2 6/8] i386: implement pc interface pc_hot_del_cpu()
Implement cpu interface pc_hot_del_cpu() for unrealizing device vCPU. emiting vcpu-remove notifier to ACPI, then ACPI could send sci interrupt to OS for hot-remove vcpu. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/i386/pc.c | 29 - qom/cpu.c| 11 +++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f36903f..6f88e41 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -959,7 +959,34 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) void pc_hot_del_cpu(const int64_t id, Error **errp) { -/* TODO: hot remove vCPU. */ +CPUState *cpu; +bool found = false; +X86CPUClass *xcc; + +CPU_FOREACH(cpu) { +CPUClass *cc = CPU_GET_CLASS(cpu); +int64_t cpuid = cc-get_arch_id(cpu); + +if (cpuid == id) { +found = true; +break; +} +} + +if (!found) { +error_setg(errp, Unable to find cpu-index: % PRIi64 + , it doesn't exist or has been deleted., id); +return; +} + +if (cpu == first_cpu !CPU_NEXT(cpu)) { +error_setg(errp, Unable to delete the last +cpu when VM running.); +return; +} + +xcc = X86_CPU_GET_CLASS(DEVICE(cpu)); +xcc-parent_unrealize(DEVICE(cpu), errp); } void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge) diff --git a/qom/cpu.c b/qom/cpu.c index c6d7ebc..9cd7fcd 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -227,6 +227,16 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) } } +static void cpu_common_unrealizefn(DeviceState *dev, Error **errp) +{ +CPUNotifier notifier; + +notifier.dev = dev; +notifier.type = UNPLUG; + +notifier_list_notify(cpu_hotplug_notifiers, notifier); +} + static void cpu_common_initfn(Object *obj) { CPUState *cpu = CPU(obj); @@ -257,6 +267,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k-gdb_read_register = cpu_common_gdb_read_register; k-gdb_write_register = cpu_common_gdb_write_register; dc-realize = cpu_common_realizefn; +dc-unrealize = cpu_common_unrealizefn; dc-no_user = 1; } -- 1.8.1.4
[Qemu-devel] [RFC qom-cpu v2 0/8] i386: add cpu hot remove support
Via implementing ACPI standard methods _EJ0 in bios, after Guest OS hot remove one vCPU, it is able to send a signal to QEMU, then QEMU could notify the assigned vCPU of exiting. this work is based on Andreas Färber's qom-cpu branch tree. git://github.com/afaerber/qemu-cpu.git this series patches must be used with seabios patch and KVM patch together. for KVM patches: http://comments.gmane.org/gmane.comp.emulators.kvm.devel/114347 for seabios patches: http://comments.gmane.org/gmane.comp.emulators.qemu/230460 Chen Fan (8): apic: remove apic_no from apic_init_common() x86: add x86_cpu_unrealizefn() for cpu apic remove qmp: add 'cpu-del' command support qom cpu: rename variable 'cpu_added_notifier' to 'cpu_hotplug_notifier' qom cpu: add UNPLUG cpu notifier support i386: implement pc interface pc_hot_del_cpu() piix4: implement function cpu_status_write() for vcpu ejection cpus: release allocated vCPU objects cpus.c | 46 hw/acpi/piix4.c | 66 + hw/cpu/icc_bus.c| 11 +++ hw/i386/kvm/apic.c | 6 hw/i386/pc.c| 34 - hw/i386/pc_piix.c | 1 + hw/intc/apic.c | 7 + hw/intc/apic_common.c | 15 -- include/hw/boards.h | 2 ++ include/hw/cpu/icc_bus.h| 1 + include/hw/i386/apic_internal.h | 1 + include/hw/i386/pc.h| 1 + include/qom/cpu.h | 20 + include/sysemu/kvm.h| 1 + include/sysemu/sysemu.h | 2 +- kvm-all.c | 25 qapi-schema.json| 12 qmp-commands.hx | 23 ++ qmp.c | 9 ++ qom/cpu.c | 25 target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 36 ++ 22 files changed, 323 insertions(+), 22 deletions(-) -- 1.8.1.4
[Qemu-devel] [RFC qom-cpu v2 8/8] cpus: release allocated vCPU objects
After ACPI get a signal to eject a vCPU, then it will notify the vCPU thread to exit when using KVM, and the vCPU must be removed from CPU list, before the vCPU really removed, there will release the all related vCPU objects and apic device. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- cpus.c | 46 ++ hw/acpi/piix4.c | 23 +-- include/qom/cpu.h| 10 ++ include/sysemu/kvm.h | 1 + kvm-all.c| 25 + 5 files changed, 99 insertions(+), 6 deletions(-) diff --git a/cpus.c b/cpus.c index 980697e..10dded3 100644 --- a/cpus.c +++ b/cpus.c @@ -714,6 +714,26 @@ void async_run_on_cpu(CPUState *cpu, void (*func)(void *data), void *data) qemu_cpu_kick(cpu); } +static void qemu_kvm_destroy_vcpu(CPUState *cpu) +{ +CPU_REMOVE(cpu); + +if (kvm_destroy_vcpu(cpu) 0) { +fprintf(stderr, kvm_destroy_vcpu failed.\n); +exit(1); +} + +object_property_set_bool(OBJECT(cpu), false, realized, NULL); +qdev_free(DEVICE(cpu)); +} + +static void qemu_tcg_destroy_vcpu(CPUState *cpu) +{ +CPU_REMOVE(cpu); +object_property_set_bool(OBJECT(cpu), false, realized, NULL); +qdev_free(DEVICE(cpu)); +} + static void flush_queued_work(CPUState *cpu) { struct qemu_work_item *wi; @@ -805,6 +825,11 @@ static void *qemu_kvm_cpu_thread_fn(void *arg) } } qemu_kvm_wait_io_event(cpu); +if (cpu-exit !cpu_can_run(cpu)) { +qemu_kvm_destroy_vcpu(cpu); +qemu_mutex_unlock(qemu_global_mutex); +return NULL; +} } return NULL; @@ -857,6 +882,7 @@ static void tcg_exec_all(void); static void *qemu_tcg_cpu_thread_fn(void *arg) { CPUState *cpu = arg; +CPUState *remove_cpu = NULL; qemu_tcg_init_cpu_signals(); qemu_thread_get_self(cpu-thread); @@ -889,6 +915,16 @@ static void *qemu_tcg_cpu_thread_fn(void *arg) } } qemu_tcg_wait_io_event(); +CPU_FOREACH(cpu) { +if (cpu-exit !cpu_can_run(cpu)) { +remove_cpu = cpu; +break; +} +} +if (remove_cpu) { +qemu_tcg_destroy_vcpu(remove_cpu); +remove_cpu = NULL; +} } return NULL; @@ -1045,6 +1081,13 @@ void resume_all_vcpus(void) } } +void cpu_remove(CPUState *cpu) +{ +cpu-stop = true; +cpu-exit = true; +qemu_cpu_kick(cpu); +} + static void qemu_tcg_init_vcpu(CPUState *cpu) { /* share a single thread for all cpus with TCG */ @@ -1219,6 +1262,9 @@ static void tcg_exec_all(void) break; } } else if (cpu-stop || cpu-stopped) { +if (cpu-exit) { +next_cpu = CPU_NEXT(cpu); +} break; } } diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 0e9b5bd..c2cf519 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -611,10 +611,21 @@ static const MemoryRegionOps piix4_pci_ops = { }, }; -static void acpi_piix_eject_vcpu(int64_t cpuid) +static void acpi_piix_eject_vcpu(PIIX4PMState *s, int64_t cpuid) { -/* TODO: eject a vcpu, release allocated vcpu and exit the vcpu pthread. */ -PIIX4_DPRINTF(vcpu: % PRIu64 need to be ejected.\n, cpuid); +CPUStatus *g = s-gpe_cpu; +CPUState *cpu; + +CPU_FOREACH(cpu) { +CPUClass *cc = CPU_GET_CLASS(cpu); +int64_t id = cc-get_arch_id(cpu); + +if (cpuid == id) { +g-old_sts[cpuid / 8] = ~(1 (cpuid % 8)); +cpu_remove(cpu); +break; +} +} } static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size) @@ -633,7 +644,7 @@ static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data, CPUStatus *cpus = s-gpe_cpu; uint8_t val; int i; -int64_t cpuid = 0; +int64_t cpuid = -1; val = cpus-old_sts[addr] ^ data; @@ -647,8 +658,8 @@ static void cpu_status_write(void *opaque, hwaddr addr, uint64_t data, } } -if (cpuid != 0) { -acpi_piix_eject_vcpu(cpuid); +if (cpuid != -1) { +acpi_piix_eject_vcpu(s, cpuid); } } diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 0238532..eb8d32b 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -181,6 +181,7 @@ struct CPUState { bool created; bool stop; bool stopped; +bool exit; volatile sig_atomic_t exit_request; volatile sig_atomic_t tcg_exit_req; uint32_t interrupt_request; @@ -206,6 +207,7 @@ struct CPUState { QTAILQ_HEAD(CPUTailQ, CPUState); extern struct CPUTailQ cpus; #define CPU_NEXT(cpu) QTAILQ_NEXT(cpu, node) +#define CPU_REMOVE(cpu) QTAILQ_REMOVE(cpus, cpu, node) #define CPU_FOREACH(cpu) QTAILQ_FOREACH(cpu, cpus, node) #define CPU_FOREACH_SAFE(cpu, next_cpu) \ QTAILQ_FOREACH_SAFE(cpu, cpus, node, next_cpu) @@ -487,6
Re: [Qemu-devel] [PATCH vgabios] Make windows8 work with high resolution when using -vga std in qmeu
On 09/10/13 05:24, Bo Yang wrote: This patch has been sent to upstream vgabios maillist, but there is no response. Since it is useful for windows8 resolution, I resend it to qemu maillist for review. Signed-off-by: Bo Yang boy...@suse.com --- vbe.c | 42 ++ 1 files changed, 38 insertions(+), 4 deletions(-) SeaBIOS / SeaVGABIOS is separate from the asm-ized vgabios; this patch doesn't apply AFAICS. Regarding the win8 resolution problem, see this seabios thread: http://www.seabios.org/pipermail/seabios/2013-September/006875.html Laszlo
Re: [Qemu-devel] [RFC PATCH v3 3/5] Makefile: introduce common-obj-m and block-obj-m for DSO
Il 10/09/2013 11:42, Fam Zheng ha scritto: On Tue, 09/10 08:45, Paolo Bonzini wrote: Il 10/09/2013 03:02, Fam Zheng ha scritto: -all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all +# static linked mods are expanded to .o list +dummy := $(call expand-mod-obj,common-obj-y) +dummy := $(call expand-mod-obj,block-obj-y) + +modules-m = $(patsubst %.o,%$(DSOSUF),$(filter %.o,$(block-obj-m) $(common-obj-m))) \ +$(patsubst %.mo,%$(DSOSUF),$(filter %.mo,$(block-obj-m) $(common-obj-m))) + +all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all $(modules-m) + +# Generate rules for single file modules (%.so: %.o). +$(foreach o,$(filter %.o,$(block-obj-m) $(common-obj-m)),$(eval \ + $(patsubst %.o,%.so,$o): $o)) + +# For multi file modules, dependencies should be listed explicitly in +# Makefile.objs as +# foo.mo-objs := bar.o biz.o +$(foreach o,$(filter %.mo,$(block-obj-m) $(common-obj-m)),$(eval \ + $(patsubst %.mo,%.so,$o): $($o-objs))) I agree that this foo.mo-objs variable is homogeneous with how you handle libraries and cflags. I like it now. However, I don't like the many places in which you have to special-case modules (expand-mod-obj, modules-m, etc.), and the duplication between Makefile and Makefile.target. I would prefer if you try doing this patch along the lines I suggested in my review of v2, using .mo files as a placeholder and then doing the final link either into the .so or in the executable. This should remove the need for at least expand-mod-obj, and probably for more of the duplicated constructs you have. OK. I'll try. In particular, I would like modules-m to be simply $(block-obj-m) $(common-obj-m). There need to be some variable with %.o and %.mo subst to %.so, to become dependency of target all. I think you are putting too much weight on %.so, which complicates things when handling both modular and non-modular builds. Assuming you have transformed block-obj-m and common-obj-m to only contain .mo files, with something like this: define add-modules $(foreach o, $(filter-out %.o, $($1)), $(eval $o-objs := $o)) $(eval modules-m += $(patsubst %.o,%.mo,$($1))) endif dummy := $(call add-modules,block-obj-m) dummy := $(call add-modules,common-obj-m) then building modules can be just a bunch of extra targets: ifeq ($(CONFIG_MODULES),y) modules: $(patsubst %.mo,%$(DSOSUF),$(modules-m)) all: modules endif In the medium term, we need to find a way to avoid the duplication: block-obj-y = block/ block-obj-m = block/ Perhaps by introducing a dirs variable that automatically triggers recursion on all nested variables. But this can be the topic of a separate patch series, if you prefer. Agree but prefer to do it in a separate series. Sure. Paolo
[Qemu-devel] [PATCH 2/3] qxl: trace io port name
Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/display/qxl.c | 5 +++-- trace-events | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 7649f2b..c50e285 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -1541,8 +1541,9 @@ async_common: default: break; } -trace_qxl_io_write(d-id, qxl_mode_to_string(d-mode), addr, val, size, - async); +trace_qxl_io_write(d-id, qxl_mode_to_string(d-mode), + addr, io_port_to_string(addr), + val, size, async); switch (io_port) { case QXL_IO_UPDATE_AREA: diff --git a/trace-events b/trace-events index 8285c5a..d4dba24 100644 --- a/trace-events +++ b/trace-events @@ -1059,7 +1059,7 @@ qxl_io_destroy_primary_ignored(int qid, const char *mode) %d %s qxl_io_log(int qid, const uint8_t *log_buf) %d %s qxl_io_read_unexpected(int qid) %d qxl_io_unexpected_vga_mode(int qid, uint64_t addr, uint64_t val, const char *desc) %d 0x%PRIx64=%PRIu64 (%s) -qxl_io_write(int qid, const char *mode, uint64_t addr, uint64_t val, unsigned size, int async) %d %s addr=%PRIu64 val=%PRIu64 size=%u async=%d +qxl_io_write(int qid, const char *mode, uint64_t addr, const char *aname, uint64_t val, unsigned size, int async) %d %s addr=%PRIu64 (%s) val=%PRIu64 size=%u async=%d qxl_memslot_add_guest(int qid, uint32_t slot_id, uint64_t guest_start, uint64_t guest_end) %d %u: guest phys 0x%PRIx64 - 0x% PRIx64 qxl_post_load(int qid, const char *mode) %d %s qxl_pre_load(int qid) %d -- 1.8.3.1
[Qemu-devel] [PULL 0/3] spice patch queue
Hi, Carrying three little fixes. please pull, Gerd The following changes since commit 94c2b6aff43cdfcfdfb552773a6b6b973a72ef0b: mips_malta: support up to 2GiB RAM (2013-09-09 18:42:22 +0200) are available in the git repository at: git://anongit.freedesktop.org/spice/qemu spice.v73 for you to fetch changes up to c58c7b959b93b864a27fd6b3646ee1465ab8832b: qxl: fix local renderer (2013-09-10 11:14:08 +0200) Christophe Fergeau (1): spice-core: Use g_strdup_printf instead of snprintf Gerd Hoffmann (2): qxl: trace io port name qxl: fix local renderer hw/display/qxl-render.c | 15 ++- hw/display/qxl.c| 5 +++-- trace-events| 2 +- ui/spice-core.c | 28 ++-- 4 files changed, 28 insertions(+), 22 deletions(-)
[Qemu-devel] [PATCH 1/3] spice-core: Use g_strdup_printf instead of snprintf
From: Christophe Fergeau cferg...@redhat.com Several places in spice-core.c were using either g_malloc+snprintf or snprintf+g_strdup to achieve the same result as g_strdup_printf. Signed-off-by: Christophe Fergeau cferg...@redhat.com Signed-off-by: Gerd Hoffmann kra...@redhat.com --- ui/spice-core.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ui/spice-core.c b/ui/spice-core.c index 3a2cd7e..33ef837 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -511,7 +511,9 @@ SpiceInfo *qmp_query_spice(Error **errp) int port, tls_port; const char *addr; SpiceInfo *info; -char version_string[20]; /* 12 = |255.255.255\0| is the max */ +unsigned int major; +unsigned int minor; +unsigned int micro; info = g_malloc0(sizeof(*info)); @@ -534,11 +536,10 @@ SpiceInfo *qmp_query_spice(Error **errp) info-host = g_strdup(addr ? addr : 0.0.0.0); info-has_compiled_version = true; -snprintf(version_string, sizeof(version_string), %d.%d.%d, - (SPICE_SERVER_VERSION 0xff) 16, - (SPICE_SERVER_VERSION 0xff00) 8, - SPICE_SERVER_VERSION 0xff); -info-compiled_version = g_strdup(version_string); +major = (SPICE_SERVER_VERSION 0xff) 16; +minor = (SPICE_SERVER_VERSION 0xff00) 8; +micro = SPICE_SERVER_VERSION 0xff; +info-compiled_version = g_strdup_printf(%d.%d.%d, major, minor, micro); if (port) { info-has_port = true; @@ -640,7 +641,7 @@ void qemu_spice_init(void) char *x509_key_file = NULL, *x509_cert_file = NULL, *x509_cacert_file = NULL; -int port, tls_port, len, addr_flags; +int port, tls_port, addr_flags; spice_image_compression_t compression; spice_wan_compression_t wan_compr; bool seamless_migration; @@ -671,30 +672,29 @@ void qemu_spice_init(void) if (NULL == x509_dir) { x509_dir = .; } -len = strlen(x509_dir) + 32; str = qemu_opt_get(opts, x509-key-file); if (str) { x509_key_file = g_strdup(str); } else { -x509_key_file = g_malloc(len); -snprintf(x509_key_file, len, %s/%s, x509_dir, X509_SERVER_KEY_FILE); +x509_key_file = g_strdup_printf(%s/%s, x509_dir, +X509_SERVER_KEY_FILE); } str = qemu_opt_get(opts, x509-cert-file); if (str) { x509_cert_file = g_strdup(str); } else { -x509_cert_file = g_malloc(len); -snprintf(x509_cert_file, len, %s/%s, x509_dir, X509_SERVER_CERT_FILE); +x509_cert_file = g_strdup_printf(%s/%s, x509_dir, + X509_SERVER_CERT_FILE); } str = qemu_opt_get(opts, x509-cacert-file); if (str) { x509_cacert_file = g_strdup(str); } else { -x509_cacert_file = g_malloc(len); -snprintf(x509_cacert_file, len, %s/%s, x509_dir, X509_CA_CERT_FILE); +x509_cacert_file = g_strdup_printf(%s/%s, x509_dir, + X509_CA_CERT_FILE); } x509_key_password = qemu_opt_get(opts, x509-key-password); -- 1.8.3.1
[Qemu-devel] [PATCH 3/3] qxl: fix local renderer
The local spice renderer assumes the primary surface is located at the start of the ram bar. This used to be a requirement in qxl hardware revision 1. In revision 2+ this is relaxed. Nevertheless guest drivers continued to use the traditional location, for historical and backward compatibility reasons. The qxl kms driver doesn't though as it depends on qxl revision 4+ anyway. Result is that local rendering is hosed for recent linux guests, you'll get pixel garbage with non-spice ui (gtk, sdl, vnc) and when doing screendumps. Fix that by doing a proper mapping of the guest-specified memory location. https://bugzilla.redhat.com/show_bug.cgi?id=948717 Signed-off-by: Gerd Hoffmann kra...@redhat.com --- hw/display/qxl-render.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c index 269b1a7..d34b0c4 100644 --- a/hw/display/qxl-render.c +++ b/hw/display/qxl-render.c @@ -31,10 +31,6 @@ static void qxl_blit(PCIQXLDevice *qxl, QXLRect *rect) if (is_buffer_shared(surface)) { return; } -if (!qxl-guest_primary.data) { -trace_qxl_render_blit_guest_primary_initialized(); -qxl-guest_primary.data = memory_region_get_ram_ptr(qxl-vga.vram); -} trace_qxl_render_blit(qxl-guest_primary.qxl_stride, rect-left, rect-right, rect-top, rect-bottom); src = qxl-guest_primary.data; @@ -104,7 +100,12 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl) if (qxl-guest_primary.resized) { qxl-guest_primary.resized = 0; -qxl-guest_primary.data = memory_region_get_ram_ptr(qxl-vga.vram); +qxl-guest_primary.data = qxl_phys2virt(qxl, +qxl-guest_primary.surface.mem, +MEMSLOT_GROUP_GUEST); +if (!qxl-guest_primary.data) { +return; +} qxl_set_rect_to_surface(qxl, qxl-dirty[0]); qxl-num_dirty_rects = 1; trace_qxl_render_guest_primary_resized( @@ -128,6 +129,10 @@ static void qxl_render_update_area_unlocked(PCIQXLDevice *qxl) } dpy_gfx_replace_surface(vga-con, surface); } + +if (!qxl-guest_primary.data) { +return; +} for (i = 0; i qxl-num_dirty_rects; i++) { if (qemu_spice_rect_is_empty(qxl-dirty+i)) { break; -- 1.8.3.1
[Qemu-devel] [PATCH v2] e1000: NetClientInfo.receive_iov implemented
This patch implements the NetClientInfo.receive_iov method for the e1000 device emulation. In this way a network backend that uses qemu_sendv_packet() can deliver the fragmented packet without requiring an additional copy in the frontend/backend network code (nc_sendv_compat() function). The existing method NetClientInfo.receive has been reimplemented using the new method. Signed-off-by: Vincenzo Maffione v.maffi...@gmail.com --- hw/net/e1000.c | 71 -- 1 file changed, 59 insertions(+), 12 deletions(-) I propose this patch also because our research group (University of Pisa, Department of Computer Engineering) is working on the e1000 device (optimizations and paravirtual extensions) and we have patches to support the VALE switch as a network backend (see http://info.iet.unipi.it/~luigi/vale/). The VALE backend uses qemu_sendv_packet() to send fragmented packets: For this reason we think it could be interesting to better support these packets with e1000. diff --git a/hw/net/e1000.c b/hw/net/e1000.c index f5ebed4..6ff54b5 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -32,6 +32,7 @@ #include hw/loader.h #include sysemu/sysemu.h #include sysemu/dma.h +#include qemu/iov.h #include e1000_regs.h @@ -64,6 +65,8 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL); /* this is the size past which hardware will drop packets when setting LPE=1 */ #define MAXIMUM_ETHERNET_LPE_SIZE 16384 +#define MAXIMUM_ETHERNET_HDR_LEN (14+4) + /* * HW models: * E1000_DEV_ID_82540EM works with Windows and Linux @@ -825,7 +828,7 @@ static uint64_t rx_desc_base(E1000State *s) } static ssize_t -e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) +e1000_receive_iov(NetClientState *nc, const struct iovec *iov, int iovcnt) { E1000State *s = qemu_get_nic_opaque(nc); PCIDevice *d = PCI_DEVICE(s); @@ -834,8 +837,12 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) unsigned int n, rdt; uint32_t rdh_start; uint16_t vlan_special = 0; -uint8_t vlan_status = 0, vlan_offset = 0; +uint8_t vlan_status = 0; uint8_t min_buf[MIN_BUF_SIZE]; +struct iovec min_iov; +uint8_t *filter_buf = iov-iov_base; +size_t size = iov_size(iov, iovcnt); +size_t iov_ofs = 0; size_t desc_offset; size_t desc_size; size_t total_size; @@ -850,10 +857,16 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) /* Pad to minimum Ethernet frame length */ if (size sizeof(min_buf)) { -memcpy(min_buf, buf, size); +iov_to_buf(iov, iovcnt, 0, min_buf, size); memset(min_buf[size], 0, sizeof(min_buf) - size); -buf = min_buf; -size = sizeof(min_buf); +min_iov.iov_base = filter_buf = min_buf; +min_iov.iov_len = size = sizeof(min_buf); +iovcnt = 1; +iov = min_iov; +} else if (iov-iov_len MAXIMUM_ETHERNET_HDR_LEN) { +/* This is very unlikely, but may happen. */ +iov_to_buf(iov, iovcnt, 0, min_buf, MAXIMUM_ETHERNET_HDR_LEN); +filter_buf = min_buf; } /* Discard oversized packets if !LPE and !SBP. */ @@ -864,14 +877,24 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) return size; } -if (!receive_filter(s, buf, size)) +if (!receive_filter(s, filter_buf, size)) { return size; +} -if (vlan_enabled(s) is_vlan_packet(s, buf)) { -vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(buf + 14))); -memmove((uint8_t *)buf + 4, buf, 12); +if (vlan_enabled(s) is_vlan_packet(s, filter_buf)) { +vlan_special = cpu_to_le16(be16_to_cpup((uint16_t *)(filter_buf ++ 14))); +iov_ofs = 4; +if (filter_buf == iov-iov_base) { +memmove(filter_buf + 4, filter_buf, 12); +} else { +iov_from_buf(iov, iovcnt, 4, filter_buf, 12); +while (iov-iov_len = iov_ofs) { +iov_ofs -= iov-iov_len; +iov++; +} +} vlan_status = E1000_RXD_STAT_VP; -vlan_offset = 4; size -= 4; } @@ -893,12 +916,24 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) desc.status |= (vlan_status | E1000_RXD_STAT_DD); if (desc.buffer_addr) { if (desc_offset size) { +size_t iov_copy, copied = 0; +hwaddr ba = le64_to_cpu(desc.buffer_addr); size_t copy_size = size - desc_offset; if (copy_size s-rxbuf_size) { copy_size = s-rxbuf_size; } -pci_dma_write(d, le64_to_cpu(desc.buffer_addr), - buf + desc_offset + vlan_offset, copy_size); +do { +iov_copy = MIN(copy_size, iov-iov_len - iov_ofs); +
Re: [Qemu-devel] [PATCH V4 0/3] qemu-iotests: add test for fd passing via SCM rights
Am 09.09.2013 um 13:57 hat Stefan Hajnoczi geschrieben: On Fri, Sep 06, 2013 at 11:24:31AM +0800, Wenchao Xia wrote: This series add test case for fd passing with unix socket at runtime. Since getfd and closefd interface will interact with monitor's data, so it will help to do regression test for monitor patches. Since python2 do not support sendmsg(), so a C helper program is added to do the job. v2: 1: add missing $ in the makefile rule. v3: Address Eric's comments: 1: typo fix, remove . in the end of error message, strick check argc as !=, use EXIT_SUCCESS and EXIT_FAILURE as exit values, strict error check for strtol() call. Address Luiz's comments: 1: change the helper program parameter as bin socket-fd file-path , the program open the file itself now, data parameter is removed and blank is always used as iov data, better usage tip message, folder the string parsing code into a function. 2: related change for helper program parameter change. 3: related change for helper program parameter change. Other: 1: remove LINK rule in makefile, remove fd checking code inside send_fd() since it is already checked before calling, add '' around %s for path and number string in error message. 2: renamed fd_bin to bin in send_fd_scm() to tip better, add '' around %s for path in error message. v4: Address Stefan's comments: 2: add space after # for comments, refined the comment's grammar. 3: add space after # for comments, refined the comment's grammar, add two test cases for error path. Wenchao Xia (3): 1 qemu-iotests: add unix socket help program 2 qemu-iotests: add infrastructure of fd passing via SCM 3 qemu-iotests: add tests for runtime fd passing via SCM rights QMP/qmp.py |6 ++ configure |2 +- tests/Makefile |3 +- tests/qemu-iotests/045 | 51 - tests/qemu-iotests/045.out |4 +- tests/qemu-iotests/check |1 + tests/qemu-iotests/iotests.py | 23 ++ tests/qemu-iotests/socket_scm_helper.c | 135 8 files changed, 220 insertions(+), 5 deletions(-) create mode 100644 tests/qemu-iotests/socket_scm_helper.c Reviewed-by: Stefan Hajnoczi stefa...@redhat.com I'm not completely convinced that it's a good idea to introduce a helper binary that isn't automatically rebuilt after an upgrade (I basically never run 'make check-block', which is the only way that would trigger it), but given this Reviewed-by, I've applied this to the block branch. Kevin
Re: [Qemu-devel] [PATCH] hw/9pfs/virtio_9p_device: use virtio wrappers to access headers.
Greg Kurz gk...@linux.vnet.ibm.com writes: Follow-up to Rusty's virtio endianness serie: enough to get a working virtfs mount. Note that st*_raw and ld*_raw are effectively replaced by st*_p and ld*_p. Signed-off-by: Greg Kurz gk...@linux.vnet.ibm.com Thanks! I've reworked my patches in line with the anticipated KVM_GET_ONE_REG from Mikey, and put this into the series. Mikey, here's the template I assumed (needs CONFIG_KVM implementation of kvmppc_update_spr_lpcr). Cheers, Rusty. FIXME: Implement for KVM using KVM_GET_ONE_REG! diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index 771cfbe..30d8af6 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -29,6 +29,7 @@ int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); int kvmppc_or_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits); int kvmppc_set_tcr(PowerPCCPU *cpu); int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu); +void kvmppc_update_spr_lpcr(PowerPCCPU *cpu); #ifndef CONFIG_USER_ONLY off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem); void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd); @@ -159,6 +160,10 @@ static inline bool kvmppc_has_cap_epr(void) { return false; } + +static inline void kvmppc_update_spr_lpcr(PowerPCCPU *cpu) +{ +} #endif #ifndef CONFIG_KVM
Re: [Qemu-devel] [PATCH RFC 2/4] Curling: cmdline interface
Jules Wang junqing.w...@cs2c.com.cn wrote: Parse the word 'curling' when incoming/outgoing migration is starting. So we know whether to enable fault tolerant or not. Signed-off-by: Jules Wang junqing.w...@cs2c.com.cn --- include/migration/migration.h | 2 ++ migration.c | 16 2 files changed, 18 insertions(+) diff --git a/include/migration/migration.h b/include/migration/migration.h index 140e6b4..4cbb62f 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -162,4 +162,6 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size, int *bytes_sent); +bool ft_enabled(void); + #endif diff --git a/migration.c b/migration.c index 200d404..59c8f32 100644 --- a/migration.c +++ b/migration.c @@ -58,6 +58,12 @@ enum { static NotifierList migration_state_notifiers = NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); +static bool ft_mode; +bool ft_enabled(void) +{ +return ft_mode; Shouldn't this be in migration_state? Just wondering. And yes, I don't see either a trivial place how to get it. get_current_migration()? +} + /* When we add fault tolerance, we could have several migrations at once. For now we don't need to add dynamic creation of migration */ @@ -78,6 +84,11 @@ void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p; +if (strstart(uri, curling:, p)) { +ft_mode = true; +uri = p; +} + Syntax is at least weird: curling:tcp:foo: curling+tcp:foo: could be better? Suggestions folks? notice that we still need more things: tcp+tls should happen at some time soon. This is not related with this patch. if (strstart(uri, tcp:, p)) tcp_start_incoming_migration(p, errp); #ifdef CONFIG_RDMA @@ -420,6 +431,11 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk, s = migrate_init(params); +if (strstart(uri, curling:, p)) { +ft_mode = true; +uri = p; +} + if (strstart(uri, tcp:, p)) { tcp_start_outgoing_migration(s, p, local_err); #ifdef CONFIG_RDMA
Re: [Qemu-devel] [PATCH] qemu-iotests: New test case in 061
Am 05.09.2013 um 10:55 hat Max Reitz geschrieben: Add one test case for zero cluster expansion on qcow2 version downgrade in shared L2 tables (i.e., L2 tables with a refcount 1) and one for zero expansion on backed clusters in shared L2 tables. Signed-off-by: Max Reitz mre...@redhat.com Thanks, applied to the block branch. Kevin
Re: [Qemu-devel] [PATCH RFC 3/4] Curling: the sender
Jules Wang junqing.w...@cs2c.com.cn wrote: By leveraging live migration feature, the sender simply starts a new migration when the previous migration is completed. We need to handle the variables related to live migration very carefully. So the new migration does not restart from the very begin of the migration, instead, it continues the previous migration. Signed-off-by: Jules Wang junqing.w...@cs2c.com.cn --- arch_init.c | 18 +- migration.c | 23 ++- savevm.c| 4 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/arch_init.c b/arch_init.c index e47e139..5d006f6 100644 --- a/arch_init.c +++ b/arch_init.c @@ -611,10 +611,14 @@ static int ram_save_setup(QEMUFile *f, void *opaque) { RAMBlock *block; int64_t ram_pages = last_ram_offset() TARGET_PAGE_BITS; +bool create = false; This variable is never set. -migration_bitmap = bitmap_new(ram_pages); -bitmap_set(migration_bitmap, 0, ram_pages); -migration_dirty_pages = ram_pages; +if (!ft_enabled() || !migration_bitmap) { +migration_bitmap = bitmap_new(ram_pages); Nothing in this patch sets the migration_bitmap to anything. +bitmap_set(migration_bitmap, 0, ram_pages); +migration_dirty_pages = ram_pages; +create = true; +} mig_throttle_on = false; dirty_rate_high_cnt = 0; @@ -634,7 +638,9 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_mutex_lock_iothread(); qemu_mutex_lock_ramlist(); bytes_transferred = 0; -reset_ram_globals(); +if (!ft_enabled() || create) { +reset_ram_globals(); +} memory_global_dirty_log_start(); migration_bitmap_sync(); @@ -744,7 +750,9 @@ static int ram_save_complete(QEMUFile *f, void *opaque) } ram_control_after_iterate(f, RAM_CONTROL_FINISH); -migration_end(); +if (!ft_enabled()) { +migration_end(); +} What you want here? My guess is that you want to sent device state without sending the end of migration command, right? qemu_mutex_unlock_ramlist(); qemu_put_be64(f, RAM_SAVE_FLAG_EOS); diff --git a/migration.c b/migration.c index 59c8f32..d8a9b2d 100644 --- a/migration.c +++ b/migration.c @@ -567,6 +567,7 @@ static void *migration_thread(void *opaque) int64_t max_size = 0; int64_t start_time = initial_time; bool old_vm_running = false; +int time_window = 100; DPRINTF(beginning savevm\n); qemu_savevm_state_begin(s-file, s-params); @@ -578,6 +579,8 @@ static void *migration_thread(void *opaque) while (s-state == MIG_STATE_ACTIVE) { int64_t current_time; +int64_t time_spent; +int64_t migration_start_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); uint64_t pending_size; if (!qemu_file_rate_limit(s-file)) { @@ -607,10 +610,28 @@ static void *migration_thread(void *opaque) break; } -if (!qemu_file_get_error(s-file)) { +if (!qemu_file_get_error(s-file) !ft_enabled()) { migrate_set_state(s, MIG_STATE_ACTIVE, MIG_STATE_COMPLETED); break; } + +if (ft_enabled()) { +if (old_vm_running) { +qemu_mutex_lock_iothread(); +vm_start(); +qemu_mutex_unlock_iothread(); + +current_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME); +time_spent = current_time - migration_start_time; +DPRINTF(this migration lasts for % PRId64 ms\n, +time_spent); +if (time_spent time_window) { +g_usleep((time_window - time_spent)*1000); Why are we waiting here? If we are migration faster than allowed, why we are waiting? +initial_time += time_window - time_spent; +} +} +qemu_savevm_state_begin(s-file, s-params); +} } } diff --git a/savevm.c b/savevm.c index c536aa4..6daf690 100644 --- a/savevm.c +++ b/savevm.c @@ -1824,6 +1824,7 @@ static void vmstate_save(QEMUFile *f, SaveStateEntry *se) #define QEMU_VM_SECTION_END 0x03 #define QEMU_VM_SECTION_FULL 0x04 #define QEMU_VM_SUBSECTION 0x05 +#define QEMU_VM_EOF_MAGIC0xFeedCafe bool qemu_savevm_state_blocked(Error **errp) { @@ -1983,6 +1984,9 @@ void qemu_savevm_state_complete(QEMUFile *f) } qemu_put_byte(f, QEMU_VM_EOF); +if (ft_enabled()) { +qemu_put_be32(f, QEMU_VM_EOF_MAGIC); +} qemu_fflush(f); }
Re: [Qemu-devel] [RFC qom-cpu v2 1/8] apic: remove apic_no from apic_init_common()
On Tue, 10 Sep 2013 17:43:41 +0800 Chen Fan chen.fan.f...@cn.fujitsu.com wrote: the 'apic_no' is increased by one when initialize/create a vCPU each time, which causes APICCommonState s-idx always is increased. but if we want to re-add a vCPU after removing a vCPU, we need to re-use the vacant s-idx which the corresponding vCPU had been removed. so we could use the unique cpu apic_id instead of the progressive s-idx. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/intc/apic_common.c | 4 +--- target-i386/cpu.c | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index a0beb10..5568621 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -289,13 +289,11 @@ static int apic_init_common(ICCDevice *dev) APICCommonState *s = APIC_COMMON(dev); APICCommonClass *info; static DeviceState *vapic; -static int apic_no; static bool mmio_registered; -if (apic_no = MAX_APICS) { +if (s-idx = MAX_APICS) { return -1; } -s-idx = apic_no++; info = APIC_COMMON_GET_CLASS(s); info-init(s); diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 42c5de0..2b99683 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2322,6 +2322,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp) /* TODO: convert to link */ apic = APIC_COMMON(env-apic_state); apic-cpu = cpu; +apic-idx = env-cpuid_apic_id; earlier here we set: qdev_prop_set_uint8(env-apic_state, id, env-cpuid_apic_id); so apic-idx = env-cpuid_apic_id is redundant. it would be better to search by apic-id and preferably replace O(MAX_APIC) scans with a faster approach since for TCG iqr delivery might be a hot path, dropping MAX_APIC altogether and using dynamic present APICs list. } static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)
Re: [Qemu-devel] [RFC qom-cpu v2 2/8] x86: add x86_cpu_unrealizefn() for cpu apic remove
Am 10.09.2013 11:43, schrieb Chen Fan: Implement x86_cpu_unrealizefn() for corresponding x86_cpu_realizefn(), which is mostly used to clear the apic related information at here. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/cpu/icc_bus.c| 11 +++ hw/i386/kvm/apic.c | 6 ++ hw/intc/apic.c | 7 +++ hw/intc/apic_common.c | 11 +++ include/hw/cpu/icc_bus.h| 1 + include/hw/i386/apic_internal.h | 1 + target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 35 +++ 8 files changed, 73 insertions(+) Some nitpicks below, mostly about adopting the latest concepts. diff --git a/hw/cpu/icc_bus.c b/hw/cpu/icc_bus.c index 8748cc5..45e87d1 100644 --- a/hw/cpu/icc_bus.c +++ b/hw/cpu/icc_bus.c @@ -54,11 +54,22 @@ static void icc_device_realize(DeviceState *dev, Error **errp) } } +static void icc_device_unrealize(DeviceState *dev, Error **errp) +{ +ICCDevice *id = ICC_DEVICE(dev); +ICCDeviceClass *idc = ICC_DEVICE_GET_CLASS(id); + +if (idc-exit) { +idc-exit(id); -unrealize +} +} + static void icc_device_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); dc-realize = icc_device_realize; +dc-unrealize = icc_device_unrealize; dc-bus_type = TYPE_ICC_BUS; } diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c index 5609063..8f028a1 100644 --- a/hw/i386/kvm/apic.c +++ b/hw/i386/kvm/apic.c @@ -181,11 +181,17 @@ static void kvm_apic_init(APICCommonState *s) } } +static void kvm_apic_exit(APICCommonState *s) kvm_apic_unrealize +{ +memory_region_destroy(s-io_memory); +} + static void kvm_apic_class_init(ObjectClass *klass, void *data) { APICCommonClass *k = APIC_COMMON_CLASS(klass); k-init = kvm_apic_init; +k-exit = kvm_apic_exit; k-set_base = kvm_apic_set_base; k-set_tpr = kvm_apic_set_tpr; k-get_tpr = kvm_apic_get_tpr; diff --git a/hw/intc/apic.c b/hw/intc/apic.c index a913186..23488b4 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -882,11 +882,18 @@ static void apic_init(APICCommonState *s) msi_supported = true; } +static void apic_uninit(APICCommonState *s) apic_unrealize +{ +memory_region_destroy(s-io_memory); +local_apics[s-idx] = NULL; +} + static void apic_class_init(ObjectClass *klass, void *data) { APICCommonClass *k = APIC_COMMON_CLASS(klass); k-init = apic_init; +k-exit = apic_uninit; k-set_base = apic_set_base; k-set_tpr = apic_set_tpr; k-get_tpr = apic_get_tpr; diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 5568621..32c2f74 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -316,6 +316,16 @@ static int apic_init_common(ICCDevice *dev) return 0; } +static void apic_exit_common(ICCDevice *dev) +{ +APICCommonState *s = APIC_COMMON(dev); +APICCommonClass *info; acc please + +info = APIC_COMMON_GET_CLASS(s); +if (info-exit) +info-exit(s); Braces missing - checkpatch.pl +} + static void apic_dispatch_pre_save(void *opaque) { APICCommonState *s = APIC_COMMON(opaque); @@ -387,6 +397,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data) dc-no_user = 1; dc-props = apic_properties_common; idc-init = apic_init_common; +idc-exit = apic_exit_common; } static const TypeInfo apic_common_type = { diff --git a/include/hw/cpu/icc_bus.h b/include/hw/cpu/icc_bus.h index b550070..15d5374 100644 --- a/include/hw/cpu/icc_bus.h +++ b/include/hw/cpu/icc_bus.h @@ -67,6 +67,7 @@ typedef struct ICCDeviceClass { /* public */ int (*init)(ICCDevice *dev); /* TODO replace with QOM realize */ +void (*exit)(ICCDevice *dev); DeviceUnrealize unrealize; } ICCDeviceClass; #define TYPE_ICC_DEVICE icc-device diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h index 1b0a7fb..87d5248 100644 --- a/include/hw/i386/apic_internal.h +++ b/include/hw/i386/apic_internal.h @@ -81,6 +81,7 @@ typedef struct APICCommonClass ICCDeviceClass parent_class; void (*init)(APICCommonState *s); +void (*exit)(APICCommonState *s); DeviceUnrealize unrealize; void (*set_base)(APICCommonState *s, uint64_t val); void (*set_tpr)(APICCommonState *s, uint8_t val); uint8_t (*get_tpr)(APICCommonState *s); diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index c4447c2..1e520be 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -50,6 +50,7 @@ typedef struct X86CPUClass { /* public */ DeviceRealize parent_realize; +DeviceUnrealize parent_unrealize; void (*parent_reset)(CPUState *cpu); } X86CPUClass; diff --git a/target-i386/cpu.c b/target-i386/cpu.c
Re: [Qemu-devel] [SeaBIOS] [PATCH] q35: fix GPE method for cpu hotplug
On Wed, 21 Aug 2013 13:05:27 +0200 Gerd Hoffmann kra...@redhat.com wrote: Hi, Method(_L01) { +} +Method(_E02) { // CPU hotplug event \_SB.PRSC() } -Method(_L02) { -} E02? Typo? _E02 is correct. see commit 9c6635bd4 for reasoning. Perhaps commit message should be more verbose and contain a reference to that commit. cheers, Gerd
Re: [Qemu-devel] [PATCH RFC 4/4] Curling: the receiver
Jules Wang junqing.w...@cs2c.com.cn wrote: The receiver does migration loop until the migration connection is lost. Then, it is started as a backup. The receiver does not load vm state once a migration begins, instead, it perfetches one whole migration data into a buffer, then loads vm state from that buffer afterwards. Signed-off-by: Jules Wang junqing.w...@cs2c.com.cn --- include/migration/qemu-file.h | 1 + include/sysemu/sysemu.h | 1 + migration.c | 22 -- savevm.c | 154 -- 4 files changed, 168 insertions(+), 10 deletions(-) diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index 0f757fb..f01ff10 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -92,6 +92,7 @@ typedef struct QEMUFileOps { QEMURamHookFunc *after_ram_iterate; QEMURamHookFunc *hook_ram_load; QEMURamSaveFunc *save_page; +QEMUFileGetBufferFunc *get_prefetch_buffer; } QEMUFileOps; QEMUFile *qemu_fopen_ops(void *opaque, const QEMUFileOps *ops); diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index b1aa059..44f23d0 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -81,6 +81,7 @@ void qemu_savevm_state_complete(QEMUFile *f); void qemu_savevm_state_cancel(void); uint64_t qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size); int qemu_loadvm_state(QEMUFile *f); +int qemu_loadvm_state_ft(QEMUFile *f); /* SLIRP */ void do_info_slirp(Monitor *mon); diff --git a/migration.c b/migration.c index d8a9b2d..9be22a4 100644 --- a/migration.c +++ b/migration.c @@ -19,6 +19,7 @@ #include monitor/monitor.h #include migration/qemu-file.h #include sysemu/sysemu.h +#include sysemu/cpus.h #include block/block.h #include qemu/sockets.h #include migration/block.h @@ -112,13 +113,24 @@ static void process_incoming_migration_co(void *opaque) { QEMUFile *f = opaque; int ret; +int count = 0; -ret = qemu_loadvm_state(f); -qemu_fclose(f); -if (ret 0) { -fprintf(stderr, load of migration failed\n); -exit(EXIT_FAILURE); +if (ft_enabled()) { +while (qemu_loadvm_state_ft(f) = 0) { +count++; +DPRINTF(incoming count %d\r, count); +} +qemu_fclose(f); +fprintf(stderr, ft connection lost, launching self..\n); Obviously, here we are needing something more that an fprintf,, right? We are not checking either if it is one error. +} else { +ret = qemu_loadvm_state(f); +qemu_fclose(f); +if (ret 0) { +fprintf(stderr, load of migration failed\n); +exit(EXIT_FAILURE); +} } +cpu_synchronize_all_post_init(); qemu_announce_self(); DPRINTF(successfully loaded vm state\n); diff --git a/savevm.c b/savevm.c index 6daf690..d5bf153 100644 --- a/savevm.c +++ b/savevm.c @@ -52,6 +52,8 @@ #define ARP_PTYPE_IP 0x0800 #define ARP_OP_REQUEST_REV 0x3 +#define PFB_SIZE 0x01 + static int announce_self_create(uint8_t *buf, uint8_t *mac_addr) { @@ -135,6 +137,10 @@ struct QEMUFile { unsigned int iovcnt; int last_error; + +uint8_t *pfb; /* pfb - PerFetch Buffer */ s/PreFetch/Prefetcth/ prefetch_buffer as name? not used in so many places, makes things clearer or more convoluted? Other comments? +static int socket_get_prefetch_buffer(void *opaque, uint8_t *buf, + int64_t pos, int size) +{ +QEMUFile *f = opaque; + +if (f-pfb_size - pos = 0) { +return 0; +} + +if (f-pfb_size - pos size) { +size = f-pfb_size - pos; +} + +memcpy(buf, f-pfb+pos, size); + +return size; +} + + static int socket_close(void *opaque) { QEMUFileSocket *s = opaque; @@ -440,6 +465,7 @@ QEMUFile *qemu_fdopen(int fd, const char *mode) static const QEMUFileOps socket_read_ops = { .get_fd = socket_get_fd, .get_buffer = socket_get_buffer, +.get_prefetch_buffer = socket_get_prefetch_buffer, .close = socket_close }; if (f-last_error) { ret = f-last_error; } + +if (f-pfb) { +g_free(f-pfb); g_free(f-pfb); It already checks for NULL. +} + g_free(f); return ret; } @@ -822,6 +853,14 @@ void qemu_put_byte(QEMUFile *f, int v) static void qemu_file_skip(QEMUFile *f, int size) { +if (f-pfb_index + size = f-pfb_size) { +f-pfb_index += size; +return; +} else { +size -= f-pfb_size - f-pfb_index; +f-pfb_index = f-pfb_size; +} + if (f-buf_index + size = f-buf_size) { f-buf_index += size; } @@ -831,6 +870,21 @@ static int qemu_peek_buffer(QEMUFile *f, uint8_t *buf, int size, size_t offset) {
Re: [Qemu-devel] [RFC qom-cpu v2 1/8] apic: remove apic_no from apic_init_common()
Am 10.09.2013 14:09, schrieb Igor Mammedov: On Tue, 10 Sep 2013 17:43:41 +0800 Chen Fan chen.fan.f...@cn.fujitsu.com wrote: the 'apic_no' is increased by one when initialize/create a vCPU each time, which causes APICCommonState s-idx always is increased. but if we want to re-add a vCPU after removing a vCPU, we need to re-use the vacant s-idx which the corresponding vCPU had been removed. so we could use the unique cpu apic_id instead of the progressive s-idx. Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com --- hw/intc/apic_common.c | 4 +--- target-i386/cpu.c | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index a0beb10..5568621 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -289,13 +289,11 @@ static int apic_init_common(ICCDevice *dev) APICCommonState *s = APIC_COMMON(dev); APICCommonClass *info; static DeviceState *vapic; -static int apic_no; static bool mmio_registered; -if (apic_no = MAX_APICS) { +if (s-idx = MAX_APICS) { return -1; } -s-idx = apic_no++; info = APIC_COMMON_GET_CLASS(s); info-init(s); diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 42c5de0..2b99683 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2322,6 +2322,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp) /* TODO: convert to link */ apic = APIC_COMMON(env-apic_state); apic-cpu = cpu; +apic-idx = env-cpuid_apic_id; earlier here we set: qdev_prop_set_uint8(env-apic_state, id, env-cpuid_apic_id); so apic-idx = env-cpuid_apic_id is redundant. it would be better to search by apic-id and preferably replace O(MAX_APIC) scans with a faster approach since for TCG iqr delivery might be a hot path, dropping MAX_APIC altogether and using dynamic present APICs list. Independent of that, the recent removal of X86_CPU() cast from x86_env_get_cpu() should allow us to finally tackle the TODO above, moving apic_state field from CPUX86State to X86CPU. Andreas } static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH RFC 0/4] Curling: KVM Fault Tolerance
On 09/10/2013 06:43 AM, Jules Wang wrote: The goal of Curling(sports) is to provide a fault tolerant mechanism for KVM, so that in the event of a hardware failure, the virtual machine fails over to the backup in a way that is completely transparent to the guest operating system. Our goal is exactly the same as the goal of Kemari, by which Curling is inspired. However, Curling is simpler than Kemari(too simple, I afraid): * By leveraging live migration feature, we do endless live migrations between the sender and receiver, so the two virtual machines are synchronized. Hi, There are two issues I see with your solution, The first is that if the VM failure happen in the middle on the live migration the backup VM state will be inconsistent which means you can't failover to it. Solving it is not simple as you need some transaction mechanism that will change the backup VM state only when the transaction completes (the live migration completes). Kemari has something like that. The second is that sadly live migration doesn't always converge this means that the backup VM won't have a consist state to failover to. You need to detect such a case and throttle down the guest to force convergence. Regards, Orit * The receiver does not load vm state once the migration begins, instead, it perfetches one whole migration data into a buffer, then loads vm state from that buffer afterwards. This all or nothing approach prevents the broken-in-the-middle problem Kemari has. * The sender sleeps a little while after each migration, to ease the performance penalty entailed by vm_stop and iothread locks. This is a tradeoff between performance and accuracy. Usage: The steps of curling are the same as the steps of live migration except the following: 1. Start the receiver vm with -incoming curling:tcp:address:port 2. Start ft in the qemu monitor of sender vm by following cmdline: migrate_set_speed full bandwidth migrate curling:tcp:address:port 3. Connect to the receiver vm by vnc or spice. The screen of the vm is displayed when curling is ready. 4. Now, the sender vm is protected by ft, When it encounters a failure, the failover kicks in. Problems to be discussed: 1. When the receiver is prefectching data, how does it know where is the EOF of one migration? Currently, we use a magic number 0xfeedcafe to indicate the EOF. Any better solutions? 2. How to reduce the overhead entailed by vm_stop and iothread locks? Any solutions other than sleeping? -- Jules Wang (4): Curling: add doc Curling: cmdline interface Curling: the sender Curling: the receiver arch_init.c | 18 +++-- docs/curling.txt | 52 ++ include/migration/migration.h | 2 + include/migration/qemu-file.h | 1 + include/sysemu/sysemu.h | 1 + migration.c | 61 ++-- savevm.c | 158 -- 7 files changed, 277 insertions(+), 16 deletions(-) create mode 100644 docs/curling.txt
Re: [Qemu-devel] [PATCH V7 0/8] add internal snapshot support at block device level
Am 07.08.2013 um 05:00 hat Wenchao Xia geschrieben: This series brings internal snapshot support at block devices level, now we have two three methods to do block snapshot lively: 1) backing chain, 2) internal one and 3) drive-back up approach. Comparation: Advantages:Disadvantages: 1)delta data, taken fast, export, sizeperformance, delete slow. 2) taken fast, delete fast, performance, size delta data, format 3) performance, export, format taken slow, delta data, size, host I/O I think in most case, saving vmstate in an standalone file is better than saving it inside qcow2, So suggest treat internal snapshot as block level methods and not encourage user to savevm in qcow2 any more. Implemention details: To avoid trouble, this serial have hide ID in create interfaces, this make sure no chaos of ID and name will be introduced by these interfaces. There is one patch may be common to Pavel's savvm transaction, patch 1/11, others are not quite related. Patch 1/11 will not set errp when no snapshot find, since patch 3/11 need to distinguish real error case. Next steps to better full VM snapshot: Improve internal snapshot's export capability. Better vmstate saving. Thanks Kevin to give advisement about how add it in qmp_transaction, oldest version comes drom Dietmar Maurer. This series needs to be rebased. The last patch (qemu-iotests) doesn't apply any more because other tests were added in the meantime, and when applying only the code changes, it fails to compile: blockdev.c: In function 'internal_snapshot_prepare': blockdev.c:1040:5: error: implicit declaration of function 'qemu_get_clock_ns' [-Werror=implicit-function-declaration] blockdev.c:1040:5: error: nested extern declaration of 'qemu_get_clock_ns' [-Werror=nested-externs] blockdev.c:1040:43: error: 'vm_clock' undeclared (first use in this function) blockdev.c:1040:43: note: each undeclared identifier is reported only once for each function it appears in Kevin
Re: [Qemu-devel] [PATCH V7 2/8] snapshot: distinguish id and name in snapshot delete
Am 07.08.2013 um 05:00 hat Wenchao Xia geschrieben: Snapshot creation actually already distinguish id and name since it take a structured parameter *sn, but delete can't. Later an accurate delete is needed in qmp_transaction abort and blockdev-snapshot-delete-sync, so change its prototype. Also *errp is added to tip error, but return value is kepted to let caller check what kind of error happens. Existing caller for it are savevm, delvm and qemu-img, they are not impacted by introducing a new function bdrv_snapshot_delete_by_id_or_name(), which check the return value and do the operation again. Before this patch: For qcow2, it search id first then name to find the one to delete. For rbd, it search name. For sheepdog, it does nothing. After this patch: For qcow2, logic is the same by call it twice in caller. For rbd, it always fails in delete with id, but still search for name in second try, no change to user. Some code for *errp is based on Pavel's patch. Signed-off-by: Wenchao Xia xiaw...@linux.vnet.ibm.com Signed-off-by: Pavel Hrdina phrd...@redhat.com diff --git a/savevm.c b/savevm.c index 03fc4d9..0808414 100644 --- a/savevm.c +++ b/savevm.c @@ -2325,18 +2325,21 @@ static int del_existing_snapshots(Monitor *mon, const char *name) { BlockDriverState *bs; QEMUSnapshotInfo sn1, *snapshot = sn1; -int ret; +Error *err = NULL; bs = NULL; while ((bs = bdrv_next(bs))) { if (bdrv_can_snapshot(bs) bdrv_snapshot_find(bs, snapshot, name) = 0) { -ret = bdrv_snapshot_delete(bs, name); -if (ret 0) { +bdrv_snapshot_delete_by_id_or_name(bs, name, err); +if (error_is_set(err)) { monitor_printf(mon, - Error while deleting snapshot on '%s'\n, - bdrv_get_device_name(bs)); + Error while deleting snapshot on device '%s', + reason: %s\n, More commonly, error messages just use a colon before the detailed error code instead of saying , reason: + bdrv_get_device_name(bs), + error_get_pretty(err)); +error_free(err); return -1; } } Kevin
Re: [Qemu-devel] [PATCH RFC v2 2/2] hw/pci: handle unassigned pci addresses
On Mon, Sep 09, 2013 at 02:16:41PM +0100, Peter Maydell wrote: On 9 September 2013 14:07, Marcel Apfelbaum marce...@redhat.com wrote: This is exactly my point. ALL device on the bus can be masters of a DMA transaction. So adding an interface as suggested by Michael: pci_set_master_for_master_abort(PCIBus *, PCIDevice *) for the general case (a device doing DMA) it is too far from reality. Actually I don't think it would be too painful. At the moment in do_pci_register_device() we do this to create the memory region used by a device for its bus master transactions: memory_region_init_alias(pci_dev-bus_master_enable_region, OBJECT(pci_dev), bus master, dma_as-root, 0, memory_region_size(dma_as-root)); If instead of using this alias directly as the bus_master_enable region you instead: * create a container region * create a 'background' region at negative priority (ie one per device, and you can make the 'opaque' pointer point to the device, not the bus) * put the alias and the background region into the container * use the container as the bus_master_enable region Interesting. There's one thing I don't understand here: as far as I can see bus_master_enable_region covers the whole 64 bit memory address space. It looks like it will always override the background region in the same container. What did I miss? then you will get in your callback a pointer to the device which caused the abort. You can then have your callback call a method defined on PCIDevice which we implement: * as do-nothing in the PCI device base class * as set-the-master-abort bit in the PCI host bridge class (and anybody who wants to get fancy about handling aborts can override it in their own device implementation) That seems achievable without really requiring new infrastructure. Have I missed something that wouldn't work if we did this? thanks -- PMM Actually, I think a base class would have to set received master abort bit in the status register. And it's not even that simple: memory writes are completed by a P2P bridge so I think it has to set a bit in the primary status register for the bridge and not for the device (though I'm speaking from memory, need to check the spec). -- MST
Re: [Qemu-devel] [PATCH 3/6] range: add min/max operations on ranges
On Tue, Sep 10, 2013 at 11:35:54AM +0200, Igor Mammedov wrote: On Wed, 4 Sep 2013 13:48:35 +0300 Michael S. Tsirkin m...@redhat.com wrote: Signed-off-by: Michael S. Tsirkin m...@redhat.com --- include/qemu/range.h | 17 + 1 file changed, 17 insertions(+) diff --git a/include/qemu/range.h b/include/qemu/range.h index 4a0780d..1c688ca 100644 --- a/include/qemu/range.h +++ b/include/qemu/range.h @@ -17,6 +17,23 @@ struct Range { uint64_t end; /* 1 + the last byte. 0 if range empty or ends at ~0x0LL. */ }; +static inline void range_extend(Range *range, Range *extend_by) doc comment what it does pls. +{ +if (!extend_by-begin !extend_by-end) { +return; +} +if (!range-begin !range-end) { +*range = *extend_by; +return; +} +if (range-begin extend_by-begin) { +range-begin = extend_by-begin; +} +if (range-end - 1 extend_by-end - 1) { (foo)-end could be 0 at this point leading to overflow when subtracted, is it intended to be so? Absolutely - as the comment near this field definition states: 0 means region ends at ~0x0LL. +range-end = extend_by-end; +} +} + /* Get last byte of a range from offset + length. * Undefined for ranges that wrap around 0. */ static inline uint64_t range_get_last(uint64_t offset, uint64_t len)
Re: [Qemu-devel] [PATCH RFC v2 2/2] hw/pci: handle unassigned pci addresses
On 10 September 2013 13:39, Michael S. Tsirkin m...@redhat.com wrote: On Mon, Sep 09, 2013 at 02:16:41PM +0100, Peter Maydell wrote: memory_region_init_alias(pci_dev-bus_master_enable_region, OBJECT(pci_dev), bus master, dma_as-root, 0, memory_region_size(dma_as-root)); If instead of using this alias directly as the bus_master_enable region you instead: * create a container region * create a 'background' region at negative priority (ie one per device, and you can make the 'opaque' pointer point to the device, not the bus) * put the alias and the background region into the container * use the container as the bus_master_enable region Interesting. There's one thing I don't understand here: as far as I can see bus_master_enable_region covers the whole 64 bit memory address space. It looks like it will always override the background region in the same container. What did I miss? That should be itself a container, so assuming it doesn't itself have any kind of background region the holes inside it will still be present when we put it in our new container. (Basically putting a container, or an alias to one, inside a region is just saying put everything in that container inside this region at the appropriate place). then you will get in your callback a pointer to the device which caused the abort. You can then have your callback call a method defined on PCIDevice which we implement: * as do-nothing in the PCI device base class * as set-the-master-abort bit in the PCI host bridge class (and anybody who wants to get fancy about handling aborts can override it in their own device implementation) That seems achievable without really requiring new infrastructure. Have I missed something that wouldn't work if we did this? Actually, I think a base class would have to set received master abort bit in the status register. And it's not even that simple: memory writes are completed by a P2P bridge so I think it has to set a bit in the primary status register for the bridge and not for the device (though I'm speaking from memory, need to check the spec). Yes, I didn't really work through how bridges might need to be handled. Hopefully we can come up with a neat trick for those too :-) -- PMM
Re: [Qemu-devel] [PATCH RFC v2 2/2] hw/pci: handle unassigned pci addresses
On Tue, Sep 10, 2013 at 01:50:47PM +0100, Peter Maydell wrote: On 10 September 2013 13:39, Michael S. Tsirkin m...@redhat.com wrote: On Mon, Sep 09, 2013 at 02:16:41PM +0100, Peter Maydell wrote: memory_region_init_alias(pci_dev-bus_master_enable_region, OBJECT(pci_dev), bus master, dma_as-root, 0, memory_region_size(dma_as-root)); If instead of using this alias directly as the bus_master_enable region you instead: * create a container region * create a 'background' region at negative priority (ie one per device, and you can make the 'opaque' pointer point to the device, not the bus) * put the alias and the background region into the container * use the container as the bus_master_enable region Interesting. There's one thing I don't understand here: as far as I can see bus_master_enable_region covers the whole 64 bit memory address space. It looks like it will always override the background region in the same container. What did I miss? That should be itself a container, so assuming it doesn't itself have any kind of background region the holes inside it will still be present when we put it in our new container. (Basically putting a container, or an alias to one, inside a region is just saying put everything in that container inside this region at the appropriate place). Confused. That and it here refers to what exactly? then you will get in your callback a pointer to the device which caused the abort. You can then have your callback call a method defined on PCIDevice which we implement: * as do-nothing in the PCI device base class * as set-the-master-abort bit in the PCI host bridge class (and anybody who wants to get fancy about handling aborts can override it in their own device implementation) That seems achievable without really requiring new infrastructure. Have I missed something that wouldn't work if we did this? Actually, I think a base class would have to set received master abort bit in the status register. And it's not even that simple: memory writes are completed by a P2P bridge so I think it has to set a bit in the primary status register for the bridge and not for the device (though I'm speaking from memory, need to check the spec). Yes, I didn't really work through how bridges might need to be handled. Hopefully we can come up with a neat trick for those too :-) -- PMM
Re: [Qemu-devel] [PATCH RFC 2/4] Curling: cmdline interface
Il 10/09/2013 15:57, Juan Quintela ha scritto: +if (strstart(uri, curling:, p)) { +ft_mode = true; +uri = p; +} + Syntax is at least weird: curling:tcp:foo: curling+tcp:foo: could be better? Suggestions folks? notice that we still need more things: tcp+tls should happen at some time soon. This is not related with this patch. I think for the outgoing side it should just be migrate -f tcp:foo:. On the incoming side, perhaps you could have a different ID instead of QEMU_VM_FILE_MAGIC, that triggers fault-tolerance mode automatically? Then again it would be simply -incoming tcp:foo:. Paolo
Re: [Qemu-devel] [PATCH V7 0/8] add internal snapshot support at block device level
Am 07.08.2013 um 05:00 hat Wenchao Xia geschrieben: This series brings internal snapshot support at block devices level, now we have two three methods to do block snapshot lively: 1) backing chain, 2) internal one and 3) drive-back up approach. Comparation: Advantages:Disadvantages: 1)delta data, taken fast, export, sizeperformance, delete slow. 2) taken fast, delete fast, performance, size delta data, format 3) performance, export, format taken slow, delta data, size, host I/O I think in most case, saving vmstate in an standalone file is better than saving it inside qcow2, So suggest treat internal snapshot as block level methods and not encourage user to savevm in qcow2 any more. Looks good and should be mergable after a rebase. Kevin
Re: [Qemu-devel] [PATCH RFC v2 2/2] hw/pci: handle unassigned pci addresses
On 10 September 2013 14:02, Michael S. Tsirkin m...@redhat.com wrote: On Tue, Sep 10, 2013 at 01:50:47PM +0100, Peter Maydell wrote: On 10 September 2013 13:39, Michael S. Tsirkin m...@redhat.com wrote: On Mon, Sep 09, 2013 at 02:16:41PM +0100, Peter Maydell wrote: memory_region_init_alias(pci_dev-bus_master_enable_region, OBJECT(pci_dev), bus master, dma_as-root, 0, memory_region_size(dma_as-root)); If instead of using this alias directly as the bus_master_enable region you instead: * create a container region * create a 'background' region at negative priority (ie one per device, and you can make the 'opaque' pointer point to the device, not the bus) * put the alias and the background region into the container * use the container as the bus_master_enable region Interesting. There's one thing I don't understand here: as far as I can see bus_master_enable_region covers the whole 64 bit memory address space. It looks like it will always override the background region in the same container. What did I miss? That should be itself a container, so assuming it doesn't itself have any kind of background region the holes inside it will still be present when we put it in our new container. (Basically putting a container, or an alias to one, inside a region is just saying put everything in that container inside this region at the appropriate place). Confused. That and it here refers to what exactly? Well, I was a bit confused by your talking about the properties of bus_master_enable_region when my suggestion is effectively that we change what that is. So let's start again: * create a container region This is 64 bits wide, but totally empty * create a 'background' region at negative priority 64 bits wide * put the alias and the background region into the container The alias is 64 bits wide too, but it is an alias of dma_as-root, which is a container with no background region. * use the container as the bus_master_enable region -- all you see in this container is the background region and anyhing that was in dma_as-root. So when I said that and it I meant dma_as-root. Hope that is a little less opaque. -- PMM
[Qemu-devel] [RFC PATCH v4 1/6] make.rule: fix $(obj) to a real relative path
Makefile.target includes rule.mak and unnested common-obj-y, then prefix them with '../', this will ignore object specific QEMU_CFLAGS in subdir Makefile.objs: $(obj)/curl.o: QEMU_CFLAGS += $(CURL_CFLAGS) Because $(obj) here is './block', instead of '../block'. This doesn't hurt compiling because we basically build all .o from top Makefile, before entering Makefile.target, but it will affact arriving per-object libs support. The starting point of $(obj) is passed in as argument of unnest-vars, as well as nested variables, so that different Makefiles can pass in a right value. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile| 16 +++- Makefile.objs | 16 +--- Makefile.target | 16 +--- configure | 1 + rules.mak | 12 +++- tests/Makefile | 2 ++ 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 806946e..9e603c6 100644 --- a/Makefile +++ b/Makefile @@ -115,14 +115,28 @@ defconfig: ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/Makefile.objs -include $(SRC_PATH)/tests/Makefile endif ifeq ($(CONFIG_SMARTCARD_NSS),y) include $(SRC_PATH)/libcacard/Makefile endif +dummy := $(call unnest-vars,, \ +stub-obj-y \ +util-obj-y \ +qga-obj-y \ +block-obj-y \ +common-obj-y) + +ifneq ($(wildcard config-host.mak),) +include $(SRC_PATH)/tests/Makefile +endif + all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all +vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) + +vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) + config-host.h: config-host.h-timestamp config-host.h-timestamp: config-host.mak qemu-options.def: $(SRC_PATH)/qemu-options.hx diff --git a/Makefile.objs b/Makefile.objs index f46a4cd..4f7a364 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -41,7 +41,7 @@ libcacard-y += libcacard/vcardt.o # single QEMU executable should support all CPUs and machines. ifeq ($(CONFIG_SOFTMMU),y) -common-obj-y = $(block-obj-y) blockdev.o blockdev-nbd.o block/ +common-obj-y = blockdev.o blockdev-nbd.o block/ common-obj-y += net/ common-obj-y += readline.o common-obj-y += qdev-monitor.o device-hotplug.o @@ -109,17 +109,3 @@ version-lobj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.lo # FIXME: a few definitions from qapi-types.o/qapi-visit.o are needed # by libqemuutil.a. These should be moved to a separate .json schema. qga-obj-y = qga/ qapi-types.o qapi-visit.o - -vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) - -vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) - -QEMU_CFLAGS+=$(GLIB_CFLAGS) - -nested-vars += \ - stub-obj-y \ - util-obj-y \ - qga-obj-y \ - block-obj-y \ - common-obj-y -dummy := $(call unnest-vars) diff --git a/Makefile.target b/Makefile.target index 9a49852..1d92523 100644 --- a/Makefile.target +++ b/Makefile.target @@ -143,13 +143,23 @@ endif # CONFIG_SOFTMMU # Workaround for http://gcc.gnu.org/PR55489, see configure. %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS) -nested-vars += obj-y +dummy := $(call unnest-vars,,obj-y) -# This resolves all nested paths, so it must come last +# we are making another call to unnest-vars with different vars, protect obj-y, +# it can be overriden in subdir Makefile.objs +obj-y-save := $(obj-y) + +block-obj-y := +common-obj-y := include $(SRC_PATH)/Makefile.objs +dummy := $(call unnest-vars,..,block-obj-y common-obj-y) + +# Now restore obj-y +obj-y := $(obj-y-save) all-obj-y = $(obj-y) -all-obj-y += $(addprefix ../, $(common-obj-y)) +all-obj-y += $(addprefix ../, $(common-obj-y) $(block-obj-y)) + ifndef CONFIG_HAIKU LIBS+=-lm diff --git a/configure b/configure index e989609..cc3cd4d 100755 --- a/configure +++ b/configure @@ -2251,6 +2251,7 @@ fi if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then glib_cflags=`$pkg_config --cflags gthread-2.0` glib_libs=`$pkg_config --libs gthread-2.0` +CFLAGS=$glib_cflags $CFLAGS LIBS=$glib_libs $LIBS libs_qga=$glib_libs $libs_qga else diff --git a/rules.mak b/rules.mak index 4499745..c08b356 100644 --- a/rules.mak +++ b/rules.mak @@ -103,9 +103,6 @@ clean: clean-timestamp # magic to descend into other directories -obj := . -old-nested-dirs := - define push-var $(eval save-$2-$1 = $(value $1)) $(eval $1 :=) @@ -119,9 +116,11 @@ endef define unnest-dir $(foreach var,$(nested-vars),$(call push-var,$(var),$1/)) -$(eval obj := $(obj)/$1) +$(eval obj-parent-$1 := $(obj)) +$(eval obj := $(if $(obj),$(obj)/$1,$1)) $(eval include $(SRC_PATH)/$1/Makefile.objs) -$(eval obj := $(patsubst %/$1,%,$(obj))) +$(eval obj := $(obj-parent-$1)) +$(eval obj-parent-$1 := ) $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/)) endef @@ -136,6 +135,9 @@ $(if $(nested-dirs), endef define unnest-vars +$(eval obj := $1) +$(eval nested-vars := $2) +$(eval old-nested-dirs := ) $(call unnest-vars-1) $(foreach var,$(nested-vars),$(eval $(var) := $(filter-out %/, $($(var) $(shell mkdir -p $(sort
[Qemu-devel] [RFC PATCH v4 2/6] rule.mak: allow per object cflags and libs
Adds extract-libs in LINK to expand any per object libs, the syntax to define such a libs options is like: foo.o-libs := $(CURL_LIBS) in block/Makefile.objs. Similarly, foo.o-cflags := $(FOO_CFLAGS) is also supported. foo.o must be listed a nested var (e.g. common-obj-y) to make the option variables effective. Signed-off-by: Fam Zheng f...@redhat.com --- rules.mak | 19 --- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/rules.mak b/rules.mak index c08b356..6342d60 100644 --- a/rules.mak +++ b/rules.mak @@ -17,15 +17,17 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d # Same as -I$(SRC_PATH) -I., but for the nested source/object directories QEMU_INCLUDES += -I$(D) -I$(@D) +extract-libs = $(strip $(foreach o,$1,$($o-libs))) + %.o: %.c - $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $, CC$(TARGET_DIR)$@) + $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) -c -o $@ $, CC$(TARGET_DIR)$@) %.o: %.rc $(call quiet-command,$(WINDRES) -I. -o $@ $, RC$(TARGET_DIR)$@) ifeq ($(LIBTOOL),) LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \ $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \ - $(LIBS), LINK $(TARGET_DIR)$@) + $(call extract-libs,$^) $(LIBS), LINK $(TARGET_DIR)$@) else LIBTOOL += $(if $(V),,--quiet) %.lo: %.c @@ -41,7 +43,7 @@ LINK = $(call quiet-command,\ $(sort $(filter %.o, $1)) $(filter-out %.o, $1) \ $(if $(filter %.lo %.la,$^),$(version-lobj-y),$(version-obj-y)) \ $(if $(filter %.lo %.la,$^),$(LIBTOOLFLAGS)) \ - $(LIBS),$(if $(filter %.lo %.la,$^),lt LINK , LINK )$(TARGET_DIR)$@) + $(call extract-libs,$^) $(LIBS),$(if $(filter %.lo %.la,$^),lt LINK , LINK )$(TARGET_DIR)$@) endif %.asm: %.S @@ -114,11 +116,22 @@ $(eval $1 = $(value save-$2-$1) $$(subdir-$2-$1)) $(eval save-$2-$1 :=) endef +define fix-obj-vars +$(foreach v,$($1), \ + $(if $($v-cflags), \ + $(eval $2$v-cflags := $($v-cflags)) \ + $(eval $v-cflags := )) \ + $(if $($v-libs), \ + $(eval $2$v-libs := $($v-libs)) \ + $(eval $v-libs := ))) +endef + define unnest-dir $(foreach var,$(nested-vars),$(call push-var,$(var),$1/)) $(eval obj-parent-$1 := $(obj)) $(eval obj := $(if $(obj),$(obj)/$1,$1)) $(eval include $(SRC_PATH)/$1/Makefile.objs) +$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(if $(obj),$(obj)/))) $(eval obj := $(obj-parent-$1)) $(eval obj-parent-$1 := ) $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/)) -- 1.8.3.1
[Qemu-devel] [RFC PATCH v4 0/6] Shared Library Module Support
This series implements feature of shared object building as described in: http://wiki.qemu.org/Features/Modules It's achieved in three steps, with extra bonus to change curl and qed to shared library modules in the end (only to demonstrate the usage, no make install support of .so files yet). v4: Added --enable-modules in the end of series. Make nested-vars and obj-base as arguemnts to unnest-vars. Take Paolo's idea in comments for v2 and switch back module objects syntax to: $(obj)/foo.mo : $(addprefix $(obj)/, bar.o biz.o qux.o) because this needs less duplication among Makefiles. Fam Zheng (6): make.rule: fix $(obj) to a real relative path rule.mak: allow per object cflags and libs Makefile: introduce common-obj-m and block-obj-m for DSO module: implement module loading function configure: introduce --enable-modules block: build qed and curl as shared library Makefile | 42 +++- Makefile.objs | 18 +++-- Makefile.target | 16 +--- block.c | 1 + block/Makefile.objs | 7 --- bsd-user/main.c | 3 +++ configure | 40 +++--- include/qemu/module.h | 9 + linux-user/main.c | 3 +++ rules.mak | 53 ++- scripts/create_config | 4 tests/Makefile| 2 ++ util/module.c | 53 +++ vl.c | 2 ++ 14 files changed, 207 insertions(+), 46 deletions(-) -- 1.8.3.1
[Qemu-devel] [RFC PATCH v4 3/6] Makefile: introduce common-obj-m and block-obj-m for DSO
Add necessary rules and flags for shared object generation. $(common-obj-m) will include $(block-obj-m), like $(common-obj-y) does for $(block-obj-y). The new rules introduced here are: 0) For all %.so compiling: QEMU_CFLAGS += -fPIC 1) %.o in $(common-obj-m) is compiled to %.o, then linked to %.so. 2) %.mo in $(common-obj-m) is the placeholder for %.so for pattern matching in Makefile. It's linked to -shared with all its dependencies (multiple *.o) as input. Which means the list of depended objects must be ruled out in each sub-Makefile.objs with: $(obj)/foo.mo : $(addprefix $(obj)/, bar.o baz.o qux.o) With target and dependencies both prefixed with $(obj)/. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile | 20 +++- Makefile.objs | 2 ++ configure | 6 ++ rules.mak | 26 +++--- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 9e603c6..3685bbd 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,9 @@ dummy := $(call unnest-vars,, \ util-obj-y \ qga-obj-y \ block-obj-y \ -common-obj-y) +block-obj-m \ +common-obj-y \ +common-obj-m) ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/tests/Makefile @@ -133,6 +135,18 @@ endif all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all +define add-modules +$(foreach o,$(filter %.o,$($1)),$(eval \ + $(patsubst %.o,%.mo,$o): $o)) +$(eval modules-m += $(patsubst %.o,%.mo,$($1))) +endef + +dummy := $(call add-modules,block-obj-m) +dummy := $(call add-modules,common-obj-m) + +modules: $(patsubst %.mo,%$(DSOSUF),$(modules-m)) +all: modules + vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) @@ -249,6 +263,10 @@ clean: rm -f qemu-options.def find . -name '*.[oda]' -type f -exec rm -f {} + find . -name '*.l[oa]' -type f -exec rm -f {} + + find . -name '*.so' -type f -exec rm -f {} + + find . -name '*.mo' -type f -exec rm -f {} + + find . -name '*.dll' -type f -exec rm -f {} + + rm -f $(TOOLS) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ rm -Rf .libs rm -f qemu-img-cmds.h diff --git a/Makefile.objs b/Makefile.objs index 4f7a364..023166b 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -19,6 +19,8 @@ block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o block-obj-y += qemu-coroutine-sleep.o block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o +block-obj-m = block/ + ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) # Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add. # only pull in the actual virtio-9p device if we also enabled virtio. diff --git a/configure b/configure index cc3cd4d..c6d4a62 100755 --- a/configure +++ b/configure @@ -190,6 +190,8 @@ mingw32=no gcov=no gcov_tool=gcov EXESUF= +DSOSUF=.so +LDFLAGS_SHARED=-shared prefix=/usr/local mandir=\${prefix}/share/man datadir=\${prefix}/share @@ -485,6 +487,7 @@ OpenBSD) Darwin) bsd=yes darwin=yes + LDFLAGS_SHARED=-bundle if [ $cpu = x86_64 ] ; then QEMU_CFLAGS=-arch x86_64 $QEMU_CFLAGS LDFLAGS=-arch x86_64 $LDFLAGS @@ -584,6 +587,7 @@ fi if test $mingw32 = yes ; then EXESUF=.exe + DSOSUF=.dll QEMU_CFLAGS=-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) QEMU_CFLAGS=-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS @@ -4175,6 +4179,8 @@ echo LIBTOOLFLAGS=$LIBTOOLFLAGS $config_host_mak echo LIBS+=$LIBS $config_host_mak echo LIBS_TOOLS+=$libs_tools $config_host_mak echo EXESUF=$EXESUF $config_host_mak +echo DSOSUF=$DSOSUF $config_host_mak +echo LDFLAGS_SHARED=$LDFLAGS_SHARED $config_host_mak echo LIBS_QGA+=$libs_qga $config_host_mak echo POD2MAN=$POD2MAN $config_host_mak echo TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS $config_host_mak diff --git a/rules.mak b/rules.mak index 6342d60..2be7901 100644 --- a/rules.mak +++ b/rules.mak @@ -18,6 +18,10 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d QEMU_INCLUDES += -I$(D) -I$(@D) extract-libs = $(strip $(foreach o,$1,$($o-libs))) +expand-objs = $(strip $(sort $(filter %.o,$1)) \ + $(if $(realpath $(filter %.mo,$1)), \ + $(shell cat $(realpath $(filter %.mo,$1 \ + $(filter-out %.o %.mo,$1)) %.o: %.c $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) -c -o $@ $, CC$(TARGET_DIR)$@) @@ -26,8 +30,8 @@ extract-libs = $(strip $(foreach o,$1,$($o-libs))) ifeq ($(LIBTOOL),) LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \ - $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \ - $(call extract-libs,$^) $(LIBS), LINK $(TARGET_DIR)$@) + $(call expand-objs $1)
[Qemu-devel] [RFC PATCH v4 6/6] block: build qed and curl as shared library
Curl and qed block drivers are built as shared object module. We have per object cflags and libs support now, move CURL_CFLAGS and CURL_LIBS from global option variables to a per object basis. make install is not installing them yet, manually copy it to ${prefix}/qemu/block/ to make it loaded. Signed-off-by: Fam Zheng f...@redhat.com --- block/Makefile.objs | 7 --- configure | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/block/Makefile.objs b/block/Makefile.objs index 3bb85b5..1b23b88 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -1,7 +1,6 @@ block-obj-y += raw_bsd.o cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o block-obj-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o qcow2-cache.o -block-obj-y += qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o -block-obj-y += qed-check.o +block-obj-m += qed.mo block-obj-y += vhdx.o block-obj-y += parallels.o blkdebug.o blkverify.o block-obj-y += snapshot.o qapi.o @@ -23,4 +22,6 @@ common-obj-y += commit.o common-obj-y += mirror.o common-obj-y += backup.o -$(obj)/curl.o: QEMU_CFLAGS+=$(CURL_CFLAGS) +curl.o-cflags := $(CURL_CFLAGS) +curl.o-libs := $(CURL_LIBS) +$(obj)/qed.mo : $(addprefix $(obj)/, qed.o qed-gencb.o qed-l2-cache.o qed-table.o qed-cluster.o qed-check.o) diff --git a/configure b/configure index f1d7fa7..f8be093 100755 --- a/configure +++ b/configure @@ -2217,8 +2217,6 @@ EOF curl_libs=`$curlconfig --libs 2/dev/null` if compile_prog $curl_cflags $curl_libs ; then curl=yes -libs_tools=$curl_libs $libs_tools -libs_softmmu=$curl_libs $libs_softmmu else if test $curl = yes ; then feature_not_found curl @@ -3901,8 +3899,9 @@ if test $bswap_h = yes ; then echo CONFIG_MACHINE_BSWAP_H=y $config_host_mak fi if test $curl = yes ; then - echo CONFIG_CURL=y $config_host_mak + echo CONFIG_CURL=m $config_host_mak echo CURL_CFLAGS=$curl_cflags $config_host_mak + echo CURL_LIBS=$curl_libs $config_host_mak fi if test $brlapi = yes ; then echo CONFIG_BRLAPI=y $config_host_mak -- 1.8.3.1
Re: [Qemu-devel] [PATCH v3 00/29] tcg-aarch64 improvements
On 09/10/2013 01:27 AM, Claudio Fontana wrote: There are two aspects. On one side, although some changes do not break anything, I see some problems in them. Then let us discuss them, sooner rather than later. Putting them as a prerequisite for the rest forces us to agreeing on everything before moving forward, instead of being able to agree on separate chunks (meat first, rest later). In my view, this makes the process longer. If we have no common ground on how the port should look, then we simply cannot move forward full stop. Having put together a foundation of AArch64Insn and tcg_fmt_*, that I believe to be clean and easy to understand, I simply refuse on aesthetic grounds to rewrite later patches to instead use the magic number and open-coded insn format used throughout the port today. That way leads to a much greater chance of error in my opinion. r~
[Qemu-devel] [RFC PATCH v4 5/6] configure: introduce --enable-modules
The new option will enable support of shared object build. Otherwise objects are static linked to executables. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile | 8 configure | 8 2 files changed, 16 insertions(+) diff --git a/Makefile b/Makefile index 3685bbd..5a2c6f2 100644 --- a/Makefile +++ b/Makefile @@ -135,6 +135,7 @@ endif all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all +ifeq ($(CONFIG_MODULES),y) define add-modules $(foreach o,$(filter %.o,$($1)),$(eval \ $(patsubst %.o,%.mo,$o): $o)) @@ -146,6 +147,13 @@ dummy := $(call add-modules,common-obj-m) modules: $(patsubst %.mo,%$(DSOSUF),$(modules-m)) all: modules +else +block-obj-y += $(block-obj-m) +common-obj-y += $(common-obj-m) +block-obj-m := +common-obj-m := +endif + vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) diff --git a/configure b/configure index a2858c2..f1d7fa7 100755 --- a/configure +++ b/configure @@ -192,6 +192,7 @@ gcov_tool=gcov EXESUF= DSOSUF=.so LDFLAGS_SHARED=-shared +modules=no prefix=/usr/local mandir=\${prefix}/share/man datadir=\${prefix}/share @@ -650,6 +651,8 @@ for opt do ;; --disable-debug-info) ;; + --enable-modules) modules=yes + ;; --cpu=*) ;; --target-list=*) target_list=$optarg @@ -1052,6 +1055,7 @@ echo --libdir=PATHinstall libraries in PATH echo --sysconfdir=PATHinstall config in PATH$confsuffix echo --localstatedir=PATH install local state in PATH (set at runtime on win32) echo --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir [$confsuffix] +echo --enable-modules enable modules support echo --enable-debug-tcg enable TCG debugging echo --disable-debug-tcg disable TCG debugging (default) echo --enable-debug-info enable debugging information (default) @@ -3580,6 +3584,7 @@ echo python$python if test $slirp = yes ; then echo smbd $smbd fi +echo module support$modules echo host CPU $cpu echo host big endian $bigendian echo target list $target_list @@ -3697,6 +3702,9 @@ echo libs_softmmu=$libs_softmmu $config_host_mak echo ARCH=$ARCH $config_host_mak +if test $modules = yes; then + echo CONFIG_MODULES=y $config_host_mak +fi case $cpu in arm|i386|x86_64|x32|ppc|aarch64) # The TCG interpreter currently does not support ld/st optimization. -- 1.8.3.1
[Qemu-devel] [RFC PATCH v4 4/6] module: implement module loading function
Added three types of modules: typedef enum { MODULE_LOAD_BLOCK = 0, MODULE_LOAD_UI, MODULE_LOAD_NET, MODULE_LOAD_MAX, } module_load_type; and their loading function: void module_load(module_load_type). which loads all .so files in a subdir under ${PREFIX}/qemu/, e.g. /usr/lib/qemu/block. Modules of each type should be loaded before respective subsystem initialization code. Requires gmodule-2.0 from glib. Signed-off-by: Fam Zheng f...@redhat.com --- block.c | 1 + bsd-user/main.c | 3 +++ configure | 22 - include/qemu/module.h | 9 + linux-user/main.c | 3 +++ scripts/create_config | 4 util/module.c | 53 +++ vl.c | 2 ++ 8 files changed, 88 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index 26639e8..16ceaaf 100644 --- a/block.c +++ b/block.c @@ -4008,6 +4008,7 @@ BlockDriverAIOCB *bdrv_aio_discard(BlockDriverState *bs, void bdrv_init(void) { +module_load(MODULE_LOAD_BLOCK); module_call_init(MODULE_INIT_BLOCK); } diff --git a/bsd-user/main.c b/bsd-user/main.c index f9246aa..6cb9e35 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -33,6 +33,7 @@ #include tcg.h #include qemu/timer.h #include qemu/envlist.h +#include qemu/module.h int singlestep; #if defined(CONFIG_USE_GUEST_BASE) @@ -749,6 +750,8 @@ int main(int argc, char **argv) if (argc = 1) usage(); +module_load(MODULE_LOAD_UI); +module_load(MODULE_LOAD_NET); module_call_init(MODULE_INIT_QOM); if ((envlist = envlist_create()) == NULL) { diff --git a/configure b/configure index c6d4a62..a2858c2 100755 --- a/configure +++ b/configure @@ -2252,15 +2252,19 @@ if test $mingw32 = yes; then else glib_req_ver=2.12 fi -if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then -glib_cflags=`$pkg_config --cflags gthread-2.0` -glib_libs=`$pkg_config --libs gthread-2.0` -CFLAGS=$glib_cflags $CFLAGS -LIBS=$glib_libs $LIBS -libs_qga=$glib_libs $libs_qga -else -error_exit glib-$glib_req_ver required to compile QEMU -fi + +for i in gthread-2.0 gmodule-2.0; do +if $pkg_config --atleast-version=$glib_req_ver $i; then +glib_cflags=`$pkg_config --cflags $i` +glib_libs=`$pkg_config --libs $i` +CFLAGS=$glib_cflags $CFLAGS +LIBS=$glib_libs $LIBS +libs_qga=$glib_libs $libs_qga +else +error_exit glib-$glib_req_ver required to compile QEMU +fi +done + ## # pixman support probe diff --git a/include/qemu/module.h b/include/qemu/module.h index c4ccd57..f00bc25 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -37,4 +37,13 @@ void register_module_init(void (*fn)(void), module_init_type type); void module_call_init(module_init_type type); +typedef enum { +MODULE_LOAD_BLOCK = 0, +MODULE_LOAD_UI, +MODULE_LOAD_NET, +MODULE_LOAD_MAX, +} module_load_type; + +void module_load(module_load_type type); + #endif diff --git a/linux-user/main.c b/linux-user/main.c index 5c2f7b2..db08c23 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -34,6 +34,7 @@ #include qemu/timer.h #include qemu/envlist.h #include elf.h +#include qemu/module.h char *exec_path; @@ -3551,6 +3552,8 @@ int main(int argc, char **argv, char **envp) int i; int ret; +module_load(MODULE_LOAD_UI); +module_load(MODULE_LOAD_NET); module_call_init(MODULE_INIT_QOM); qemu_cache_utils_init(envp); diff --git a/scripts/create_config b/scripts/create_config index b1adbf5..7a54f2d 100755 --- a/scripts/create_config +++ b/scripts/create_config @@ -25,6 +25,7 @@ case $line in prefix=*) # save for the next definitions prefix=${line#*=} +echo #define CONFIG_PREFIX \$prefix\ ;; CONFIG_AUDIO_DRIVERS=*) drivers=${line#*=} @@ -104,6 +105,9 @@ case $line in value=${line#*=} echo #define $name $value ;; + DSOSUF=*) +echo #define HOST_DSOSUF \${line#*=}\ +;; esac done # read diff --git a/util/module.c b/util/module.c index 7acc33d..ef75f8e 100644 --- a/util/module.c +++ b/util/module.c @@ -13,6 +13,8 @@ * GNU GPL, version 2 or (at your option) any later version. */ +#include gmodule.h +#include dirent.h #include qemu-common.h #include qemu/queue.h #include qemu/module.h @@ -79,3 +81,54 @@ void module_call_init(module_init_type type) e-init(); } } + +void module_load(module_load_type type) +{ +const char *path; +const char *dsosuf = HOST_DSOSUF; +char *fname; +int suf_len = strlen(dsosuf); +DIR *dp; +struct dirent *ep = NULL; +GModule *g_module; + +if (!g_module_supported()) { +return; +} + +switch (type) { +case MODULE_LOAD_BLOCK: +path = CONFIG_PREFIX /qemu/block/; +break; +case MODULE_LOAD_UI: +
[Qemu-devel] [PATCH v3 0/5] Do not set SO_REUSEADDR on Windows
This patchset disabels all use of SO_REUSEADDR on Windows. On Windows systems the default behaviour is equivalent to SO_REUSEADDR on other operating systems. SO_REUSEADDR can still be set but results in undesired behaviour instead. It may even lead to situations were system behaviour is unspecified. More information on this can be found at: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspx I originally encountered this issue when accidentally launching two QEMU instances with identical GDB ports at the same time. In which case QEMU won't fail as one might expect. v3 Changes: - Fixed coding style issues. According to checkpatch.pl patch #4 still introduces style errors as tabs are used instead of space for some indentation. I keept the tabs to stay consistent with the sourrounding code, as tabs seem to be used consitently in parts (all?) of the slirp code. - Changed patch #3 to keep SO_REUSEADDR for multicast sockets on windows and added an explainatory comment. - Rebased to current master (94c2b6aff43cdfcfdfb552773a6b6b973a72ef0b). v2 Changes: - Introduce a function with os specific implementation instead of using #ifdef I named it socket_set_fast_reuse instead of the suggested qemu_set_reuseaddr so the name better reflects what the function actually does. gdbstub.c |6 ++ include/qemu/sockets.h |1 + net/socket.c | 18 ++ slirp/misc.c |3 +-- slirp/socket.c |4 +--- slirp/tcp_subr.c |6 ++ slirp/udp.c|4 ++-- util/oslib-posix.c | 14 ++ util/oslib-win32.c | 10 ++ util/qemu-sockets.c|6 +++--- 10 files changed, 46 insertions(+), 26 deletions(-) util: add socket_set_fast_reuse function which will gdbstub: call socket_set_fast_reuse instead of net: call socket_set_fast_reuse instead of setting slirp: call socket_set_fast_reuse instead of setting util: call socket_set_fast_reuse instead of setting
[Qemu-devel] [PATCH v3 4/5] slirp: call socket_set_fast_reuse instead of setting SO_REUSEADDR
SO_REUSEADDR should be avoided on Windows but is desired on other operating systems. So instead of setting it we call socket_set_fast_reuse that will result in the appropriate behaviour on all operating systems. Signed-off-by: Sebastian Ottlik ott...@fzi.de --- slirp/misc.c |3 +-- slirp/socket.c |4 +--- slirp/tcp_subr.c |6 ++ slirp/udp.c |4 ++-- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/slirp/misc.c b/slirp/misc.c index c0d4899..6c1636f 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -212,8 +212,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty) so-s = accept(s, (struct sockaddr *)addr, addrlen); } while (so-s 0 errno == EINTR); closesocket(s); -opt = 1; -qemu_setsockopt(so-s, SOL_SOCKET, SO_REUSEADDR, opt, sizeof(int)); +socket_set_fast_reuse(so-s); opt = 1; qemu_setsockopt(so-s, SOL_SOCKET, SO_OOBINLINE, opt, sizeof(int)); qemu_set_nonblock(so-s); diff --git a/slirp/socket.c b/slirp/socket.c index 25d60e7..37ac5cf 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -627,9 +627,7 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, addr.sin_port = hport; if (((s = qemu_socket(AF_INET,SOCK_STREAM,0)) 0) || -#ifndef _WIN32 - (qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, opt, sizeof(int)) 0) || -#endif + (socket_set_fast_reuse(s) 0) || (bind(s,(struct sockaddr *)addr, sizeof(addr)) 0) || (listen(s,1) 0)) { int tmperrno = errno; /* Don't clobber the real reason we failed */ diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c index 043f28f..7571c5a 100644 --- a/slirp/tcp_subr.c +++ b/slirp/tcp_subr.c @@ -337,8 +337,7 @@ int tcp_fconnect(struct socket *so) struct sockaddr_in addr; qemu_set_nonblock(s); -opt = 1; -qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, opt, sizeof(opt)); +socket_set_fast_reuse(s); opt = 1; qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, opt, sizeof(opt)); @@ -426,8 +425,7 @@ void tcp_connect(struct socket *inso) return; } qemu_set_nonblock(s); -opt = 1; -qemu_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, opt, sizeof(int)); +socket_set_fast_reuse(s); opt = 1; qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, opt, sizeof(int)); socket_set_nodelay(s); diff --git a/slirp/udp.c b/slirp/udp.c index b105f87..8cc6cb6 100644 --- a/slirp/udp.c +++ b/slirp/udp.c @@ -354,7 +354,7 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, { struct sockaddr_in addr; struct socket *so; - socklen_t addrlen = sizeof(struct sockaddr_in), opt = 1; + socklen_t addrlen = sizeof(struct sockaddr_in); so = socreate(slirp); if (!so) { @@ -372,7 +372,7 @@ udp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr, udp_detach(so); return NULL; } - qemu_setsockopt(so-s, SOL_SOCKET, SO_REUSEADDR, opt, sizeof(int)); + socket_set_fast_reuse(so-s); getsockname(so-s,(struct sockaddr *)addr,addrlen); so-so_fport = addr.sin_port; -- 1.7.9.5
[Qemu-devel] [PATCH v3 2/5] gdbstub: call socket_set_fast_reuse instead of setting SO_REUSEADDR
SO_REUSEADDR should be avoided on Windows but is desired on other operating systems. So instead of setting it we call socket_set_fast_reuse that will result in the appropriate behaviour on all operating systems. Signed-off-by: Sebastian Ottlik ott...@fzi.de --- gdbstub.c |6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 2b7f22b..0e5a3f5 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1553,7 +1553,7 @@ static void gdb_accept(void) static int gdbserver_open(int port) { struct sockaddr_in sockaddr; -int fd, val, ret; +int fd, ret; fd = socket(PF_INET, SOCK_STREAM, 0); if (fd 0) { @@ -1564,9 +1564,7 @@ static int gdbserver_open(int port) fcntl(fd, F_SETFD, FD_CLOEXEC); #endif -/* allow fast reuse */ -val = 1; -qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, val, sizeof(val)); +socket_set_fast_reuse(fd); sockaddr.sin_family = AF_INET; sockaddr.sin_port = htons(port); -- 1.7.9.5
[Qemu-devel] [PATCH v3 1/5] util: add socket_set_fast_reuse function which will replace setting SO_REUSEADDR
If a socket is closed it remains in TIME_WAIT state for some time. On operating systems using BSD sockets the endpoint of the socket may not be reused while in this state unless SO_REUSEADDR was set on the socket. On windows on the other hand the default behaviour is to allow reuse (i.e. identical to SO_REUSEADDR on other operating systems) and setting SO_REUSEADDR on a socket allows it to be bound to a endpoint even if the endpoint is already used by another socket independently of the other sockets state. This can even result in undefined behaviour. Many sockets used by QEMU should not block the use of their endpoint after being closed while they are still in TIME_WAIT state. Currently QEMU sets SO_REUSEADDR for such sockets, which can lead to problems on Windows. This patch introduces the function socket_set_fast_reuse that should be used instead of setting SO_REUSEADDR and does the right thing on all operating systems. Signed-off-by: Sebastian Ottlik ott...@fzi.de --- include/qemu/sockets.h |1 + util/oslib-posix.c | 14 ++ util/oslib-win32.c | 10 ++ 3 files changed, 25 insertions(+) diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index c5174d7..45588d7 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -39,6 +39,7 @@ int socket_set_cork(int fd, int v); int socket_set_nodelay(int fd); void qemu_set_block(int fd); void qemu_set_nonblock(int fd); +int socket_set_fast_reuse(int fd); int send_all(int fd, const void *buf, int len1); int recv_all(int fd, void *buf, int len1, bool single_read); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 3dc8b1b..c01c847 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -159,6 +159,20 @@ void qemu_set_nonblock(int fd) fcntl(fd, F_SETFL, f | O_NONBLOCK); } +int socket_set_fast_reuse(int fd) +{ +int val = 1, ret; + +ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, + (const char *)val, sizeof(val)); + +if (ret 0) { +perror(setsockopt(SOL_SOCKET, SO_REUSEADDR)); +} + +return ret; +} + void qemu_set_cloexec(int fd) { int f; diff --git a/util/oslib-win32.c b/util/oslib-win32.c index 961fbf5..dd81f55 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -127,6 +127,16 @@ void qemu_set_nonblock(int fd) qemu_fd_register(fd); } +int socket_set_fast_reuse(int fd) +{ +/* Enabling the reuse of an endpoint that was used by a socket still in + * TIME_WAIT state is usually performed by setting SO_REUSEADDR. On Windows + * fast reuse is the default and SO_REUSEADDR does strange things. So we + * don't have to do anything here. More info can be found at: + * http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspx */ +return 0; +} + int inet_aton(const char *cp, struct in_addr *ia) { uint32_t addr = inet_addr(cp); -- 1.7.9.5
Re: [Qemu-devel] [PATCH V12 10/13] NUMA: add qmp command set-mem-policy to set memory policy for NUMA node
On Wed, 4 Sep 2013 17:03:39 +0800 Wanlong Gao gaowanl...@cn.fujitsu.com wrote: This QMP command allows user set guest node's memory policy through the QMP protocol. The qmp-shell command is like: set-mem-policy nodeid=0 policy=membind relative=true host-nodes=0-1 Signed-off-by: Wanlong Gao gaowanl...@cn.fujitsu.com QMP part looks good: Reviewed-by: Luiz Capitulino lcapitul...@redhat.com --- numa.c | 66 qapi-schema.json | 21 ++ qmp-commands.hx | 41 +++ 3 files changed, 128 insertions(+) diff --git a/numa.c b/numa.c index 915a67a..19ee7f7 100644 --- a/numa.c +++ b/numa.c @@ -28,6 +28,7 @@ #include qapi/opts-visitor.h #include qapi/dealloc-visitor.h #include exec/memory.h +#include qmp-commands.h #ifdef __linux__ #include sys/syscall.h @@ -327,3 +328,68 @@ void set_numa_modes(void) } } } + +void qmp_set_mem_policy(uint16_t nodeid, bool has_policy, NumaNodePolicy policy, +bool has_relative, bool relative, +bool has_host_nodes, uint16List *host_nodes, +Error **errp) +{ +NumaNodePolicy old_policy; +bool old_relative; +DECLARE_BITMAP(host_mem, MAX_NODES); +uint16List *nodes; + +if (nodeid = nb_numa_nodes) { +error_setg(errp, Only has '%d' NUMA nodes, nb_numa_nodes); +return; +} + +bitmap_copy(host_mem, numa_info[nodeid].host_mem, MAX_NODES); +old_policy = numa_info[nodeid].policy; +old_relative = numa_info[nodeid].relative; + +numa_info[nodeid].policy = NUMA_NODE_POLICY_DEFAULT; +numa_info[nodeid].relative = false; +bitmap_zero(numa_info[nodeid].host_mem, MAX_NODES); + +if (!has_policy) { +if (set_node_mem_policy(nodeid) == -1) { +error_setg(errp, Failed to set memory policy for node% PRIu16, + nodeid); +goto error; +} +return; +} + +numa_info[nodeid].policy = policy; + +if (has_relative) { +numa_info[nodeid].relative = relative; +} + +if (!has_host_nodes) { +bitmap_empty(numa_info[nodeid].host_mem, MAX_NODES); +bitmap_set(numa_info[nodeid].host_mem, 0, 1); +} + +for (nodes = host_nodes; nodes; nodes = nodes-next) { +if (nodes-value MAX_NODES) { +continue; +} +bitmap_set(numa_info[nodeid].host_mem, nodes-value, 1); +} + +if (set_node_mem_policy(nodeid) == -1) { +error_setg(errp, Failed to set memory policy for node% PRIu16, + nodeid); +goto error; +} + +return; + +error: +bitmap_copy(numa_info[nodeid].host_mem, host_mem, MAX_NODES); +numa_info[nodeid].policy = old_policy; +numa_info[nodeid].relative = old_relative; +return; +} diff --git a/qapi-schema.json b/qapi-schema.json index 2fba592..7a8cf6a 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3849,3 +3849,24 @@ '*policy': 'NumaNodePolicy', '*relative': 'bool', '*host-nodes': ['uint16'] }} + +## +# @set-mem-policy: +# +# Set the host memory binding policy for guest NUMA node. +# +# @nodeid: The node ID of guest NUMA node to set memory policy to. +# +# @policy: #optional The memory policy to be set (default 'default'). +# +# @relative: #optional If the specified nodes are relative (default 'false') +# +# @host-nodes: #optional The host nodes range for memory policy. +# +# Returns: Nothing on success +# +# Since: 1.7 +## +{ 'command': 'set-mem-policy', + 'data': {'nodeid': 'uint16', '*policy': 'NumaNodePolicy', + '*relative': 'bool', '*host-nodes': ['uint16'] } } diff --git a/qmp-commands.hx b/qmp-commands.hx index 8a8f342..67a9dd2 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3061,6 +3061,7 @@ Example: - { return: {} } EQMP + { .name = query-rx-filter, .args_type = name:s?, @@ -3124,3 +3125,43 @@ Example: } EQMP + +{ +.name = set-mem-policy, +.args_type = nodeid:i,policy:s?,relative:b?,host-nodes:q?, +.help = Set the host memory binding policy for guest NUMA node, +.mhandler.cmd_new = qmp_marshal_input_set_mem_policy, +}, + +SQMP +set-mem-policy +-- + +Set the host memory binding policy for guest NUMA node + +Arguments: + +- nodeid: The nodeid of guest NUMA node to set memory policy to. +(json-int) +- policy: The memory policy to set. +(json-string, optional) +- relative: If the specified nodes are relative. + (json-bool, optional) +- host-nodes: The host nodes contained to this memory policy. +(a json-array of int, optional) + +Example: + +- { execute: set-mem-policy, arguments: { nodeid: 0, +
[Qemu-devel] [PATCH v3 3/5] net: call socket_set_fast_reuse instead of setting SO_REUSEADDR
SO_REUSEADDR should be avoided on Windows but is desired on other operating systems. So instead of setting it we call socket_set_fast_reuse that will result in the appropriate behaviour on all operating systems. An exception to this rule are multicast sockets where it is sensible to have multiple sockets listen on the same ip and port an we should set SO_REUSEADDR on windows. Signed-off-by: Sebastian Ottlik ott...@fzi.de --- net/socket.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/net/socket.c b/net/socket.c index e61309d..56218ce 100644 --- a/net/socket.c +++ b/net/socket.c @@ -262,6 +262,11 @@ static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr return -1; } +/* Allow multiple sockets to bind the same multicast ip and port by setting + * SO_REUSEADDR. This is the only situation where SO_REUSEADDR should be set + * on windows. Use socket_set_fast_reuse otherwise as it sets SO_REUSEADDR + * only on posix systems. + */ val = 1; ret = qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, val, sizeof(val)); if (ret 0) { @@ -510,7 +515,7 @@ static int net_socket_listen_init(NetClientState *peer, NetClientState *nc; NetSocketState *s; struct sockaddr_in saddr; -int fd, val, ret; +int fd, ret; if (parse_host_port(saddr, host_str) 0) return -1; @@ -523,8 +528,7 @@ static int net_socket_listen_init(NetClientState *peer, qemu_set_nonblock(fd); /* allow fast reuse */ -val = 1; -qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, val, sizeof(val)); +socket_set_fast_reuse(fd); ret = bind(fd, (struct sockaddr *)saddr, sizeof(saddr)); if (ret 0) { @@ -645,7 +649,7 @@ static int net_socket_udp_init(NetClientState *peer, const char *lhost) { NetSocketState *s; -int fd, val, ret; +int fd, ret; struct sockaddr_in laddr, raddr; if (parse_host_port(laddr, lhost) 0) { @@ -661,11 +665,9 @@ static int net_socket_udp_init(NetClientState *peer, perror(socket(PF_INET, SOCK_DGRAM)); return -1; } -val = 1; -ret = qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, - val, sizeof(val)); + +ret = socket_set_fast_reuse(fd); if (ret 0) { -perror(setsockopt(SOL_SOCKET, SO_REUSEADDR)); closesocket(fd); return -1; } -- 1.7.9.5
[Qemu-devel] [PATCH v3 5/5] util: call socket_set_fast_reuse instead of setting SO_REUSEADDR
SO_REUSEADDR should be avoided on Windows but is desired on other operating systems. So instead of setting it we call socket_set_fast_reuse that will result in the appropriate behaviour on all operating systems. Signed-off-by: Sebastian Ottlik ott...@fzi.de --- util/qemu-sockets.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 095716e..6b97dc1 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -155,7 +155,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) continue; } -qemu_setsockopt(slisten, SOL_SOCKET, SO_REUSEADDR, on, sizeof(on)); +socket_set_fast_reuse(slisten); #ifdef IPV6_V6ONLY if (e-ai_family == PF_INET6) { /* listen on both ipv4 and ipv6 */ @@ -274,7 +274,7 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress, error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); return -1; } -qemu_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, on, sizeof(on)); +socket_set_fast_reuse(sock); if (connect_state != NULL) { qemu_set_nonblock(sock); } @@ -455,7 +455,7 @@ int inet_dgram_opts(QemuOpts *opts, Error **errp) error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED); goto err; } -qemu_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, on, sizeof(on)); +socket_set_fast_reuse(sock); /* bind socket */ if (bind(sock, local-ai_addr, local-ai_addrlen) 0) { -- 1.7.9.5
Re: [Qemu-devel] [PATCH V12 11/13] NUMA: add hmp command set-mem-policy
On Wed, 4 Sep 2013 17:03:40 +0800 Wanlong Gao gaowanl...@cn.fujitsu.com wrote: Add hmp command set-mem-policy to set host memory policy for a guest NUMA node. Then we can also set node's memory policy using the monitor command like: (qemu) set-mem-policy 0 policy=membind,relative=false,host-nodes=0-1 Signed-off-by: Wanlong Gao gaowanl...@cn.fujitsu.com --- hmp-commands.hx | 16 ++ hmp.c | 65 + hmp.h | 1 + 3 files changed, 82 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 65b7f60..b7f6049 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1587,6 +1587,22 @@ Executes a qemu-io command on the given block device. ETEXI { +.name = set-mem-policy, +.args_type = nodeid:i,args:s?, +.params = nodeid [args], Please, document args. +.help = set host memory policy for a guest NUMA node, +.mhandler.cmd = hmp_set_mem_policy, +}, + +STEXI +@item set-mem-policy @var{nodeid} @var{args} +@findex set-mem-policy + +Set host memory policy for a guest NUMA node + +ETEXI + +{ .name = info, .args_type = item:s?, .params = [subcommand], diff --git a/hmp.c b/hmp.c index fcca6ae..ae695b0 100644 --- a/hmp.c +++ b/hmp.c @@ -24,6 +24,9 @@ #include ui/console.h #include block/qapi.h #include qemu-io.h +#include qapi-visit.h +#include qapi/opts-visitor.h +#include qapi/dealloc-visitor.h static void hmp_handle_error(Monitor *mon, Error **errp) { @@ -1514,3 +1517,65 @@ void hmp_qemu_io(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } + +void hmp_set_mem_policy(Monitor *mon, const QDict *qdict) +{ +Error *local_err = NULL; +bool has_policy = true; +bool has_relative = true; +bool has_host_nodes = true; +QemuOpts *opts; +NumaMemOptions *object = NULL; +NumaNodePolicy policy = NUMA_NODE_POLICY_DEFAULT; +bool relative = false; +uint16List *host_nodes = NULL; + +uint64_t nodeid = qdict_get_int(qdict, nodeid); +const char *args = qdict_get_try_str(qdict, args); + +if (args == NULL) { +has_policy = false; +has_relative = false; +has_host_nodes = false; +} else { +opts = qemu_opts_parse(qemu_find_opts(numa), args, 1); +if (opts == NULL) { +monitor_printf(mon, Parsing memory policy args failed\n); +return; +} else { +OptsVisitor *ov = opts_visitor_new(opts); +visit_type_NumaMemOptions(opts_get_visitor(ov), object, NULL, + local_err); +opts_visitor_cleanup(ov); + +if (error_is_set(local_err)) { +goto error; +} + +has_policy = object-has_policy; +if (has_policy) { +policy = object-policy; +} +has_relative = object-has_relative; +if (has_relative) { +relative = object-relative; +} +has_host_nodes = object-has_host_nodes; +if (has_host_nodes) { +host_nodes = object-host_nodes; +} +} +} + +qmp_set_mem_policy(nodeid, has_policy, policy, has_relative, relative, + has_host_nodes, host_nodes, local_err); +error: Nitpick: this is executed on non-error path, so I'd call this label out. +if (object) { +QapiDeallocVisitor *dv = qapi_dealloc_visitor_new(); +visit_type_NumaMemOptions(qapi_dealloc_get_visitor(dv), + object, NULL, NULL); +qapi_dealloc_visitor_cleanup(dv); +} + +hmp_handle_error(mon, local_err); +} diff --git a/hmp.h b/hmp.h index 6c3bdcd..ae09525 100644 --- a/hmp.h +++ b/hmp.h @@ -87,5 +87,6 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict); void hmp_chardev_add(Monitor *mon, const QDict *qdict); void hmp_chardev_remove(Monitor *mon, const QDict *qdict); void hmp_qemu_io(Monitor *mon, const QDict *qdict); +void hmp_set_mem_policy(Monitor *mon, const QDict *qdict); #endif
Re: [Qemu-devel] [PATCH 1/6] q35: make pci window address/size match guest cfg
On Wed, 4 Sep 2013 13:48:29 +0300 Michael S. Tsirkin m...@redhat.com wrote: For Q35, MMCFG address and size are guest configurable. Update w32 property to make it behave accordingly. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- hw/pci-host/q35.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 4febd24..3f1d447 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -214,6 +214,16 @@ static void mch_update_pciexbar(MCHPCIState *mch) } addr = pciexbar addr_mask; pcie_host_mmcfg_update(pehb, enable, addr, length); +/* Leave enough space for the MCFG BAR */ +/* + * TODO: this matches current bios behaviour, but it's not a power of two, + * which means an MTRR can't cover it exactly. + */ +if (enable) { +mch-pci_info.w32.begin = addr + length; +} else { +mch-pci_info.w32.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT; +} } I probably miss something but where is remapping in system address space? If there is none then, then updated w32 might mismatch actually/initially mapped alias. /* PAM */
Re: [Qemu-devel] [PATCH 4/6] pci: add helper to retrieve the 64-bit range
On Wed, 4 Sep 2013 13:48:37 +0300 Michael S. Tsirkin m...@redhat.com wrote: Signed-off-by: Michael S. Tsirkin m...@redhat.com --- include/hw/pci/pci.h | 1 + hw/pci/pci.c | 43 +++ 2 files changed, 44 insertions(+) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 2374aa9..7be93ae 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -397,6 +397,7 @@ const char *pci_root_bus_path(PCIDevice *dev); PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn); int pci_qdev_find_device(const char *id, PCIDevice **pdev); PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root, const char *devaddr); +void pci_bus_get_w64_range(PCIBus *bus, Range *range); int pci_parse_devaddr(const char *addr, int *domp, int *busp, unsigned int *slotp, unsigned int *funcp); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 8c33352..d9f9bdf 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2257,6 +2257,49 @@ void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque) bus-iommu_opaque = opaque; } +static void pci_dev_get_w64(PCIBus *b, PCIDevice *dev, void *opaque) +{ +Range *range = opaque; +PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); +uint16_t cmd = pci_get_word(dev-config + PCI_COMMAND); +int r; + +if (!(cmd PCI_COMMAND_MEMORY)) { +return; +} + +if (pc-is_bridge) { +pcibus_t base = pci_bridge_get_base(dev, PCI_BASE_ADDRESS_MEM_PREFETCH); what guaranties that 'base' won't be below 4Gb and be above '4Gb + above_4g_mem_size'? +pcibus_t limit = pci_bridge_get_limit(dev, PCI_BASE_ADDRESS_MEM_PREFETCH); + +if (limit = base) { +Range pref_range; +pref_range.begin = base; +pref_range.end = limit + 1; +range_extend(range, pref_range); +} +} +for (r = 0; r PCI_NUM_REGIONS; ++r) { +PCIIORegion *region = dev-io_regions[r]; +Range region_range; + +if (!region-size || +(region-type PCI_BASE_ADDRESS_SPACE_IO) || +!(region-type PCI_BASE_ADDRESS_MEM_TYPE_64)) { +continue; +} +region_range.begin = pci_get_quad(dev-config + pci_bar(dev, r)); +region_range.end = region_range.begin + region-size; +range_extend(range, region_range); +} +} + +void pci_bus_get_w64_range(PCIBus *bus, Range *range) +{ +range-begin = range-end = 0; +pci_for_each_device_under_bus(bus, pci_dev_get_w64, range); +} + static const TypeInfo pci_device_type_info = { .name = TYPE_PCI_DEVICE, .parent = TYPE_DEVICE,
Re: [Qemu-devel] [RFC PATCH v4 5/6] configure: introduce --enable-modules
Il 10/09/2013 15:16, Fam Zheng ha scritto: +ifeq ($(CONFIG_MODULES),y) define add-modules $(foreach o,$(filter %.o,$($1)),$(eval \ $(patsubst %.o,%.mo,$o): $o)) @@ -146,6 +147,13 @@ dummy := $(call add-modules,common-obj-m) modules: $(patsubst %.mo,%$(DSOSUF),$(modules-m)) all: modules +else +block-obj-y += $(block-obj-m) +common-obj-y += $(common-obj-m) +block-obj-m := +common-obj-m := +endif + Should this be done in unnest-vars instead? Paolo
Re: [Qemu-devel] [PATCH 1/6] q35: make pci window address/size match guest cfg
On Tue, Sep 10, 2013 at 03:37:12PM +0200, Igor Mammedov wrote: On Wed, 4 Sep 2013 13:48:29 +0300 Michael S. Tsirkin m...@redhat.com wrote: For Q35, MMCFG address and size are guest configurable. Update w32 property to make it behave accordingly. Signed-off-by: Michael S. Tsirkin m...@redhat.com --- hw/pci-host/q35.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 4febd24..3f1d447 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -214,6 +214,16 @@ static void mch_update_pciexbar(MCHPCIState *mch) } addr = pciexbar addr_mask; pcie_host_mmcfg_update(pehb, enable, addr, length); +/* Leave enough space for the MCFG BAR */ +/* + * TODO: this matches current bios behaviour, but it's not a power of two, + * which means an MTRR can't cover it exactly. + */ +if (enable) { +mch-pci_info.w32.begin = addr + length; +} else { +mch-pci_info.w32.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT; +} } I probably miss something but where is remapping in system address space? If there is none then, then updated w32 might mismatch actually/initially mapped alias. /* PAM */ You mean mmcfg? The re-mapping is in hw/pci/pcie_host.c
Re: [Qemu-devel] [RFC PATCH v4 3/6] Makefile: introduce common-obj-m and block-obj-m for DSO
Il 10/09/2013 15:16, Fam Zheng ha scritto: Add necessary rules and flags for shared object generation. $(common-obj-m) will include $(block-obj-m), like $(common-obj-y) does for $(block-obj-y). The new rules introduced here are: 0) For all %.so compiling: QEMU_CFLAGS += -fPIC 1) %.o in $(common-obj-m) is compiled to %.o, then linked to %.so. 2) %.mo in $(common-obj-m) is the placeholder for %.so for pattern matching in Makefile. It's linked to -shared with all its dependencies (multiple *.o) as input. Which means the list of depended objects must be ruled out in each sub-Makefile.objs with: $(obj)/foo.mo : $(addprefix $(obj)/, bar.o baz.o qux.o) With target and dependencies both prefixed with $(obj)/. Just curious why you abandoned the foo.mo-objs idea. But anyway it can be implemented on top, together with dirs. Signed-off-by: Fam Zheng f...@redhat.com --- Makefile | 20 +++- Makefile.objs | 2 ++ configure | 6 ++ rules.mak | 26 +++--- 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 9e603c6..3685bbd 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,9 @@ dummy := $(call unnest-vars,, \ util-obj-y \ qga-obj-y \ block-obj-y \ -common-obj-y) +block-obj-m \ +common-obj-y \ +common-obj-m) Do block-obj-m and common-obj-m need to be expanded in Makefile.target too? Perhaps unnest-vars should automatically handle both -y and -m variants; possibly even call add-modules. Even though it would be unused in Makefile.target, it would keep all the logic in one place in rules.mak. ifneq ($(wildcard config-host.mak),) include $(SRC_PATH)/tests/Makefile @@ -133,6 +135,18 @@ endif all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all +define add-modules +$(foreach o,$(filter %.o,$($1)),$(eval \ + $(patsubst %.o,%.mo,$o): $o)) +$(eval modules-m += $(patsubst %.o,%.mo,$($1))) +endef + +dummy := $(call add-modules,block-obj-m) +dummy := $(call add-modules,common-obj-m) + +modules: $(patsubst %.mo,%$(DSOSUF),$(modules-m)) +all: modules + vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) @@ -249,6 +263,10 @@ clean: rm -f qemu-options.def find . -name '*.[oda]' -type f -exec rm -f {} + find . -name '*.l[oa]' -type f -exec rm -f {} + + find . -name '*.so' -type f -exec rm -f {} + + find . -name '*.mo' -type f -exec rm -f {} + + find . -name '*.dll' -type f -exec rm -f {} + + rm -f $(TOOLS) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~ rm -Rf .libs rm -f qemu-img-cmds.h diff --git a/Makefile.objs b/Makefile.objs index 4f7a364..023166b 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -19,6 +19,8 @@ block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o block-obj-y += qemu-coroutine-sleep.o block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o +block-obj-m = block/ + ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy) # Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add. # only pull in the actual virtio-9p device if we also enabled virtio. diff --git a/configure b/configure index cc3cd4d..c6d4a62 100755 --- a/configure +++ b/configure @@ -190,6 +190,8 @@ mingw32=no gcov=no gcov_tool=gcov EXESUF= +DSOSUF=.so +LDFLAGS_SHARED=-shared prefix=/usr/local mandir=\${prefix}/share/man datadir=\${prefix}/share @@ -485,6 +487,7 @@ OpenBSD) Darwin) bsd=yes darwin=yes + LDFLAGS_SHARED=-bundle if [ $cpu = x86_64 ] ; then QEMU_CFLAGS=-arch x86_64 $QEMU_CFLAGS LDFLAGS=-arch x86_64 $LDFLAGS @@ -584,6 +587,7 @@ fi if test $mingw32 = yes ; then EXESUF=.exe + DSOSUF=.dll QEMU_CFLAGS=-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) QEMU_CFLAGS=-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS @@ -4175,6 +4179,8 @@ echo LIBTOOLFLAGS=$LIBTOOLFLAGS $config_host_mak echo LIBS+=$LIBS $config_host_mak echo LIBS_TOOLS+=$libs_tools $config_host_mak echo EXESUF=$EXESUF $config_host_mak +echo DSOSUF=$DSOSUF $config_host_mak +echo LDFLAGS_SHARED=$LDFLAGS_SHARED $config_host_mak echo LIBS_QGA+=$libs_qga $config_host_mak echo POD2MAN=$POD2MAN $config_host_mak echo TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS $config_host_mak diff --git a/rules.mak b/rules.mak index 6342d60..2be7901 100644 --- a/rules.mak +++ b/rules.mak @@ -18,6 +18,10 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d QEMU_INCLUDES += -I$(D) -I$(@D) extract-libs = $(strip $(foreach o,$1,$($o-libs))) +expand-objs = $(strip $(sort $(filter %.o,$1)) \ + $(if $(realpath $(filter %.mo,$1)), \ + $(shell cat $(realpath $(filter %.mo,$1 \ Why