Skip to content

update block example#147

Merged
yomimono merged 3 commits intomirage:masterfrom
hannesm:block
Jul 2, 2016
Merged

update block example#147
yomimono merged 3 commits intomirage:masterfrom
hannesm:block

Conversation

@hannesm
Copy link
Copy Markdown
Member

@hannesm hannesm commented Jun 29, 2016

I stole^Wcherry-picked this commit from @Engil (and added the Makefile modifications myself)

@Drup
Copy link
Copy Markdown
Member

Drup commented Jun 29, 2016

Don't we want that in mirage directly ?

@Drup
Copy link
Copy Markdown
Member

Drup commented Jun 29, 2016

Actually, it's a very good example on how to have custom devices inside a config.ml, so it might be a good idea to keep it in skeleton ...

Comment thread block/config.ml
method clean i =
let dir = Info.root i in
Functoria_app.Cmd.run "rm %s/disk.img" dir
method module_name = "Functoria_runtime"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the module name is useless here, right?

Copy link
Copy Markdown
Member

@Drup Drup Jun 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. In those cases, my usual practice is to use "whichever module name is defined and mildly relevant".

We could define an empty module and use it for all those cases. Arguably we should have a way to express that, though ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe that should be set in base_configurable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have a default in base_configurable sounds sensible to me... it will break code, though (clients need method !module_name now).. I prepared a PR for functoria mirage/functoria#62 -- let me know what you think (this is independent from this PR: this improves the block example for current released stack ; certainly block should be updated once (a released) functoria provides a default module_name)

Comment thread block/config.ml

method clean i =
let dir = Info.root i in
Functoria_app.Cmd.run "rm -f %s/disk.img" dir
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Drup would be really nice if functoria provided a safe (array-based) alternative to run. String-interpolation + rm -f is not a good example to set... (will break if dir contains spaces or other special characters, etc).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@talex5 I agree. could we discuss this in the functoria issue tracker, instead of here, please?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know @samoht wanted to replace the various misc stuff by bos at some point. I don't know much about those APIs, it's probably a good idea, but please open a ticket and discuss it with him.

@hannesm
Copy link
Copy Markdown
Member Author

hannesm commented Jul 2, 2016

While this change raised some ideas to improve (mirage and functoria), it is good to merge as is (and already improves the block example by not needing an external shell script)!

@yomimono yomimono merged commit 8d54927 into mirage:master Jul 2, 2016
@yomimono
Copy link
Copy Markdown
Contributor

yomimono commented Jul 2, 2016

I agree with your assessment, @hannesm ! Thanks for upstreaming this improvement, and for starting a good discussion.

@hannesm hannesm deleted the block branch July 3, 2016 06:21
@hannesm hannesm mentioned this pull request Jul 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants