[libvirt] [PATCH 4/4] vcpupin: add vcpupin resetting feature to qemu driver
Daniel Veillard
veillard at redhat.com
Mon Jun 20 06:55:19 UTC 2011
On Fri, Jun 10, 2011 at 03:41:18PM +0900, Taku Izumi wrote:
>
> Pinning to all physical cpus means resetting, hence it is preferable to
> delete vcpupin setting of XML.
>
> This patch changes qemu driver to delete vcpupin setting by invoking
> virDomainVcpupinDel API when pinning the specified virtual cpu to
> all host physical cpus.
>
> Signed-off-by: Taku Izumi <izumi.taku at jp.fujitsu.com>
> ---
> src/qemu/qemu_driver.c | 64 +++++++++++++++++++++++++++++++++++--------------
> 1 file changed, 46 insertions(+), 18 deletions(-)
>
> Index: libvirt/src/qemu/qemu_driver.c
> ===================================================================
> --- libvirt.orig/src/qemu/qemu_driver.c
> +++ libvirt/src/qemu/qemu_driver.c
> @@ -2894,6 +2894,7 @@ qemudDomainPinVcpuFlags(virDomainPtr dom
> int ret = -1;
> bool isActive;
> qemuDomainObjPrivatePtr priv;
> + bool canResetting = true;
>
> virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
> VIR_DOMAIN_AFFECT_CONFIG, -1);
> @@ -2944,15 +2945,23 @@ qemudDomainPinVcpuFlags(virDomainPtr dom
> goto cleanup;
> }
>
> - if (flags & VIR_DOMAIN_AFFECT_LIVE) {
> -
> - if (nodeGetInfo(dom->conn, &nodeinfo) < 0)
> - goto cleanup;
> + if (nodeGetInfo(dom->conn, &nodeinfo) < 0)
> + goto cleanup;
> + hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
> + maxcpu = maplen * 8;
> + if (maxcpu > hostcpus)
> + maxcpu = hostcpus;
> + /* pinning to all physical cpus means resetting,
> + * so check if we can reset setting.
> + */
> + for (int pcpu = 0; pcpu < hostcpus; pcpu++) {
> + if ((cpumap[pcpu/8] & (1 << (pcpu % 8))) == 0) {
> + canResetting = false;
> + break;
> + }
> + }
>
> - hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
> - maxcpu = maplen * 8;
> - if (maxcpu > hostcpus)
> - maxcpu = hostcpus;
> + if (flags & VIR_DOMAIN_AFFECT_LIVE) {
>
> if (priv->vcpupids != NULL) {
> if (virProcessInfoSetAffinity(priv->vcpupids[vcpu],
> @@ -2964,23 +2973,42 @@ qemudDomainPinVcpuFlags(virDomainPtr dom
> goto cleanup;
> }
>
> - if (virDomainVcpupinAdd(vm->def, cpumap, maplen, vcpu) < 0) {
> - qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> - _("failed to update or add vcpupin xml of "
> - "a running domain"));
> - goto cleanup;
> + if (canResetting) {
> + if (virDomainVcpupinDel(vm->def, vcpu) < 0) {
> + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("failed to delete vcpupin xml of "
> + "a running domain"));
> + goto cleanup;
> + }
> + } else {
> + if (virDomainVcpupinAdd(vm->def, cpumap, maplen, vcpu) < 0) {
> + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("failed to update or add vcpupin xml of "
> + "a running domain"));
> + goto cleanup;
> + }
> }
>
> }
>
> if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
>
> - if (virDomainVcpupinAdd(persistentDef, cpumap, maplen, vcpu) < 0) {
> - qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> - _("failed to update or add vcpupin xml of "
> - "a persistent domain"));
> - goto cleanup;
> + if (canResetting) {
> + if (virDomainVcpupinDel(persistentDef, vcpu) < 0) {
> + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("failed to delete vcpupin xml of "
> + "a persistent domain"));
> + goto cleanup;
> + }
> + } else {
> + if (virDomainVcpupinAdd(persistentDef, cpumap, maplen, vcpu) < 0) {
> + qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("failed to update or add vcpupin xml of "
> + "a persistent domain"));
> + goto cleanup;
> + }
> }
> +
> ret = virDomainSaveConfig(driver->configDir, persistentDef);
> goto cleanup;
> }
ACK,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list