diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py index 191ae4d8..76db4bd8 100644 --- a/gns3server/compute/qemu/qemu_vm.py +++ b/gns3server/compute/qemu/qemu_vm.py @@ -111,6 +111,7 @@ class QemuVM(BaseNode): self._options = "" self._ram = 256 self._cpus = 1 + self._maxcpus = 1 self._ethernet_adapters = [] self._adapter_type = "e1000" self._initrd = "" @@ -752,6 +753,27 @@ class QemuVM(BaseNode): log.info('QEMU VM "{name}" [{id}] has set the number of vCPUs to {cpus}'.format(name=self._name, id=self._id, cpus=cpus)) self._cpus = cpus + @property + def maxcpus(self): + """ + Returns the maximum number of hotpluggable vCPUs for this QEMU VM. + + :returns: maximum number of hotpluggable vCPUs. + """ + + return self._maxcpus + + @maxcpus.setter + def maxcpus(self, maxcpus): + """ + Sets the maximum number of hotpluggable vCPUs for this QEMU VM. + + :param maxcpus: maximum number of hotpluggable vCPUs + """ + + log.info('QEMU VM "{name}" [{id}] has set maximum number of hotpluggable vCPUs to {maxcpus}'.format(name=self._name, id=self._id, maxcpus=maxcpus)) + self._maxcpus = maxcpus + @property def options(self): """ @@ -2013,7 +2035,11 @@ class QemuVM(BaseNode): command = [self.qemu_path] command.extend(["-name", self._name]) command.extend(["-m", "{}M".format(self._ram)]) - command.extend(["-smp", "cpus={}".format(self._cpus)]) + # set the maximum number of the hotpluggable CPUs to match the number of CPUs to avoid issues. + maxcpus = self._maxcpus + if self._cpus > maxcpus: + maxcpus = self._cpus + command.extend(["-smp", "cpus={},maxcpus={}".format(self._cpus, maxcpus)]) if (await self._run_with_hardware_acceleration(self.qemu_path, self._options)): if sys.platform.startswith("linux"): command.extend(["-enable-kvm"]) diff --git a/gns3server/schemas/qemu.py b/gns3server/schemas/qemu.py index 567e5c3f..b4a9bcf3 100644 --- a/gns3server/schemas/qemu.py +++ b/gns3server/schemas/qemu.py @@ -145,6 +145,12 @@ QEMU_CREATE_SCHEMA = { "minimum": 1, "maximum": 255, }, + "maxcpus": { + "description": "Maximum number of hotpluggable vCPUs", + "type": ["integer", "null"], + "minimum": 1, + "maximum": 255, + }, "adapters": { "description": "Number of adapters", "type": ["integer", "null"], @@ -335,6 +341,12 @@ QEMU_UPDATE_SCHEMA = { "minimum": 1, "maximum": 255, }, + "maxcpus": { + "description": "Maximum number of hotpluggable vCPUs", + "type": ["integer", "null"], + "minimum": 1, + "maximum": 255, + }, "adapters": { "description": "Number of adapters", "type": ["integer", "null"], @@ -528,6 +540,12 @@ QEMU_OBJECT_SCHEMA = { "minimum": 1, "maximum": 255, }, + "maxcpus": { + "description": "Maximum number of hotpluggable vCPUs", + "type": ["integer", "null"], + "minimum": 1, + "maximum": 255, + }, "adapters": { "description": "Number of adapters", "type": "integer", @@ -642,6 +660,7 @@ QEMU_OBJECT_SCHEMA = { "boot_priority", "ram", "cpus", + "maxcpus", "adapters", "adapter_type", "mac_address", diff --git a/gns3server/schemas/qemu_template.py b/gns3server/schemas/qemu_template.py index 28cb9d50..ae3a5ffe 100644 --- a/gns3server/schemas/qemu_template.py +++ b/gns3server/schemas/qemu_template.py @@ -49,6 +49,13 @@ QEMU_TEMPLATE_PROPERTIES = { "maximum": 255, "default": 1 }, + "maxcpus": { + "description": "Maximum number of hotpluggable vCPUs", + "type": "integer", + "minimum": 1, + "maximum": 255, + "default": 1 + }, "adapters": { "description": "Number of adapters", "type": "integer",