VIR_FREE(numa);
}
-virDomainNumatuneMemMode
-virDomainNumatuneGetMode(virDomainNumaPtr numatune,
- int cellid)
+/**
+ * virDomainNumatuneGetMode:
+ * @numatune: pointer to numatune definition
+ * @cellid: cell selector
+ * @mode: where to store the result
+ *
+ * Get the defined mode for domain's memory. It's safe to pass
+ * NULL to @mode if the return value is the only info needed.
+ *
+ * Returns: 0 on success (with @mode updated)
+ * -1 if no mode was defined in XML
+ */
+int virDomainNumatuneGetMode(virDomainNumaPtr numatune,
+ int cellid,
+ virDomainNumatuneMemMode *mode)
{
+ int ret = -1;
+ virDomainNumatuneMemMode tmp_mode;
+
if (!numatune)
- return 0;
+ return ret;
if (virDomainNumatuneNodeSpecified(numatune, cellid))
- return numatune->mem_nodes[cellid].mode;
-
- if (numatune->memory.specified)
- return numatune->memory.mode;
+ tmp_mode = numatune->mem_nodes[cellid].mode;
+ else if (numatune->memory.specified)
+ tmp_mode = numatune->memory.mode;
+ else
+ goto cleanup;
- return 0;
+ if (mode)
+ *mode = tmp_mode;
+ ret = 0;
+ cleanup:
+ return ret;
}
virBitmapPtr
/*
* Getters
*/
-virDomainNumatuneMemMode virDomainNumatuneGetMode(virDomainNumaPtr numatune,
- int cellid);
+int virDomainNumatuneGetMode(virDomainNumaPtr numatune,
+ int cellid,
+ virDomainNumatuneMemMode *mode);
virBitmapPtr virDomainNumatuneGetNodeset(virDomainNumaPtr numatune,
virBitmapPtr auto_nodeset,
{
int ret = -1;
char *mask = NULL;
+ virDomainNumatuneMemMode mode;
if (def->placement_mode != VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO &&
def->cpumask) {
VIR_FREE(mask);
}
- if (virDomainNumatuneGetMode(def->numa, -1) !=
- VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
+ if (virDomainNumatuneGetMode(def->numa, -1, &mode) < 0 ||
+ mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
ret = 0;
goto cleanup;
}
virBitmapPtr nodeset = NULL;
virDomainNumatuneMemMode mode;
- mode = virDomainNumatuneGetMode(ctrl->def->numa, -1);
-
- if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
- virCgroupControllerAvailable(VIR_CGROUP_CONTROLLER_CPUSET)) {
- /* Use virNuma* API iff necessary. Once set and child is exec()-ed,
- * there's no way for us to change it. Rely on cgroups (if available
- * and enabled in the config) rather than virNuma*. */
- VIR_DEBUG("Relying on CGroups for memory binding");
- } else {
+ if (virDomainNumatuneGetMode(ctrl->def->numa, -1, &mode) == 0) {
+ if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
+ virCgroupControllerAvailable(VIR_CGROUP_CONTROLLER_CPUSET)) {
+ /* Use virNuma* API iff necessary. Once set and child is exec()-ed,
+ * there's no way for us to change it. Rely on cgroups (if available
+ * and enabled in the config) rather than virNuma*. */
+ VIR_DEBUG("Relying on CGroups for memory binding");
+ } else {
- VIR_DEBUG("Setting up process resource limits");
+ VIR_DEBUG("Setting up process resource limits");
- if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0)
- goto cleanup;
+ if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0)
+ goto cleanup;
- nodeset = virDomainNumatuneGetNodeset(ctrl->def->numa, auto_nodeset, -1);
+ nodeset = virDomainNumatuneGetNodeset(ctrl->def->numa, auto_nodeset, -1);
- if (virNumaSetupMemoryPolicy(mode, nodeset) < 0)
- goto cleanup;
+ if (virNumaSetupMemoryPolicy(mode, nodeset) < 0)
+ goto cleanup;
+ }
}
if (virLXCControllerSetupCpuAffinity(ctrl) < 0)
size_t i;
PRL_VM_TYPE vmType;
PRL_RESULT pret;
+ virDomainNumatuneMemMode memMode;
if (def->title) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
* virDomainDefPtr always contain non zero NUMA configuration
* So, just make sure this configuration does't differ from auto generated.
*/
- if ((virDomainNumatuneGetMode(def->numa, -1) !=
- VIR_DOMAIN_NUMATUNE_MEM_STRICT) ||
+ if ((virDomainNumatuneGetMode(def->numa, -1, &memMode) == 0 &&
+ memMode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) ||
virDomainNumatuneHasPerNodeBinding(def->numa)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("numa parameters are not supported "
{
virCgroupPtr cgroup_temp = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
+ virDomainNumatuneMemMode mode;
char *mem_mask = NULL;
int ret = -1;
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
return 0;
- if (virDomainNumatuneGetMode(vm->def->numa, -1) !=
- VIR_DOMAIN_NUMATUNE_MEM_STRICT)
+ if (virDomainNumatuneGetMode(vm->def->numa, -1, &mode) < 0 ||
+ mode != VIR_DOMAIN_NUMATUNE_MEM_STRICT)
return 0;
if (virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
unsigned long long period = vm->def->cputune.period;
long long quota = vm->def->cputune.quota;
char *mem_mask = NULL;
+ virDomainNumatuneMemMode mem_mode;
if ((period || quota) &&
!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
return 0;
}
- if (virDomainNumatuneGetMode(vm->def->numa, -1) ==
- VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
+ if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 &&
+ mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
priv->autoNodeset,
&mem_mask, -1) < 0)
unsigned long long period = vm->def->cputune.period;
long long quota = vm->def->cputune.quota;
char *mem_mask = NULL;
+ virDomainNumatuneMemMode mem_mode;
if ((period || quota) &&
!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
if (priv->cgroup == NULL)
return 0;
- if (virDomainNumatuneGetMode(vm->def->numa, -1) ==
- VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
+ if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 &&
+ mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
priv->autoNodeset,
&mem_mask, -1) < 0)
return -1;
memAccess = virDomainNumaGetNodeMemoryAccessMode(def->numa, guestNode);
- mode = virDomainNumatuneGetMode(def->numa, guestNode);
+ if (virDomainNumatuneGetMode(def->numa, guestNode, &mode) < 0 &&
+ virDomainNumatuneGetMode(def->numa, -1, &mode) < 0)
+ mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
if (pagesize == 0 || pagesize != system_page_size) {
/* Find the huge page size we want to use */
int ncpupids;
virCgroupPtr cgroup_vcpu = NULL;
char *mem_mask = NULL;
+ virDomainNumatuneMemMode mem_mode;
qemuDomainObjEnterMonitor(driver, vm);
goto cleanup;
}
- if (virDomainNumatuneGetMode(vm->def->numa, -1) ==
- VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
+ if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 &&
+ mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
priv->autoNodeset,
&mem_mask, -1) < 0)
qemuMonitorIOThreadInfoPtr *new_iothreads = NULL;
virCgroupPtr cgroup_iothread = NULL;
char *mem_mask = NULL;
+ virDomainNumatuneMemMode mode;
virDomainIOThreadIDDefPtr iothrid;
virBitmapPtr cpumask;
}
vm->def->iothreads = exp_niothreads;
- if (virDomainNumatuneGetMode(vm->def->numa, -1) ==
- VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
+ if (virDomainNumatuneGetMode(vm->def->numa, -1, &mode) == 0 &&
+ mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
priv->autoNodeset,
&mem_mask, -1) < 0)
virCgroupPtr cgroup_temp = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
char *nodeset_str = NULL;
+ virDomainNumatuneMemMode mode;
size_t i = 0;
int ret = -1;
- if (virDomainNumatuneGetMode(vm->def->numa, -1) !=
- VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
+ if (virDomainNumatuneGetMode(vm->def->numa, -1, &mode) < 0 ||
+ mode != VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("change of nodeset for running domain "
"requires strict numa mode"));
virCapsPtr caps = NULL;
qemuDomainObjPrivatePtr priv;
virBitmapPtr nodeset = NULL;
+ virDomainNumatuneMemMode config_mode;
int mode = -1;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (mode != -1 &&
- virDomainNumatuneGetMode(vm->def->numa, -1) != mode) {
+ virDomainNumatuneGetMode(vm->def->numa, -1, &config_mode) == 0 &&
+ config_mode != mode) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("can't change numatune mode for running domain"));
goto endjob;
VIR_TYPED_PARAM_INT, 0) < 0)
goto cleanup;
- param->value.i = virDomainNumatuneGetMode(def->numa, -1);
+ virDomainNumatuneGetMode(def->numa, -1,
+ (virDomainNumatuneMemMode *) ¶m->value.i);
break;
case 1: /* fill numa nodeset here */
if (virSecurityManagerClearSocketLabel(h->driver->securityManager, h->vm->def) < 0)
goto cleanup;
- mode = virDomainNumatuneGetMode(h->vm->def->numa, -1);
-
- if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
- h->cfg->cgroupControllers & (1 << VIR_CGROUP_CONTROLLER_CPUSET) &&
- virCgroupControllerAvailable(VIR_CGROUP_CONTROLLER_CPUSET)) {
- /* Use virNuma* API iff necessary. Once set and child is exec()-ed,
- * there's no way for us to change it. Rely on cgroups (if available
- * and enabled in the config) rather than virNuma*. */
- VIR_DEBUG("Relying on CGroups for memory binding");
- } else {
- nodeset = virDomainNumatuneGetNodeset(h->vm->def->numa,
- priv->autoNodeset, -1);
+ if (virDomainNumatuneGetMode(h->vm->def->numa, -1, &mode) == 0) {
+ if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
+ h->cfg->cgroupControllers & (1 << VIR_CGROUP_CONTROLLER_CPUSET) &&
+ virCgroupControllerAvailable(VIR_CGROUP_CONTROLLER_CPUSET)) {
+ /* Use virNuma* API iff necessary. Once set and child is exec()-ed,
+ * there's no way for us to change it. Rely on cgroups (if available
+ * and enabled in the config) rather than virNuma*. */
+ VIR_DEBUG("Relying on CGroups for memory binding");
+ } else {
+ nodeset = virDomainNumatuneGetNodeset(h->vm->def->numa,
+ priv->autoNodeset, -1);
- if (virNumaSetupMemoryPolicy(mode, nodeset) < 0)
- goto cleanup;
+ if (virNumaSetupMemoryPolicy(mode, nodeset) < 0)
+ goto cleanup;
+ }
}
ret = 0;