[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] Modify Hello World Example to Accept Input



On 25 July 2016 at 17:13, John P. McDermott (USN Civilian)
<john.mcdermott@xxxxxxxxxxxx> wrote:
> Mirage Developers,
>
> I have worked through most of the tutorials (very smooth by the way) but I 
> want to learn the Mirage idiom for accepting command line input. I thought I 
> would modify the Hello World example in mirage-skeleton/console, to read from 
> the guest console. Using my new rudimentary understanding of OCaml, I see the 
> example using function ‘log' with V1_LWT.CONSOLE to write to the guest 
> console.

Hi John,

Glad you liked the tutorials.

For reading, the key line is:

https://github.com/mirage/mirage/blob/fa3fbe352f6091dde25448a21c24e60f8203debf/types/V1.mli#L207

module type CONSOLE = sig
  ...
  include FLOW ...

This says that every console implements the FLOW interface. A FLOW
defines a `read` operation, which should do what you want:

https://github.com/mirage/mirage/blob/fa3fbe352f6091dde25448a21c24e60f8203debf/types/V1.mli#L149

> However, the V1_LWT.CONSOLE documentation says it is an ‘io' module. This 
> corresponds nicely to lwt_io, and to the code I see in my local 
> "lib/mirage-console/s.ml", but lwt_io does not have a log function.
>
> Is lwt_io even the right idiom, or should I be using something entirely 
> different to read from my Xen guest console?

The "io" after the type means that instead of reading and then
returning the text directly, the read operation returns a Lwt thread
which is performing the operation. This allows you to perform multiple
operations at the same time. Use >>= to wait for the actual value.


-- 
talex5 (GitHub/Twitter)        http://roscidus.com/blog/
GPG: 5DD5 8D70 899C 454A 966D  6A51 7513 3C8F 94F6 E0CC
GPG: DA98 25AE CAD0 8975 7CDA  BD8E 0713 3F96 CA74 D8BA

_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.