From patchwork Wed May 28 14:57:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Canet?= X-Patchwork-Id: 353493 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 008791400A8 for ; Thu, 29 May 2014 00:59:51 +1000 (EST) Received: from localhost ([::1]:42754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpfKX-0000gu-03 for incoming@patchwork.ozlabs.org; Wed, 28 May 2014 10:59:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpfId-0005pV-Cb for qemu-devel@nongnu.org; Wed, 28 May 2014 10:57:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WpfIV-0004gX-Vb for qemu-devel@nongnu.org; Wed, 28 May 2014 10:57:51 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:38138 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WpfIV-0004g8-MX for qemu-devel@nongnu.org; Wed, 28 May 2014 10:57:43 -0400 Received: from paradis.irqsave.net (unknown [192.168.77.254]) by paradis.irqsave.net (Postfix) with ESMTP id DD4859E6EC; Wed, 28 May 2014 16:57:41 +0200 (CEST) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Wed, 28 May 2014 16:57:35 +0200 Message-Id: <1401289058-9042-4-git-send-email-benoit.canet@irqsave.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1401289058-9042-1-git-send-email-benoit.canet@irqsave.net> References: <1401289058-9042-1-git-send-email-benoit.canet@irqsave.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 80.12.84.125 Cc: kwolf@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , Benoit Canet , armbru@redhat.com, lcapitulino@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [RFC 3/6] qemu-nbd: build QAPI block core into qemu-nbd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Compile and link QAPI block core code into qemu-nbd. This patch circle around unwanted dependecies by stubing some functions in qmp-stub.c. Signed-off-by: Benoit Canet --- Makefile | 33 +++++++++++++++++++++-- Makefile.objs | 4 +++ block/Makefile.objs | 11 +++++--- qmp-stub.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ qom/Makefile.objs | 9 ++++--- 5 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 qmp-stub.c diff --git a/Makefile b/Makefile index d830483..bd969ae 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,13 @@ ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) endif endif +GENERATED_BLOCK_HEADERS = block/qapi-generated/qmp-commands.h +GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-types.h +GENERATED_BLOCK_HEADERS += block/qapi-generated/qapi-visit.h +GENERATED_BLOCK_SOURCES = block/qapi-generated/qmp-marshal.c +GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-types.c +GENERATED_BLOCK_SOURCES += block/qapi-generated/qapi-visit.c + GENERATED_HEADERS = config-host.h qemu-options.def GENERATED_HEADERS += qmp-commands.h qapi-types.h qapi-visit.h GENERATED_SOURCES += qmp-marshal.c qapi-types.c qapi-visit.c @@ -136,6 +143,7 @@ dummy := $(call unnest-vars,, \ qga-vss-dll-obj-y \ block-obj-y \ block-obj-m \ + qapi-block-obj-y \ common-obj-y \ common-obj-m) @@ -212,7 +220,8 @@ util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)' qemu-img.o: qemu-img-cmds.h qemu-img$(EXESUF): qemu-img.o $(block-obj-y) libqemuutil.a libqemustub.a -qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a +qemu-nbd$(EXESUF): qemu-nbd.o $(block-obj-y) libqemuutil.a libqemustub.a \ + $(qapi-block-obj-y) qemu-io$(EXESUF): qemu-io.o $(block-obj-y) libqemuutil.a libqemustub.a qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o @@ -262,6 +271,22 @@ $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) $(gen-out-type) -o "." -m -i $<, \ " GEN $@") +block/qapi-generated/qapi-types.c block/qapi-generated/qapi-types.h :\ +$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \ + $(gen-out-type) -o block/qapi-generated -b -i $<, \ + " GEN $@") +block/qapi-generated/qapi-visit.c block/qapi-generated/qapi-visit.h :\ +$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \ + $(gen-out-type) -o block/qapi-generated -b -i $<, \ + " GEN $@") +block/qapi-generated/qmp-commands.h block/qapi-generated/qmp-marshal.c :\ +$(SRC_PATH)/qapi/block-core.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \ + $(gen-out-type) -o block/qapi-generated -m -i $<, \ + " GEN $@") + QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h) $(qga-obj-y) qemu-ga.o: $(QGALIB_GEN) @@ -282,8 +307,11 @@ clean: rm -f trace/generated-tracers-dtrace.h* rm -f $(foreach f,$(GENERATED_HEADERS),$(f) $(f)-timestamp) rm -f $(foreach f,$(GENERATED_SOURCES),$(f) $(f)-timestamp) + rm -f $(foreach f,$(GENERATED_BLOCK_HEADERS),$(f) $(f)-timestamp) + rm -f $(foreach f,$(GENERATED_BLOCK_SOURCES),$(f) $(f)-timestamp) rm -rf qapi-generated rm -rf qga/qapi-generated + rm -rf block/qapi-generated for d in $(ALL_SUBDIRS); do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \ @@ -548,7 +576,8 @@ endif # CONFIG_WIN # Add a dependency on the generated files, so that they are always # rebuilt before other object files ifneq ($(filter-out %clean,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) -Makefile: $(GENERATED_HEADERS) +Makefile: $(GENERATED_HEADERS) $(GENERATED_BLOCK_HEADERS)\ + $(GENERATED_BLOCK_SOURCES) endif # Include automatically generated dependency files diff --git a/Makefile.objs b/Makefile.objs index a8d8540..2c95a01 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -21,6 +21,10 @@ block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o block-obj-m = block/ +qapi-block-obj-y = block/qapi-generated/qmp-marshal.o blockdev.o qmp.o +qapi-block-obj-y += qmp-stub.o qemu-log.o +qapi-block-obj-y += block/ +qapi-block-obj-y += qom/ ###################################################################### # smartcard diff --git a/block/Makefile.objs b/block/Makefile.objs index fd88c03..a368e98 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -20,10 +20,13 @@ block-obj-$(CONFIG_GLUSTERFS) += gluster.o block-obj-$(CONFIG_LIBSSH2) += ssh.o endif -common-obj-y += stream.o -common-obj-y += commit.o -common-obj-y += mirror.o -common-obj-y += backup.o +block-job-obj-y = stream.o +block-job-obj-y += commit.o +block-job-obj-y += mirror.o +block-job-obj-y += backup.o + +common-obj-y += $(block-job-obj-y) +qapi-block-obj-y += $(block-job-obj-y) iscsi.o-cflags := $(LIBISCSI_CFLAGS) iscsi.o-libs := $(LIBISCSI_LIBS) diff --git a/qmp-stub.c b/qmp-stub.c new file mode 100644 index 0000000..77238f7 --- /dev/null +++ b/qmp-stub.c @@ -0,0 +1,77 @@ +/* + * QEMU monitor + * + * Copyright (c) 2003-2004 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/* this file contains function stubs and variables required to link + * monitor.o with something other than vl.o. + * It's used to link monitor.o with qemu-nbd and qemu-io. + */ + +#include "sysemu/sysemu.h" +#include "sysemu/kvm.h" +#include "sysemu/char.h" +#include "ui/console.h" + +bool is_daemonized(void) +{ + return 0; +} + +CharDriverState *vc_init(ChardevVC *vc) +{ + return NULL; +} + +void qemu_add_machine_init_done_notifier(Notifier *notify) +{ +} + +void kvm_cpu_synchronize_post_init(CPUState *cpu) +{ + +} + +void kvm_cpu_synchronize_state(CPUState *cpu) +{ +} + +int runstate_is_running(void) +{ + return 1; +} + +CharDriverState *qemu_chr_open_msmouse(void) +{ + return NULL; +} + +CharDriverState *serial_hds[MAX_SERIAL_PORTS]; + +struct CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus); + +bool kvm_allowed; + +int autostart; + +const uint32_t arch_type = -1; + diff --git a/qom/Makefile.objs b/qom/Makefile.objs index 985003b..a2ff669 100644 --- a/qom/Makefile.objs +++ b/qom/Makefile.objs @@ -1,3 +1,6 @@ -common-obj-y = object.o container.o qom-qobject.o -common-obj-y += cpu.o -common-obj-y += object_interfaces.o +qom-obj-y = object.o container.o qom-qobject.o +qom-obj-y += cpu.o +qom-obj-y += object_interfaces.o + +common-obj-y += $(qom-obj-y) +qapi-block-obj-y += $(qom-obj-y)