From 54d50be688aba80e0fd5ba53f23a074a0ce2e381 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Mon, 14 Nov 2011 11:25:09 -0200 Subject: [PATCH 1/5] qapi: Check for negative enum values We don't currently check for negative enum values in qmp_output_type_enum(), this will very likely generate a segfault when triggered. However, it _seems_ that no code in tree can trigger this today. Acked-by: Michael Roth Signed-off-by: Luiz Capitulino --- qapi/qmp-output-visitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/qmp-output-visitor.c b/qapi/qmp-output-visitor.c index d67724ea4b..f76d0159cd 100644 --- a/qapi/qmp-output-visitor.c +++ b/qapi/qmp-output-visitor.c @@ -190,7 +190,7 @@ static void qmp_output_type_enum(Visitor *v, int *obj, const char *strings[], assert(strings); while (strings[i++] != NULL); - if (value >= i - 1) { + if (value < 0 || value >= i - 1) { error_set(errp, QERR_INVALID_PARAMETER, name ? name : "null"); return; } From 611b727374ad76fb0078ea65bc1387194913980e Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 16 Nov 2011 23:58:46 +0200 Subject: [PATCH 2/5] Makefile: remove more generated files on clean make clean missed the source qmp files generated by python. Fix that. Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini Signed-off-by: Luiz Capitulino --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 168093c6cf..b335f2a1ec 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ ifeq ($(TRACE_BACKEND),dtrace) GENERATED_HEADERS += trace-dtrace.h endif GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h +GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c ifneq ($(wildcard config-host.mak),) # Put the all: rule here so that config-host.mak can contain dependencies. @@ -227,6 +228,7 @@ clean: rm -f trace.c trace.h trace.c-timestamp trace.h-timestamp rm -f trace-dtrace.dtrace trace-dtrace.dtrace-timestamp rm -f trace-dtrace.h trace-dtrace.h-timestamp + rm -f $(GENERATED_SOURCES) rm -rf $(qapi-dir) $(MAKE) -C tests clean for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ From 599825c565f4e5f0790ff61ef14574b463e3b710 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 16 Nov 2011 23:58:18 +0200 Subject: [PATCH 3/5] Makefile: fix dependencies for generated .h, .c We have a single rule generating .c and .h files, so .h doesn't depend on .c: both depend on the source schema. Fix Makefile to reflect that - without this, if .c is there and .h is missing, Makefile does not know how to remake .h and assumes it's a dummy target, triggering endless rebuilds. Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini Signed-off-by: Luiz Capitulino --- Makefile | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index b335f2a1ec..a3c4bb4421 100644 --- a/Makefile +++ b/Makefile @@ -172,34 +172,34 @@ qapi-dir := qapi-generated test-visitor.o test-qmp-commands.o qemu-ga$(EXESUF): QEMU_CFLAGS += -I $(qapi-dir) qemu-ga$(EXESUF): LIBS = $(LIBS_QGA) -$(qapi-dir)/test-qapi-types.c: $(qapi-dir)/test-qapi-types.h -$(qapi-dir)/test-qapi-types.h: $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py +$(qapi-dir)/test-qapi-types.c $(qapi-dir)/test-qapi-types.h :\ +$(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py -o "$(qapi-dir)" -p "test-" < $<, " GEN $@") -$(qapi-dir)/test-qapi-visit.c: $(qapi-dir)/test-qapi-visit.h -$(qapi-dir)/test-qapi-visit.h: $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-visit.py +$(qapi-dir)/test-qapi-visit.c $(qapi-dir)/test-qapi-visit.h :\ +$(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-visit.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py -o "$(qapi-dir)" -p "test-" < $<, " GEN $@") -$(qapi-dir)/test-qmp-commands.h: $(qapi-dir)/test-qmp-marshal.c -$(qapi-dir)/test-qmp-marshal.c: $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py +$(qapi-dir)/test-qmp-commands.h $(qapi-dir)/test-qmp-marshal.c :\ +$(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py -o "$(qapi-dir)" -p "test-" < $<, " GEN $@") -$(qapi-dir)/qga-qapi-types.c: $(qapi-dir)/qga-qapi-types.h -$(qapi-dir)/qga-qapi-types.h: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-types.py +$(qapi-dir)/qga-qapi-types.c $(qapi-dir)/qga-qapi-types.h :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-types.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py -o "$(qapi-dir)" -p "qga-" < $<, " GEN $@") -$(qapi-dir)/qga-qapi-visit.c: $(qapi-dir)/qga-qapi-visit.h -$(qapi-dir)/qga-qapi-visit.h: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-visit.py +$(qapi-dir)/qga-qapi-visit.c $(qapi-dir)/qga-qapi-visit.h :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-visit.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py -o "$(qapi-dir)" -p "qga-" < $<, " GEN $@") -$(qapi-dir)/qga-qmp-commands.h: $(qapi-dir)/qga-qmp-marshal.c -$(qapi-dir)/qga-qmp-marshal.c: $(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-commands.py +$(qapi-dir)/qga-qmp-commands.h $(qapi-dir)/qga-qmp-marshal.c :\ +$(SRC_PATH)/qapi-schema-guest.json $(SRC_PATH)/scripts/qapi-commands.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py -o "$(qapi-dir)" -p "qga-" < $<, " GEN $@") -qapi-types.c: qapi-types.h -qapi-types.h: $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py +qapi-types.c qapi-types.h :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py -o "." < $<, " GEN $@") -qapi-visit.c: qapi-visit.h -qapi-visit.h: $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py +qapi-visit.c qapi-visit.h :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py -o "." < $<, " GEN $@") -qmp-commands.h: qmp-marshal.c -qmp-marshal.c: $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py +qmp-commands.h qmp-marshal.c :\ +$(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py -m -o "." < $<, " GEN $@") test-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y) From b1beac3db243b67711740340c3e3a3ac311aa76b Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 16 Nov 2011 23:58:24 +0200 Subject: [PATCH 4/5] Makefile: dependency fix qga/guest-agent-commands.c includes qga-qmp-commands.h, but it was missing in its dependencies. Add it in QGALIB_GEN. Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini Signed-off-by: Luiz Capitulino --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a3c4bb4421..c7f2cbdfff 100644 --- a/Makefile +++ b/Makefile @@ -208,7 +208,7 @@ test-visitor: test-visitor.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qap test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c test-qmp-commands.h) $(qapi-obj-y) test-qmp-commands: test-qmp-commands.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o $(qapi-dir)/test-qmp-marshal.o module.o -QGALIB_GEN=$(addprefix $(qapi-dir)/, qga-qapi-types.c qga-qapi-types.h qga-qapi-visit.c qga-qmp-marshal.c) +QGALIB_GEN=$(addprefix $(qapi-dir)/, qga-qapi-types.c qga-qapi-types.h qga-qapi-visit.c qga-qmp-marshal.c qga-qmp-commands.h) $(QGALIB_GEN): $(GENERATED_HEADERS) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) From 1b14254b4815a0ddf9c5b6094b6f6fccd7203fca Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 16 Nov 2011 23:58:31 +0200 Subject: [PATCH 5/5] Makefile: fix qga dependencies .c files include .h files, so .o depends on .h, and the linked result depends on .o. We got it wrong for qga rules, fix it up. Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini Signed-off-by: Luiz Capitulino --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c7f2cbdfff..7c93739604 100644 --- a/Makefile +++ b/Makefile @@ -208,11 +208,12 @@ test-visitor: test-visitor.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qap test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c test-qmp-commands.h) $(qapi-obj-y) test-qmp-commands: test-qmp-commands.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o $(qapi-dir)/test-qmp-marshal.o module.o -QGALIB_GEN=$(addprefix $(qapi-dir)/, qga-qapi-types.c qga-qapi-types.h qga-qapi-visit.c qga-qmp-marshal.c qga-qmp-commands.h) -$(QGALIB_GEN): $(GENERATED_HEADERS) -$(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) +QGALIB_OBJ=$(addprefix $(qapi-dir)/, qga-qapi-types.o qga-qapi-visit.o qga-qmp-marshal.o) +QGALIB_GEN=$(addprefix $(qapi-dir)/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) +$(QGALIB_OBJ): $(QGALIB_GEN) $(GENERATED_HEADERS) +$(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) $(GENERATED_HEADERS) -qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qobject-obj-y) $(version-obj-y) $(addprefix $(qapi-dir)/, qga-qapi-visit.o qga-qapi-types.o qga-qmp-marshal.o) +qemu-ga$(EXESUF): qemu-ga.o $(qga-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qobject-obj-y) $(version-obj-y) $(QGALIB_OBJ) QEMULIBS=libhw32 libhw64 libuser libdis libdis-user