From 9d50cc1ff9a0145154a6510478f2dab3178e9a80 Mon Sep 17 00:00:00 2001 From: Vijay Dhanraj Date: Sat, 26 Oct 2019 09:48:30 -0700 Subject: [PATCH] HV: Remove number of guest CPU configuration in ACRN ACRN doesn't support configuring number of guest vcpu option ('-c') anymore. Number of guest vcpus will be defined in the hypervisor scenario configuration file instead. Removed the -c option from the acrn-dm parameters when launching VMs and also trimmed configuration.toml file accordingly. fixes #2136 Signed-off-by: Vijay Dhanraj --- Makefile | 3 +++ cli/config/configuration-acrn.toml.in | 9 +-------- virtcontainers/acrn.go | 3 +-- virtcontainers/acrn_arch_base.go | 12 ------------ virtcontainers/acrn_test.go | 7 +------ 5 files changed, 6 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 60bf32339f..9a27fbbca0 100644 --- a/Makefile +++ b/Makefile @@ -329,6 +329,7 @@ ifneq (,$(ACRNCMD)) CONFIGS += $(CONFIG_ACRN) # acrn-specific options (all should be suffixed by "_ACRN") + DEFMAXVCPUS_ACRN := 1 DEFBLOCKSTORAGEDRIVER_ACRN := virtio-blk DEFNETWORKMODEL_ACRN := macvtap KERNEL_NAME_ACRN = $(call MAKE_KERNEL_NAME,$(KERNELTYPE)) @@ -431,6 +432,7 @@ USER_VARS += SHIMPATH USER_VARS += SYSCONFDIR USER_VARS += DEFVCPUS USER_VARS += DEFMAXVCPUS +USER_VARS += DEFMAXVCPUS_ACRN USER_VARS += DEFMEMSZ USER_VARS += DEFMEMSLOTS USER_VARS += DEFBRIDGES @@ -598,6 +600,7 @@ $(GENERATED_FILES): %: %.in $(MAKEFILE_LIST) VERSION .git-commit -e "s|@SHIMPATH@|$(SHIMPATH)|g" \ -e "s|@DEFVCPUS@|$(DEFVCPUS)|g" \ -e "s|@DEFMAXVCPUS@|$(DEFMAXVCPUS)|g" \ + -e "s|@DEFMAXVCPUS_ACRN@|$(DEFMAXVCPUS_ACRN)|g" \ -e "s|@DEFMEMSZ@|$(DEFMEMSZ)|g" \ -e "s|@DEFMEMSLOTS@|$(DEFMEMSLOTS)|g" \ -e "s|@DEFBRIDGES@|$(DEFBRIDGES)|g" \ diff --git a/cli/config/configuration-acrn.toml.in b/cli/config/configuration-acrn.toml.in index b38dd3436c..0fad4fc5b0 100644 --- a/cli/config/configuration-acrn.toml.in +++ b/cli/config/configuration-acrn.toml.in @@ -32,13 +32,6 @@ kernel_params = "@KERNELPARAMS@" # If you want that acrn uses the default firmware leave this option empty firmware = "@FIRMWAREPATH@" -# Default number of vCPUs per SB/VM: -# unspecified or 0 --> will be set to @DEFVCPUS@ -# < 0 --> will be set to the actual number of physical cores -# > 0 <= number of physical cores --> will be set to the specified number -# > number of physical cores --> will be set to the actual number of physical cores -default_vcpus = 1 - # Default maximum number of vCPUs per SB/VM: # unspecified or == 0 --> will be set to the actual number of physical cores or to the maximum number # of vCPUs supported by KVM if that number is exceeded @@ -53,7 +46,7 @@ default_vcpus = 1 # `default_maxvcpus = 8` the memory footprint will be small, but 8 will be the maximum number of # vCPUs supported by the SB/VM. In general, we recommend that you do not edit this variable, # unless you know what are you doing. -default_maxvcpus = @DEFMAXVCPUS@ +default_maxvcpus = @DEFMAXVCPUS_ACRN@ # Bridges can be used to hot plug devices. # Limitations: diff --git a/virtcontainers/acrn.go b/virtcontainers/acrn.go index 747c954ee1..5c69b8ae3b 100644 --- a/virtcontainers/acrn.go +++ b/virtcontainers/acrn.go @@ -124,7 +124,7 @@ func (a *Acrn) kernelParameters() string { params = append(params, acrnDefaultKernelParameters...) // set the maximum number of vCPUs - params = append(params, Param{"maxcpus", fmt.Sprintf("%d", a.config.NumVCPUs)}) + params = append(params, Param{"maxcpus", fmt.Sprintf("%d", a.config.DefaultMaxVCPUs)}) // add the params specified by the provided config. As the kernel // honours the last parameter value set and since the config-provided @@ -405,7 +405,6 @@ func (a *Acrn) createSandbox(ctx context.Context, id string, networkNS NetworkNa Path: acrnPath, CtlPath: acrnctlPath, Memory: memory, - NumCPU: a.config.NumVCPUs, Devices: devices, Kernel: kernel, Name: fmt.Sprintf("sandbox-%s", a.id), diff --git a/virtcontainers/acrn_arch_base.go b/virtcontainers/acrn_arch_base.go index 5fa58a876e..61197ea2fc 100644 --- a/virtcontainers/acrn_arch_base.go +++ b/virtcontainers/acrn_arch_base.go @@ -306,9 +306,6 @@ type Config struct { // ACPI virtualization support ACPIVirt bool - - // NumCPU is the number of CPUs for guest - NumCPU uint32 } // MaxAcrnVCPUs returns the maximum number of vCPUs supported @@ -571,14 +568,6 @@ func (config *Config) appendMemory() { } } -func (config *Config) appendCPUs() { - if config.NumCPU != 0 { - config.acrnParams = append(config.acrnParams, "-c") - config.acrnParams = append(config.acrnParams, fmt.Sprintf("%d", config.NumCPU)) - } - -} - func (config *Config) appendKernel() { if config.Kernel.Path == "" { return @@ -603,7 +592,6 @@ func LaunchAcrn(config Config, logger *logrus.Entry) (int, string, error) { config.appendUUID() config.appendACPI() config.appendMemory() - config.appendCPUs() config.appendDevices() config.appendKernel() config.appendName() diff --git a/virtcontainers/acrn_test.go b/virtcontainers/acrn_test.go index 3aaa3606c8..f335833a87 100644 --- a/virtcontainers/acrn_test.go +++ b/virtcontainers/acrn_test.go @@ -48,7 +48,7 @@ func testAcrnKernelParameters(t *testing.T, kernelParams []Param, debug bool) { arch: &acrnArchBase{}, } - expected := fmt.Sprintf("panic=1 maxcpus=%d foo=foo bar=bar", a.config.NumVCPUs) + expected := fmt.Sprintf("panic=1 maxcpus=%d foo=foo bar=bar", a.config.DefaultMaxVCPUs) params := a.kernelParameters() assert.Equal(params, expected) @@ -218,11 +218,6 @@ func TestAcrnCreateSandbox(t *testing.T) { }, } - // Even though this test doesn't need to create a vcStore, - // we are forced to create a vcStore as GetAndSetSandboxBlockIndex() - // which is called from createSandbox needs a valid vcStore. vcStore - // creation can be removed once https://github.com/kata-containers/runtime/issues/2026 - // issue is resolved. vcStore, err := store.NewVCSandboxStore(sandbox.ctx, sandbox.id) assert.NoError(err) sandbox.store = vcStore