From patchwork Wed Sep 5 08:31:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 1406581 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 5E32ADF264 for ; Wed, 5 Sep 2012 08:36:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758131Ab2IEIgK (ORCPT ); Wed, 5 Sep 2012 04:36:10 -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 S1758115Ab2IEIgH (ORCPT ); Wed, 5 Sep 2012 04:36:07 -0400 Received: by mail-we0-f174.google.com with SMTP id x8so223930wey.19 for ; Wed, 05 Sep 2012 01:36:07 -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=A4iCJZTHf6DsQxnF/UL0T8KMAoK8A8CgLZcjrZqUcJY=; b=ENlij89rk8WDaijJ0z103yqHXz+yHrL5c4z/ftQv6AIX9RC8EF0PryTmGwGfwZHSgv 5sTRv80tNYo1OAAShrsFLHwn4vI0ZffZT4LMnmJwMXlthTb+pOE98xWMp8a7u+vjDMwR pVEyqYtEzmiyOY+eEUU7cJbzU4M6mkX6ERa99wTdPSi60l6whJCERQftxE65DU6CdzOk t+lrlutFv3FmRt5RBU2pfP0QawY2K3m3jvSHnANdR56Jl3sDJrN2wn1S8RQIDmg8c1gX xCsRaNLllRLMZkY2QBb6nRBqthrMtIwKRG0YK4LOVuq+LjjaaR7xFALfuUjxdeDalvGx G3rg== Received: by 10.180.80.134 with SMTP id r6mr36473286wix.1.1346834167137; Wed, 05 Sep 2012 01:36:07 -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.04 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 05 Sep 2012 01:36:06 -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 18/33] kvm tools: virtio-rng init/exit Date: Wed, 5 Sep 2012 10:31:52 +0200 Message-Id: <1346833927-15740-19-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-rng 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 | 7 +++++-- tools/kvm/virtio/rng.c | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index ef539b9a..ed7babc 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -1130,8 +1130,11 @@ static int kvm_cmd_run_init(int argc, const char **argv) goto fail; } - if (kvm->cfg.virtio_rng) - virtio_rng__init(kvm); + r = virtio_rng__init(kvm); + if (r < 0) { + pr_err("virtio_rng__init() failed with error %d\n", r); + goto fail; + } if (kvm->cfg.balloon) virtio_bln__init(kvm); diff --git a/tools/kvm/virtio/rng.c b/tools/kvm/virtio/rng.c index 2b1ab39..91228e2 100644 --- a/tools/kvm/virtio/rng.c +++ b/tools/kvm/virtio/rng.c @@ -147,6 +147,9 @@ int virtio_rng__init(struct kvm *kvm) struct rng_dev *rdev; int r; + if (!kvm->cfg.virtio_rng) + return 0; + rdev = malloc(sizeof(*rdev)); if (rdev == NULL) return -ENOMEM;