]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: virtio-bln init/exit
authorSasha Levin <levinsasha928@gmail.com>
Wed, 5 Sep 2012 08:31:53 +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-balloon 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/include/kvm/virtio-balloon.h
tools/kvm/virtio/balloon.c

index 906d7134ccfba78469d62320613a0ad6c4a5b700..236078aeda32499b05d1eb1a0b3c0117d1d83e45 100644 (file)
@@ -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);
index eb49fd48344f0782198b7bb31c20c2bd993efca8..844a1bab7e41a89b73fa5067a8a27a1655766558 100644 (file)
@@ -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 */
index ea64fd4ba0df0e9360f578714438759bbfaef303..07852d7c21423f5c0dcc46b14dcad6885aeb443e 100644 (file)
@@ -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;
 }