Support for CPUs setting for Qemu VMs.

This commit is contained in:
grossmj 2015-08-05 17:17:55 -06:00
parent 217945339e
commit 5121753232
2 changed files with 42 additions and 1 deletions

View File

@ -97,6 +97,7 @@ class QemuVM(BaseVM):
self._mac_address = ""
self._options = ""
self._ram = 256
self._cpus = 1
self._ethernet_adapters = []
self._adapter_type = "e1000"
self._initrd = ""
@ -602,6 +603,27 @@ class QemuVM(BaseVM):
log.info('QEMU VM "{name}" [{id}] has set the RAM to {ram}'.format(name=self._name, id=self._id, ram=ram))
self._ram = ram
@property
def cpus(self):
"""
Returns the number of vCPUs this QEMU VM.
:returns: number of vCPUs.
"""
return self._cpus
@cpus.setter
def cpus(self, cpus):
"""
Sets the number of vCPUs this QEMU VM.
:param cpus: number of vCPUs.
"""
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 options(self):
"""
@ -1344,6 +1366,7 @@ class QemuVM(BaseVM):
command = [self.qemu_path]
command.extend(["-name", self._name])
command.extend(["-m", str(self._ram)])
command.extend(["-smp", "cpus={}".format(self._cpus)])
if sys.platform.startswith("linux") and self.manager.config.get_section_config("Qemu").getboolean("enable_kvm", True) \
and "-no-kvm" not in self._options:
if not os.path.exists("/dev/kvm"):

View File

@ -121,6 +121,12 @@ QEMU_CREATE_SCHEMA = {
"description": "amount of RAM in MB",
"type": ["integer", "null"]
},
"cpus": {
"description": "number of vCPUs",
"type": ["integer", "null"],
"minimum": 1,
"maximum": 255,
},
"adapters": {
"description": "number of adapters",
"type": ["integer", "null"],
@ -284,6 +290,12 @@ QEMU_UPDATE_SCHEMA = {
"description": "amount of RAM in MB",
"type": ["integer", "null"]
},
"cpus": {
"description": "number of vCPUs",
"type": ["integer", "null"],
"minimum": 1,
"maximum": 255,
},
"adapters": {
"description": "number of adapters",
"type": ["integer", "null"],
@ -450,6 +462,12 @@ QEMU_OBJECT_SCHEMA = {
"description": "amount of RAM in MB",
"type": "integer"
},
"cpus": {
"description": "number of vCPUs",
"type": ["integer", "null"],
"minimum": 1,
"maximum": 255,
},
"adapters": {
"description": "number of adapters",
"type": "integer",
@ -529,7 +547,7 @@ QEMU_OBJECT_SCHEMA = {
"required": ["vm_id", "project_id", "name", "qemu_path", "platform", "console_type", "hda_disk_image", "hdb_disk_image",
"hdc_disk_image", "hdd_disk_image", "hda_disk_image_md5sum", "hdb_disk_image_md5sum",
"hdc_disk_image_md5sum", "hdd_disk_image_md5sum", "hda_disk_interface", "hdb_disk_interface", "hdc_disk_interface",
"hdd_disk_interface", "cdrom_image", "cdrom_image_md5sum", "boot_priority", "ram", "adapters", "adapter_type",
"hdd_disk_interface", "cdrom_image", "cdrom_image_md5sum", "boot_priority", "ram", "cpus", "adapters", "adapter_type",
"mac_address", "console", "initrd", "kernel_image", "initrd_md5sum", "kernel_image_md5sum", "kernel_command_line",
"legacy_networking", "acpi_shutdown", "cpu_throttling", "process_priority", "options", "vm_directory"]
}