[PATCH 31/33] kvm tools: use init/exit where possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Switch to using init/exit calls instead of the repeating call blocks in builtin-run.

Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 tools/kvm/Makefile          |   1 +
 tools/kvm/builtin-run.c     | 246 +-------------------------------------------
 tools/kvm/disk/core.c       |   2 +
 tools/kvm/framebuffer.c     |   3 +
 tools/kvm/hw/i8042.c        |   1 +
 tools/kvm/hw/pci-shmem.c    |   2 +
 tools/kvm/hw/rtc.c          |   2 +
 tools/kvm/hw/serial.c       |   2 +
 tools/kvm/include/kvm/kvm.h |   2 +
 tools/kvm/ioeventfd.c       |   2 +
 tools/kvm/ioport.c          |   2 +
 tools/kvm/kvm-cpu.c         |   2 +
 tools/kvm/kvm-ipc.c         |   2 +
 tools/kvm/kvm.c             |   4 +
 tools/kvm/pci.c             |   2 +
 tools/kvm/symbol.c          |   4 +-
 tools/kvm/term.c            |   2 +
 tools/kvm/ui/sdl.c          |   7 +-
 tools/kvm/ui/vnc.c          |   7 +-
 tools/kvm/util/threadpool.c |   3 +
 tools/kvm/virtio/9p.c       |   1 +
 tools/kvm/virtio/balloon.c  |   2 +
 tools/kvm/virtio/blk.c      |   2 +
 tools/kvm/virtio/console.c  |   2 +
 tools/kvm/virtio/net.c      |   2 +
 tools/kvm/virtio/rng.c      |   2 +
 tools/kvm/virtio/scsi.c     |   2 +
 tools/kvm/x86/irq.c         |   2 +
 28 files changed, 66 insertions(+), 247 deletions(-)

diff --git a/tools/kvm/Makefile b/tools/kvm/Makefile
index efa3d4f..862e76b 100644
--- a/tools/kvm/Makefile
+++ b/tools/kvm/Makefile
@@ -84,6 +84,7 @@ OBJS	+= net/uip/buf.o
 OBJS	+= net/uip/csum.o
 OBJS	+= net/uip/dhcp.o
 OBJS	+= kvm-cmd.o
+OBJS	+= util/init.o
 OBJS	+= util/rbtree.o
 OBJS	+= util/threadpool.o
 OBJS	+= util/parse-options.o
diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 183aa42..bca9122 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -476,7 +476,6 @@ static int kvm_cmd_run_init(int argc, const char **argv)
 {
 	static char real_cmdline[2048], default_name[20];
 	unsigned int nr_online_cpus;
-	int r;
 
 	kvm = kvm__new();
 	if (IS_ERR(kvm))
@@ -646,160 +645,7 @@ static int kvm_cmd_run_init(int argc, const char **argv)
 	printf("  # %s run -k %s -m %Lu -c %d --name %s\n", KVM_BINARY_NAME,
 		kvm->cfg.kernel_filename, kvm->cfg.ram_size / 1024 / 1024, kvm->cfg.nrcpus, kvm->cfg.guest_name);
 
-	r = kvm__init(kvm);
-	if (r)
-		goto fail;
-
-	r = term_init(kvm);
-	if (r < 0) {
-		pr_err("term_init() failed with error %d\n", r);
-		goto fail;
-	}
-
-
-	r = ioeventfd__init(kvm);
-	if (r < 0) {
-		pr_err("ioeventfd__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = kvm_cpu__init(kvm);
-	if (r < 0) {
-		pr_err("kvm_cpu__init() failed with error %d\n", r);
-		goto fail;
-	}
-	
-	r = irq__init(kvm);
-	if (r < 0) {
-		pr_err("irq__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = pci__init(kvm);
-	if (r < 0) {
-		pr_err("pci__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = ioport__init(kvm);
-	if (r < 0) {
-		pr_err("ioport__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = disk_image__init(kvm);
-	if (r < 0) {
-		pr_err("disk_image__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = symbol_init(kvm);
-	if (r < 0)
-		pr_debug("symbol_init() failed with error %d\n", r);
-
-	r = rtc__init(kvm);
-	if (r < 0) {
-		pr_err("rtc__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = serial8250__init(kvm);
-	if (r < 0) {
-		pr_err("serial__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = virtio_blk__init(kvm);
-	if (r < 0) {
-		pr_err("virtio_blk__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = virtio_scsi_init(kvm);
-	if (r < 0) {
-		pr_err("virtio_scsi_init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = virtio_console__init(kvm);
-	if (r < 0) {
-		pr_err("virtio_console__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = virtio_rng__init(kvm);
-	if (r < 0) {
-		pr_err("virtio_rng__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = virtio_bln__init(kvm);
-	if (r < 0) {
-		pr_err("virtio_rng__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = virtio_9p__init(kvm);
-	if (r < 0) {
-		pr_err("virtio_9p__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = virtio_net__init(kvm);
-	if (r < 0) {
-		pr_err("virtio_net__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = kbd__init(kvm);
-	if (r < 0) {
-		pr_err("kbd__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = pci_shmem__init(kvm);
-	if (r < 0) {
-		pr_err("pci_shmem__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = vnc__init(kvm);
-	if (r < 0) {
-		pr_err("vnc__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = sdl__init(kvm);
-	if (r < 0) {
-		pr_err("sdl__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = fb__init(kvm);
-	if (r < 0) {
-		pr_err("fb__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	/* 
-	 * Device init all done; firmware init must
-	 * come after this (it may set up device trees etc.)
-	 */
-
-	r = kvm_timer__init(kvm);
-	if (r < 0) {
-		pr_err("kvm_timer__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-	r = thread_pool__init(kvm);
-	if (r < 0) {
-		pr_err("thread_pool__init() failed with error %d\n", r);
-		goto fail;
-	}
-
-fail:
-	return r;
+	return init_list__init(kvm);
 }
 
 static int kvm_cmd_run_work(void)
@@ -818,97 +664,9 @@ static int kvm_cmd_run_work(void)
 
 static void kvm_cmd_run_exit(int guest_ret)
 {
-	int r = 0;
-
 	compat__print_all_messages();
 
-	r = kvm_cpu__exit(kvm);
-	if (r < 0)
-		pr_warning("kvm_cpu__exit() failed with error %d\n", r);
-
-	r = symbol_exit(kvm);
-	if (r < 0)
-		pr_warning("symbol_exit() failed with error %d\n", r);
-
-	r = irq__exit(kvm);
-	if (r < 0)
-		pr_warning("irq__exit() failed with error %d\n", r);
-
-	r = kvm_timer__exit(kvm);
-	if (r < 0)
-		pr_warning("kvm_timer__exit() failed with error %d\n", r);
-
-	r = fb__exit(kvm);
-	if (r < 0)
-		pr_warning("kvm_timer__exit() failed with error %d\n", r);
-
-	r = virtio_net__exit(kvm);
-	if (r < 0)
-		pr_warning("virtio_net__exit() failed with error %d\n", r);
-
-	r = virtio_scsi_exit(kvm);
-	if (r < 0)
-		pr_warning("virtio_scsi_exit() failed with error %d\n", r);
-
-	r = virtio_blk__exit(kvm);
-	if (r < 0)
-		pr_warning("virtio_blk__exit() failed with error %d\n", r);
-
-	r = virtio_rng__exit(kvm);
-	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);
-
-	r = pci_shmem__exit(kvm);
-	if (r < 0)
-		pr_warning("pci_shmem__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);
-
-	r = serial8250__exit(kvm);
-	if (r < 0)
-		pr_warning("serial8250__exit() failed with error %d\n", r);
-
-	r = rtc__exit(kvm);
-	if (r < 0)
-		pr_warning("rtc__exit() failed with error %d\n", r);
-
-	r = kvm__arch_free_firmware(kvm);
-	if (r < 0)
-		pr_warning("kvm__arch_free_firmware() failed with error %d\n", r);
-
-	r = ioport__exit(kvm);
-	if (r < 0)
-		pr_warning("ioport__exit() failed with error %d\n", r);
-
-	r = ioeventfd__exit(kvm);
-	if (r < 0)
-		pr_warning("ioeventfd__exit() failed with error %d\n", r);
-
-	r = pci__exit(kvm);
-	if (r < 0)
-		pr_warning("pci__exit() failed with error %d\n", r);
-
-	r = term_exit(kvm);
-	if (r < 0)
-		pr_warning("pci__exit() failed with error %d\n", r);
-
-	r = thread_pool__exit(kvm);
-	if (r < 0)
-		pr_warning("thread_pool__exit() failed with error %d\n", r);
-
-	r = kvm__exit(kvm);
-	if (r < 0)
-		pr_warning("pci__exit() failed with error %d\n", r);
+	init_list__exit(kvm);
 
 	if (guest_ret == 0)
 		printf("\n  # KVM session ended normally.\n");
diff --git a/tools/kvm/disk/core.c b/tools/kvm/disk/core.c
index 639b7b3..b313b28 100644
--- a/tools/kvm/disk/core.c
+++ b/tools/kvm/disk/core.c
@@ -345,8 +345,10 @@ int disk_image__init(struct kvm *kvm)
 
 	return 0;
 }
+dev_base_init(disk_image__init);
 
 int disk_image__exit(struct kvm *kvm)
 {
 	return disk_image__close_all(kvm->disks, kvm->nr_disks);
 }
+dev_base_exit(disk_image__exit);
diff --git a/tools/kvm/framebuffer.c b/tools/kvm/framebuffer.c
index a9d6f75..fb8f51d 100644
--- a/tools/kvm/framebuffer.c
+++ b/tools/kvm/framebuffer.c
@@ -1,4 +1,5 @@
 #include "kvm/framebuffer.h"
+#include "kvm/kvm.h"
 
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -58,6 +59,7 @@ int fb__init(struct kvm *kvm)
 
 	return 0;
 }
+firmware_init(fb__init);
 
 int fb__exit(struct kvm *kvm)
 {
@@ -75,3 +77,4 @@ int fb__exit(struct kvm *kvm)
 
 	return 0;
 }
+firmware_exit(fb__exit);
diff --git a/tools/kvm/hw/i8042.c b/tools/kvm/hw/i8042.c
index fac54ca..5893d1d 100644
--- a/tools/kvm/hw/i8042.c
+++ b/tools/kvm/hw/i8042.c
@@ -352,3 +352,4 @@ int kbd__init(struct kvm *kvm)
 
 	return 0;
 }
+dev_init(kbd__init);
diff --git a/tools/kvm/hw/pci-shmem.c b/tools/kvm/hw/pci-shmem.c
index 47bb337..0eefa4e 100644
--- a/tools/kvm/hw/pci-shmem.c
+++ b/tools/kvm/hw/pci-shmem.c
@@ -396,8 +396,10 @@ int pci_shmem__init(struct kvm *kvm)
 			  mem);
 	return 0;
 }
+dev_init(pci_shmem__init);
 
 int pci_shmem__exit(struct kvm *kvm)
 {
 	return 0;
 }
+dev_exit(pci_shmem__exit);
diff --git a/tools/kvm/hw/rtc.c b/tools/kvm/hw/rtc.c
index 4941daf..dd6dca3 100644
--- a/tools/kvm/hw/rtc.c
+++ b/tools/kvm/hw/rtc.c
@@ -126,6 +126,7 @@ int rtc__init(struct kvm *kvm)
 
 	return r;
 }
+dev_init(rtc__init);
 
 int rtc__exit(struct kvm *kvm)
 {
@@ -135,3 +136,4 @@ int rtc__exit(struct kvm *kvm)
 
 	return 0;
 }
+dev_exit(rtc__exit);
diff --git a/tools/kvm/hw/serial.c b/tools/kvm/hw/serial.c
index 63dedd0..5348a92 100644
--- a/tools/kvm/hw/serial.c
+++ b/tools/kvm/hw/serial.c
@@ -432,6 +432,7 @@ cleanup:
 
 	return r;
 }
+dev_init(serial8250__init);
 
 int serial8250__exit(struct kvm *kvm)
 {
@@ -448,3 +449,4 @@ int serial8250__exit(struct kvm *kvm)
 
 	return 0;
 }
+dev_exit(serial8250__exit);
diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h
index 2cd30e4..f009695 100644
--- a/tools/kvm/include/kvm/kvm.h
+++ b/tools/kvm/include/kvm/kvm.h
@@ -3,6 +3,8 @@
 
 #include "kvm/kvm-arch.h"
 #include "kvm/kvm-config.h"
+#include "kvm/util-init.h"
+#include "kvm/kvm.h"
 
 #include <stdbool.h>
 #include <linux/types.h>
diff --git a/tools/kvm/ioeventfd.c b/tools/kvm/ioeventfd.c
index 742b008..a68d8d0 100644
--- a/tools/kvm/ioeventfd.c
+++ b/tools/kvm/ioeventfd.c
@@ -93,6 +93,7 @@ cleanup:
 
 	return r;
 }
+base_init(ioeventfd__init);
 
 int ioeventfd__exit(struct kvm *kvm)
 {
@@ -115,6 +116,7 @@ int ioeventfd__exit(struct kvm *kvm)
 
 	return 0;
 }
+base_exit(ioeventfd__exit);
 
 int ioeventfd__add_event(struct ioevent *ioevent, bool is_pio, bool poll_in_userspace)
 {
diff --git a/tools/kvm/ioport.c b/tools/kvm/ioport.c
index f5fb246..8d6e382 100644
--- a/tools/kvm/ioport.c
+++ b/tools/kvm/ioport.c
@@ -188,9 +188,11 @@ int ioport__init(struct kvm *kvm)
 
 	return 0;
 }
+dev_base_init(ioport__init);
 
 int ioport__exit(struct kvm *kvm)
 {
 	ioport__unregister_all();
 	return 0;
 }
+dev_base_exit(ioport__exit);
diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
index f712730..86d3b04 100644
--- a/tools/kvm/kvm-cpu.c
+++ b/tools/kvm/kvm-cpu.c
@@ -212,6 +212,7 @@ fail_alloc:
 		free(kvm->cpus[i]);
 	return -ENOMEM;
 }
+base_init(kvm_cpu__init);
 
 int kvm_cpu__exit(struct kvm *kvm)
 {
@@ -238,3 +239,4 @@ int kvm_cpu__exit(struct kvm *kvm)
 
 	return r;
 }
+late_exit(kvm_cpu__exit);
diff --git a/tools/kvm/kvm-ipc.c b/tools/kvm/kvm-ipc.c
index 70273c2..6b47270 100644
--- a/tools/kvm/kvm-ipc.c
+++ b/tools/kvm/kvm-ipc.c
@@ -477,6 +477,7 @@ err_epoll:
 err:
 	return ret;
 }
+base_init(kvm_ipc__init);
 
 int kvm_ipc__exit(struct kvm *kvm)
 {
@@ -494,3 +495,4 @@ int kvm_ipc__exit(struct kvm *kvm)
 
 	return ret;
 }
+base_exit(kvm_ipc__exit);
diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index cca2e93..20322a3 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -140,6 +140,7 @@ int kvm__exit(struct kvm *kvm)
 
 	return 0;
 }
+core_exit(kvm__exit);
 
 /*
  * Note: KVM_SET_USER_MEMORY_REGION assumes that we don't pass overlapping
@@ -274,6 +275,7 @@ err_free:
 err:
 	return ret;
 }
+core_init(kvm__init);
 
 /* RFC 1952 */
 #define GZIP_ID1		0x1f
@@ -375,6 +377,7 @@ int kvm_timer__init(struct kvm *kvm)
 
 	return 0;
 }
+firmware_init(kvm_timer__init);
 
 int kvm_timer__exit(struct kvm *kvm)
 {
@@ -386,6 +389,7 @@ int kvm_timer__exit(struct kvm *kvm)
 
 	return 0;
 }
+firmware_exit(kvm_timer__exit);
 
 void kvm__dump_mem(struct kvm *kvm, unsigned long addr, unsigned long size)
 {
diff --git a/tools/kvm/pci.c b/tools/kvm/pci.c
index 38f4778..fc4ad39 100644
--- a/tools/kvm/pci.c
+++ b/tools/kvm/pci.c
@@ -203,6 +203,7 @@ int pci__init(struct kvm *kvm)
 
 	return 0;
 }
+base_init(pci__init);
 
 int pci__exit(struct kvm *kvm)
 {
@@ -211,3 +212,4 @@ int pci__exit(struct kvm *kvm)
 
 	return 0;
 }
+base_exit(pci__exit);
diff --git a/tools/kvm/symbol.c b/tools/kvm/symbol.c
index b76d98b..07dd9d5 100644
--- a/tools/kvm/symbol.c
+++ b/tools/kvm/symbol.c
@@ -15,7 +15,7 @@ int symbol_init(struct kvm *kvm)
 	int ret = 0;
 
 	if (!kvm->vmlinux)
-		return -EINVAL;
+		return 0;
 
 	bfd_init();
 
@@ -38,6 +38,7 @@ int symbol_init(struct kvm *kvm)
 
 	return ret;
 }
+late_init(symbol_init);
 
 static asymbol *lookup(asymbol **symbols, int nr_symbols, const char *symbol_name)
 {
@@ -129,3 +130,4 @@ int symbol_exit(struct kvm *kvm)
 
 	return -EFAULT;
 }
+late_exit(symbol_exit);
diff --git a/tools/kvm/term.c b/tools/kvm/term.c
index 66f4804..d47a75e 100644
--- a/tools/kvm/term.c
+++ b/tools/kvm/term.c
@@ -163,8 +163,10 @@ int term_init(struct kvm *kvm)
 
 	return 0;
 }
+dev_init(term_init);
 
 int term_exit(struct kvm *kvm)
 {
 	return 0;
 }
+dev_exit(term_exit);
diff --git a/tools/kvm/ui/sdl.c b/tools/kvm/ui/sdl.c
index a041b3b..172a12b 100644
--- a/tools/kvm/ui/sdl.c
+++ b/tools/kvm/ui/sdl.c
@@ -309,8 +309,13 @@ int sdl__init(struct kvm *kvm)
 
 	return fb__attach(fb, &sdl_ops);
 }
+dev_init(sdl__init);
 
 int sdl__exit(struct kvm *kvm)
 {
-	return sdl__stop(NULL);
+	if (kvm->cfg.sdl)
+		return sdl__stop(NULL);
+
+	return 0;
 }
+dev_exit(sdl__exit);
diff --git a/tools/kvm/ui/vnc.c b/tools/kvm/ui/vnc.c
index d445059..efdc0f4 100644
--- a/tools/kvm/ui/vnc.c
+++ b/tools/kvm/ui/vnc.c
@@ -236,8 +236,13 @@ int vnc__init(struct kvm *kvm)
 
 	return fb__attach(fb, &vnc_ops);
 }
+dev_init(vnc__init);
 
 int vnc__exit(struct kvm *kvm)
 {
-	return vnc__stop(NULL);
+	if (kvm->cfg.vnc)
+		return vnc__stop(NULL);
+
+	return 0;
 }
+dev_exit(vnc__exit);
diff --git a/tools/kvm/util/threadpool.c b/tools/kvm/util/threadpool.c
index 6c7566d..24e2344 100644
--- a/tools/kvm/util/threadpool.c
+++ b/tools/kvm/util/threadpool.c
@@ -1,5 +1,6 @@
 #include "kvm/threadpool.h"
 #include "kvm/mutex.h"
+#include "kvm/kvm.h"
 
 #include <linux/kernel.h>
 #include <linux/list.h>
@@ -131,6 +132,7 @@ int thread_pool__init(struct kvm *kvm)
 
 	return i;
 }
+late_init(thread_pool__init);
 
 int thread_pool__exit(struct kvm *kvm)
 {
@@ -151,6 +153,7 @@ int thread_pool__exit(struct kvm *kvm)
 
 	return 0;
 }
+late_exit(thread_pool__exit);
 
 void thread_pool__do_job(struct thread_pool__job *job)
 {
diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c
index 0705d79..4864b2f 100644
--- a/tools/kvm/virtio/9p.c
+++ b/tools/kvm/virtio/9p.c
@@ -1404,6 +1404,7 @@ int virtio_9p__init(struct kvm *kvm)
 
 	return 0;
 }
+virtio_dev_init(virtio_9p__init);
 
 int virtio_9p__register(struct kvm *kvm, const char *root, const char *tag_name)
 {
diff --git a/tools/kvm/virtio/balloon.c b/tools/kvm/virtio/balloon.c
index b8192b5..d6bde32 100644
--- a/tools/kvm/virtio/balloon.c
+++ b/tools/kvm/virtio/balloon.c
@@ -262,8 +262,10 @@ int virtio_bln__init(struct kvm *kvm)
 
 	return 0;
 }
+virtio_dev_init(virtio_bln__init);
 
 int virtio_bln__exit(struct kvm *kvm)
 {
 	return 0;
 }
+virtio_dev_exit(virtio_bln__exit);
diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c
index 98f17a2..cff38aa 100644
--- a/tools/kvm/virtio/blk.c
+++ b/tools/kvm/virtio/blk.c
@@ -299,6 +299,7 @@ int virtio_blk__init(struct kvm *kvm)
 cleanup:
 	return virtio_blk__exit(kvm);
 }
+virtio_dev_init(virtio_blk__init);
 
 int virtio_blk__exit(struct kvm *kvm)
 {
@@ -311,3 +312,4 @@ int virtio_blk__exit(struct kvm *kvm)
 
 	return 0;
 }
+virtio_dev_exit(virtio_blk__exit);
diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c
index a1cb8f4..b4c0463 100644
--- a/tools/kvm/virtio/console.c
+++ b/tools/kvm/virtio/console.c
@@ -194,8 +194,10 @@ int virtio_console__init(struct kvm *kvm)
 
 	return 0;
 }
+virtio_dev_init(virtio_console__init);
 
 int virtio_console__exit(struct kvm *kvm)
 {
 	return 0;
 }
+virtio_dev_exit(virtio_console__exit);
diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c
index 4aca581..e6da7f8 100644
--- a/tools/kvm/virtio/net.c
+++ b/tools/kvm/virtio/net.c
@@ -663,8 +663,10 @@ int virtio_net__init(struct kvm *kvm)
 
 	return 0;
 }
+virtio_dev_init(virtio_net__init);
 
 int virtio_net__exit(struct kvm *kvm)
 {
 	return 0;
 }
+virtio_dev_exit(virtio_net__exit);
diff --git a/tools/kvm/virtio/rng.c b/tools/kvm/virtio/rng.c
index 91228e2..b2616d8 100644
--- a/tools/kvm/virtio/rng.c
+++ b/tools/kvm/virtio/rng.c
@@ -176,6 +176,7 @@ cleanup:
 
 	return r;
 }
+virtio_dev_init(virtio_rng__init);
 
 int virtio_rng__exit(struct kvm *kvm)
 {
@@ -189,3 +190,4 @@ int virtio_rng__exit(struct kvm *kvm)
 
 	return 0;
 }
+virtio_dev_exit(virtio_rng__exit);
diff --git a/tools/kvm/virtio/scsi.c b/tools/kvm/virtio/scsi.c
index c445f08..881898b 100644
--- a/tools/kvm/virtio/scsi.c
+++ b/tools/kvm/virtio/scsi.c
@@ -293,6 +293,7 @@ int virtio_scsi_init(struct kvm *kvm)
 cleanup:
 	return virtio_scsi_exit(kvm);
 }
+virtio_dev_init(virtio_scsi_init);
 
 int virtio_scsi_exit(struct kvm *kvm)
 {
@@ -305,3 +306,4 @@ int virtio_scsi_exit(struct kvm *kvm)
 
 	return 0;
 }
+virtio_dev_exit(virtio_scsi_exit);
diff --git a/tools/kvm/x86/irq.c b/tools/kvm/x86/irq.c
index e83df99..8dc90bf 100644
--- a/tools/kvm/x86/irq.c
+++ b/tools/kvm/x86/irq.c
@@ -172,6 +172,7 @@ int irq__init(struct kvm *kvm)
 
 	return 0;
 }
+dev_base_init(irq__init);
 
 int irq__exit(struct kvm *kvm)
 {
@@ -195,6 +196,7 @@ int irq__exit(struct kvm *kvm)
 
 	return 0;
 }
+dev_base_exit(irq__exit);
 
 int irq__add_msix_route(struct kvm *kvm, struct msi_msg *msg)
 {
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux