mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-11-17 09:14:52 +02:00
Add maxcpus property for Qemu VMs. Ref #1674
This commit is contained in:
parent
47bb2edbfa
commit
01b2c72767
@ -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"])
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user