From patchwork Wed Sep 5 08:31:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 1406731 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 27554DF264 for ; Wed, 5 Sep 2012 08:37:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758122Ab2IEIgI (ORCPT ); Wed, 5 Sep 2012 04:36:08 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:58173 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750990Ab2IEIgF (ORCPT ); Wed, 5 Sep 2012 04:36:05 -0400 Received: by wgbdr13 with SMTP id dr13so393355wgb.1 for ; Wed, 05 Sep 2012 01:36:04 -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=jz/jmjyiMfuGXHxqnHmL1m+GjPHKEBYbuhFBqBIBwOQ=; b=PznhUWzBC0ReKIO0QcZon/Sh0p3NtkeanteuPG5Q7de6+fC/uZC1JTpwF4w/Q6Cv2M 4lXzSbCKudRDMo9Ede6XXi5HwqM+dexd7VmEcGJ69oM4GsfRfZLyImnY6LugFyvOcmQv AvGUbYdq0P733y1aXUORAuDLeTmv6klsxsKNwKL8RxszI35JNPrcjz46ruXWNQm0czvL 8Il5u7NS7b4MY5Uio4uY+OVldeEu1l6KZhHWhta/NRxeA7mUFQiVabm1gIFL5dEFc52P pj37kZqyz75Y+7kZFx+0NP3iiEOc0iohp9laJm4on+fX+XCxEn2dPHtWqqz1099ZC2Vi 7tzQ== Received: by 10.180.104.197 with SMTP id gg5mr36428989wib.9.1346834164447; Wed, 05 Sep 2012 01:36:04 -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.01 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 01:36:03 -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 17/33] kvm tools: virtio-console init/exit Date: Wed, 5 Sep 2012 10:31:51 +0200 Message-Id: <1346833927-15740-18-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-console 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 | 12 +++++++++--- tools/kvm/include/kvm/virtio-console.h | 3 ++- tools/kvm/virtio/console.c | 12 +++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index f09aac8..ef539b9a 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -1124,9 +1124,11 @@ static int kvm_cmd_run_init(int argc, const char **argv) goto fail; } - - if (kvm->cfg.active_console == CONSOLE_VIRTIO) - virtio_console__init(kvm); + r = virtio_console__init(kvm); + if (r < 0) { + pr_err("virtio_console__init() failed with error %d\n", r); + goto fail; + } if (kvm->cfg.virtio_rng) virtio_rng__init(kvm); @@ -1282,6 +1284,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_console__exit(kvm); + if (r < 0) + pr_warning("virtio_console__exit() failed with error %d\n", r); + r = disk_image__exit(kvm); if (r < 0) pr_warning("disk_image__exit() failed with error %d\n", r); diff --git a/tools/kvm/include/kvm/virtio-console.h b/tools/kvm/include/kvm/virtio-console.h index 50d8653..8980920 100644 --- a/tools/kvm/include/kvm/virtio-console.h +++ b/tools/kvm/include/kvm/virtio-console.h @@ -3,7 +3,8 @@ struct kvm; -void virtio_console__init(struct kvm *kvm); +int virtio_console__init(struct kvm *kvm); void virtio_console__inject_interrupt(struct kvm *kvm); +int virtio_console__exit(struct kvm *kvm); #endif /* KVM__CONSOLE_VIRTIO_H */ diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c index 4a9ca9f..a1cb8f4 100644 --- a/tools/kvm/virtio/console.c +++ b/tools/kvm/virtio/console.c @@ -182,10 +182,20 @@ static struct virtio_ops con_dev_virtio_ops = (struct virtio_ops) { .get_size_vq = get_size_vq, }; -void virtio_console__init(struct kvm *kvm) +int virtio_console__init(struct kvm *kvm) { + if (kvm->cfg.active_console != CONSOLE_VIRTIO) + return 0; + virtio_init(kvm, &cdev, &cdev.vdev, &con_dev_virtio_ops, VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_CONSOLE, VIRTIO_ID_CONSOLE, PCI_CLASS_CONSOLE); if (compat_id == -1) compat_id = virtio_compat_add_message("virtio-console", "CONFIG_VIRTIO_CONSOLE"); + + return 0; +} + +int virtio_console__exit(struct kvm *kvm) +{ + return 0; }