Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit e286c66

Browse files
committed
remove HotAddCpuMem
always treat it as true for x84 & arm64 always treat it as false for other arch currently. Signed-off-by: Lai Jiangshan <[email protected]>
1 parent 8a8b75e commit e286c66

File tree

8 files changed

+24
-53
lines changed

8 files changed

+24
-53
lines changed

factory/direct/direct.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ type directFactory struct {
1212

1313
func New(cpu, mem int, kernel, initrd string, vsock bool) base.Factory {
1414
b := hypervisor.BootConfig{
15-
CPU: cpu,
16-
Memory: mem,
17-
HotAddCpuMem: true,
18-
EnableVsock: vsock,
19-
Kernel: kernel,
20-
Initrd: initrd,
15+
CPU: cpu,
16+
Memory: mem,
17+
EnableVsock: vsock,
18+
Kernel: kernel,
19+
Initrd: initrd,
2120
}
2221
return &directFactory{config: b}
2322
}

hypervisor/driver.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
type BootConfig struct {
1414
CPU int
1515
Memory int
16-
HotAddCpuMem bool
1716
BootToBeTemplate bool
1817
BootFromTemplate bool
1918
EnableVsock bool

hypervisor/libvirt/libvirt.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ func (lc *LibvirtContext) domainXml(ctx *hypervisor.VmContext) (string, error) {
442442

443443
dom.OS.Supported = "yes"
444444
dom.OS.Type.Arch = "x86_64"
445-
dom.OS.Type.Machine = "pc-i440fx-2.0"
445+
dom.OS.Type.Machine = "pc-i440fx-2.1"
446446
dom.OS.Type.Content = "hvm"
447447

448448
dom.SecLabel.Type = "none"
@@ -460,19 +460,16 @@ func (lc *LibvirtContext) domainXml(ctx *hypervisor.VmContext) (string, error) {
460460
cmdline += " clocksource=acpi_pm notsc"
461461
}
462462

463-
if ctx.Boot.HotAddCpuMem {
464-
dom.OS.Type.Machine = "pc-i440fx-2.1"
465-
dom.VCpu.Content = hypervisor.DefaultMaxCpus
466-
dom.MaxMem = &maxmem{Unit: "MiB", Slots: "1", Content: hypervisor.DefaultMaxMem}
463+
dom.VCpu.Content = hypervisor.DefaultMaxCpus
464+
dom.MaxMem = &maxmem{Unit: "MiB", Slots: "1", Content: hypervisor.DefaultMaxMem}
467465

468-
cells := make([]cell, 1)
469-
cells[0].Id = "0"
470-
cells[0].Cpus = fmt.Sprintf("0-%d", hypervisor.DefaultMaxCpus-1)
471-
cells[0].Memory = strconv.Itoa(ctx.Boot.Memory * 1024) // older libvirt always considers unit='KiB'
472-
cells[0].Unit = "KiB"
466+
cells := make([]cell, 1)
467+
cells[0].Id = "0"
468+
cells[0].Cpus = fmt.Sprintf("0-%d", hypervisor.DefaultMaxCpus-1)
469+
cells[0].Memory = strconv.Itoa(ctx.Boot.Memory * 1024) // older libvirt always considers unit='KiB'
470+
cells[0].Unit = "KiB"
473471

474-
dom.CPU.Numa = &numa{Cell: cells}
475-
}
472+
dom.CPU.Numa = &numa{Cell: cells}
476473

477474
if ctx.Boot.EnableVsock {
478475
dom.XmlnsQemu = "http://libvirt.org/schemas/domain/qemu/1.0"

hypervisor/qemu/qemu_amd64.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package qemu
55
import (
66
"fmt"
77
"os"
8-
"strconv"
98

109
"github.com/golang/glog"
1110
"github.com/hyperhq/runv/hypervisor"
@@ -28,15 +27,9 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
2827
qc.cpus = boot.CPU
2928

3029
var machineClass, memParams, cpuParams string
31-
if boot.HotAddCpuMem || boot.BootToBeTemplate || boot.BootFromTemplate {
32-
machineClass = "pc-i440fx-2.1"
33-
memParams = fmt.Sprintf("size=%d,slots=1,maxmem=%dM", boot.Memory, hypervisor.DefaultMaxMem) // TODO set maxmem to the total memory of the system
34-
cpuParams = fmt.Sprintf("cpus=%d,maxcpus=%d", boot.CPU, hypervisor.DefaultMaxCpus) // TODO set it to the cpus of the system
35-
} else {
36-
machineClass = "pc-i440fx-2.0"
37-
memParams = strconv.Itoa(boot.Memory)
38-
cpuParams = strconv.Itoa(boot.CPU)
39-
}
30+
machineClass = "pc-i440fx-2.1"
31+
memParams = fmt.Sprintf("size=%d,slots=1,maxmem=%dM", boot.Memory, hypervisor.DefaultMaxMem) // TODO set maxmem to the total memory of the system
32+
cpuParams = fmt.Sprintf("cpus=%d,maxcpus=%d", boot.CPU, hypervisor.DefaultMaxCpus) // TODO set it to the cpus of the system
4033

4134
cmdline := "console=ttyS0 panic=1 no_timer_check"
4235
params := []string{
@@ -78,7 +71,7 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
7871
if boot.BootFromTemplate {
7972
params = append(params, "-S", "-incoming", fmt.Sprintf("exec:cat %s", boot.DevicesStatePath))
8073
}
81-
} else if boot.HotAddCpuMem {
74+
} else {
8275
nodeConfig := fmt.Sprintf("node,nodeid=0,cpus=0-%d,mem=%d", hypervisor.DefaultMaxCpus-1, boot.Memory)
8376
params = append(params, "-numa", nodeConfig)
8477
}

hypervisor/qemu/qemu_arm64.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,8 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
3939
}
4040

4141
var memParams, cpuParams string
42-
if boot.HotAddCpuMem {
43-
memParams = fmt.Sprintf("size=%d,slots=1,maxmem=%dM", boot.Memory, hypervisor.DefaultMaxMem)
44-
cpuParams = fmt.Sprintf("cpus=%d,maxcpus=%d", boot.CPU, hypervisor.DefaultMaxCpus)
45-
} else {
46-
memParams = strconv.Itoa(boot.Memory)
47-
cpuParams = strconv.Itoa(boot.CPU)
48-
}
42+
memParams = fmt.Sprintf("size=%d,slots=1,maxmem=%dM", boot.Memory, hypervisor.DefaultMaxMem)
43+
cpuParams = fmt.Sprintf("cpus=%d,maxcpus=%d", boot.CPU, hypervisor.DefaultMaxCpus)
4944

5045
gic_version3 := false
5146
if f, err := os.Open("/proc/cpuinfo"); err == nil {

hypervisor/qemu/qemu_ppc64le.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,8 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
3333
}
3434

3535
var memParams, cpuParams string
36-
if boot.HotAddCpuMem {
37-
memParams = fmt.Sprintf("size=%d,slots=1,maxmem=%dM", boot.Memory, hypervisor.DefaultMaxMem) // TODO set maxmem to the total memory of the system
38-
cpuParams = fmt.Sprintf("cpus=%d,maxcpus=%d", boot.CPU, hypervisor.DefaultMaxCpus) // TODO set it to the cpus of the system
39-
} else {
40-
memParams = strconv.Itoa(boot.Memory)
41-
cpuParams = strconv.Itoa(boot.CPU)
42-
}
36+
memParams = strconv.Itoa(boot.Memory)
37+
cpuParams = strconv.Itoa(boot.CPU)
4338

4439
return []string{
4540
"-machine", "pseries,accel=kvm,usb=off", "-global", "kvm-pit.lost_tick_policy=discard", "-cpu", "host",

hypervisor/qemu/qemu_s390x.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@ func (qc *QemuContext) arguments(ctx *hypervisor.VmContext) []string {
2626
qc.cpus = boot.CPU
2727

2828
var memParams, cpuParams string
29-
if boot.HotAddCpuMem {
30-
memParams = fmt.Sprintf("size=%d,slots=1,maxmem=%dM", boot.Memory, hypervisor.DefaultMaxMem) // TODO set maxmem to the total memory of the system
31-
cpuParams = fmt.Sprintf("cpus=%d,maxcpus=%d", boot.CPU, hypervisor.DefaultMaxCpus) // TODO set it to the cpus of the system
32-
} else {
33-
memParams = strconv.Itoa(boot.Memory)
34-
cpuParams = strconv.Itoa(boot.CPU)
35-
}
29+
memParams = strconv.Itoa(boot.Memory)
30+
cpuParams = strconv.Itoa(boot.CPU)
3631

3732
return []string{
3833
"-machine", "s390-ccw-virtio,accel=kvm,usb=off", "-cpu", "host",

template/template.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func CreateTemplateVM(statePath, vmName string, cpu, mem int, kernel, initrd str
6161
b := &hypervisor.BootConfig{
6262
CPU: cpu,
6363
Memory: mem,
64-
HotAddCpuMem: true,
6564
BootToBeTemplate: true,
6665
BootFromTemplate: false,
6766
EnableVsock: vsock,
@@ -118,7 +117,6 @@ func (t *TemplateVmConfig) BootConfigFromTemplate() *hypervisor.BootConfig {
118117
return &hypervisor.BootConfig{
119118
CPU: t.Cpu,
120119
Memory: t.Memory,
121-
HotAddCpuMem: true,
122120
BootToBeTemplate: false,
123121
BootFromTemplate: true,
124122
MemoryPath: t.StatePath + "/memory",

0 commit comments

Comments
 (0)