KVM使用virsh命令行调整虚拟机的cpu和内存

1、virsh edit centos73 (更改前要将virsh shutdown centos73 )
找到“memory”和“vcpu”标签,将

<name>centos73</name>
  <uuid>2220a6d1-a36a-4fbb-8523-e078b3dfe795</uuid>
  <memory>2097152</memory>
  <currentMemory>2097152</currentMemory>
  <vcpu>1</vcpu>

改为:

<name>centos73</name>
  <uuid>2220a6d1-a36a-4fbb-8523-e078b3dfe795</uuid>
  <memory>3145728</memory>
  <currentMemory>3145728</currentMemory>
  <vcpu>2</vcpu>

virsh define /etc/libvirt/qemu/centos73.xml 重定义使配置生效

重启虚拟机

virsh start centos73 --console

查看原配置信息

[root@localhost kvm]# virsh dominfo centos734
Id:             -
Name:           centos73
UUID:           2220a6d1-a36a-4fbb-8523-e078b3dfe795
OS Type:        hvm
State:          shut off
CPU(s):         1
Max memory:     2097152 KiB
Used memory:    2097152 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: none
Security DOI:   0

调整后信息:

[root@localhost kvm]# virsh dominfo centos73
Id:             -
Name:           centos73
UUID:           2220a6d1-a36a-4fbb-8523-e078b3dfe795
OS Type:        hvm
State:          shut off
CPU(s):         2
Max memory:     3145728 KiB
Used memory:    3145728 KiB
Persistent:     yes
Autostart:      disable
Managed save:   no
Security model: none
Security DOI:   0
标签:KVM 发布于:2019-11-11 22:50:42