Konrad Rzeszutek Wilk
2012-Jan-23 18:32 UTC
[PATCH] xen/tmem: Return -ENODEV if the backends are not registered.
.. otherwise the driver might still reside in the memory consuming memory (that is the theory at least). CC: Dan Magenheimer <dan.magenheimer at oracle.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk at oracle.com> --- drivers/xen/tmem.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/xen/tmem.c b/drivers/xen/tmem.c index d369965..e61b5a3 100644 --- a/drivers/xen/tmem.c +++ b/drivers/xen/tmem.c @@ -377,8 +377,10 @@ static struct frontswap_ops tmem_frontswap_ops = { static int __init xen_tmem_init(void) { + bool loaded = false; + if (!xen_domain()) - return 0; + return -ENODEV; #ifdef CONFIG_FRONTSWAP if (tmem_enabled && use_frontswap) { char *s = ""; @@ -390,6 +392,7 @@ static int __init xen_tmem_init(void) s = " (WARNING: frontswap_ops overridden)"; printk(KERN_INFO "frontswap enabled, RAM provided by " "Xen Transcendent Memory\n"); + loaded = true; } #endif #ifdef CONFIG_CLEANCACHE @@ -402,9 +405,10 @@ static int __init xen_tmem_init(void) s = " (WARNING: cleancache_ops overridden)"; printk(KERN_INFO "cleancache enabled, RAM provided by " "Xen Transcendent Memory%s\n", s); + loaded = true; } #endif - return 0; + return loaded ? 0 : -ENODEV; } module_init(xen_tmem_init) -- 1.7.7.5> > Signed-off-by: Andrew Jones <drjones at redhat.com> > --- > drivers/xen/Kconfig | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig > index 1d24061..7e8d728 100644 > --- a/drivers/xen/Kconfig > +++ b/drivers/xen/Kconfig > @@ -143,7 +143,7 @@ config SWIOTLB_XEN > select SWIOTLB > > config XEN_TMEM > - bool > + bool "Xen Transcendent Memory (tmem)" > default y if (CLEANCACHE || FRONTSWAP) > help > Shim to interface in-kernel Transcendent Memory hooks > -- > 1.7.7.5