Skip to content

Re-write argument parsing#39

Merged
tylerfanelli merged 10 commits into
libkrun:mainfrom
jakecorrenti:default-image-format
Feb 28, 2025
Merged

Re-write argument parsing#39
tylerfanelli merged 10 commits into
libkrun:mainfrom
jakecorrenti:default-image-format

Conversation

@jakecorrenti
Copy link
Copy Markdown
Collaborator

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.

Closes: #30

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

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
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 <jakecorrenti+github@proton.me>
Updates virtio-net argument parsing to use new helper functions.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Updates virtio-serial argument parsing to use the new helper functions

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Updates virtio-vsock argument parsing to use the new helper functions

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Updates virtio-fs argument parsing to use the new helper functions

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Updates virtio-input to use the new helper functions

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Updates virtio-gpu to use the new helper functions

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
Updates the argument parsing in src/cmdline.rs to no longer use
`args_parse` or `val_parse`.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
@jakecorrenti
Copy link
Copy Markdown
Collaborator Author

@tylerfanelli PTAL

@tylerfanelli tylerfanelli merged commit 559160e into libkrun:main Feb 28, 2025
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