Skip to content

Commit

Permalink
hvc_xen: introduce HVC_XEN_FRONTEND
Browse files Browse the repository at this point in the history
Introduce a new config option HVC_XEN_FRONTEND to enable/disable the
xenbus based pv console frontend.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Stefano Stabellini authored and Konrad Rzeszutek Wilk committed Mar 13, 2012
1 parent 02e19f9 commit cf8e019
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 54 deletions.
8 changes: 8 additions & 0 deletions drivers/tty/hvc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ config HVC_XEN
help
Xen virtual console device driver

config HVC_XEN_FRONTEND
bool "Xen Hypervisor Multiple Consoles support"
depends on HVC_XEN
select XEN_XENBUS_FRONTEND
default y
help
Xen driver for secondary virtual consoles

config HVC_UDBG
bool "udbg based fake hypervisor console"
depends on PPC && EXPERIMENTAL
Expand Down
116 changes: 62 additions & 54 deletions drivers/tty/hvc/hvc_xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ struct xencons_info {

static LIST_HEAD(xenconsoles);
static DEFINE_SPINLOCK(xencons_lock);
static struct xenbus_driver xencons_driver;

/* ------------------------------------------------------------------ */

Expand Down Expand Up @@ -298,53 +297,6 @@ static int xen_initial_domain_console_init(void)
return 0;
}

static int __init xen_hvc_init(void)
{
int r;
struct xencons_info *info;
const struct hv_ops *ops;

if (!xen_domain())
return -ENODEV;

if (xen_initial_domain()) {
ops = &dom0_hvc_ops;
r = xen_initial_domain_console_init();
if (r < 0)
return r;
info = vtermno_to_xencons(HVC_COOKIE);
} else {
ops = &domU_hvc_ops;
if (xen_hvm_domain())
r = xen_hvm_console_init();
else
r = xen_pv_console_init();
if (r < 0)
return r;

info = vtermno_to_xencons(HVC_COOKIE);
info->irq = bind_evtchn_to_irq(info->evtchn);
}
if (info->irq < 0)
info->irq = 0; /* NO_IRQ */
else
irq_set_noprobe(info->irq);

info->hvc = hvc_alloc(HVC_COOKIE, info->irq, ops, 256);
if (IS_ERR(info->hvc)) {
r = PTR_ERR(info->hvc);
spin_lock(&xencons_lock);
list_del(&info->list);
spin_unlock(&xencons_lock);
if (info->irq)
unbind_from_irqhandler(info->irq, NULL);
kfree(info);
return r;
}

return xenbus_register_frontend(&xencons_driver);
}

void xen_console_resume(void)
{
struct xencons_info *info = vtermno_to_xencons(HVC_COOKIE);
Expand Down Expand Up @@ -392,6 +344,9 @@ static int xen_console_remove(struct xencons_info *info)
return 0;
}

#ifdef CONFIG_HVC_XEN_FRONTEND
static struct xenbus_driver xencons_driver;

static int xencons_remove(struct xenbus_device *dev)
{
return xen_console_remove(dev_get_drvdata(&dev->dev));
Expand Down Expand Up @@ -543,6 +498,65 @@ static const struct xenbus_device_id xencons_ids[] = {
};


static DEFINE_XENBUS_DRIVER(xencons, "xenconsole",
.probe = xencons_probe,
.remove = xencons_remove,
.resume = xencons_resume,
.otherend_changed = xencons_backend_changed,
);
#endif /* CONFIG_HVC_XEN_FRONTEND */

static int __init xen_hvc_init(void)
{
int r;
struct xencons_info *info;
const struct hv_ops *ops;

if (!xen_domain())
return -ENODEV;

if (xen_initial_domain()) {
ops = &dom0_hvc_ops;
r = xen_initial_domain_console_init();
if (r < 0)
return r;
info = vtermno_to_xencons(HVC_COOKIE);
} else {
ops = &domU_hvc_ops;
if (xen_hvm_domain())
r = xen_hvm_console_init();
else
r = xen_pv_console_init();
if (r < 0)
return r;

info = vtermno_to_xencons(HVC_COOKIE);
info->irq = bind_evtchn_to_irq(info->evtchn);
}
if (info->irq < 0)
info->irq = 0; /* NO_IRQ */
else
irq_set_noprobe(info->irq);

info->hvc = hvc_alloc(HVC_COOKIE, info->irq, ops, 256);
if (IS_ERR(info->hvc)) {
r = PTR_ERR(info->hvc);
spin_lock(&xencons_lock);
list_del(&info->list);
spin_unlock(&xencons_lock);
if (info->irq)
unbind_from_irqhandler(info->irq, NULL);
kfree(info);
return r;
}

r = 0;
#ifdef CONFIG_HVC_XEN_FRONTEND
r = xenbus_register_frontend(&xencons_driver);
#endif
return r;
}

static void __exit xen_hvc_fini(void)
{
struct xencons_info *entry, *next;
Expand Down Expand Up @@ -580,12 +594,6 @@ static int xen_cons_init(void)
return 0;
}

static DEFINE_XENBUS_DRIVER(xencons, "xenconsole",
.probe = xencons_probe,
.remove = xencons_remove,
.resume = xencons_resume,
.otherend_changed = xencons_backend_changed,
);

module_init(xen_hvc_init);
module_exit(xen_hvc_fini);
Expand Down

0 comments on commit cf8e019

Please sign in to comment.