-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add support for multiple port forwarding parameters in QEMU startup script #2575
base: main
Are you sure you want to change the base?
Conversation
One thing that Im not sure about is where I should add the mention about it to the changelog file? 🤔 |
Yes please. In the
|
Build action triggered: https://github.com/flatcar/scripts/actions/runs/12712382397 |
build_library/qemu_template.sh
Outdated
for port in $PORT_FORWARDS; do | ||
host_port=$(echo "$port" | cut -d':' -f1) | ||
guest_port=$(echo "$port" | cut -d':' -f2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the ${PORT_FORWARDS}
notation (with brackets) for all variables (same goes for ${port}
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed. please check :)
build_library/qemu_template.sh
Outdated
@@ -84,6 +86,9 @@ while [ $# -ge 1 ]; do | |||
-p|-ssh-port) | |||
SSH_PORT="$2" | |||
shift 2 ;; | |||
-f|-forward-port) | |||
PORT_FORWARDS="${PORT_FORWARDS} $2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit-pick: what about using FORWARD_PORT
as variable name (to stay consistent with the flag name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't really have the same meaning as "SSH port" though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changelog/changes/2025-01-10-qemu-startup-script-port-forwarding.md
Outdated
Show resolved
Hide resolved
…ng.md Co-authored-by: Mathieu Tortuyaux <mathieu.tortuyaux@gmail.com>
Co-authored-by: Mathieu Tortuyaux <mathieu.tortuyaux@gmail.com>
build_library/qemu_template.sh
Outdated
@@ -84,6 +86,9 @@ while [ $# -ge 1 ]; do | |||
-p|-ssh-port) | |||
SSH_PORT="$2" | |||
shift 2 ;; | |||
-f|-forward-port) | |||
PORT_FORWARDS="${PORT_FORWARDS} $2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't really have the same meaning as "SSH port" though.
build_library/qemu_template.sh
Outdated
for port in $PORT_FORWARDS; do | ||
host_port=$(echo "$port" | cut -d':' -f1) | ||
guest_port=$(echo "$port" | cut -d':' -f2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not using shell built-ins makes me cry. 😛
for port in $PORT_FORWARDS; do | |
host_port=$(echo "$port" | cut -d':' -f1) | |
guest_port=$(echo "$port" | cut -d':' -f2) | |
for port in ${PORT_FORWARDS}; do | |
host_port=${port%:*} | |
guest_port=${port#*:} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Add support for multiple port forwarding parameters in QEMU startup script
This PR introduces a new feature to the
flatcar_qemu_startup.sh
script, allowing users to specify multiple port forwards using the-f
option. This enhancement improves the flexibility and usability of the script by enabling users to forward multiple ports from the host to the guest VM.Key Changes:
Added the
-f
option to specify port forwards in the formathost_port:guest_port
. Updated the script to process multiple-f
options and construct the appropriate QEMU command line arguments. Modified the usage instructions to include the new-f
option.How to Use:
To use the new port forwarding feature, specify the
-f
option followed by thehost_port:guest_port
pairs. Multiple-f
options can be used to forward multiple ports. For example:This command sets the VM memory to 6144 MB, forwards ports
25565
,25575
, and2223
, and uses a specified Ignition config file.Testing Done:
Verified that the script correctly processes multiple
-f
options and constructs the QEMU command line with the specified port forwards. Tested the script with various combinations of port forwards to ensure proper functionality. Example command used for testing:Confirmed that the VM starts with the specified port forwards and that the ports are accessible from the host.
changelog/
directory (user-facing change, bug fix, security fix, update)/boot
and/usr
size, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.