提交 59ba7023 编写于 作者: J John Ferlan

Convert virDomainVcpuPinDefPtr to virDomainPinDefPtr

As pointed out by jtomko in his review of the IOThreads pinning code:

http://www.redhat.com/archives/libvir-list/2015-March/msg00495.html

there are some comments sprinkled in indicating IOThreads were using
the same structure as the VcpuPin code...

This is the first patch of a few that will change the virDomainVcpuPin*
structures and code to just virDomainPin* - starting with the data
structure naming...
上级 ffa9f8a1
...@@ -2003,11 +2003,11 @@ virDomainClockDefClear(virDomainClockDefPtr def) ...@@ -2003,11 +2003,11 @@ virDomainClockDefClear(virDomainClockDefPtr def)
VIR_FREE(def->timers); VIR_FREE(def->timers);
} }
virDomainVcpuPinDefPtr * virDomainPinDefPtr *
virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src, int nvcpupin) virDomainVcpuPinDefCopy(virDomainPinDefPtr *src, int nvcpupin)
{ {
size_t i; size_t i;
virDomainVcpuPinDefPtr *ret = NULL; virDomainPinDefPtr *ret = NULL;
if (VIR_ALLOC_N(ret, nvcpupin) < 0) if (VIR_ALLOC_N(ret, nvcpupin) < 0)
goto error; goto error;
...@@ -2037,7 +2037,7 @@ virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src, int nvcpupin) ...@@ -2037,7 +2037,7 @@ virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src, int nvcpupin)
} }
void void
virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr def) virDomainVcpuPinDefFree(virDomainPinDefPtr def)
{ {
if (def) { if (def) {
virBitmapFree(def->cpumask); virBitmapFree(def->cpumask);
...@@ -2046,7 +2046,7 @@ virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr def) ...@@ -2046,7 +2046,7 @@ virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr def)
} }
void void
virDomainVcpuPinDefArrayFree(virDomainVcpuPinDefPtr *def, virDomainVcpuPinDefArrayFree(virDomainPinDefPtr *def,
int nvcpupin) int nvcpupin)
{ {
size_t i; size_t i;
...@@ -12759,14 +12759,14 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, ...@@ -12759,14 +12759,14 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
* A vcpuid of -1 is valid and only valid for emulatorpin. So callers * A vcpuid of -1 is valid and only valid for emulatorpin. So callers
* have to check the returned cpuid for validity. * have to check the returned cpuid for validity.
*/ */
static virDomainVcpuPinDefPtr static virDomainPinDefPtr
virDomainVcpuPinDefParseXML(xmlNodePtr node, virDomainVcpuPinDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
int maxvcpus, int maxvcpus,
bool emulator, bool emulator,
bool iothreads) bool iothreads)
{ {
virDomainVcpuPinDefPtr def; virDomainPinDefPtr def;
xmlNodePtr oldnode = ctxt->node; xmlNodePtr oldnode = ctxt->node;
int vcpuid = -1; int vcpuid = -1;
unsigned int iothreadid; unsigned int iothreadid;
...@@ -13523,7 +13523,7 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -13523,7 +13523,7 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error; goto error;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
virDomainVcpuPinDefPtr vcpupin = NULL; virDomainPinDefPtr vcpupin = NULL;
vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt, vcpupin = virDomainVcpuPinDefParseXML(nodes[i], ctxt,
def->maxvcpus, false, false); def->maxvcpus, false, false);
...@@ -13566,7 +13566,7 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -13566,7 +13566,7 @@ virDomainDefParseXML(xmlDocPtr xml,
i)) i))
continue; continue;
virDomainVcpuPinDefPtr vcpupin = NULL; virDomainPinDefPtr vcpupin = NULL;
if (VIR_ALLOC(vcpupin) < 0) if (VIR_ALLOC(vcpupin) < 0)
goto error; goto error;
...@@ -13615,7 +13615,7 @@ virDomainDefParseXML(xmlDocPtr xml, ...@@ -13615,7 +13615,7 @@ virDomainDefParseXML(xmlDocPtr xml,
goto error; goto error;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
virDomainVcpuPinDefPtr iothreadpin = NULL; virDomainPinDefPtr iothreadpin = NULL;
iothreadpin = virDomainVcpuPinDefParseXML(nodes[i], ctxt, iothreadpin = virDomainVcpuPinDefParseXML(nodes[i], ctxt,
def->iothreads, def->iothreads,
false, true); false, true);
...@@ -16737,7 +16737,7 @@ virDomainDefAddImplicitControllers(virDomainDefPtr def) ...@@ -16737,7 +16737,7 @@ virDomainDefAddImplicitControllers(virDomainDefPtr def)
/* Check if vcpupin with same vcpuid already exists. /* Check if vcpupin with same vcpuid already exists.
* Return 1 if exists, 0 if not. */ * Return 1 if exists, 0 if not. */
int int
virDomainVcpuPinIsDuplicate(virDomainVcpuPinDefPtr *def, virDomainVcpuPinIsDuplicate(virDomainPinDefPtr *def,
int nvcpupin, int nvcpupin,
int vcpu) int vcpu)
{ {
...@@ -16754,8 +16754,8 @@ virDomainVcpuPinIsDuplicate(virDomainVcpuPinDefPtr *def, ...@@ -16754,8 +16754,8 @@ virDomainVcpuPinIsDuplicate(virDomainVcpuPinDefPtr *def,
return 0; return 0;
} }
virDomainVcpuPinDefPtr virDomainPinDefPtr
virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def, virDomainVcpuPinFindByVcpu(virDomainPinDefPtr *def,
int nvcpupin, int nvcpupin,
int vcpu) int vcpu)
{ {
...@@ -16773,13 +16773,13 @@ virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def, ...@@ -16773,13 +16773,13 @@ virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def,
} }
int int
virDomainVcpuPinAdd(virDomainVcpuPinDefPtr **vcpupin_list, virDomainVcpuPinAdd(virDomainPinDefPtr **vcpupin_list,
size_t *nvcpupin, size_t *nvcpupin,
unsigned char *cpumap, unsigned char *cpumap,
int maplen, int maplen,
int vcpu) int vcpu)
{ {
virDomainVcpuPinDefPtr vcpupin = NULL; virDomainPinDefPtr vcpupin = NULL;
if (!vcpupin_list) if (!vcpupin_list)
return -1; return -1;
...@@ -16821,7 +16821,7 @@ void ...@@ -16821,7 +16821,7 @@ void
virDomainVcpuPinDel(virDomainDefPtr def, int vcpu) virDomainVcpuPinDel(virDomainDefPtr def, int vcpu)
{ {
int n; int n;
virDomainVcpuPinDefPtr *vcpupin_list = def->cputune.vcpupin; virDomainPinDefPtr *vcpupin_list = def->cputune.vcpupin;
for (n = 0; n < def->cputune.nvcpupin; n++) { for (n = 0; n < def->cputune.nvcpupin; n++) {
if (vcpupin_list[n]->vcpuid == vcpu) { if (vcpupin_list[n]->vcpuid == vcpu) {
...@@ -16838,7 +16838,7 @@ virDomainEmulatorPinAdd(virDomainDefPtr def, ...@@ -16838,7 +16838,7 @@ virDomainEmulatorPinAdd(virDomainDefPtr def,
unsigned char *cpumap, unsigned char *cpumap,
int maplen) int maplen)
{ {
virDomainVcpuPinDefPtr emulatorpin = NULL; virDomainPinDefPtr emulatorpin = NULL;
if (!def->cputune.emulatorpin) { if (!def->cputune.emulatorpin) {
/* No emulatorpin exists yet. */ /* No emulatorpin exists yet. */
...@@ -16879,14 +16879,13 @@ virDomainEmulatorPinDel(virDomainDefPtr def) ...@@ -16879,14 +16879,13 @@ virDomainEmulatorPinDel(virDomainDefPtr def)
} }
int int
virDomainIOThreadsPinAdd(virDomainVcpuPinDefPtr **iothreadspin_list, virDomainIOThreadsPinAdd(virDomainPinDefPtr **iothreadspin_list,
size_t *niothreadspin, size_t *niothreadspin,
unsigned char *cpumap, unsigned char *cpumap,
int maplen, int maplen,
unsigned int iothread_id) unsigned int iothread_id)
{ {
/* IOThreads share the virDomainVcpuPinDefPtr */ virDomainPinDefPtr iothreadpin = NULL;
virDomainVcpuPinDefPtr iothreadpin = NULL;
if (!iothreadspin_list) if (!iothreadspin_list)
return -1; return -1;
...@@ -16929,8 +16928,7 @@ virDomainIOThreadsPinDel(virDomainDefPtr def, ...@@ -16929,8 +16928,7 @@ virDomainIOThreadsPinDel(virDomainDefPtr def,
unsigned int iothread_id) unsigned int iothread_id)
{ {
size_t i; size_t i;
/* IOThreads share the virDomainVcpuPinDefPtr */ virDomainPinDefPtr *iothreadspin_list = def->cputune.iothreadspin;
virDomainVcpuPinDefPtr *iothreadspin_list = def->cputune.iothreadspin;
for (i = 0; i < def->cputune.niothreadspin; i++) { for (i = 0; i < def->cputune.niothreadspin; i++) {
if (iothreadspin_list[i]->vcpuid == iothread_id) { if (iothreadspin_list[i]->vcpuid == iothread_id) {
......
...@@ -1900,26 +1900,26 @@ struct _virDomainClockDef { ...@@ -1900,26 +1900,26 @@ struct _virDomainClockDef {
# define VIR_DOMAIN_CPUMASK_LEN 1024 # define VIR_DOMAIN_CPUMASK_LEN 1024
typedef struct _virDomainVcpuPinDef virDomainVcpuPinDef; typedef struct _virDomainPinDef virDomainPinDef;
typedef virDomainVcpuPinDef *virDomainVcpuPinDefPtr; typedef virDomainPinDef *virDomainPinDefPtr;
struct _virDomainVcpuPinDef { struct _virDomainPinDef {
int vcpuid; int vcpuid;
virBitmapPtr cpumask; virBitmapPtr cpumask;
}; };
void virDomainVcpuPinDefFree(virDomainVcpuPinDefPtr def); void virDomainVcpuPinDefFree(virDomainPinDefPtr def);
void virDomainVcpuPinDefArrayFree(virDomainVcpuPinDefPtr *def, int nvcpupin); void virDomainVcpuPinDefArrayFree(virDomainPinDefPtr *def, int nvcpupin);
virDomainVcpuPinDefPtr *virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src, virDomainPinDefPtr *virDomainVcpuPinDefCopy(virDomainPinDefPtr *src,
int nvcpupin); int nvcpupin);
int virDomainVcpuPinIsDuplicate(virDomainVcpuPinDefPtr *def, int virDomainVcpuPinIsDuplicate(virDomainPinDefPtr *def,
int nvcpupin, int nvcpupin,
int vcpu); int vcpu);
virDomainVcpuPinDefPtr virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def, virDomainPinDefPtr virDomainVcpuPinFindByVcpu(virDomainPinDefPtr *def,
int nvcpupin, int nvcpupin,
int vcpu); int vcpu);
typedef struct _virBlkioDevice virBlkioDevice; typedef struct _virBlkioDevice virBlkioDevice;
typedef virBlkioDevice *virBlkioDevicePtr; typedef virBlkioDevice *virBlkioDevicePtr;
...@@ -2009,10 +2009,10 @@ struct _virDomainCputune { ...@@ -2009,10 +2009,10 @@ struct _virDomainCputune {
unsigned long long emulator_period; unsigned long long emulator_period;
long long emulator_quota; long long emulator_quota;
size_t nvcpupin; size_t nvcpupin;
virDomainVcpuPinDefPtr *vcpupin; virDomainPinDefPtr *vcpupin;
virDomainVcpuPinDefPtr emulatorpin; virDomainPinDefPtr emulatorpin;
size_t niothreadspin; size_t niothreadspin;
virDomainVcpuPinDefPtr *iothreadspin; virDomainPinDefPtr *iothreadspin;
size_t nvcpusched; size_t nvcpusched;
virDomainThreadSchedParamPtr vcpusched; virDomainThreadSchedParamPtr vcpusched;
...@@ -2557,7 +2557,7 @@ int virDomainDefCompatibleDevice(virDomainDefPtr def, ...@@ -2557,7 +2557,7 @@ int virDomainDefCompatibleDevice(virDomainDefPtr def,
virDomainDeviceDefPtr dev, virDomainDeviceDefPtr dev,
virDomainDeviceAction action); virDomainDeviceAction action);
int virDomainVcpuPinAdd(virDomainVcpuPinDefPtr **vcpupin_list, int virDomainVcpuPinAdd(virDomainPinDefPtr **vcpupin_list,
size_t *nvcpupin, size_t *nvcpupin,
unsigned char *cpumap, unsigned char *cpumap,
int maplen, int maplen,
...@@ -2571,8 +2571,7 @@ int virDomainEmulatorPinAdd(virDomainDefPtr def, ...@@ -2571,8 +2571,7 @@ int virDomainEmulatorPinAdd(virDomainDefPtr def,
int virDomainEmulatorPinDel(virDomainDefPtr def); int virDomainEmulatorPinDel(virDomainDefPtr def);
/* IOThreads share the virDomainVcpuPinDefPtr */ int virDomainIOThreadsPinAdd(virDomainPinDefPtr **iothreadspin_list,
int virDomainIOThreadsPinAdd(virDomainVcpuPinDefPtr **iothreadspin_list,
size_t *niothreads, size_t *niothreads,
unsigned char *cpumap, unsigned char *cpumap,
int maplen, int maplen,
......
...@@ -2047,7 +2047,7 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps, ...@@ -2047,7 +2047,7 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
virDomainObjPtr vm = NULL; virDomainObjPtr vm = NULL;
virDomainDefPtr targetDef = NULL; virDomainDefPtr targetDef = NULL;
virDomainVcpuPinDefPtr *vcpupin_list; virDomainPinDefPtr *vcpupin_list;
virBitmapPtr cpumask = NULL; virBitmapPtr cpumask = NULL;
int maxcpu, hostcpus, vcpu, pcpu, n, ret = -1; int maxcpu, hostcpus, vcpu, pcpu, n, ret = -1;
unsigned char *cpumap; unsigned char *cpumap;
......
...@@ -941,7 +941,7 @@ qemuSetupCgroupVcpuBW(virCgroupPtr cgroup, ...@@ -941,7 +941,7 @@ qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
int int
qemuSetupCgroupVcpuPin(virCgroupPtr cgroup, qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
virDomainVcpuPinDefPtr *vcpupin, virDomainPinDefPtr *vcpupin,
int nvcpupin, int nvcpupin,
int vcpuid) int vcpuid)
{ {
...@@ -957,7 +957,7 @@ qemuSetupCgroupVcpuPin(virCgroupPtr cgroup, ...@@ -957,7 +957,7 @@ qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
int int
qemuSetupCgroupIOThreadsPin(virCgroupPtr cgroup, qemuSetupCgroupIOThreadsPin(virCgroupPtr cgroup,
virDomainVcpuPinDefPtr *iothreadspin, virDomainPinDefPtr *iothreadspin,
int niothreadspin, int niothreadspin,
int iothreadid) int iothreadid)
{ {
......
...@@ -53,12 +53,12 @@ int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup, ...@@ -53,12 +53,12 @@ int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
unsigned long long period, unsigned long long period,
long long quota); long long quota);
int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup, int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
virDomainVcpuPinDefPtr *vcpupin, virDomainPinDefPtr *vcpupin,
int nvcpupin, int nvcpupin,
int vcpuid); int vcpuid);
int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup, virBitmapPtr cpumask); int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup, virBitmapPtr cpumask);
int qemuSetupCgroupIOThreadsPin(virCgroupPtr cgroup, int qemuSetupCgroupIOThreadsPin(virCgroupPtr cgroup,
virDomainVcpuPinDefPtr *iothreadspin, virDomainPinDefPtr *iothreadspin,
int niothreadspin, int niothreadspin,
int iothreadid); int iothreadid);
int qemuSetupCgroupForVcpu(virDomainObjPtr vm); int qemuSetupCgroupForVcpu(virDomainObjPtr vm);
......
...@@ -4744,7 +4744,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver, ...@@ -4744,7 +4744,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
/* vm->def->cputune.vcpupin can't be NULL if /* vm->def->cputune.vcpupin can't be NULL if
* vm->def->cpumask is not NULL. * vm->def->cpumask is not NULL.
*/ */
virDomainVcpuPinDefPtr vcpupin = NULL; virDomainPinDefPtr vcpupin = NULL;
if (VIR_ALLOC(vcpupin) < 0) if (VIR_ALLOC(vcpupin) < 0)
goto cleanup; goto cleanup;
...@@ -5046,7 +5046,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, ...@@ -5046,7 +5046,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
bool doReset = false; bool doReset = false;
size_t newVcpuPinNum = 0; size_t newVcpuPinNum = 0;
virDomainVcpuPinDefPtr *newVcpuPin = NULL; virDomainPinDefPtr *newVcpuPin = NULL;
virBitmapPtr pcpumap = NULL; virBitmapPtr pcpumap = NULL;
virQEMUDriverConfigPtr cfg = NULL; virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
...@@ -5283,7 +5283,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom, ...@@ -5283,7 +5283,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom,
goto cleanup; goto cleanup;
for (vcpu = 0; vcpu < ncpumaps; vcpu++) { for (vcpu = 0; vcpu < ncpumaps; vcpu++) {
virDomainVcpuPinDefPtr pininfo; virDomainPinDefPtr pininfo;
virBitmapPtr bitmap = NULL; virBitmapPtr bitmap = NULL;
unsigned char *tmpmap = NULL; unsigned char *tmpmap = NULL;
int tmpmaplen; int tmpmaplen;
...@@ -5336,7 +5336,7 @@ qemuDomainPinEmulator(virDomainPtr dom, ...@@ -5336,7 +5336,7 @@ qemuDomainPinEmulator(virDomainPtr dom,
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
bool doReset = false; bool doReset = false;
size_t newVcpuPinNum = 0; size_t newVcpuPinNum = 0;
virDomainVcpuPinDefPtr *newVcpuPin = NULL; virDomainPinDefPtr *newVcpuPin = NULL;
virBitmapPtr pcpumap = NULL; virBitmapPtr pcpumap = NULL;
virQEMUDriverConfigPtr cfg = NULL; virQEMUDriverConfigPtr cfg = NULL;
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
...@@ -5815,7 +5815,7 @@ qemuDomainGetIOThreadsConfig(virDomainDefPtr targetDef, ...@@ -5815,7 +5815,7 @@ qemuDomainGetIOThreadsConfig(virDomainDefPtr targetDef,
goto cleanup; goto cleanup;
for (i = 0; i < targetDef->iothreads; i++) { for (i = 0; i < targetDef->iothreads; i++) {
virDomainVcpuPinDefPtr pininfo; virDomainPinDefPtr pininfo;
if (VIR_ALLOC(info_ret[i]) < 0) if (VIR_ALLOC(info_ret[i]) < 0)
goto cleanup; goto cleanup;
...@@ -5920,7 +5920,7 @@ qemuDomainPinIOThread(virDomainPtr dom, ...@@ -5920,7 +5920,7 @@ qemuDomainPinIOThread(virDomainPtr dom,
virDomainDefPtr persistentDef = NULL; virDomainDefPtr persistentDef = NULL;
virBitmapPtr pcpumap = NULL; virBitmapPtr pcpumap = NULL;
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
virDomainVcpuPinDefPtr *newIOThreadsPin = NULL; virDomainPinDefPtr *newIOThreadsPin = NULL;
size_t newIOThreadsPinNum = 0; size_t newIOThreadsPinNum = 0;
virCgroupPtr cgroup_iothread = NULL; virCgroupPtr cgroup_iothread = NULL;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
......
...@@ -2413,7 +2413,7 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm) ...@@ -2413,7 +2413,7 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr def = vm->def; virDomainDefPtr def = vm->def;
virDomainVcpuPinDefPtr pininfo; virDomainPinDefPtr pininfo;
int n; int n;
int ret = -1; int ret = -1;
VIR_DEBUG("Setting affinity on CPUs nvcpupin=%zu nvcpus=%d nvcpupids=%d", VIR_DEBUG("Setting affinity on CPUs nvcpupin=%zu nvcpus=%d nvcpupids=%d",
...@@ -2479,7 +2479,7 @@ qemuProcessSetIOThreadsAffinity(virDomainObjPtr vm) ...@@ -2479,7 +2479,7 @@ qemuProcessSetIOThreadsAffinity(virDomainObjPtr vm)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr def = vm->def; virDomainDefPtr def = vm->def;
virDomainVcpuPinDefPtr pininfo; virDomainPinDefPtr pininfo;
size_t i; size_t i;
int ret = -1; int ret = -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册