From 3e0760dbc5d534dee6e0abc7777907dcda43ebf8 Mon Sep 17 00:00:00 2001
From: Jie Tang <tangjie18@huawei.com>
Date: Thu, 7 May 2020 20:13:11 +0800
Subject: [PATCH 67/77] arm_vcpu_hotplug_opts: hot-unplug vcpu action is not
 supported on aarch64.

aarch64 do not support vcpu hot-unplug by now.

Signed-off-by: Jie Tang <tangjie18@huawei.com>
---
 libvirt/tests/src/cpu/guestpin.py          | 21 ++++++----
 libvirt/tests/src/cpu/setvcpu.py           | 45 ++++++++++++++--------
 libvirt/tests/src/cpu/vcpu_hotpluggable.py | 10 +++--
 3 files changed, 48 insertions(+), 28 deletions(-)

diff --git a/libvirt/tests/src/cpu/guestpin.py b/libvirt/tests/src/cpu/guestpin.py
index b6e9ff5d..707904a7 100644
--- a/libvirt/tests/src/cpu/guestpin.py
+++ b/libvirt/tests/src/cpu/guestpin.py
@@ -2,6 +2,7 @@ import logging
 import os
 import random
 import time
+import platform
 
 from avocado.utils import process
 from avocado.utils import cpu as cpuutil
@@ -98,14 +99,18 @@ def run(test, params, env):
             elif condn == "stress":
                 utils_test.unload_stress("stress_in_vms", params=params, vms=[vm])
             elif condn == "hotplug":
-                result = virsh.setvcpus(vm_name, current_vcpu, "--live",
-                                        ignore_status=True, debug=True)
-                libvirt.check_exit_status(result)
-                exp_vcpu = {'max_config': max_vcpu, 'max_live': current_vcpu,
-                            'cur_config': current_vcpu, 'cur_live': current_vcpu,
-                            'guest_live': current_vcpu}
-                result = cpu.check_vcpu_value(vm, exp_vcpu,
-                                              option="--live")
+                # aarch64 platform do not support vcpu hot-unplug.
+                if platform.machine() != 'aarch64':
+                    result = virsh.setvcpus(vm_name, current_vcpu, "--live",
+                                            ignore_status=True, debug=True)
+                    libvirt.check_exit_status(result)
+                    exp_vcpu = {'max_config': max_vcpu, 'max_live': current_vcpu,
+                                'cur_config': current_vcpu, 'cur_live': current_vcpu,
+                                'guest_live': current_vcpu}
+                    result = cpu.check_vcpu_value(vm, exp_vcpu,
+                                                  option="--live")
+                else:
+                    logging.warn("aarch64 do not support vcpu hot-unplug by now")
             elif condn == "host_smt":
                 result = process.run("ppc64_cpu --smt=2", shell=True)
                 # Change back the host smt
diff --git a/libvirt/tests/src/cpu/setvcpu.py b/libvirt/tests/src/cpu/setvcpu.py
index 3ec7cca1..98c267f4 100644
--- a/libvirt/tests/src/cpu/setvcpu.py
+++ b/libvirt/tests/src/cpu/setvcpu.py
@@ -1,5 +1,6 @@
 import logging
 import collections
+import platform
 
 from virttest import virsh
 from virttest import cpu
@@ -63,9 +64,12 @@ def run(test, params, env):
                 if (vmxml.vcpus.vcpu[cpu_id].get('enabled') != "yes"):
                     test.fail("vcpu status check fail")
             elif "disable" in cpu_option:
-                cpu_count -= 1
-                if (vmxml.vcpus.vcpu[cpu_id].get('enabled') != "no"):
-                    test.fail("vcpu status check fail")
+                if platform.machine() == 'aarch64':
+                    logging.warn("aarch64 do not support vcpu hot-unplug by now")
+                else:
+                    cpu_count -= 1
+                    if (vmxml.vcpus.vcpu[cpu_id].get('enabled') != "no"):
+                        test.fail("vcpu status check fail")
             else:
                 test.fail("wrong vcpu status in xml")
 
@@ -115,11 +119,15 @@ def run(test, params, env):
             order_expect = order_pre.copy()
             order_expect[vcpu] = len(order_pre) + 1
         elif "disable" in cpu_option:
-            for vcpuid, order in order_pre.items():
-                if order > order_pre[vcpu]:
-                    order_pre[vcpuid] = order - 1
-            order_pre.pop(vcpu)
-            order_expect = order_pre.copy()
+            if platform.machine() == 'aarch64':
+                logging.warn("aarch64 do not support vcpu hot-unplug by now")
+                order_expect = order_new
+            else:
+                for vcpuid, order in order_pre.items():
+                    if order > order_pre[vcpu]:
+                        order_pre[vcpuid] = order - 1
+                order_pre.pop(vcpu)
+                order_expect = order_pre.copy()
 
         if order_expect != order_new:
             test.fail("vcpu order check fail")
@@ -193,15 +201,18 @@ def run(test, params, env):
 
         if check.startswith("hotplug"):
             for cpus, option in setvcpu_option.items():
-                vmxml_pre = vm_xml.VMXML.new_from_dumpxml(vm_name)
-                cpus_online_pre = vm.get_cpu_count()
-                result_to_check = virsh.setvcpu(vm_name, cpus, option, debug=True)
-                if not status_error:
-                    cpulist = cpu.cpus_parser(cpus)
-                    check_vcpu_status(cpulist, option, cpus_online_pre)
-                    # check vcpu order only when live status of vcpu is changed
-                    if 'config' not in option:
-                        check_vcpu_order(cpulist, option, vmxml_pre)
+                if 'disable' in option and platform.machine() == 'aarch64':
+                    logging.warn("aarch64 do not support vcpu hot-unplug by now")
+                else:
+                    vmxml_pre = vm_xml.VMXML.new_from_dumpxml(vm_name)
+                    cpus_online_pre = vm.get_cpu_count()
+                    result_to_check = virsh.setvcpu(vm_name, cpus, option, debug=True)
+                    if not status_error:
+                        cpulist = cpu.cpus_parser(cpus)
+                        check_vcpu_status(cpulist, option, cpus_online_pre)
+                        # check vcpu order only when live status of vcpu is changed
+                        if 'config' not in option:
+                            check_vcpu_order(cpulist, option, vmxml_pre)
 
         if 'result_to_check' in locals():
             if err_msg:
diff --git a/libvirt/tests/src/cpu/vcpu_hotpluggable.py b/libvirt/tests/src/cpu/vcpu_hotpluggable.py
index ade586a9..f5e8e213 100644
--- a/libvirt/tests/src/cpu/vcpu_hotpluggable.py
+++ b/libvirt/tests/src/cpu/vcpu_hotpluggable.py
@@ -3,6 +3,7 @@ import re
 import copy
 import ast
 import logging
+import platform
 
 from avocado.utils import process
 from avocado.utils import distro
@@ -132,9 +133,12 @@ def run(test, params, env):
                                     ignore_status=False, debug=True)
                 vcpus_crt += 1
             if disable_vcpu:
-                ret = virsh.setvcpu(vm_name, disable_vcpu, "--disable",
-                                    ingnore_status=False, debug=True)
-                vcpus_crt -= 1
+                if platform.machine() == 'aarch64':
+                    logging.warn("aarch64 do not support vcpu hot-unplug by now")
+                else:
+                    ret = virsh.setvcpu(vm_name, disable_vcpu, "--disable",
+                                        ingnore_status=False, debug=True)
+                    vcpus_crt -= 1
             if live_vcpus:
                 ret = virsh.setvcpus(vm_name, live_vcpus, ignore_status=False,
                                      debug=True)
-- 
2.23.0

