KVM修改虚拟机配置

1. 修改内存或 CPU

编辑虚拟机配置文件:

[root@controller ~]# virsh edit centos2

如,

<domain type='kvm'>
  <name>centos2name>
  <uuid>12343a79-8c41-4e75-916e-feaecc2606fcuuid>
  <memory unit='KiB'>1048576memory>
  <currentMemory unit='KiB'>1048576currentMemory>
  <vcpu placement='static'>2vcpu>
...

注:不要修改 nameuuid

更新虚拟机配置:

[root@controller ~]# virsh define /etc/libvirt/qemu/centos2.xml

即使虚拟机仍处于运行状态也可以执行此命令,只是要到虚拟机重启后,新的配置才会起作用。

重启虚拟机:

[root@controller ~]# virsh reboot centos2

2. 新增磁盘

创建磁盘:

[root@controller ~]# qemu-img create -f qcow2 /var/lib/libvirt/images/server-vdb.qcow2 10G

编辑虚拟机配置文件:

[root@controller ~]# virsh edit centos2

新增:

<disk type='file' device='disk'>
  <driver name='qemu' type='qcow2' cache='none'/>
  <source file='/var/lib/libvirt/images/server-vdb.qcow2'/>
  <target dev='vdc' bus='virtio'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</disk>

更新配置:

[root@controller ~]# virsh define /etc/libvirt/qemu/centos2.xml
[root@controller ~]# virsh reboot centos2

你可能感兴趣的:(云计算,kvm,虚拟机)