kvm tools: virtio-console init/exit

Make the init/exit of virtio-console 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>
This commit is contained in:
Sasha Levin
2012-09-05 10:31:51 +02:00
committed by Will Deacon
parent b4532ca933
commit a3fa3f86b8
3 changed files with 22 additions and 5 deletions
+9 -3
View File
@@ -1124,9 +1124,11 @@ static int kvm_cmd_run_init(int argc, const char **argv)
goto fail;
}
if (kvm->cfg.active_console == CONSOLE_VIRTIO)
virtio_console__init(kvm);
r = virtio_console__init(kvm);
if (r < 0) {
pr_err("virtio_console__init() failed with error %d\n", r);
goto fail;
}
if (kvm->cfg.virtio_rng)
virtio_rng__init(kvm);
@@ -1282,6 +1284,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_console__exit(kvm);
if (r < 0)
pr_warning("virtio_console__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);
+2 -1
View File
@@ -3,7 +3,8 @@
struct kvm;
void virtio_console__init(struct kvm *kvm);
int virtio_console__init(struct kvm *kvm);
void virtio_console__inject_interrupt(struct kvm *kvm);
int virtio_console__exit(struct kvm *kvm);
#endif /* KVM__CONSOLE_VIRTIO_H */
+11 -1
View File
@@ -182,10 +182,20 @@ static struct virtio_ops con_dev_virtio_ops = (struct virtio_ops) {
.get_size_vq = get_size_vq,
};
void virtio_console__init(struct kvm *kvm)
int virtio_console__init(struct kvm *kvm)
{
if (kvm->cfg.active_console != CONSOLE_VIRTIO)
return 0;
virtio_init(kvm, &cdev, &cdev.vdev, &con_dev_virtio_ops,
VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_CONSOLE, VIRTIO_ID_CONSOLE, PCI_CLASS_CONSOLE);
if (compat_id == -1)
compat_id = virtio_compat_add_message("virtio-console", "CONFIG_VIRTIO_CONSOLE");
return 0;
}
int virtio_console__exit(struct kvm *kvm)
{
return 0;
}