Skip to content

refactor: replace string concatenation in monitor CLI option construc… - #858

Open
singhshresth26 wants to merge 1 commit into
urunc-dev:mainfrom
singhshresth26:issue-844-refactor-monitor-cli
Open

refactor: replace string concatenation in monitor CLI option construc…#858
singhshresth26 wants to merge 1 commit into
urunc-dev:mainfrom
singhshresth26:issue-844-refactor-monitor-cli

Conversation

@singhshresth26

@singhshresth26 singhshresth26 commented Jul 29, 2026

Copy link
Copy Markdown

Description

This PR refactors the monitor/hypervisor command line arguments construction to use string slices directly instead of inefficient string concatenation.

Previously, monitors (such as HVT, SPT, QEMU, Firecracker, and Cloud Hypervisor) built their CLI options as a single space-separated string using cli += " option" and split it into a string slice at the end using strings.Split. This is inefficient because strings are immutable in Go, leading to unnecessary memory allocations, and the split operation adds overhead.

This PR:

  • Updates the Unikernel interface method MonitorNetCli to return []string instead of string.
  • Updates MonitorBlockArgs.ExactArgs and MonitorCliArgs.OtherArgs to use []string instead of string.
  • Updates all hypervisors to construct their arguments directly as slices of strings, avoiding all string concatenations and subsequent splits.

Related issues

How was this tested?

Compiled the packages and verified that unit tests build successfully targeting Linux:

  • go build ./pkg/unikontainers/... - Passed successfully.
  • go test -c ./pkg/unikontainers/... - Passed successfully.

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

@netlify

netlify Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit c87d026
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a69baecf65752000822d7d5

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.

Replace the string concatenation in the monitor command line construction

1 participant