</dl>
+ <h3><a name="resPartition">Resource partitioning</a></h3>
+
+ <p>
+ Hypervisors may allow for virtual machines to be placed into
+ resource partitions, potentially with nesting of said partitions.
+ The <code>resource</code> element groups together configuration
+ related to resource partitioning. It currently supports a child
+ element <code>partition</code> whose content defines the path
+ of the resource partition in which to place the domain. If no
+ partition is listed, then the domain will be placed in a default
+ partition. It is the responsibility of the app/admin to ensure
+ that the partition exists prior to starting the guest. Only the
+ (hypervisor specific) default partition can be assumed to exist
+ by default.
+ </p>
+<pre>
+ ...
+ <resource>
+ <partition>/virtualmachines/production</partition>
+ </resource>
+ ...
+</pre>
+
+ <p>
+ Resource partitions are currently supported by the QEMU and
+ LXC drivers, which map partition paths onto cgroups directories,
+ in all mounted controllers. <span class="since">Since 1.0.5</span>
+ </p>
+
<h3><a name="elementsCPU">CPU model and topology</a></h3>
<p>
VIR_FREE(def);
}
+
+void
+virDomainResourceDefFree(virDomainResourceDefPtr resource)
+{
+ if (!resource)
+ return;
+
+ VIR_FREE(resource->partition);
+ VIR_FREE(resource);
+}
+
+
void virDomainDefFree(virDomainDefPtr def)
{
unsigned int i;
if (!def)
return;
+ virDomainResourceDefFree(def->resource);
+
/* hostdevs must be freed before nets (or any future "intelligent
* hostdevs") because the pointer to the hostdev is really
* pointing into the middle of the higher level device's object,
}
+static virDomainResourceDefPtr
+virDomainResourceDefParse(xmlNodePtr node,
+ xmlXPathContextPtr ctxt)
+{
+ virDomainResourceDefPtr def = NULL;
+ xmlNodePtr tmp = ctxt->node;
+
+ ctxt->node = node;
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ goto error;
+ }
+
+ /* Find out what type of virtualization to use */
+ if (!(def->partition = virXPathString("string(./partition)", ctxt))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("missing resource partition attribute"));
+ goto error;
+ }
+
+ ctxt->node = tmp;
+ return def;
+
+error:
+ ctxt->node = tmp;
+ virDomainResourceDefFree(def);
+ return NULL;
+}
+
+
static virDomainDefPtr
virDomainDefParseXML(xmlDocPtr xml,
xmlNodePtr root,
}
VIR_FREE(nodes);
+ /* Extract numatune if exists. */
+ if ((n = virXPathNodeSet("./resource", ctxt, &nodes)) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("cannot extract resource nodes"));
+ goto error;
+ }
+
+ if (n > 1) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("only one resource element is supported"));
+ goto error;
+ }
+
+ if (n &&
+ !(def->resource = virDomainResourceDefParse(nodes[0], ctxt)))
+ goto error;
+ VIR_FREE(nodes);
+
if ((n = virXPathNodeSet("./features/*", ctxt, &nodes)) < 0)
goto error;
}
}
+
+static void
+virDomainResourceDefFormat(virBufferPtr buf,
+ virDomainResourceDefPtr def)
+{
+ virBufferAddLit(buf, " <resource>\n");
+ virBufferEscapeString(buf, " <partition>%s</partition>\n", def->partition);
+ virBufferAddLit(buf, " </resource>\n");
+}
+
+
#define DUMPXML_FLAGS \
(VIR_DOMAIN_XML_SECURE | \
VIR_DOMAIN_XML_INACTIVE | \
virBufferAddLit(buf, " </numatune>\n");
}
+ if (def->resource)
+ virDomainResourceDefFormat(buf, def->resource);
+
if (def->sysinfo)
virDomainSysinfoDefFormat(buf, def->sysinfo);
void virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights,
int ndevices);
+typedef struct _virDomainResourceDef virDomainResourceDef;
+typedef virDomainResourceDef *virDomainResourceDefPtr;
+struct _virDomainResourceDef {
+ char *partition;
+};
/*
* Guest VM main configuration
} cputune;
virNumaTuneDef numatune;
+ virDomainResourceDefPtr resource;
/* These 3 are based on virDomainLifeCycleAction enum flags */
int onReboot;
bool virDomainObjTaint(virDomainObjPtr obj,
enum virDomainTaintFlags taint);
+void virDomainResourceDefFree(virDomainResourceDefPtr resource);
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
void virDomainDiskDefFree(virDomainDiskDefPtr def);