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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/google/go-containerregistry v0.20.7
github.com/gorilla/websocket v1.5.3
github.com/itchyny/json2yaml v0.1.4
github.com/kernel/hypeman-go v0.28.0
github.com/kernel/hypeman-go v0.28.1-0.20260902143136-e6c2b7bc0171
github.com/knadh/koanf/parsers/yaml v1.1.0
github.com/knadh/koanf/providers/env v1.1.0
github.com/knadh/koanf/providers/file v1.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 h1:8Tjv8EJ+pM1xP8mK6egEbD1OgnV
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2/go.mod h1:pkJQ2tZHJ0aFOVEEot6oZmaVEZcRme73eIFmhiVuRWs=
github.com/itchyny/json2yaml v0.1.4 h1:/pErVOXGG5iTyXHi/QKR4y3uzhLjGTEmmJIy97YT+k8=
github.com/itchyny/json2yaml v0.1.4/go.mod h1:6iudhBZdarpjLFRNj+clWLAkGft+9uCcjAZYXUH9eGI=
github.com/kernel/hypeman-go v0.28.0 h1:1flQG6NfifaqrZsoU5LHydnVEUzaVdWt64/9JvEaOk8=
github.com/kernel/hypeman-go v0.28.0/go.mod h1:of8qI/nef2OPLzt0EMlIRbMdJHEvuc4yWG8g/ioNg48=
github.com/kernel/hypeman-go v0.28.1-0.20260902143136-e6c2b7bc0171 h1:psPDtnXBaPABqymQW5lu1o9YOF7gyyxJZeQOCqcuxyo=
github.com/kernel/hypeman-go v0.28.1-0.20260902143136-e6c2b7bc0171/go.mod h1:of8qI/nef2OPLzt0EMlIRbMdJHEvuc4yWG8g/ioNg48=
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
github.com/knadh/koanf/maps v0.1.2 h1:RBfmAW5CnZT+PJ1CVc1QSJKf4Xu9kxfQgYVQSu8hpbo=
Expand Down
13 changes: 13 additions & 0 deletions pkg/cmd/coveragecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ func TestParseInstanceWaitState(t *testing.T) {
})
}

func TestParseInstanceLogsSource(t *testing.T) {
t.Run("accepts mixed-case source names", func(t *testing.T) {
source, err := parseInstanceLogsSource("SwTpM")
require.NoError(t, err)
assert.Equal(t, hypeman.InstanceLogsParamsSourceSwtpm, source)
})

t.Run("rejects unsupported source names", func(t *testing.T) {
_, err := parseInstanceLogsSource("kernel")
require.EqualError(t, err, "invalid source: kernel (must be app, vmm, hypeman, or swtpm)")
})
}

func TestParseAutoStandbyPorts(t *testing.T) {
t.Run("parses valid port values", func(t *testing.T) {
ports, err := parseAutoStandbyPorts([]string{"80", " 443 "}, "ignore-destination-port")
Expand Down
24 changes: 22 additions & 2 deletions pkg/cmd/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"fmt"
"strings"

"github.com/kernel/hypeman-go"
"github.com/kernel/hypeman-go/option"
Expand All @@ -27,7 +28,7 @@ var logsCmd = cli.Command{
&cli.StringFlag{
Name: "source",
Aliases: []string{"s"},
Usage: "Log source: app (default), vmm (Cloud Hypervisor), or hypeman (operations log)",
Usage: "Log source: app (default), vmm (Cloud Hypervisor), hypeman (operations log), or swtpm (software TPM emulator)",
},
},
Action: handleLogs,
Expand Down Expand Up @@ -56,7 +57,11 @@ func handleLogs(ctx context.Context, cmd *cli.Command) error {
params.Tail = hypeman.Opt(int64(cmd.Int("tail")))
}
if cmd.IsSet("source") {
params.Source = hypeman.InstanceLogsParamsSource(cmd.String("source"))
source, err := parseInstanceLogsSource(cmd.String("source"))
if err != nil {
return err
}
params.Source = source
}

var opts []option.RequestOption
Expand All @@ -78,3 +83,18 @@ func handleLogs(ctx context.Context, cmd *cli.Command) error {

return stream.Err()
}

func parseInstanceLogsSource(raw string) (hypeman.InstanceLogsParamsSource, error) {
switch strings.ToLower(raw) {
case "app":
return hypeman.InstanceLogsParamsSourceApp, nil
case "vmm":
return hypeman.InstanceLogsParamsSourceVmm, nil
case "hypeman":
return hypeman.InstanceLogsParamsSourceHypeman, nil
case "swtpm":
return hypeman.InstanceLogsParamsSourceSwtpm, nil
default:
return "", fmt.Errorf("invalid source: %s (must be app, vmm, hypeman, or swtpm)", raw)
}
}
5 changes: 3 additions & 2 deletions pkg/cmd/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ func formatGPU(gpu hypeman.InstanceGPU) string {
if gpu.Profile != "" {
return gpu.Profile
}
// Check if mdev UUID is set (indicates vGPU without profile name shown)
if gpu.MdevUuid != "" {
// A vGPU is attached without a profile name shown. mdev_uuid is only populated on
// mdev hosts; vendor VFIO hosts report device_path instead.
if gpu.MdevUuid != "" || gpu.DevicePath != "" {
return "vgpu"
}
return "-"
Expand Down
7 changes: 7 additions & 0 deletions pkg/cmd/ps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ func TestFormatGPU(t *testing.T) {
},
expected: "vgpu",
},
{
name: "vGPU without profile but with device path",
gpu: hypeman.InstanceGPU{
DevicePath: "/sys/bus/pci/devices/0000:41:00.4",
},
expected: "vgpu",
},
}

for _, tt := range tests {
Expand Down
Loading