From 2e3332b4f486910d34bc53e37092bece11506b26 Mon Sep 17 00:00:00 2001 From: Jeffrey Cody Date: Tue, 20 Mar 2012 14:07:41 -0300 Subject: [RHEL6 qemu-kvm PATCH 21/21] Only build group snapshots if CONFIG_LIVE_SNAPSHOTS = y RH-Author: Jeffrey Cody Message-id: <2b66d4320429873848c066bfe676dce19df8675b.1332249823.git.jcody@redhat.com> Patchwork-id: 38648 O-Subject: [RHEL6.3 qemu-kvm PATCH v3 21/21] Only build group snapshots if CONFIG_LIVE_SNAPSHOTS = y Bugzilla: 784153 RH-Acked-by: Kevin Wolf RH-Acked-by: Paolo Bonzini RH-Acked-by: Markus Armbruster RHEL and RHEV have different binaries, where RHEV qemu-kvm binaries support live snapshots. Since group snapshots is a form of live snapshots, do some re-arranging so the JSON file can be excluded out as needed. The JSON files qapi-schema-rhel.json and qapi-schema-rhev.json are automatically generated from the qapi-schema.json, by looking for 'ifdef' comments in the 'master' JSON file. The Makefile variable RHEV_CONFIGS can be appended with additional config items that may appear in the qapi-schema.json file. For instance, to have features CONFIG_LIVE_SNAPSHOTS and CONFIG_SOME_FEATURE both be RHEV only, set the variable like so: RHEV_CONFIGS = CONFIG_LIVE_SNAPSHOTS CONFIG_SOME_FEATURE RHEV_CONFIGS is then turned into a regex. For the example above, the following pattern is matched when generating the RHEL/RHEV JSON files: ^#ifdef +(\bCONFIG_LIVE_SNAPSHOTS\b|\bCONFIG_SOME_FEATURE\b) The original qmp-commands.h header is used, and auto-generated to included the appropriate rhel-qmp-commands.h or rhev-qmp-commands.h Signed-off-by: Jeff Cody --- Makefile | 86 +++++++++++++++++++++++++++++++++++++++++++++++------- Makefile.objs | 10 +++++- blockdev.c | 2 + qapi-schema.json | 2 + qemu-monitor.hx | 2 + 5 files changed, 90 insertions(+), 12 deletions(-) Signed-off-by: Eduardo Habkost --- Makefile | 86 +++++++++++++++++++++++++++++++++++++++++++++++------- Makefile.objs | 10 +++++- blockdev.c | 2 + qapi-schema.json | 2 + qemu-monitor.hx | 2 + 5 files changed, 90 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 23d4c7f..a128447 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,17 @@ # Makefile for QEMU. +# useful for passing ' ' and ',' into Makefile functional calls, +# as these characters cannot be passed otherwise +_empty := +_space := $(_empty) $(_empty) +_comma := , + +qapi-dir := qapi-generated GENERATED_HEADERS = config-host.h trace.h config-all-devices.h ifeq ($(TRACE_BACKEND),dtrace) GENERATED_HEADERS += trace-dtrace.h endif -GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h - +GENERATED_HEADERS += qmp-commands.h ifneq ($(wildcard config-host.mak),) # Put the all: rule here so that config-host.mak can contain dependencies. @@ -21,6 +27,16 @@ config-host.mak: @exit 1 endif +ifeq ($(CONFIG_LIVE_SNAPSHOTS),y) +rhel_rhev_qmp_commands.h = rhev-qmp-commands.h +GENERATED_HEADERS += rhev-qmp-commands.h rhev-qapi-types.h rhev-qapi-visit.h +GENERATED_SOURCES += rhev-qmp-marshal.c rhev-qapi-types.c rhev-qapi-visit.c +else +rhel_rhev_qmp_commands.h = rhel-qmp-commands.h +GENERATED_HEADERS += rhel-qmp-commands.h rhel-qapi-types.h rhel-qapi-visit.h +GENERATED_SOURCES += rhel-qmp-marshal.c rhel-qapi-types.c rhel-qapi-visit.c +endif + # Don't try to regenerate Makefile or configure # We don't generate any of them Makefile: ; @@ -229,15 +245,60 @@ $(qapi-dir)/qga-suspend-qmp-commands.h $(qapi-dir)/qga-suspend-qmp-marshal.c :\ $(SRC_PATH)/qapi-schema-guest-suspend.json $(SRC_PATH)/scripts/qapi-commands.py $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o "$(qapi-dir)" -p "qga-suspend-" < $<, " GEN $@") -qapi-types.c: qapi-types.h -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 - $(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 - $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py -m -o "." < $<, " GEN $@") +rhev-qapi-types.c rhev-qapi-types.h :\ +qapi-schema-rhev.json $(SRC_PATH)/scripts/qapi-types.py + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." -p "rhev-" < $<, " GEN $@") +rhev-qapi-visit.c rhev-qapi-visit.h :\ +qapi-schema-rhev.json $(SRC_PATH)/scripts/qapi-visit.py + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." -p "rhev-" < $<, " GEN $@") +rhev-qmp-commands.h rhev-qmp-marshal.c :\ +qapi-schema-rhev.json $(SRC_PATH)/scripts/qapi-commands.py + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." -p "rhev-" < $<, " GEN $@") + +# if there are multiple config items to be RHEV-only, simply add it to +# RHEV_CONFIGS, like so: RHEV_CONFIGS = CONFIG_LIVE_SNAPSHOTS CONFIG_SOME_FEATURE +RHEV_CONFIGS = CONFIG_LIVE_SNAPSHOTS +# Turn $(RHEV_CONFIGS) into a regex with logical OR, and whole word matching +RHEV_ONLY_CONFIG_ITEMS = (\b$(subst $(_space),\b|\b,$(strip $(RHEV_CONFIGS)))\b) + +GENERATED_JSON_FILES = $(addprefix $(SRC_PATH)/, qapi-schema-rhel.json qapi-schema-rhev.json) + +qapi-schema-rhev.json: $(SRC_PATH)/qapi-schema.json + -@echo "# THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY" > $@ + -@echo "#" >> $@ + $(call quiet-command,sed -r "/^#ifdef +$(RHEV_ONLY_CONFIG_ITEMS)/d;/^#endif/d" $< >> $@, " GEN $@") + +qapi-schema-rhel.json: $(SRC_PATH)/qapi-schema.json + -@echo "# THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY" > $@ + -@echo "#" >> $@ + $(call quiet-command,sed -r "/^#ifdef +$(RHEV_ONLY_CONFIG_ITEMS)/$(_comma)/^#endif/d" $< >> $@, " GEN $@") + +rhel-qapi-types.c rhel-qapi-types.h :\ +qapi-schema-rhel.json $(SRC_PATH)/scripts/qapi-types.py + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "." -p "rhel-" < $<, " GEN $@") +rhel-qapi-visit.c rhel-qapi-visit.h :\ +qapi-schema-rhel.json $(SRC_PATH)/scripts/qapi-visit.py + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "." -p "rhel-" < $<, " GEN $@") +rhel-qmp-commands.h rhel-qmp-marshal.c :\ +qapi-schema-rhel.json $(SRC_PATH)/scripts/qapi-commands.py + $(call quiet-command,python $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -m -o "." -p "rhel-" < $<, " GEN $@") + +define QMP_COMMANDS_H +/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */ + +#ifndef QMP_COMMANDS_H +#define QMP_COMMANDS_H + +#include "$(rhel_rhev_qmp_commands.h)" + + +#endif +endef + +export QMP_COMMANDS_H +qmp-commands.h: $(rhel_rhev_qmp_commands.h) + $(call quiet-command, echo "$$QMP_COMMANDS_H" > $@, " 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) test-visitor: test-visitor.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o $(qapi-obj-y) error.o osdep.o qemu-malloc.o $(oslib-obj-y) qjson.o json-streamer.o json-lexer.o json-parser.o qerror.o qemu-error.o qemu-tool.o $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o @@ -263,6 +324,9 @@ clean: rm -f trace-dtrace.dtrace trace-dtrace.dtrace-timestamp rm -f trace-dtrace.h trace-dtrace.h-timestamp rm -rf $(qapi-dir) + rm -rf $(GENERATED_HEADERS) + rm -rf $(GENERATED_SOURCES) + rm -rf $(GENERATED_JSON_FILES) $(MAKE) -C tests clean for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ diff --git a/Makefile.objs b/Makefile.objs index bfb31bf..7086535 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -192,9 +192,16 @@ hw-obj-$(CONFIG_QDEV_ADDR) += qdev-addr.o qapi-nested-y = qapi-visit-core.o qmp-input-visitor.o qmp-output-visitor.o qapi-dealloc-visitor.o qapi-nested-y += qmp-registry.o qmp-dispatch.o + +ifeq ($(CONFIG_LIVE_SNAPSHOTS),y) +qapi-generated-y += rhev-qapi-visit.o rhev-qapi-types.o rhev-qmp-marshal.o +else +qapi-generated-y += rhel-qapi-visit.o rhel-qapi-types.o rhel-qmp-marshal.o +endif + qapi-obj-y = $(addprefix qapi/, $(qapi-nested-y)) -common-obj-y += qmp-marshal.o qapi-visit.o qapi-types.o $(qapi-obj-y) +common-obj-y += $(qapi-obj-y) $(qapi-generated-y) ###################################################################### # guest agent @@ -208,6 +215,7 @@ qga-obj-y += qemu-ga.o qemu-tool.o qemu-error.o module.o cutils.o osdep.o qga-obj-$(CONFIG_WIN32) += qemu-malloc.o qga-obj-$(CONFIG_POSIX) += qemu-malloc.o qemu-sockets.o qemu-option.o $(qga-nested-qapi-y) + vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) diff --git a/blockdev.c b/blockdev.c index bbd7635..574e85d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -914,6 +914,7 @@ out: } #endif +#ifdef CONFIG_LIVE_SNAPSHOTS /* New and old BlockDriverState structs for group snapshots */ typedef struct BlkGroupSnapshotStates { BlockDriverState *old_bs; @@ -1042,6 +1043,7 @@ exit: } return; } +#endif static void monitor_print_block_stream(Monitor *mon, const QObject *data) diff --git a/qapi-schema.json b/qapi-schema.json index 1287120..5fb482a 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2,6 +2,7 @@ # # QAPI Schema +#ifdef CONFIG_LIVE_SNAPSHOTS ## # @SnapshotDev # @@ -39,3 +40,4 @@ ## { 'command': 'blockdev-group-snapshot-sync', 'data': { 'devlist': [ 'SnapshotDev' ] } } +#endif diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 705ce86..17b7e91 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -1638,6 +1638,7 @@ STEXI Remove host-to-guest TCP or UDP redirection. ETEXI +#ifdef CONFIG_LIVE_SNAPSHOTS { .name = "blockdev-group-snapshot-sync", .args_type = "devlist:O", @@ -1645,6 +1646,7 @@ ETEXI .user_print = monitor_user_noop, .mhandler.cmd_new = qmp_marshal_input_blockdev_group_snapshot_sync, }, +#endif SQMP blockdev-group-snapshot-sync -- 1.7.3.2