xref: /openbmc/qemu/tests/avocado/hotplug_cpu.py (revision 816d4201)
1# Functional test that hotplugs a CPU and checks it on a Linux guest
2#
3# Copyright (c) 2021 Red Hat, Inc.
4#
5# Author:
6#  Cleber Rosa <crosa@redhat.com>
7#
8# This work is licensed under the terms of the GNU GPL, version 2 or
9# later.  See the COPYING file in the top-level directory.
10
11from avocado_qemu.linuxtest import LinuxTest
12
13
14class HotPlugCPU(LinuxTest):
15
16    def test(self):
17        """
18        :avocado: tags=arch:x86_64
19        :avocado: tags=machine:q35
20        :avocado: tags=accel:kvm
21        """
22        self.require_accelerator('kvm')
23        self.vm.add_args('-accel', 'kvm')
24        self.vm.add_args('-cpu', 'Haswell')
25        self.vm.add_args('-smp', '1,sockets=1,cores=2,threads=1,maxcpus=2')
26        self.launch_and_wait()
27
28        self.ssh_command('test -e /sys/devices/system/cpu/cpu0')
29        with self.assertRaises(AssertionError):
30            self.ssh_command('test -e /sys/devices/system/cpu/cpu1')
31
32        self.vm.cmd('device_add',
33                    driver='Haswell-x86_64-cpu',
34                    socket_id=0,
35                    core_id=1,
36                    thread_id=0)
37        self.ssh_command('test -e /sys/devices/system/cpu/cpu1')
38