vcpupin: add virDomainVcpupinDel function

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@jp.fujitsu.com>
This commit is contained in:
Taku Izumi 2011-06-10 15:40:36 +09:00 committed by Wen Congyang
parent c4a8ca71b1
commit 3711c0b051
3 changed files with 42 additions and 0 deletions

View File

@ -8206,6 +8206,45 @@ cleanup:
return -1; 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 static int
virDomainLifecycleDefFormat(virBufferPtr buf, virDomainLifecycleDefFormat(virBufferPtr buf,
int type, int type,

View File

@ -1412,6 +1412,8 @@ int virDomainVcpupinAdd(virDomainDefPtr def,
int maplen, int maplen,
int vcpu); int vcpu);
int virDomainVcpupinDel(virDomainDefPtr def, int vcpu);
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name); int virDomainDiskIndexByName(virDomainDefPtr def, const char *name);
int virDomainDiskInsert(virDomainDefPtr def, int virDomainDiskInsert(virDomainDefPtr def,
virDomainDiskDefPtr disk); virDomainDiskDefPtr disk);

View File

@ -364,6 +364,7 @@ virDomainTimerTickpolicyTypeToString;
virDomainTimerTrackTypeFromString; virDomainTimerTrackTypeFromString;
virDomainTimerTrackTypeToString; virDomainTimerTrackTypeToString;
virDomainVcpupinAdd; virDomainVcpupinAdd;
virDomainVcpupinDel;
virDomainVcpupinFindByVcpu; virDomainVcpupinFindByVcpu;
virDomainVcpupinIsDuplicate; virDomainVcpupinIsDuplicate;
virDomainVideoDefFree; virDomainVideoDefFree;