From: Sasha Levin Date: Wed, 5 Sep 2012 08:31:52 +0000 (+0200) Subject: kvm tools: virtio-rng init/exit X-Git-Tag: next-20120910~8^2~11 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3b190952134bca2748b3902b57c646565107adcd;p=karo-tx-linux.git kvm tools: virtio-rng init/exit 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 Signed-off-by: Pekka Enberg --- diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index c9a7f208e011..906d7134ccfb 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 2b1ab39f34c3..91228e2fffb3 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;