From c9fb301ff17b454ccb1f10a04ee5669d64a04609 Mon Sep 17 00:00:00 2001 From: Keqian Zhu Date: Tue, 12 May 2020 17:18:54 +0800 Subject: [PATCH 1/2] arm/virt: Support CPU cold plug This adds CPU cold plug support to arm virt machine board. CPU cold plug means adding CPU by using "-device xx-arm-cpu" when we bring up Qemu. Signed-off-by: Keqian Zhu --- arm-virt-Support-CPU-cold-plug.patch | 92 ++++++++++++++++++++++++++++ qemu.spec | 4 ++ 2 files changed, 96 insertions(+) create mode 100644 arm-virt-Support-CPU-cold-plug.patch diff --git a/arm-virt-Support-CPU-cold-plug.patch b/arm-virt-Support-CPU-cold-plug.patch new file mode 100644 index 00000000..3f96fede --- /dev/null +++ b/arm-virt-Support-CPU-cold-plug.patch @@ -0,0 +1,92 @@ +From e3a1af72fca5bbcc840fba44d512bbe69ec55ca9 Mon Sep 17 00:00:00 2001 +From: Keqian Zhu +Date: Tue, 12 May 2020 15:05:06 +0800 +Subject: [PATCH] arm/virt: Support CPU cold plug + +This adds CPU cold plug support to arm virt machine board. +CPU cold plug means adding CPU by using "-device xx-arm-cpu" +when we bring up Qemu. + +Signed-off-by: Keqian Zhu +--- + hw/arm/virt.c | 36 +++++++++++++++++++----------------- + 1 file changed, 19 insertions(+), 17 deletions(-) + +diff --git a/hw/arm/virt.c b/hw/arm/virt.c +index 112a6ae7cb..4c7279392f 100644 +--- a/hw/arm/virt.c ++++ b/hw/arm/virt.c +@@ -2093,25 +2093,12 @@ static void virt_cpu_pre_plug(HotplugHandler *hotplug_dev, + int smp_cores = ms->smp.cores; + int smp_threads = ms->smp.threads; + +- /* Some hotplug capability checks */ +- + if (!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) { + error_setg(errp, "Invalid CPU type, expected cpu type: '%s'", + ms->cpu_type); + return; + } + +- if (dev->hotplugged && !vms->acpi_dev) { +- error_setg(errp, "CPU hotplug is disabled: missing acpi device."); +- return; +- } +- +- if (dev->hotplugged && !vms->cpu_hotplug_enabled) { +- error_setg(errp, "CPU hotplug is disabled: " +- "should use AArch64 CPU and GICv3."); +- return; +- } +- + /* if cpu idx is not set, set it based on socket/core/thread properties */ + if (cs->cpu_index == UNASSIGNED_CPU_INDEX) { + int max_socket = ms->smp.max_cpus / smp_threads / smp_cores; +@@ -2137,6 +2124,20 @@ static void virt_cpu_pre_plug(HotplugHandler *hotplug_dev, + cs->cpu_index = idx_from_topo_ids(smp_cores, smp_threads, &topo); + } + ++ /* Some hotplug capability checks */ ++ if (cs->cpu_index >= ms->smp.cpus) { ++ if (!vms->acpi_dev) { ++ error_setg(errp, "CPU cold/hot plug is disabled: " ++ "missing acpi device."); ++ return; ++ } ++ if (!vms->cpu_hotplug_enabled) { ++ error_setg(errp, "CPU cold/hot plug is disabled: " ++ "should use AArch64 CPU and GICv3."); ++ return; ++ } ++ } ++ + /* if 'address' properties socket-id/core-id/thread-id are not set, set them + * so that machine_query_hotpluggable_cpus would show correct values + */ +@@ -2237,7 +2238,8 @@ static void virt_cpu_plug(HotplugHandler *hotplug_dev, + ARMGICv3CommonClass *agcc; + Error *local_err = NULL; + +- if (dev->hotplugged) { ++ /* For CPU that is cold/hot plugged */ ++ if (ncpu >= ms->smp.cpus) { + /* Realize GIC related parts of CPU */ + assert(vms->gic_version == 3); + gicv3 = ARM_GICV3_COMMON(vms->gic); +@@ -2250,10 +2252,10 @@ static void virt_cpu_plug(HotplugHandler *hotplug_dev, + cpu_hotplug_register_reset(ncpu); + cpu_hotplug_reset_manually(ncpu); + cpu_synchronize_post_reset(cs); ++ } + +- if (kvm_enabled()) { +- resume_all_vcpus(); +- } ++ if (dev->hotplugged && kvm_enabled()) { ++ resume_all_vcpus(); + } + + if (vms->acpi_dev) { +-- +2.19.1 + diff --git a/qemu.spec b/qemu.spec index 57f1c734..2b393898 100644 --- a/qemu.spec +++ b/qemu.spec @@ -161,6 +161,7 @@ Patch0148: vtimer-compat-cross-version-migration-from-v4.0.1.patch Patch0149: migration-ram-Do-error_free-after-migrate_set_error-.patch Patch0150: migration-ram-fix-memleaks-in-multifd_new_send_chann.patch Patch0151: migration-rdma-fix-a-memleak-on-error-path-in-rdma_s.patch +Patch0152: arm-virt-Support-CPU-cold-plug.patch BuildRequires: flex BuildRequires: bison @@ -506,6 +507,9 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Tue May 12 2020 Huawei Technologies Co., Ltd. +- arm/virt: Support CPU cold plug + * Sat May 9 2020 Huawei Technologies Co., Ltd. - migration/ram: do error_free after migrate_set_error to avoid memleaks. - migration/ram: fix memleaks in multifd_new_send_channel_async. -- Gitee From dd9af1f5f4078e02121b16629942a0d999e5e381 Mon Sep 17 00:00:00 2001 From: Ying Fang Date: Tue, 12 May 2020 17:24:19 +0800 Subject: [PATCH 2/2] spec: Update release version increase release version by one Signed-off-by: Ying Fang --- qemu.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu.spec b/qemu.spec index 2b393898..5243270b 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,6 +1,6 @@ Name: qemu Version: 4.1.0 -Release: 6 +Release: 7 Epoch: 2 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY -- Gitee