]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: virtio-rng init/exit
authorSasha Levin <levinsasha928@gmail.com>
Wed, 5 Sep 2012 08:31:52 +0000 (10:31 +0200)
committerPekka Enberg <penberg@kernel.org>
Wed, 5 Sep 2012 13:22:37 +0000 (16:22 +0300)
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 <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/builtin-run.c
tools/kvm/virtio/rng.c

index c9a7f208e011573db94737eb2872b79e6ca75e4c..906d7134ccfba78469d62320613a0ad6c4a5b700 100644 (file)
@@ -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);
index 2b1ab39f34c33c29ae502447ea3640a9b5117326..91228e2fffb3d73e0a03e52f2923f9a024ce1a6e 100644 (file)
@@ -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;