mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #5571 from wanyaoqi/hotfix/wyq/guest-add-metadata-cpu-mode
guest add metadata cpu mode
This commit is contained in:
@@ -150,6 +150,11 @@ const (
|
||||
HYPERVISOR_DEFAULT = HYPERVISOR_KVM
|
||||
)
|
||||
|
||||
const (
|
||||
CPU_MODE_QEMU = "qemu"
|
||||
CPU_MODE_HOST = "host"
|
||||
)
|
||||
|
||||
var VM_RUNNING_STATUS = []string{VM_START_START, VM_STARTING, VM_RUNNING, VM_BLOCK_STREAM, VM_BLOCK_STREAM_FAIL}
|
||||
var VM_CREATING_STATUS = []string{VM_CREATE_NETWORK, VM_CREATE_DISK, VM_START_DEPLOY, VM_DEPLOYING}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ type ScheduleInput struct {
|
||||
LiveMigrate bool `json:"live_migrate"`
|
||||
CpuDesc string `json:"cpu_desc"`
|
||||
CpuMicrocode string `json:"cpu_microcode"`
|
||||
CpuMode string `json:"cpu_mode"`
|
||||
|
||||
PendingUsages []jsonutils.JSONObject
|
||||
}
|
||||
|
||||
@@ -3151,7 +3151,7 @@ func (self *SGuest) createDiskOnStorage(ctx context.Context, userCred mcclient.T
|
||||
lockman.LockClass(ctx, QuotaManager, self.ProjectId)
|
||||
defer lockman.ReleaseClass(ctx, QuotaManager, self.ProjectId)
|
||||
|
||||
diskName := fmt.Sprintf("vdisk_%s_%d", self.Name, time.Now().UnixNano())
|
||||
diskName := fmt.Sprintf("vdisk-%s-%d", self.Name, time.Now().UnixNano())
|
||||
|
||||
billingType := billing_api.BILLING_TYPE_POSTPAID
|
||||
billingCycle := ""
|
||||
|
||||
@@ -59,9 +59,14 @@ func (self *GuestMigrateTask) GetSchedParams() (*schedapi.ScheduleInput, error)
|
||||
guestStatus, _ := self.Params.GetString("guest_status")
|
||||
if !jsonutils.QueryBoolean(self.Params, "is_rescue_mode", false) && (guestStatus == api.VM_RUNNING || guestStatus == api.VM_SUSPEND) {
|
||||
schedDesc.LiveMigrate = true
|
||||
host := guest.GetHost()
|
||||
schedDesc.CpuDesc = host.CpuDesc
|
||||
schedDesc.CpuMicrocode = host.CpuMicrocode
|
||||
if guest.GetMetadata("__cpu_mode", self.UserCred) != api.CPU_MODE_QEMU {
|
||||
host := guest.GetHost()
|
||||
schedDesc.CpuDesc = host.CpuDesc
|
||||
schedDesc.CpuMicrocode = host.CpuMicrocode
|
||||
schedDesc.CpuMode = api.CPU_MODE_HOST
|
||||
} else {
|
||||
schedDesc.CpuMode = api.CPU_MODE_QEMU
|
||||
}
|
||||
}
|
||||
return schedDesc, nil
|
||||
}
|
||||
|
||||
@@ -1294,6 +1294,11 @@ func (s *SKVMGuestInstance) OnResumeSyncMetadataInfo() {
|
||||
if options.HostOptions.HugepagesOption == "native" {
|
||||
meta.Set("__hugepage", jsonutils.NewString("native"))
|
||||
}
|
||||
if !options.HostOptions.HostCpuPassthrough || s.getOsname() == OS_NAME_MACOS {
|
||||
meta.Set("__cpu_mode", jsonutils.NewString(compute.CPU_MODE_QEMU))
|
||||
} else {
|
||||
meta.Set("__cpu_mode", jsonutils.NewString(compute.CPU_MODE_HOST))
|
||||
}
|
||||
if s.syncMeta != nil {
|
||||
meta.Update(s.syncMeta)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package guest
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/predicates"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
)
|
||||
@@ -45,7 +46,7 @@ func (p *MigratePredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor
|
||||
return h.GetResult()
|
||||
}
|
||||
|
||||
if schedData.LiveMigrate {
|
||||
if schedData.LiveMigrate && schedData.CpuMode != compute.CPU_MODE_QEMU {
|
||||
host := c.Getter().Host()
|
||||
if schedData.CpuDesc != host.CpuDesc {
|
||||
h.Exclude(predicates.ErrHostCpuModelIsNotMatchForLiveMigrate)
|
||||
|
||||
Reference in New Issue
Block a user