Add support for empty init arguments in the command line parser#176
Add support for empty init arguments in the command line parser#176jschlumpp wants to merge 2 commits intorust-vmm:mainfrom
Conversation
This can easily arise in automated scripts where the init args are sometimes empty but the `--` seperator is unconditionally added. Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
|
Hi @mschlumpp, diff --git a/src/cmdline/mod.rs b/src/cmdline/mod.rs
index 2ac7c31..5687ca3 100644
--- a/src/cmdline/mod.rs
+++ b/src/cmdline/mod.rs
@@ -487,6 +487,10 @@ impl Cmdline {
),
};
+ if boot_args.ends_with(INIT_ARGS_SEPARATOR.trim_end()) {
+ boot_args = &boot_args[..boot_args.len() - INIT_ARGS_SEPARATOR.trim().len()];
+ }
+
boot_args = boot_args.trim();
init_args = init_args.trim();Given that we already trim the trailing Other than that, we should also adjust the documentation of |
Summary of the PR
For automated scripts it is easier to keep the trailing
--separator than to separately check whether it is strictly necessary.Without this change the crate would include the trailing
--as a kernel argument. Downstream consumers such as firecracker then proceed to append further parameters to that string (mmio parameters). The final re-assembled string looked similar to this:<kernel params> -- <mmio-args>, therefore passing the mmio parameters not to the kernel but to the init part.Requirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s), and the commit message has max 60 characters for thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafecode is properly documented.