[PATCH] mini-os: support event channel 0 for console

Juergen Gross posted 1 patch 2 years, 3 months ago
Failed in applying to current master (apply log)
console/xencons_ring.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] mini-os: support event channel 0 for console
Posted by Juergen Gross 2 years, 3 months ago
The console event channel might be 0 for the console, so use the value
of ~0 as invalid instead.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 console/xencons_ring.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/console/xencons_ring.c b/console/xencons_ring.c
index b6db74e..5c2573e 100644
--- a/console/xencons_ring.c
+++ b/console/xencons_ring.c
@@ -17,7 +17,7 @@
 DECLARE_WAIT_QUEUE_HEAD(console_queue);
 
 static struct xencons_interface *console_ring;
-uint32_t console_evtchn;
+uint32_t console_evtchn = ~0;
 
 static struct consfront_dev* resume_xen_console(struct consfront_dev* dev);
 
@@ -55,7 +55,7 @@ static inline void notify_daemon(struct consfront_dev *dev)
 
 static inline struct xencons_interface *xencons_interface(void)
 {
-    return console_evtchn ? console_ring : NULL;
+    return (console_evtchn != ~0) ? console_ring : NULL;
 } 
  
 int xencons_ring_send_no_notify(struct consfront_dev *dev, const char *data, unsigned len)
@@ -181,7 +181,7 @@ struct consfront_dev *xencons_ring_init(void)
 {
     struct consfront_dev *dev;
 
-    if (!console_evtchn)
+    if (console_evtchn != ~0)
         return 0;
 
     dev = malloc(sizeof(struct consfront_dev));
-- 
2.26.2


Re: [PATCH] mini-os: support event channel 0 for console
Posted by Jan Beulich 2 years, 3 months ago
On 06.12.2021 13:46, Juergen Gross wrote:
> The console event channel might be 0 for the console, so use the value
> of ~0 as invalid instead.

I may be missing something mini-os specific here, but in Xen channel 0
is always invalid. It's not just here that this value would be used as
a sentinel.

Jan


Re: [PATCH] mini-os: support event channel 0 for console
Posted by Juergen Gross 2 years, 3 months ago
On 06.12.21 14:24, Jan Beulich wrote:
> On 06.12.2021 13:46, Juergen Gross wrote:
>> The console event channel might be 0 for the console, so use the value
>> of ~0 as invalid instead.
> 
> I may be missing something mini-os specific here, but in Xen channel 0
> is always invalid. It's not just here that this value would be used as
> a sentinel.

This made me look at th domain creation paths again, and it seems as if
the parameter settings for HVM guests is split in an awful way: the
console ring page pfn is set from libxenguest, while the console event
channel is set from libxl only. :-(

This means that this patch can be dropped, while init-xenstore-domain
needs to gain another one.

Thanks for your feedback,


Juergen
Re: [PATCH] mini-os: support event channel 0 for console
Posted by Juergen Gross 2 years, 3 months ago
On 06.12.21 14:24, Jan Beulich wrote:
> On 06.12.2021 13:46, Juergen Gross wrote:
>> The console event channel might be 0 for the console, so use the value
>> of ~0 as invalid instead.
> 
> I may be missing something mini-os specific here, but in Xen channel 0
> is always invalid. It's not just here that this value would be used as
> a sentinel.

Maybe this is a special case for Xenstore stubdom. Without this change
I can't connect to the console when the system is up, with this patch
it is possible.


Juergen