Beispiel #1
0
int
virDomainNumaDefCPUFormat(virBufferPtr buf,
                          virDomainNumaPtr def)
{
    virNumaMemAccess memAccess;
    char *cpustr;
    size_t ncells = virDomainNumaGetNodeCount(def);
    size_t i;

    if (ncells == 0)
        return 0;

    virBufferAddLit(buf, "<numa>\n");
    virBufferAdjustIndent(buf, 2);
    for (i = 0; i < ncells; i++) {
        memAccess = virDomainNumaGetNodeMemoryAccessMode(def, i);

        if (!(cpustr = virBitmapFormat(virDomainNumaGetNodeCpumask(def, i))))
            return -1;

        virBufferAddLit(buf, "<cell");
        virBufferAsprintf(buf, " id='%zu'", i);
        virBufferAsprintf(buf, " cpus='%s'", cpustr);
        virBufferAsprintf(buf, " memory='%llu'",
                          virDomainNumaGetNodeMemorySize(def, i));
        virBufferAddLit(buf, " unit='KiB'");
        if (memAccess)
            virBufferAsprintf(buf, " memAccess='%s'",
                              virNumaMemAccessTypeToString(memAccess));
        virBufferAddLit(buf, "/>\n");
        VIR_FREE(cpustr);
    }
    virBufferAdjustIndent(buf, -2);
    virBufferAddLit(buf, "</numa>\n");

    return 0;
}
Beispiel #2
0
int
virDomainNumaDefCPUFormatXML(virBufferPtr buf,
                             virDomainNumaPtr def)
{
    virDomainMemoryAccess memAccess;
    virTristateBool discard;
    char *cpustr;
    size_t ncells = virDomainNumaGetNodeCount(def);
    size_t i;

    if (ncells == 0)
        return 0;

    virBufferAddLit(buf, "<numa>\n");
    virBufferAdjustIndent(buf, 2);
    for (i = 0; i < ncells; i++) {
        int ndistances;

        memAccess = virDomainNumaGetNodeMemoryAccessMode(def, i);
        discard = virDomainNumaGetNodeDiscard(def, i);

        if (!(cpustr = virBitmapFormat(virDomainNumaGetNodeCpumask(def, i))))
            return -1;

        virBufferAddLit(buf, "<cell");
        virBufferAsprintf(buf, " id='%zu'", i);
        virBufferAsprintf(buf, " cpus='%s'", cpustr);
        virBufferAsprintf(buf, " memory='%llu'",
                          virDomainNumaGetNodeMemorySize(def, i));
        virBufferAddLit(buf, " unit='KiB'");
        if (memAccess)
            virBufferAsprintf(buf, " memAccess='%s'",
                              virDomainMemoryAccessTypeToString(memAccess));

        if (discard)
            virBufferAsprintf(buf, " discard='%s'",
                              virTristateBoolTypeToString(discard));

        ndistances = def->mem_nodes[i].ndistances;
        if (ndistances == 0) {
            virBufferAddLit(buf, "/>\n");
        } else {
            size_t j;
            virDomainNumaDistancePtr distances = def->mem_nodes[i].distances;

            virBufferAddLit(buf, ">\n");
            virBufferAdjustIndent(buf, 2);
            virBufferAddLit(buf, "<distances>\n");
            virBufferAdjustIndent(buf, 2);
            for (j = 0; j < ndistances; j++) {
                if (distances[j].value) {
                    virBufferAddLit(buf, "<sibling");
                    virBufferAsprintf(buf, " id='%d'", distances[j].cellid);
                    virBufferAsprintf(buf, " value='%d'", distances[j].value);
                    virBufferAddLit(buf, "/>\n");
                }
            }
            virBufferAdjustIndent(buf, -2);
            virBufferAddLit(buf, "</distances>\n");
            virBufferAdjustIndent(buf, -2);
            virBufferAddLit(buf, "</cell>\n");
        }

        VIR_FREE(cpustr);
    }
    virBufferAdjustIndent(buf, -2);
    virBufferAddLit(buf, "</numa>\n");

    return 0;
}