Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I Change amount of Ram and CPU cores for a virtual machine in KVM that is already created? Thanks

share|improve this question
IN run-time or with reboot? That would be really good to know BTW. – Andrew Smith Jun 29 '12 at 22:11
+1 - Also would be worth clarifying whether this would be in virt-manager (as referenced in previous question) or from command line. – rnxrx Jun 30 '12 at 1:44
Thanks, I think It's easier to change this in reboot and yes I created VMs in virt-manager but command-line is ok. – Zim3r Jun 30 '12 at 4:18
you can't change number of cores or amount of RAM on a running kernel. – Michael Martinez Sep 11 '15 at 17:28
up vote 6 down vote accepted

You can edit its XML from command-line with:

virsh name_vhost

Then, you only have to search the <memory> tag and modify it

Keep in mind that the memory allocation is in kilobytes, so to allocate 512MB of memory, use 512 * 1024, or 524288.

share|improve this answer
Really Thanks, Can I increase CPU cores with this method ? – Zim3r Jun 30 '12 at 10:12
You should check this out… ;) – blacksoul Jun 30 '12 at 10:15
Is there any other way ? besides what is explaing on – Zim3r Jun 30 '12 at 11:09
-1 because I simply get: "error: unknown command: name_vhost" . Note that I am using the name of my host instead of that literal string. I like Ahmed's answer in any event, more comprehensive. – Mike S Apr 27 at 21:44

You can edit the VM settings in virt-manager or in cli by changing the XML in virsh edit VMNAME

share|improve this answer
Thanks for your help. – Zim3r Jul 1 '12 at 13:44

For offline configuration:

To increase the number of CPUs:

virsh setvcpus <vm_name> <vcpu_count> --config

If you get an error that you exceeded the maximum number, first do:

virsh setvcpus <vm_name> <vcpu_count> --config --maximum

Then repeat the above:

virsh setvcpus <vm_name> <vcpu_count> --config

To increase the memory size:

virsh setmaxmem <vm_name> <memsize> --config
virsh setmem <vm_name> <memsize> --config

For online configuration:

You can set the vCPU and memory while the VM is running with --current instead of --config, but the new numbers has to be within the maximum values already set. You can not set these maximum numbers while the VM is running. You will have to shutdown the VM with virsh shutdown <vm_name>, use the above command and start back the VM with virsh start <vm_name>.

share|improve this answer

To increase the maximum amount of memory that can be allocated to the VM you have to increase the maximum memory limit, power off the VM, increase the memory allocated, the start the VM. There's a step-by-step guide here:

To get more VCPUs you have to edit the virsh XML file and restart the VM. There's a step-by-step guide to do this here:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.