Citrix Xen: How to modify VM memory via command line

root's picture

I know, you have XenCenter and everything is easily done from there.
But what happens if you are not able to use it? Time to fire up the command line :)
In the example below, we will change the memory from 256M to 1G.

Commands to be executed:

xe vm-shutdown name-label=<vm>
xe vm-list params=uuid name-label=<vm>
xe vm-list params=all name-label=<vm> | grep memory
new_mem=1073741824; xe vm-param-set memory-static-max=${new_mem} memory-dynamic-max=${new_mem} memory-dynamic-min=${new_mem} uuid=<vm uuid>
xe vm-list params=all name-label=<vm> | grep memory
xe vm-start vm=<vm>
xe vm-list params=all name-label=<vm> | grep memory

Detailed execution:

Shutdown the vm and list the vm's current memory value and uuid:
[root@XenGz cd]# xe vm-shutdown name-label=debian
[root@XenGz cd]# xe vm-list params=all name-label=debian | grep memory- | grep -v recommendations
                 memory-actual ( RO): 268435456
                 memory-target ( RO): <expensive field>
               memory-overhead ( RO): 5242880
             memory-static-max ( RW): 268435456
            memory-dynamic-max ( RW): 268435456
            memory-dynamic-min ( RW): 268435456
             memory-static-min ( RW): 134217728
[root@XenGz cd]# xe vm-list params=uuid name-label=debian
uuid ( RO)    : 6e79ff87-6a67-6a07-325a-5cf7570281bb

[h5]Modify the memory:[/h3]

[root@XenGz cd]# new_mem=1073741824
[root@XenGz cd]# xe vm-param-set memory-static-max=${new_mem} memory-dynamic-max=${new_mem} memory-dynamic-min=${new_mem} uuid=6e79ff87-6a67-6a07-325a-5cf7570281bb
List the newly modified values:
[root@XenGz cd]# xe vm-list params=all name-label=debian | grep memory- | grep -v recommendations
                 memory-actual ( RO): 268435456
                 memory-target ( RO): <expensive field>
               memory-overhead ( RO): 11534336
             memory-static-max ( RW): 1073741824
            memory-dynamic-max ( RW): 1073741824
            memory-dynamic-min ( RW): 1073741824
             memory-static-min ( RW): 134217728

As you can see above and below, the memory-actual will be changed once the VM will start.

[root@XenGz cd]# xe vm-start vm=debian
[root@XenGz cd]# xe vm-list params=all name-label=gzvirt | grep memory- | grep -v recommendations
                 memory-actual ( RO): 1073745920
                 memory-target ( RO): <expensive field>
               memory-overhead ( RO): 11534336
             memory-static-max ( RW): 1073741824
            memory-dynamic-max ( RW): 1073741824
            memory-dynamic-min ( RW): 1073741824
             memory-static-min ( RW): 134217728

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content

root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root