mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-06-15 18:05:49 +00:00
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:
+9
-3
@@ -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);
|
||||
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user