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

Add ports option #79

Merged
merged 10 commits into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion internal/gok/vmrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type vmRunConfig struct {
sudo string
targetStorageBytes int
arch string
netdev string
}

func (r *vmRunConfig) effectiveGoarch() string {
Expand All @@ -62,6 +63,7 @@ func init() {
vmRunCmd.Flags().StringVarP(&vmRunImpl.sudo, "sudo", "", "", "Whether to elevate privileges using sudo when required (one of auto, always, never, default auto)")
vmRunCmd.Flags().IntVarP(&vmRunImpl.targetStorageBytes, "target_storage_bytes", "", 1258299392, "Size of the disk image in bytes")
vmRunCmd.Flags().StringVarP(&vmRunImpl.arch, "arch", "", "", "architecture for which to build and run QEMU. One of 'amd64' or 'arm64'")
vmRunCmd.Flags().StringVarP(&vmRunImpl.netdev, "netdev", "", "user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::8022-:22", "QEMU -netdev argument")
vmRunCmd.Flags().BoolVarP(&vmRunImpl.keep, "keep", "", false, "keep ephemeral disk images around instead of deleting them when QEMU exits")
vmRunCmd.Flags().BoolVarP(&vmRunImpl.dry, "dryrun", "", false, "Whether to actually run QEMU or merely print the command")
vmRunCmd.Flags().BoolVarP(&vmRunImpl.graphic, "graphic", "", true, "Run QEMU in graphical mode?")
Expand Down Expand Up @@ -166,7 +168,7 @@ func (r *vmRunConfig) runQEMU(ctx context.Context, fullDiskImage string) error {
"-watchdog-action", "reset",
"-smp", strconv.Itoa(max(runtime.NumCPU(), 2)),
"-device", "e1000,netdev=net0",
"-netdev", "user,id=net0,hostfwd=tcp::8080-:80,hostfwd=tcp::8022-:22",
"-netdev", r.netdev,
"-m", "1024")

// Start in EFI mode (not legacy BIOS) so that we get a frame buffer (for
Expand Down