From 792324b35b903d87d0a3e5c8f1960645438b337b Mon Sep 17 00:00:00 2001 From: edi-oai Date: Tue, 8 Sep 2026 10:24:42 +0100 Subject: [PATCH] Make audio and clipboard sharing opt-in (#486) --- api/openapi.yaml | 12 ++++++++---- internal/command/create/vm.go | 12 ++++++------ internal/command/get/vm.go | 4 ++-- internal/worker/vmmanager/tart/tart.go | 4 ++-- pkg/resource/v1/v1.go | 4 ++-- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index 72ce064..598842c 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -766,13 +766,17 @@ components: type: boolean description: Enable nested virtualization default: false - noAudio: + audio: type: boolean - description: Whether to disable audio pass-through to the host + description: | + Whether to enable audio pass-through to the host for a Tart VM. + Disabled by default. This field cannot be changed after the VM is created. default: false - noClipboard: + clipboard: type: boolean - description: Whether to disable clipboard sharing between host and guest + description: | + Whether to enable clipboard sharing between host and guest for a Tart VM. + Disabled by default. This field cannot be changed after the VM is created. default: false username: type: string diff --git a/internal/command/create/vm.go b/internal/command/create/vm.go index dc5022f..b937dea 100644 --- a/internal/command/create/vm.go +++ b/internal/command/create/vm.go @@ -28,8 +28,8 @@ var netSoftnetBlock []string var netBridged string var headless bool var nested bool -var noAudio bool -var noClipboard bool +var audio bool +var clipboard bool var suspendable bool var username string var password string @@ -72,8 +72,8 @@ func newCreateVMCommand() *cobra.Command { command.Flags().StringVar(&netBridged, "net-bridged", "", "whether to use Bridged network mode") command.Flags().BoolVar(&headless, "headless", true, "whether to run without graphics") command.Flags().BoolVar(&nested, "nested", false, "enable nested virtualization") - command.Flags().BoolVar(&noAudio, "no-audio", false, "disable audio pass-through to the host") - command.Flags().BoolVar(&noClipboard, "no-clipboard", false, "disable clipboard sharing between host and guest") + command.Flags().BoolVar(&audio, "audio", false, "enable audio pass-through to the host") + command.Flags().BoolVar(&clipboard, "clipboard", false, "enable clipboard sharing between host and guest") command.Flags().BoolVar(&suspendable, "suspendable", false, "treat the VM as suspendable, "+ "disabling certain devices for suspendability support and issuing \"tart suspend\" instead of \"tart stop\" "+ "when VM's specification is updated, thus preserving the VM's state between specification generations") @@ -160,8 +160,8 @@ func runCreateVM(cmd *cobra.Command, args []string) error { NetBridged: netBridged, Headless: headless, Nested: nested, - NoAudio: noAudio, - NoClipboard: noClipboard, + Audio: audio, + Clipboard: clipboard, Username: username, Password: password, RandomSerial: randomSerial, diff --git a/internal/command/get/vm.go b/internal/command/get/vm.go index dadfbb0..2998117 100644 --- a/internal/command/get/vm.go +++ b/internal/command/get/vm.go @@ -98,8 +98,8 @@ func runGetVM(cmd *cobra.Command, args []string) error { table.AddRow("Bridged networking interface", nonEmptyOrNone(vm.NetBridged)) table.AddRow("Headless mode", vm.Headless) table.AddRow("Nested virtualization", vm.Nested) - table.AddRow("Audio disabled", vm.NoAudio) - table.AddRow("Clipboard sharing disabled", vm.NoClipboard) + table.AddRow("Audio enabled", vm.Audio) + table.AddRow("Clipboard sharing enabled", vm.Clipboard) table.AddRow("Status", vm.Status) table.AddRow("Status message", vm.StatusMessage) table.AddRow("Assigned worker", nonEmptyOrNone(vm.Worker)) diff --git a/internal/worker/vmmanager/tart/tart.go b/internal/worker/vmmanager/tart/tart.go index b0e157c..771b39a 100644 --- a/internal/worker/vmmanager/tart/tart.go +++ b/internal/worker/vmmanager/tart/tart.go @@ -364,11 +364,11 @@ func (vm *VM) run(ctx context.Context, eventStreamer *client.EventStreamer) { runArgs = append(runArgs, "--nested") } - if resource.NoAudio { + if !resource.Audio { runArgs = append(runArgs, "--no-audio") } - if resource.NoClipboard { + if !resource.Clipboard { runArgs = append(runArgs, "--no-clipboard") } diff --git a/pkg/resource/v1/v1.go b/pkg/resource/v1/v1.go index fd6d111..ae1e94f 100644 --- a/pkg/resource/v1/v1.go +++ b/pkg/resource/v1/v1.go @@ -36,8 +36,8 @@ type VM struct { NetBridged string `json:"net-bridged,omitempty"` Headless bool `json:"headless,omitempty"` Nested bool `json:"nested,omitempty"` - NoAudio bool `json:"noAudio,omitempty"` - NoClipboard bool `json:"noClipboard,omitempty"` + Audio bool `json:"audio,omitempty"` + Clipboard bool `json:"clipboard,omitempty"` VMSpec VMSpecReadOnly