Merge pull request #1914 from devimc/topic/virtcontainers/supportSMPDie

virtcontainers: support SMP die
This commit is contained in:
Julio Montes
2019-07-26 18:03:56 -05:00
committed by GitHub
4 changed files with 40 additions and 7 deletions

4
Gopkg.lock generated
View File

@@ -391,11 +391,11 @@
revision = "2f1d1f20f75d5404f53b9edf6b53ed5505508675"
[[projects]]
digest = "1:6b643bd5e349019c33430301a3e5c38324c3014c423fe5e7cf857a8dd341efe2"
digest = "1:bba46c73858fda3e8066d66553615bd271f1ee811a0bf19f239ea2fb1e313f22"
name = "github.com/intel/govmm"
packages = ["qemu"]
pruneopts = "NUT"
revision = "52b2309a558fe89b3e81b85440144b535288ce4f"
revision = "e0505242c0670f1a522f5b2d827e4a7e4062a14d"
[[projects]]
digest = "1:36dfd4701e98a9d8371dd3053e32d4f29e82b07bcc9e655db82138f9273bcb0f"

View File

@@ -48,7 +48,7 @@
[[constraint]]
name = "github.com/intel/govmm"
revision = "52b2309a558fe89b3e81b85440144b535288ce4f"
revision = "e0505242c0670f1a522f5b2d827e4a7e4062a14d"
[[constraint]]
name = "github.com/kata-containers/agent"

View File

@@ -149,6 +149,7 @@ type QMPVersion struct {
type CPUProperties struct {
Node int `json:"node-id"`
Socket int `json:"socket-id"`
Die int `json:"die-id"`
Core int `json:"core-id"`
Thread int `json:"thread-id"`
}
@@ -1157,26 +1158,56 @@ func (q *QMP) ExecutePCIVFIOMediatedDeviceAdd(ctx context.Context, devID, sysfsd
return q.executeCommand(ctx, "device_add", args, nil)
}
// isSocketIDSupported returns if the cpu driver supports the socket id option
func isSocketIDSupported(driver string) bool {
if driver == "host-s390x-cpu" || driver == "host-powerpc64-cpu" {
return false
}
return true
}
// isThreadIDSupported returns if the cpu driver supports the thread id option
func isThreadIDSupported(driver string) bool {
if driver == "host-s390x-cpu" || driver == "host-powerpc64-cpu" {
return false
}
return true
}
// isDieIDSupported returns if the cpu driver and the qemu version support the die id option
func (q *QMP) isDieIDSupported(driver string) bool {
if (q.version.Major > 4 || (q.version.Major == 4 && q.version.Minor >= 1)) && driver == "host-x86_64-cpu" {
return true
}
return false
}
// ExecuteCPUDeviceAdd adds a CPU to a QEMU instance using the device_add command.
// driver is the CPU model, cpuID must be a unique ID to identify the CPU, socketID is the socket number within
// node/board the CPU belongs to, coreID is the core number within socket the CPU belongs to, threadID is the
// thread number within core the CPU belongs to. Note that socketID and threadID are not a requirement for
// architecures like ppc64le.
func (q *QMP) ExecuteCPUDeviceAdd(ctx context.Context, driver, cpuID, socketID, coreID, threadID, romfile string) error {
func (q *QMP) ExecuteCPUDeviceAdd(ctx context.Context, driver, cpuID, socketID, dieID, coreID, threadID, romfile string) error {
args := map[string]interface{}{
"driver": driver,
"id": cpuID,
"core-id": coreID,
}
if socketID != "" {
if socketID != "" && isSocketIDSupported(driver) {
args["socket-id"] = socketID
}
if threadID != "" {
if threadID != "" && isThreadIDSupported(driver) {
args["thread-id"] = threadID
}
if q.isDieIDSupported(driver) {
if dieID != "" {
args["die-id"] = dieID
}
}
if isVirtioPCI[DeviceDriver(driver)] {
args["romfile"] = romfile
}

View File

@@ -1307,6 +1307,7 @@ func (q *qemu) hotplugAddCPUs(amount uint32) (uint32, error) {
driver := hc.Type
cpuID := fmt.Sprintf("cpu-%d", len(q.state.HotpluggedVCPUs))
socketID := fmt.Sprintf("%d", hc.Properties.Socket)
dieID := fmt.Sprintf("%d", hc.Properties.Die)
coreID := fmt.Sprintf("%d", hc.Properties.Core)
threadID := fmt.Sprintf("%d", hc.Properties.Thread)
@@ -1314,9 +1315,10 @@ func (q *qemu) hotplugAddCPUs(amount uint32) (uint32, error) {
if machine.Type == "pseries" || machine.Type == "s390-ccw-virtio" {
socketID = ""
threadID = ""
dieID = ""
}
if err := q.qmpMonitorCh.qmp.ExecuteCPUDeviceAdd(q.qmpMonitorCh.ctx, driver, cpuID, socketID, coreID, threadID, romFile); err != nil {
if err := q.qmpMonitorCh.qmp.ExecuteCPUDeviceAdd(q.qmpMonitorCh.ctx, driver, cpuID, socketID, dieID, coreID, threadID, romFile); err != nil {
// don't fail, let's try with other CPU
continue
}