Simple implementation of OpenStack Nova Dynamic Add/Remove CPU memory

Source: Internet
Author: User

Environment

Version: RDO OpenStack Liberty

qemu:2.3.0

Libvirt:1.2.17-13


Ideas

Requires qemu-guest-agent support, install the Qemu-guest-agent package in the mirror, set the boot-up, and then mirror the settings metadata:

Both of these options can be set:

Glance image-update <image-id>--property Hw_qemu_guest_agent=yesnova image-meta {image_id} set Hw_qemu_guest_ Agent=yes

The resulting virtual machine libvirt XML file will then be the following information:

<channel type= ' unix ' > <source mode= ' bind ' path= '/var/lib/libvirt/qemu/org.qemu.guest_ Agent.0.instance-00000011.sock '/> <target type= ' virtio ' name= ' org.qemu.guest_agent.0 '/> <address type= ' Virtio-serial ' controller= ' 0 ' bus= ' 0 ' port= ' 1 '/></channel>


1, Hot add CPU function: Libvirt interface support, by configuring the Nova flavor meta-data Cpu:max to pre-allocate vcpus, and finally call Libvirt Setvcpusflags function to implement (note: Hard restart virtual machine, Libvirt The XML file is regenerated based on the information in the database table, which has been processed.

2, heat removal CPU function: After removing the Vcpus, the virtual machine needs to be restarted (this can be set at the end of the API limit, can be removed from the VM operation)

3, hot add, heat reduce memory: this seems to be no problem, set the maximum memory, libvirt that there can not be active domain


This is my simple implementation: https://github.com/yaoice/nova/commit/26e9e3840abc0f8c81342b58c14c5af0e397c063


Test

Token= ' OpenStack token issue | awk '/id/{print $4} ' | Head-1 ' export token=${token}export server= ' Nova list | awk '/active/{print $} '


Show Virtual machine Vcpus number

Curl-i "http://node_172_16_214_226:8774/v2.1/7d58dea58dd448d4b095da27986176f2/servers/${server}/ Os-server-cpu-hotplug "-X get-h" User-agent:python-novaclient "-H" content-type:application/jso N "-H" accept:application/json "-H" X-auth-token: ${token} "


Set up virtual machine Vcpus

Curl-g-i-x POST http://node_172_16_214_226:8774/v2.1/7d58dea58dd448d4b095da27986176f2/servers/${server}/action         -H "user-agent:python-novaclient"-H "content-type:application/json"-H "Accept:application/json" -H "x-openstack-nova-api-version:2.5"-H "X-auth-token: ${token}"-d ' {"Setvcpus": {"Vcpus": 6}} '

The Libvirt XML for setting up a successful virtual machine has the following information:

Libvirt vcpus xml: <vcpu placement= ' static ' current= ' 4 ' >16</vcpu>


Displaying the memory of a virtual machine

Curl-i "http://node_172_16_214_226:8774/v2.1/7d58dea58dd448d4b095da27986176f2/servers/${server}/ Os-server-mem-hottune "-X get-h" User-agent:python-novaclient "-H" content-type:application/jso N "-H" accept:application/json "-H" X-auth-token: ${token} "


Set the memory for a virtual machine

Curl-g-i-x POST http://node_172_16_214_226:8774/v2.1/7d58dea58dd448d4b095da27986176f2/servers/${server}/action         -H "user-agent:python-novaclient"-H "content-type:application/json"-H "Accept:application/json" -H "x-openstack-nova-api-version:2.5"-H "X-auth-token: ${token}"-d ' {"Setmem": {"mem": 4096}} '



Common error

Virsh # Setvcpus--live--guest instance-00000040 3error:invalid argument:requested vcpus count is greater than the count of enabled Vcpus in the Domain:3 > 2virsh # setmaxmem--live one 7292608error:unable to change maxmemorysizeerror:re Quested operation isn't valid:cannot resize the maximum memory on active domain



Reference links

(How to add Nova API method) https://github.com/accelazh/example-nova-exensions/blob/master/nova/nova/api/openstack/ compute/contrib/example_resource.py

(How to configure Qemu-guest-agent) https://www.sebastien-han.fr/blog/2015/02/09/ openstack-perform-consistent-snapshots-with-qemu-guest-agent/

(Flavor extra_specs usage) http://docs.openstack.org/admin-guide/compute-flavors.html

(KVM host dynamically changes CPU count and memory size) http://bbotte.blog.51cto.com/6205307/1635733

(Libvirt CPU Hot Remove will need to restart the number of CPUs to really reduce) http://www.unixarena.com/2015/12/ Linux-kvm-how-to-add-remove-vcpu-to-guest-on-fly.html





This article is from the "The-way-to-cloud" blog, make sure to keep this source http://iceyao.blog.51cto.com/9426658/1879601

Simple implementation of OpenStack Nova Dynamic Add/Remove CPU memory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.