mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
Introduce virDomainEmulatorPinAdd and virDomainEmulatorPinDel functions
Introduce 2 APIs to support emulator threads pin. 1) virDomainEmulatorPinAdd: setup emulator threads pin with a given cpumap string. 2) virDomainEmulatorPinDel: remove all emulator threads pin. Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
This commit is contained in:
parent
c152bf9425
commit
151eee5a06
@ -11124,6 +11124,77 @@ virDomainVcpuPinDel(virDomainDefPtr def, int vcpu)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
virDomainEmulatorPinAdd(virDomainDefPtr def,
|
||||
unsigned char *cpumap,
|
||||
int maplen)
|
||||
{
|
||||
virDomainVcpuPinDefPtr emulatorpin = NULL;
|
||||
char *cpumask = NULL;
|
||||
int i;
|
||||
|
||||
if (VIR_ALLOC_N(cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Convert bitmap (cpumap) to cpumask, which is byte map. */
|
||||
for (i = 0; i < maplen; i++) {
|
||||
int cur;
|
||||
|
||||
for (cur = 0; cur < 8; cur++) {
|
||||
if (cpumap[i] & (1 << cur))
|
||||
cpumask[i * 8 + cur] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!def->cputune.emulatorpin) {
|
||||
/* No emulatorpin exists yet. */
|
||||
if (VIR_ALLOC(emulatorpin) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
emulatorpin->vcpuid = -1;
|
||||
emulatorpin->cpumask = cpumask;
|
||||
def->cputune.emulatorpin = emulatorpin;
|
||||
} else {
|
||||
/* Since there is only 1 emulatorpin for each vm,
|
||||
* juest replace the old one.
|
||||
*/
|
||||
VIR_FREE(def->cputune.emulatorpin->cpumask);
|
||||
def->cputune.emulatorpin->cpumask = cpumask;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(cpumask);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
virDomainEmulatorPinDel(virDomainDefPtr def)
|
||||
{
|
||||
virDomainVcpuPinDefPtr emulatorpin = NULL;
|
||||
|
||||
/* No emulatorpin exists yet */
|
||||
if (!def->cputune.emulatorpin) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
emulatorpin = def->cputune.emulatorpin;
|
||||
|
||||
VIR_FREE(emulatorpin->cpumask);
|
||||
VIR_FREE(emulatorpin);
|
||||
def->cputune.emulatorpin = NULL;
|
||||
|
||||
if (def->cputune.emulatorpin)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
virDomainLifecycleDefFormat(virBufferPtr buf,
|
||||
int type,
|
||||
|
@ -1998,6 +1998,12 @@ int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr *vcpupin_list,
|
||||
|
||||
int virDomainVcpuPinDel(virDomainDefPtr def, int vcpu);
|
||||
|
||||
int virDomainEmulatorPinAdd(virDomainDefPtr def,
|
||||
unsigned char *cpumap,
|
||||
int maplen);
|
||||
|
||||
int virDomainEmulatorPinDel(virDomainDefPtr def);
|
||||
|
||||
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name,
|
||||
bool allow_ambiguous);
|
||||
const char *virDomainDiskPathByName(virDomainDefPtr, const char *name);
|
||||
|
@ -345,6 +345,8 @@ virDomainDiskSnapshotTypeFromString;
|
||||
virDomainDiskSnapshotTypeToString;
|
||||
virDomainDiskTypeFromString;
|
||||
virDomainDiskTypeToString;
|
||||
virDomainEmulatorPinAdd;
|
||||
virDomainEmulatorPinDel;
|
||||
virDomainFSDefFree;
|
||||
virDomainFSIndexByName;
|
||||
virDomainFSTypeFromString;
|
||||
|
Loading…
Reference in New Issue
Block a user