fix(host):no hpet and kvm=off (#24129)

* no hpet and kvm=off

* fix(host): get gpu qemu params

Signed-off-by: wanyaoqi <d3lx.yq@gmail.com>

---------

Signed-off-by: wanyaoqi <d3lx.yq@gmail.com>
This commit is contained in:
wanyaoqi
2026-02-02 20:15:12 +08:00
committed by GitHub
parent f4f83453e7
commit 5d2d64f842
2 changed files with 21 additions and 4 deletions

View File

@@ -422,6 +422,23 @@ func (s *SKVMGuestInstance) extraOptions() string {
return cmd
}
func (s *SKVMGuestInstance) hasGpu() bool {
manager := s.manager.GetHost().GetIsolatedDeviceManager()
isolatedDevices, _ := s.Desc.GetArray("isolated_devices")
for i := range isolatedDevices {
vendorDevId, _ := isolatedDevices[i].GetString("vendor_device_id")
addr, _ := isolatedDevices[i].GetString("addr")
dev := manager.GetDeviceByIdent(vendorDevId, addr)
if dev == nil {
continue
}
if dev.GetDeviceType() == api.GPU_VGA_TYPE || dev.GetDeviceType() == api.GPU_HPC_TYPE {
return true
}
}
return false
}
func (s *SKVMGuestInstance) _generateStartScript(data *jsonutils.JSONDict) (string, error) {
var (
uuid, _ = s.Desc.GetString("uuid")
@@ -560,7 +577,7 @@ function nic_mtu() {
}
}
if !guestManager.GetHost().IsNestedVirtualization() {
if s.hasGpu() {
cpuType += ",kvm=off"
}
@@ -588,6 +605,7 @@ function nic_mtu() {
cmd += " -daemonize"
cmd += " -nodefaults -nodefconfig"
cmd += " -no-kvm-pit-reinjection"
cmd += " -no-hpet"
cmd += " -global kvm-pit.lost_tick_policy=discard"
cmd += fmt.Sprintf(" -machine %s,accel=%s", s.getMachine(), accel)
cmd += " -k en-us"

View File

@@ -410,11 +410,10 @@ func getQemuParams(man *isolatedDeviceManager, devAddrs []string) *QemuParams {
continue
}
devType := dev.GetDeviceType()
devs, ok := devices[devType]
if !ok {
if _, ok := devices[devType]; !ok {
devices[devType] = []IDevice{dev}
} else {
devs = append(devs, dev)
devices[devType] = append(devices[devType], dev)
}
}