【问题标题】:is it possible to add cpu to virtual machine and make it working without restarting?是否可以将 cpu 添加到虚拟机并使其在不重新启动的情况下工作?
【发布时间】:2016-12-15 17:55:08
【问题描述】:

我正在使用 (KVM Qemu//system) 作为管理程序和 Libvirt 来连接它,所以我想知道是否有向在线虚拟机添加更多 CPU 资源并使其在不重新启动的情况下工作?

我可以添加更多 CPU,但虚拟机应该重新启动,然后我才能看到它工作,所以我正在寻找一种方法让它在不重新启动的情况下工作。

现在使用的是下面的代码

from __future__ import print_function
import sys
import libvirt
domName = 'Fedora22-x86_64-1'
conn = libvirt.open('qemu:///system')
if conn == None:
    print('Failed to open connection to qemu:///system', file=sys.stderr)
    exit(1)
dom = conn.lookupName(domName)
if dom == None:
    print('Failed to find the domain '+domName, file=sys.stderr)
    exit(1)
dom.setVcpus(4)
conn.close()
exit(0)

【问题讨论】:

    标签: qemu kvm libvirt


    【解决方案1】:

    现在 QEMU/KVM 确实支持 CPU 热添加,但是,您需要事先为其准备好客户机 XML。

    8

    将导致客户机以 8 个 CPU 启动,所有这些 CPU 都存在。如果您想允许 CPU 热插拔,您需要将 XML 更改为类似

    16

    这将导致客户机以 8 个 CPU 开始,并允许您稍后再热插拔多达 8 个,总共提供 16 个。

    【讨论】:

      最近更新 更多