Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-write argument parsing #35

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

jakecorrenti
Copy link
Member

@jakecorrenti jakecorrenti commented Feb 12, 2025

The previous method for parsing the command-line arguments required the device arguments, for example, to be in a hard-coded order, and they were all considered required. Additionally, if a specific argument was missing, or there were extra arguments, the error messages could be somewhat vague.

These changes allow for more granular error message, optional arguments that have a default value, and for the user to put the arguments in any particular order.

Fixes: #30

Adds `parse_args`, `check_required_args`, and
`check_unknown_args`.

Signed-off-by: Jake Correnti <[email protected]>
Updates the argument parsing for `virtio-blk` to use new helper
functions.

Makes the `format=` argument optional and provides the default value
`raw`.

Signed-off-by: Jake Correnti <[email protected]>
Updates virtio-net argument parsing to use new helper functions.

Signed-off-by: Jake Correnti <[email protected]>
Updates virtio-serial argument parsing to use the new helper functions

Signed-off-by: Jake Correnti <[email protected]>
Updates virtio-vsock argument parsing to use the new helper functions

Signed-off-by: Jake Correnti <[email protected]>
Updates virtio-fs argument parsing to use the new helper functions

Signed-off-by: Jake Correnti <[email protected]>
Updates virtio-input to use the new helper functions

Signed-off-by: Jake Correnti <[email protected]>
Updates virtio-gpu to use the new helper functions

Signed-off-by: Jake Correnti <[email protected]>
Updates the argument parsing in src/cmdline.rs to no longer use
`args_parse` or `val_parse`.

Signed-off-by: Jake Correnti <[email protected]>
@tylerfanelli
Copy link
Member

tylerfanelli commented Feb 12, 2025

The args needed to be in order for the virtio-blk arguments. The first virtio-blk arg was the root disk (krun_set_root_disk) and the second was the data disk (krun_set_data_disk). Otherwise, we had no way to deduce which was which. Is this no longer an issue?

@tylerfanelli
Copy link
Member

The previous method for parsing the command-line arguments required the device arguments, for example, to be in a hard-coded order, and they were all considered required.

Not all were required, I believe?

@jakecorrenti
Copy link
Member Author

jakecorrenti commented Feb 12, 2025

The args needed to be in order for the virtio-blk arguments. The first virtio-blk arg was the root disk (krun_set_root_disk) and the second was the data disk (krun_set_data_disk). Otherwise, we had no way to deduce which was which. Is this no longer an issue?

Maybe my phrasing here is wrong, but I'm talking about the order of the arguments for --device virtio-blk,format=raw,path=/home/jake/fedora.raw. You would be able to do either the path or the format first. This doesn't have to do with the ordering in which --virtio-blk for the root disk and --virtio-blk for the data disk are dealt with. AFAICT, that is

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.

breaking change: virtio-blk,format= is required
2 participants