have a list of <code>address</code> subelements, one
for each VF on this PF.
</dd>
+ <dt><code>numa</code></dt>
+ <dd>
+ This optional element contains information on the PCI device
+ with respect to NUMA. For example, the optional
+ <code>node</code> attribute tells which NUMA node is the PCI
+ device associated with.
+ </dd>
</dl>
</dd>
<dt><code>usb_device</code></dt>
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</iommuGroup>\n");
}
+ if (data->pci_dev.numa_node >= 0)
+ virBufferAsprintf(&buf, "<numa node='%d'/>\n",
+ data->pci_dev.numa_node);
break;
case VIR_NODE_DEV_CAP_USB_DEV:
virBufferAsprintf(&buf, "<bus>%d</bus>\n", data->usb_dev.bus);
return NULL;
}
+/**
+ * virNodeDevCapsDefParseIntOptional:
+ * @xpath: XPath to evaluate
+ * @ctxt: Context
+ * @value: Where to store parsed value
+ * @def: Node device which is parsed
+ * @invalid_error_fmt: error message to print on invalid format
+ *
+ * Returns: -1 on error (invalid int format under @xpath)
+ * 0 if @xpath was not found (@value is untouched)
+ * 1 on success
+ */
+static int
+virNodeDevCapsDefParseIntOptional(const char *xpath,
+ xmlXPathContextPtr ctxt,
+ int *value,
+ virNodeDeviceDefPtr def,
+ const char *invalid_error_fmt)
+{
+ int ret;
+ int val;
+
+ ret = virXPathInt(xpath, ctxt, &val);
+ if (ret < -1) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ invalid_error_fmt,
+ def->name);
+ return -1;
+ } else if (ret == -1) {
+ return 0;
+ }
+ *value = val;
+ return 1;
+}
+
static int
virNodeDevCapsDefParseULong(const char *xpath,
xmlXPathContextPtr ctxt,
goto out;
}
}
+
+ if (virNodeDevCapsDefParseIntOptional("number(./numa[1]/@node)", ctxt,
+ &data->pci_dev.numa_node, def,
+ _("invalid NUMA node ID supplied for '%s'")) < 0)
+ goto out;
+
ret = 0;
out:
ctxt->node = orignode;
goto out;
}
+ rc = udevGetIntSysfsAttr(device,
+ "numa_node",
+ &data->pci_dev.numa_node,
+ 10);
+ if (rc == PROPERTY_ERROR) {
+ goto out;
+ } else if (rc == PROPERTY_MISSING) {
+ /* The default value is -1, because it can't be 0
+ * as zero is valid node number. */
+ data->pci_dev.numa_node = -1;
+ }
+
if (!virPCIGetPhysicalFunction(syspath, &data->pci_dev.physical_function))
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;