fix(region): server add set network num queues (#24168)

This commit is contained in:
wanyaoqi
2026-02-01 20:13:11 +08:00
committed by GitHub
parent f7cb8a9b9e
commit 86475595af
4 changed files with 41 additions and 0 deletions

View File

@@ -152,6 +152,7 @@ func init() {
cmd.Get("screen-dump-show", new(options.ServerScreenDumpOptions))
cmd.Get("numa-info", new(options.ServerIdOptions))
cmd.BatchPerform("screen-dump", new(options.ServerIdsOptions))
cmd.Perform("set-network-num-queues", new(options.ServerSetNetworkNumQueues))
cmd.GetProperty(&options.ServerStatusStatisticsOptions{})
cmd.GetProperty(&options.ServerProjectStatisticsOptions{})

View File

@@ -730,6 +730,13 @@ func (input ServerDetachnetworkInput) IsForce() bool {
return input.Force != nil && *input.Force
}
type ServerSetNetworkNumQueuesInput struct {
// 虚机网卡 mac addr
MacAddr string `json:"mac_addr"`
// 网卡队列数
NumQueues int `json:"num_queues"`
}
type ServerMigrateForecastInput struct {
PreferHostId string `json:"prefer_host_id"`
// Deprecated

View File

@@ -4852,6 +4852,29 @@ func (self *SGuest) SaveRenewInfo(
return nil
}
func (self *SGuest) PerformSetNetworkNumQueues(
ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.ServerSetNetworkNumQueuesInput,
) (jsonutils.JSONObject, error) {
if self.Status != api.VM_READY {
return nil, httperrors.NewInvalidStatusError("can't set network num_queues on vm %s", self.Status)
}
if input.NumQueues < 1 {
return nil, httperrors.NewInputParameterError("invalid num_queues %d", input.NumQueues)
}
gn, err := self.GetGuestnetworkByMac(input.MacAddr)
if err != nil {
if errors.Cause(err) == sql.ErrNoRows {
return nil, httperrors.NewNotFoundError("guest network mac %s not found", input.MacAddr)
}
}
_, err = db.Update(gn, func() error {
gn.NumQueues = input.NumQueues
return nil
})
return nil, err
}
func (self *SGuest) PerformStreamDisksComplete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
disks, err := self.GetDisks()
if err != nil {

View File

@@ -1618,6 +1618,16 @@ func (o *ServerScreenDumpOptions) Params() (jsonutils.JSONObject, error) {
return jsonutils.Marshal(o), nil
}
type ServerSetNetworkNumQueues struct {
ServerIdOptions
MacAddr string `help:"server network mac addr"`
NumQueues int `help:"network num queues"`
}
func (o *ServerSetNetworkNumQueues) Params() (jsonutils.JSONObject, error) {
return jsonutils.Marshal(o), nil
}
type ServerIsoOptions struct {
ServerIdOptions
Ordinal int `help:"server iso ordinal, default 0"`