[PATCH 3/4] vcpupin: add virDomainVcpupinDel function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch add the private API (virDomainVcpupinDel).
This API can delete the vcpupin setting of a specified virtual cpu.

Signed-off-by: Taku Izumi <izumi.taku@xxxxxxxxxxxxxx>
---
 src/conf/domain_conf.c   |   39 +++++++++++++++++++++++++++++++++++++++
 src/conf/domain_conf.h   |    2 ++
 src/libvirt_private.syms |    1 +
 3 files changed, 42 insertions(+)

Index: libvirt/src/conf/domain_conf.c
===================================================================
--- libvirt.orig/src/conf/domain_conf.c
+++ libvirt/src/conf/domain_conf.c
@@ -8126,6 +8126,45 @@ cleanup:
     return -1;
 }
 
+int
+virDomainVcpupinDel(virDomainDefPtr def, int vcpu)
+{
+    int n;
+    bool deleted = false;
+    virDomainVcpupinDefPtr *vcpupin_list = def->cputune.vcpupin;
+
+    /* No vcpupin exists yet */
+    if (!def->cputune.nvcpupin) {
+        return 0;
+    }
+
+    for (n = 0; n < def->cputune.nvcpupin; n++) {
+        if (vcpupin_list[n]->vcpuid == vcpu) {
+            VIR_FREE(vcpupin_list[n]->cpumask);
+            VIR_FREE(vcpupin_list[n]);
+            memmove(&vcpupin_list[n],
+                    &vcpupin_list[n+1],
+                    (def->cputune.nvcpupin - n - 1) * sizeof(virDomainVcpupinDef *));
+            deleted = true;
+            break;
+        }
+    }
+
+    if (!deleted)
+        return 0;
+
+    if (--def->cputune.nvcpupin == 0) {
+        virDomainVcpupinDefFree(def->cputune.vcpupin, 0);
+    } else {
+        if (VIR_REALLOC_N(def->cputune.vcpupin, def->cputune.nvcpupin) < 0) {
+            virReportOOMError();
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
 static int
 virDomainLifecycleDefFormat(virBufferPtr buf,
                             int type,
Index: libvirt/src/conf/domain_conf.h
===================================================================
--- libvirt.orig/src/conf/domain_conf.h
+++ libvirt/src/conf/domain_conf.h
@@ -1381,6 +1381,8 @@ int virDomainVcpupinAdd(virDomainDefPtr 
                         int maplen,
                         int vcpu);
 
+int virDomainVcpupinDel(virDomainDefPtr def, int vcpu);
+
 int virDomainDiskIndexByName(virDomainDefPtr def, const char *name);
 int virDomainDiskInsert(virDomainDefPtr def,
                         virDomainDiskDefPtr disk);
Index: libvirt/src/libvirt_private.syms
===================================================================
--- libvirt.orig/src/libvirt_private.syms
+++ libvirt/src/libvirt_private.syms
@@ -360,6 +360,7 @@ virDomainTimerTickpolicyTypeToString;
 virDomainTimerTrackTypeFromString;
 virDomainTimerTrackTypeToString;
 virDomainVcpupinAdd;
+virDomainVcpupinDel;
 virDomainVcpupinFindByVcpu;
 virDomainVcpupinIsDuplicate;
 virDomainVideoDefFree;

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]