add option to detache the VM from CLI

This commit is contained in:
Artur Gurgul 2025-08-17 17:21:38 +02:00
parent 83a0f81cbe
commit 91a36e03a8
4 changed files with 58 additions and 4 deletions

View file

@ -58,6 +58,10 @@ module VirtualMachine
else
options[:arch] = System.arch_to_symbol(options[:arch])
end
if options[:detached] == nil
options[:detached] = false
end
end
def self.archive(options)
@ -90,7 +94,7 @@ module VirtualMachine
options[:arch],
disk_img_path,
cpus: [1, System.cpus - 2].max,
detach: true
detach: options[:detached]
)
end
@ -109,7 +113,8 @@ module VirtualMachine
disk_img_path,
cpus: [1, System.cpus - 2].max,
cdrom: path,
detach: true
detach: options[:detached],
display: DisplayMode.window
)
end
end

View file

@ -88,7 +88,7 @@ module Qemu
# for testing only
defaults[:detach] = false
defaults[:display] = DisplayMode.window
defaults[:display] = DisplayMode.fullscreen
opts = defaults.merge(options)
puts options
@ -112,7 +112,17 @@ module Qemu
else
#args += ["-device", "virtio-gpu-device"]
if opts[:display] == DisplayMode::fullscreen
args += ["-display", "cocoa,full-screen=on"]
#args += ["-display", "cocoa,full-screen=on"]
# attempts:
#args += ["-display", "cocoa,full-screen=on,retina=on"]
# brew install gtk+3 sdl2
# args += ["-display", "sdl,gl=on,full-screen=on"]
args += ["-device", "virtio-gpu-gl-pci"]
args += ["-display", "sdl,gl=on,full-screen=on"]
#args += ["-display", "gtk,gl=on,full-screen=on"]
#args += ["-display", "cocoa,full-screen=on"]
#args += ["-display", "cocoa,gl=es,full-screen=on"]
else
args += ["-display", "cocoa"]
end
@ -124,6 +134,13 @@ module Qemu
args += ["-device", "virtio-keyboard-device"]
args += ["-device", "virtio-mouse-device"]
args += ["-device", "virtio-gpu"]
#args += ['-nic', 'user,model=virtio-net-pci']
args += ["-device", "virtio-net,netdev=n0", "-netdev", "user,id=n0"]
# macOS vmnet (shares Macs LAN)
# -netdev vmnet-shared,id=n1 \
# -device virtio-net-pci,netdev=n1
end
# copy to /Users/artur/.cache/dat/vm/debian/arm64/debian/vars.fd