提交 47dd6e28 编写于 作者: A Andrea Bolognani

conf: Parse and format <target index='...'/>

Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NLaine Stump <laine@laine.org>
上级 90855eca
...@@ -3787,6 +3787,12 @@ ...@@ -3787,6 +3787,12 @@
libvirt API to attach host devices to the correct libvirt API to attach host devices to the correct
pci-expander-bus when assigning them to the domain). pci-expander-bus when assigning them to the domain).
</dd> </dd>
<dt><code>index</code></dt>
<dd>
pci-root controllers for pSeries guests use this attribute to
record the order they will show up in the guest.
<span class="since">Since 3.6.0</span>
</dd>
</dl> </dl>
<p> <p>
For machine types which provide an implicit PCI bus, the pci-root For machine types which provide an implicit PCI bus, the pci-root
......
...@@ -2027,6 +2027,11 @@ ...@@ -2027,6 +2027,11 @@
<ref name='uint8'/> <ref name='uint8'/>
</attribute> </attribute>
</optional> </optional>
<optional>
<attribute name='index'>
<ref name='uint8'/>
</attribute>
</optional>
<optional> <optional>
<element name='node'> <element name='node'>
<ref name='unsignedInt'/> <ref name='unsignedInt'/>
......
...@@ -1872,6 +1872,7 @@ virDomainControllerDefNew(virDomainControllerType type) ...@@ -1872,6 +1872,7 @@ virDomainControllerDefNew(virDomainControllerType type)
def->opts.pciopts.chassis = -1; def->opts.pciopts.chassis = -1;
def->opts.pciopts.port = -1; def->opts.pciopts.port = -1;
def->opts.pciopts.busNr = -1; def->opts.pciopts.busNr = -1;
def->opts.pciopts.targetIndex = -1;
def->opts.pciopts.numaNode = -1; def->opts.pciopts.numaNode = -1;
break; break;
case VIR_DOMAIN_CONTROLLER_TYPE_IDE: case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
...@@ -9109,6 +9110,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, ...@@ -9109,6 +9110,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
char *chassis = NULL; char *chassis = NULL;
char *port = NULL; char *port = NULL;
char *busNr = NULL; char *busNr = NULL;
char *targetIndex = NULL;
int numaNode = -1; int numaNode = -1;
char *ioeventfd = NULL; char *ioeventfd = NULL;
char *portsStr = NULL; char *portsStr = NULL;
...@@ -9181,6 +9183,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, ...@@ -9181,6 +9183,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
chassis = virXMLPropString(cur, "chassis"); chassis = virXMLPropString(cur, "chassis");
port = virXMLPropString(cur, "port"); port = virXMLPropString(cur, "port");
busNr = virXMLPropString(cur, "busNr"); busNr = virXMLPropString(cur, "busNr");
targetIndex = virXMLPropString(cur, "index");
processedTarget = true; processedTarget = true;
} }
} }
...@@ -9399,6 +9402,30 @@ virDomainControllerDefParseXML(xmlNodePtr node, ...@@ -9399,6 +9402,30 @@ virDomainControllerDefParseXML(xmlNodePtr node,
goto error; goto error;
} }
} }
if (targetIndex) {
if (virStrToLong_i(targetIndex, NULL, 0,
&def->opts.pciopts.targetIndex) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("Invalid target index '%s' in PCI controller"),
targetIndex);
goto error;
}
if (def->opts.pciopts.targetIndex < 0 ||
def->opts.pciopts.targetIndex > 31) {
virReportError(VIR_ERR_XML_ERROR,
_("PCI controller target index '%s' out of "
"range - must be 0-31"),
targetIndex);
goto error;
}
if ((def->idx == 0 && def->opts.pciopts.targetIndex != 0) ||
(def->idx != 0 && def->opts.pciopts.targetIndex == 0)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Only the PCI controller with index 0 can "
"have target index 0, and vice versa"));
goto error;
}
}
if (numaNode >= 0) if (numaNode >= 0)
def->opts.pciopts.numaNode = numaNode; def->opts.pciopts.numaNode = numaNode;
break; break;
...@@ -9420,6 +9447,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, ...@@ -9420,6 +9447,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
VIR_FREE(chassis); VIR_FREE(chassis);
VIR_FREE(port); VIR_FREE(port);
VIR_FREE(busNr); VIR_FREE(busNr);
VIR_FREE(targetIndex);
VIR_FREE(ioeventfd); VIR_FREE(ioeventfd);
VIR_FREE(portsStr); VIR_FREE(portsStr);
VIR_FREE(iothread); VIR_FREE(iothread);
...@@ -21873,6 +21901,7 @@ virDomainControllerDefFormat(virBufferPtr buf, ...@@ -21873,6 +21901,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
def->opts.pciopts.chassis != -1 || def->opts.pciopts.chassis != -1 ||
def->opts.pciopts.port != -1 || def->opts.pciopts.port != -1 ||
def->opts.pciopts.busNr != -1 || def->opts.pciopts.busNr != -1 ||
def->opts.pciopts.targetIndex != -1 ||
def->opts.pciopts.numaNode != -1) { def->opts.pciopts.numaNode != -1) {
virBufferAddLit(&childBuf, "<target"); virBufferAddLit(&childBuf, "<target");
if (def->opts.pciopts.chassisNr != -1) if (def->opts.pciopts.chassisNr != -1)
...@@ -21887,6 +21916,9 @@ virDomainControllerDefFormat(virBufferPtr buf, ...@@ -21887,6 +21916,9 @@ virDomainControllerDefFormat(virBufferPtr buf,
if (def->opts.pciopts.busNr != -1) if (def->opts.pciopts.busNr != -1)
virBufferAsprintf(&childBuf, " busNr='%d'", virBufferAsprintf(&childBuf, " busNr='%d'",
def->opts.pciopts.busNr); def->opts.pciopts.busNr);
if (def->opts.pciopts.targetIndex != -1)
virBufferAsprintf(&childBuf, " index='%d'",
def->opts.pciopts.targetIndex);
if (def->opts.pciopts.numaNode == -1) { if (def->opts.pciopts.numaNode == -1) {
virBufferAddLit(&childBuf, "/>\n"); virBufferAddLit(&childBuf, "/>\n");
} else { } else {
......
...@@ -786,6 +786,7 @@ struct _virDomainPCIControllerOpts { ...@@ -786,6 +786,7 @@ struct _virDomainPCIControllerOpts {
int chassis; int chassis;
int port; int port;
int busNr; /* used by pci-expander-bus, -1 == unspecified */ int busNr; /* used by pci-expander-bus, -1 == unspecified */
int targetIndex; /* used by spapr-pci-host-bridge, -1 == unspecified */
/* numaNode is a *subelement* of target (to match existing /* numaNode is a *subelement* of target (to match existing
* item in memory target config) -1 == unspecified * item in memory target config) -1 == unspecified
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册