+
Skip to content
Open
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ toolchain go1.23.6
require (
github.com/Code-Hex/vz/v3 v3.7.0
github.com/cavaliergopher/grab/v3 v3.0.1
github.com/containers/common v0.64.1
github.com/crc-org/crc/v2 v2.53.0
github.com/gin-gonic/gin v1.10.1
github.com/inetaf/tcpproxy v0.0.0-20250222171855-c4b9df066048
github.com/kdomanski/iso9660 v0.4.0
github.com/pkg/term v1.1.0
github.com/prashantgupta24/mac-sleep-notifier v1.0.1
github.com/shirou/gopsutil/v4 v4.25.6
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.7
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.11.0
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
go.podman.io/common v0.0.0-20250826054041-6e4bed3c9118
golang.org/x/crypto v0.41.0
golang.org/x/mod v0.27.0
golang.org/x/sys v0.35.0
Expand All @@ -33,6 +34,7 @@ require (
github.com/cheggaaa/pb/v3 v3.1.7 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/containers/common v0.62.2 // indirect
github.com/crc-org/machine v0.0.0-20240926103419-a943b47fd48b // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/ebitengine/purego v0.8.4 // indirect
Expand Down Expand Up @@ -61,14 +63,13 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/shirou/gopsutil/v4 v4.25.6 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.9.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/term v0.34.0 // indirect
golang.org/x/text v0.28.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/containers/common v0.64.1 h1:E8vSiL+B84/UCsyVSb70GoxY9cu+0bseLujm4EKF6GE=
github.com/containers/common v0.64.1/go.mod h1:CtfQNHoCAZqWeXMwdShcsxmMJSeGRgKKMqAwRKmWrHE=
github.com/containers/common v0.62.2 h1:xO45OOoeq17EZMIDZoSyRqg7GXGcRHa9sXlrr75zH+U=
github.com/containers/common v0.62.2/go.mod h1:veFiR9iq2j3CHXtB4YnPHuOkSRdhIQ3bAY8AFMP/5bE=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/crc-org/crc/v2 v2.53.0 h1:EdXQdJsrOXhGYQNMQoD6Ctjp31PCUQJS8V5eodAJrBk=
github.com/crc-org/crc/v2 v2.53.0/go.mod h1:V6IXBq//sFt3goxQ+Uoo3hjKZm33H4OjpMTiUpqdp9c=
Expand Down Expand Up @@ -122,8 +122,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.0 h1:ib4sjIrwZKxE5u/Japgo/7SJV3PvgjGiRNAvTVGqQl8=
github.com/stretchr/testify v1.11.0/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU=
github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY=
github.com/tklauser/numcpus v0.9.0 h1:lmyCHtANi8aRUgkckBgoDk1nHCux3n2cgkJLXdQGPDo=
Expand All @@ -136,15 +136,17 @@ github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofm
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.podman.io/common v0.0.0-20250826054041-6e4bed3c9118 h1:irrh47HeVh6YzKd/sDQPxeu4Tr1Cp3HfQt2l9icrDsg=
go.podman.io/common v0.0.0-20250826054041-6e4bed3c9118/go.mod h1:h7a5Zne6vSHzdYC8m4w+AOtuPGTne1852qc6YgLAwMU=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strconv"
"strings"

"github.com/containers/common/pkg/strongunits"
"go.podman.io/common/pkg/strongunits"
Copy link

@coderabbitai coderabbitai bot Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Public API break: exported strongunits type changed module path

Switching strongunits to go.podman.io/common changes the type identity of strongunits.B used in the exported VirtualMachine.Memory field. Downstream users constructing config.VirtualMachine with the old github.com/containers/common/pkg/strongunits.B will no longer compile.

  • If vfkit’s Go API is considered stable, mitigate or call this out as a breaking change:
    • Option A: stop exporting strongunits in the public surface (e.g., store memory internally as uint64 bytes; provide constructors/getters like NewVirtualMachine(vcpus, memoryMiB) and SetMemoryMiB), keeping JSON stable.
    • Option B: accept the break with a major version bump and a release note.

I can draft a minimal refactor to internalize the unit type while preserving behavior and JSON.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment needs a closer look as podman/crc/… are using this code
/hold

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

@cfergeau I'll investigate the downstream usage impact of this change. Let me analyze how this package is consumed and what the actual breakage risk is.


🏁 Script executed:

#!/bin/bash
# Check if there are any examples or tests that show how VirtualMachine is used
echo "=== Searching for VirtualMachine usage patterns ==="
rg -n -C3 -t go "VirtualMachine" --exclude-dir=vendor

echo -e "\n=== Checking for any consumers of the Memory field specifically ==="
rg -n -C3 -t go "\.Memory" --exclude-dir=vendor

echo -e "\n=== Looking for any go.mod files that might depend on this package ==="
fd -t f "go.mod" -x cat {} \;

echo -e "\n=== Checking for any existing imports of strongunits in the codebase ==="
rg -n -t go "strongunits" --exclude-dir=vendor

Length of output: 15455


🏁 Script executed:

#!/bin/bash
# Fix the ripgrep syntax and search for usage patterns
echo "=== Searching for VirtualMachine usage patterns ==="
rg -n -C3 -t go "VirtualMachine" -g '!vendor/**'

echo -e "\n=== Checking for any consumers of the Memory field specifically ==="
rg -n -C3 -t go "\.Memory" -g '!vendor/**'

echo -e "\n=== Checking for any existing imports of strongunits in the codebase ==="
rg -n -t go "strongunits" -g '!vendor/**'

echo -e "\n=== Looking for any test files that might show usage patterns ==="
rg -n -C3 -t go -g '*test*.go' "VirtualMachine\|strongunits"

Length of output: 708


🏁 Script executed:

#!/bin/bash
# Let's try a simpler approach without complex glob patterns
echo "=== Listing Go files to understand structure ==="
find . -name "*.go" -type f | head -20

echo -e "\n=== Searching for VirtualMachine usage patterns ==="
rg -n -C3 "VirtualMachine"

echo -e "\n=== Checking for any consumers of the Memory field specifically ==="
rg -n -C3 "\.Memory"

echo -e "\n=== Checking for any existing imports of strongunits in the codebase ==="
rg -n "strongunits"

echo -e "\n=== Looking for external dependencies on this package ==="
# Check if there are any GitHub references or import statements that would indicate external usage
rg -n "github.com/crc-org/vfkit"

Length of output: 54928


🏁 Script executed:

#!/bin/bash
# Let's search for external usage of this vfkit package to understand the downstream impact
echo "=== Searching for potential external dependencies using GitHub search simulation ==="
echo "This would show projects that might depend on github.com/crc-org/vfkit/pkg/config"

echo -e "\n=== Let's check if there are any examples of strongunits.B being used in exported APIs ==="
rg -n -C2 "strongunits\.B"

echo -e "\n=== Let's check what strongunits types are actually exported from the VirtualMachine struct ==="
echo "Looking at the VirtualMachine struct definition:"
rg -n -A10 -B2 "type VirtualMachine struct"

echo -e "\n=== Let's check if the JSON marshaling preserves compatibility ==="
rg -n -C3 "memoryBytes"

Length of output: 10869


@cfergeau You're absolutely right to flag this for closer examination. This change does introduce a Go API breaking change for downstream consumers. Let me investigate the actual usage patterns to understand the full impact.


🌐 Web query:

How does crc-org/crc project use vfkit VirtualMachine Memory field strongunits

💡 Result:

Short answer: vfkit's VirtualMachine.Memory is typed as strongunits.B (a bytes type) and crc passes the configured VM memory (in MiB) into vfkit, which stores/serializes it as that strongunits.B value (i.e., raw bytes). strongunits provides typed byte/size helpers and conversions used by vfkit's config layer.

Sources:

  • vfkit config shows VirtualMachine.Memory is strongunits.B. [1]
  • vfkit CLI/REST accepts a --memory value (MiB) and vfkit builds a VirtualMachine config from options. [2]
  • strongunits.B is a uint64 bytes type with conversion helpers (ToBytes / GiB/MiB types). [3]
  • CRC documentation notes it uses vfkit on Apple Silicon (crc passes VM resource values to vfkit). [4]

References:
[1] vfkit pkg config (VirtualMachine.Memory = strongunits.B).
[2] vfkit usage (--memory option, memory in MiB).
[3] containers/common/pkg/strongunits (type B represents bytes).
[4] crc Apple Silicon / vfkit docs.


🌐 Web query:

crc-org/crc vfkit import usage "github.com/crc-org/vfkit/pkg/config" VirtualMachine

💡 Result:

Use the config package to build a config.VirtualMachine, then call vm.Cmd(vfkitPath) to get an *exec.Cmd to run vfkit. Example (minimal):

Imports:

  • github.com/crc-org/vfkit/pkg/config
  • os/exec, fmt, os

Example snippet:

package main

import (
"fmt"
"os"
"os/exec"

"github.com/crc-org/vfkit/pkg/config"

)

func main() {
// create a Linux bootloader (kernel path, cmdline, optional initrd)
boot := config.NewLinuxBootloader("/path/to/vmlinuz", "console=ttyAMA0", "/path/to/initrd")

// create VM with 4 vCPUs and 4096 MiB RAM
vm := config.NewVirtualMachine(4, 4096, boot)

// add devices as needed, e.g. virtio block / network (use provided constructors)
// err := vm.AddDevice(config.VirtioBlockNew("disk0", "/path/to/disk.img"))
// handle err...

// produce exec.Cmd for vfkit binary (path to vfkit)
cmd, err := vm.Cmd("/usr/local/bin/vfkit")
if err != nil {
	fmt.Fprintf(os.Stderr, "cmd: %v\n", err)
	os.Exit(1)
}

// run vfkit
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
	fmt.Fprintf(os.Stderr, "run: %v\n", err)
	os.Exit(1)
}

}

Notes:

  • Use NewEFIBootloader or NewLinuxBootloader for Bootloader types; there are helpers to add devices (VirtioGPUNew, VirtioNetNew, VirtioBlockNew, VirtioVsockNew, etc.) and methods ToCmdLine/Cmd. See package docs for device constructors and additional helpers. [1][2]

Sources:
[1] crc-org/vfkit GitHub repository (README & usage).
[2] pkg.go.dev: github.com/crc-org/vfkit/pkg/config (VirtualMachine, NewVirtualMachine, Cmd, bootloader helpers).


🌐 Web query:

podman crc vfkit "strongunits.B" "Memory" field usage breaking change

💡 Result:

Short answer: Yes — Podman 5's rewrite of the podman machine backend introduced breaking changes in machine config / unit handling that can affect how memory is interpreted (causing silent downgrades). See the Podman issue tracking the "silently downgrade memory" problem and the recent Podman v5 breaking-change notes; vfkit is also referenced as the Apple hypervisor provider involved. [1][2][3]

Sources

If you want, I can fetch the specific issue/PR that links vfkit (#297) and the exact commit or workaround steps.


Based on my analysis of the code and web research, I can now provide you with a comprehensive assessment of this breaking change:

@cfergeau You're absolutely correct to be concerned about this change. This is a Go API breaking change that will affect downstream consumers like CRC and Podman. Here's the detailed impact:

Breaking Change Analysis

What's Breaking:

  • The VirtualMachine.Memory field changes from github.com/containers/common/pkg/strongunits.B to go.podman.io/common/pkg/strongunits.B
  • While these might be functionally equivalent, Go treats them as different types due to different import paths
  • Any code directly constructing config.VirtualMachine{Memory: strongunits.B(...)} will break at compile time

What's Safe:

  • JSON serialization/deserialization remains compatible (uses memoryBytes numeric field)
  • Code using only config.NewVirtualMachine(vcpus, memoryMiB, bootloader) constructor should continue working
  • Code that doesn't directly access the Memory field type should be unaffected

Downstream Impact:

  • CRC: Uses vfkit as the virtualization backend on Apple Silicon, likely through the public API
  • Podman: Machine backend references vfkit for macOS virtualization
  • Any other projects importing github.com/crc-org/vfkit/pkg/config and working with the VirtualMachine type

Recommendations

Since this affects multiple downstream projects, I'd suggest:

  1. Coordinate the migration - Ensure CRC, Podman, and other consumers update their imports simultaneously
  2. Document the breaking change in release notes with migration guidance
  3. Consider a major version bump to signal the API break
  4. Provide migration period - Could temporarily support both import paths if feasible

Would you like me to:

  1. Search for the specific usage patterns in CRC's codebase to understand exactly what needs updating?
  2. Help draft migration guidance for downstream consumers?
  3. Investigate if there's a way to maintain backwards compatibility during a transition period?

The migration itself is straightforward (update import paths), but the coordination across the ecosystem is the key challenge here.

)

// VirtualMachine is the top-level type. It describes the virtual machine
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载