From patchwork Wed Sep 5 08:31:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 1406591 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8CC01DF264 for ; Wed, 5 Sep 2012 08:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758143Ab2IEIgO (ORCPT ); Wed, 5 Sep 2012 04:36:14 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:40454 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750990Ab2IEIgJ (ORCPT ); Wed, 5 Sep 2012 04:36:09 -0400 Received: by mail-we0-f174.google.com with SMTP id x8so223930wey.19 for ; Wed, 05 Sep 2012 01:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=Ajd0C/uC0ZP89MnZuFODovvqMl5g+D32TxxZQbHFBkk=; b=EnThitig2l6vXXdIODzyiXV60YeRJkzSwhydQpQAWtChSx2ehKWkV2LRG72v50FPjV Zp9rbd3aCp2NoeFebJauCpwFF/AUhxHusXGgcpC3Btq1c6uXPX6UsqWCMdZg/Z1KaBjo VWEt2PP8gO3jve72rl1wdYFF3KXntxcxWJIMbwPYKkTVNeH8RCNQZMPYIbaUSRPkh6TJ gidxv9Euc17zCcw3L3qCBo4JZy1nZ9wIHEB/4H2lSnqT+zJPLEz5HfwLhbzwbR8qUBVM omuE5JhIDAUhz+qTixaeVMjAW2KpLpFehmOOxOAvBIyXZ8yxBxu7wDpafHMOcaA7dpkq vjpg== Received: by 10.180.82.39 with SMTP id f7mr36484598wiy.2.1346834169116; Wed, 05 Sep 2012 01:36:09 -0700 (PDT) Received: from lappy.capriciverd.com (20.Red-80-59-140.staticIP.rima-tde.net. [80.59.140.20]) by mx.google.com with ESMTPS id q4sm27971068wix.9.2012.09.05.01.36.07 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 01:36:08 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: asias.hejun@gmail.com, mingo@elte.hu, gorcunov@openvz.org, kvm@vger.kernel.org, Sasha Levin Subject: [PATCH 19/33] kvm tools: virtio-bln init/exit Date: Wed, 5 Sep 2012 10:31:53 +0200 Message-Id: <1346833927-15740-20-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1346833927-15740-1-git-send-email-levinsasha928@gmail.com> References: <1346833927-15740-1-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Make the init/exit of virtio-balloon self-contained, so the global init code won't need to check if it was selected or not. Signed-off-by: Sasha Levin --- tools/kvm/builtin-run.c | 11 +++++++++-- tools/kvm/include/kvm/virtio-balloon.h | 3 ++- tools/kvm/virtio/balloon.c | 12 +++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index ed7babc..ec61696 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -1136,8 +1136,11 @@ static int kvm_cmd_run_init(int argc, const char **argv) goto fail; } - if (kvm->cfg.balloon) - virtio_bln__init(kvm); + r = virtio_bln__init(kvm); + if (r < 0) { + pr_err("virtio_rng__init() failed with error %d\n", r); + goto fail; + } if (!kvm->cfg.network) kvm->cfg.network = DEFAULT_NETWORK; @@ -1287,6 +1290,10 @@ static void kvm_cmd_run_exit(int guest_ret) if (r < 0) pr_warning("virtio_rng__exit() failed with error %d\n", r); + r = virtio_bln__exit(kvm); + if (r < 0) + pr_warning("virtio_bln__exit() failed with error %d\n", r); + r = virtio_console__exit(kvm); if (r < 0) pr_warning("virtio_console__exit() failed with error %d\n", r); diff --git a/tools/kvm/include/kvm/virtio-balloon.h b/tools/kvm/include/kvm/virtio-balloon.h index eb49fd4..844a1ba 100644 --- a/tools/kvm/include/kvm/virtio-balloon.h +++ b/tools/kvm/include/kvm/virtio-balloon.h @@ -3,6 +3,7 @@ struct kvm; -void virtio_bln__init(struct kvm *kvm); +int virtio_bln__init(struct kvm *kvm); +int virtio_bln__exit(struct kvm *kvm); #endif /* KVM__BLN_VIRTIO_H */ diff --git a/tools/kvm/virtio/balloon.c b/tools/kvm/virtio/balloon.c index ea64fd4..07852d7 100644 --- a/tools/kvm/virtio/balloon.c +++ b/tools/kvm/virtio/balloon.c @@ -243,8 +243,11 @@ struct virtio_ops bln_dev_virtio_ops = (struct virtio_ops) { .get_size_vq = get_size_vq, }; -void virtio_bln__init(struct kvm *kvm) +int virtio_bln__init(struct kvm *kvm) { + if (!kvm->cfg.balloon) + return 0; + kvm_ipc__register_handler(KVM_IPC_BALLOON, handle_mem); kvm_ipc__register_handler(KVM_IPC_STAT, virtio_bln__print_stats); @@ -256,4 +259,11 @@ void virtio_bln__init(struct kvm *kvm) if (compat_id == -1) compat_id = virtio_compat_add_message("virtio-balloon", "CONFIG_VIRTIO_BALLOON"); + + return 0; +} + +int virtio_bln__exit(struct kvm *kvm) +{ + return 0; }