diff --git a/go.mod b/go.mod index f5a79f2f3..32fde4f52 100644 --- a/go.mod +++ b/go.mod @@ -64,3 +64,5 @@ require ( golang.org/x/time v0.12.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) +replace github.com/mulgadc/viperblock => ../viperblock +replace github.com/mulgadc/predastore => ../predastore diff --git a/hive/daemon/daemon.go b/hive/daemon/daemon.go index b012b4b00..3b5eacaf5 100644 --- a/hive/daemon/daemon.go +++ b/hive/daemon/daemon.go @@ -1198,11 +1198,11 @@ func (d *Daemon) StartInstance(instance *vm.VM) error { Name: instance.ID, Daemonize: true, PIDFile: pidFile, - EnableKVM: true, - NoGraphic: false, - MachineType: "ubuntu", + EnableKVM: true, // If available, if kvm fails, will use cpu max + NoGraphic: true, + MachineType: "q35", Serial: "pty", - CPUType: "host", + CPUType: "host", // If available, if kvm fails, will use cpu max Memory: int(instanceType.MemoryGB) * 1024, CPUCount: instanceType.VCPUs, Architecture: instanceType.Architecture, diff --git a/hive/vm/vm.go b/hive/vm/vm.go index 2ba6656d9..070c39ba1 100644 --- a/hive/vm/vm.go +++ b/hive/vm/vm.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "fmt" "log/slog" + "os" "os/exec" "strconv" "strings" @@ -115,12 +116,29 @@ func (cfg *Config) Execute() (*exec.Cmd, error) { args = append(args, "-qmp", fmt.Sprintf("unix:%s,server,nowait", cfg.QMPSocket)) } - if cfg.EnableKVM { - args = append(args, "-enable-kvm") + // Validate native kvm support + _, err := os.Stat("/dev/kvm") + + if err != nil { + slog.Warn("Native KVM support not detected on host. Check permissions and host") + //slog.Warn("Setting -cpu max, `host` CPU type unavailable") + // Use qemu defaults + //args = append(args, "-cpu", "max") + + } else { + + if cfg.EnableKVM { + args = append(args, "-enable-kvm") + } + + if cfg.CPUType != "" { + args = append(args, "-cpu", cfg.CPUType) + } + } if cfg.NoGraphic { - args = append(args, "-nographic") + args = append(args, "-display none") } if cfg.MachineType != "" { @@ -131,10 +149,6 @@ func (cfg *Config) Execute() (*exec.Cmd, error) { args = append(args, "-serial", cfg.Serial) } - if cfg.CPUType != "" { - args = append(args, "-cpu", cfg.CPUType) - } - if cfg.CPUCount > 0 { args = append(args, "-smp", strconv.Itoa(cfg.CPUCount)) } else {