mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
Implement public API for virDomainPinIOThread
Add virDomainPinIOThread to allow setting the CPU affinity for a specific IOThread based on the output generated from virDomainGetIOThreadsInfo The API supports updating both the --live domain and the --config data
This commit is contained in:
parent
68818dcdd5
commit
71b234ce68
@ -1609,6 +1609,11 @@ void virDomainIOThreadsInfoFree(virDomainIOThreadInfoPtr info);
|
||||
int virDomainGetIOThreadsInfo(virDomainPtr domain,
|
||||
virDomainIOThreadInfoPtr **info,
|
||||
unsigned int flags);
|
||||
int virDomainPinIOThread(virDomainPtr domain,
|
||||
unsigned int iothread_id,
|
||||
unsigned char *cpumap,
|
||||
int maplen,
|
||||
unsigned int flags);
|
||||
|
||||
/**
|
||||
* VIR_USE_CPU:
|
||||
|
@ -385,6 +385,13 @@ typedef int
|
||||
virDomainIOThreadInfoPtr **info,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainPinIOThread)(virDomainPtr domain,
|
||||
unsigned int iothread_id,
|
||||
unsigned char *cpumap,
|
||||
int maplen,
|
||||
unsigned int flags);
|
||||
|
||||
typedef int
|
||||
(*virDrvDomainGetSecurityLabel)(virDomainPtr domain,
|
||||
virSecurityLabelPtr seclabel);
|
||||
@ -1260,6 +1267,7 @@ struct _virHypervisorDriver {
|
||||
virDrvDomainGetVcpus domainGetVcpus;
|
||||
virDrvDomainGetMaxVcpus domainGetMaxVcpus;
|
||||
virDrvDomainGetIOThreadsInfo domainGetIOThreadsInfo;
|
||||
virDrvDomainPinIOThread domainPinIOThread;
|
||||
virDrvDomainGetSecurityLabel domainGetSecurityLabel;
|
||||
virDrvDomainGetSecurityLabelList domainGetSecurityLabelList;
|
||||
virDrvNodeGetSecurityModel nodeGetSecurityModel;
|
||||
|
@ -7965,6 +7965,82 @@ virDomainIOThreadsInfoFree(virDomainIOThreadInfoPtr info)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainPinIOThread:
|
||||
* @domain: a domain object
|
||||
* @iothread_id: the IOThread ID to set the CPU affinity
|
||||
* @cpumap: pointer to a bit map of real CPUs (in 8-bit bytes) (IN)
|
||||
* Each bit set to 1 means that corresponding CPU is usable.
|
||||
* Bytes are stored in little-endian order: CPU0-7, 8-15...
|
||||
* In each byte, lowest CPU number is least significant bit.
|
||||
* @maplen: number of bytes in cpumap, from 1 up to size of CPU map in
|
||||
* underlying virtualization system (Xen...).
|
||||
* If maplen < size, missing bytes are set to zero.
|
||||
* If maplen > size, failure code is returned.
|
||||
* @flags: bitwise-OR of virDomainModificationImpact
|
||||
*
|
||||
* Dynamically change the real CPUs which can be allocated to an IOThread.
|
||||
* This function may require privileged access to the hypervisor.
|
||||
*
|
||||
* @flags may include VIR_DOMAIN_AFFECT_LIVE or VIR_DOMAIN_AFFECT_CONFIG.
|
||||
* Both flags may be set.
|
||||
* If VIR_DOMAIN_AFFECT_LIVE is set, the change affects a running domain
|
||||
* and may fail if domain is not alive.
|
||||
* If VIR_DOMAIN_AFFECT_CONFIG is set, the change affects persistent state,
|
||||
* and will fail for transient domains. If neither flag is specified (that is,
|
||||
* @flags is VIR_DOMAIN_AFFECT_CURRENT), then an inactive domain modifies
|
||||
* persistent setup, while an active domain is hypervisor-dependent on whether
|
||||
* just live or both live and persistent state is changed.
|
||||
* Not all hypervisors can support all flag combinations.
|
||||
*
|
||||
* See also virDomainGetIOThreadsInfo for querying this information.
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of failure.
|
||||
*/
|
||||
int
|
||||
virDomainPinIOThread(virDomainPtr domain,
|
||||
unsigned int iothread_id,
|
||||
unsigned char *cpumap,
|
||||
int maplen,
|
||||
unsigned int flags)
|
||||
{
|
||||
virConnectPtr conn;
|
||||
|
||||
VIR_DOMAIN_DEBUG(domain, "iothread_id=%u, cpumap=%p, maplen=%d",
|
||||
iothread_id, cpumap, maplen);
|
||||
|
||||
virResetLastError();
|
||||
|
||||
virCheckDomainReturn(domain, -1);
|
||||
conn = domain->conn;
|
||||
|
||||
virCheckReadOnlyGoto(conn->flags, error);
|
||||
if ((unsigned short) iothread_id != iothread_id) {
|
||||
virReportError(VIR_ERR_OVERFLOW, _("input too large: %u"),
|
||||
iothread_id);
|
||||
goto error;
|
||||
}
|
||||
virCheckPositiveArgGoto(iothread_id, error);
|
||||
virCheckNonNullArgGoto(cpumap, error);
|
||||
virCheckPositiveArgGoto(maplen, error);
|
||||
|
||||
if (conn->driver->domainPinIOThread) {
|
||||
int ret;
|
||||
ret = conn->driver->domainPinIOThread(domain, iothread_id,
|
||||
cpumap, maplen, flags);
|
||||
if (ret < 0)
|
||||
goto error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
virReportUnsupportedError();
|
||||
|
||||
error:
|
||||
virDispatchError(domain->conn);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDomainGetSecurityLabel:
|
||||
* @domain: a domain object
|
||||
|
@ -699,6 +699,7 @@ LIBVIRT_1.2.14 {
|
||||
global:
|
||||
virDomainIOThreadsInfoFree;
|
||||
virDomainGetIOThreadsInfo;
|
||||
virDomainPinIOThread;
|
||||
} LIBVIRT_1.2.12;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
|
Loading…
x
Reference in New Issue
Block a user