mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
nodedev: refactor ccw device address parsing from XML
Move ccw device address XML parsing into new method for later reuse. Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
c586488506
commit
4402295d37
@ -1143,6 +1143,58 @@ virNodeDevAPMatrixCapabilityParseXML(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virNodeDevCCWDeviceAddressParseXML(xmlXPathContextPtr ctxt,
|
||||||
|
xmlNodePtr node,
|
||||||
|
const char *dev_name,
|
||||||
|
virCCWDeviceAddress *ccw_addr)
|
||||||
|
{
|
||||||
|
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||||
|
g_autofree char *cssid = NULL;
|
||||||
|
g_autofree char *ssid = NULL;
|
||||||
|
g_autofree char *devno = NULL;
|
||||||
|
|
||||||
|
ctxt->node = node;
|
||||||
|
|
||||||
|
if (!(cssid = virXPathString("string(./cssid[1])", ctxt))) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("missing cssid value for '%s'"), dev_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (virStrToLong_uip(cssid, NULL, 0, &ccw_addr->cssid) < 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("invalid cssid value '%s' for '%s'"),
|
||||||
|
cssid, dev_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(ssid = virXPathString("string(./ssid[1])", ctxt))) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("missing ssid value for '%s'"), dev_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (virStrToLong_uip(ssid, NULL, 0, &ccw_addr->ssid) < 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("invalid ssid value '%s' for '%s'"),
|
||||||
|
ssid, dev_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(devno = virXPathString("string(./devno[1])", ctxt))) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("missing devno value for '%s'"), dev_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (virStrToLong_uip(devno, NULL, 16, &ccw_addr->devno) < 0) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("invalid devno value '%s' for '%s'"),
|
||||||
|
devno, dev_name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virNodeDevCSSCapabilityParseXML(xmlXPathContextPtr ctxt,
|
virNodeDevCSSCapabilityParseXML(xmlXPathContextPtr ctxt,
|
||||||
xmlNodePtr node,
|
xmlNodePtr node,
|
||||||
@ -1180,50 +1232,18 @@ virNodeDevCapCCWParseXML(xmlXPathContextPtr ctxt,
|
|||||||
g_autofree xmlNodePtr *nodes = NULL;
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
g_autofree char *cssid = NULL;
|
g_autofree virCCWDeviceAddress *ccw_addr = NULL;
|
||||||
g_autofree char *ssid = NULL;
|
|
||||||
g_autofree char *devno = NULL;
|
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
if (!(cssid = virXPathString("string(./cssid[1])", ctxt))) {
|
ccw_addr = g_new0(virCCWDeviceAddress, 1);
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("missing cssid value for '%s'"), def->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virStrToLong_uip(cssid, NULL, 0, &ccw_dev->cssid) < 0) {
|
if (virNodeDevCCWDeviceAddressParseXML(ctxt, node, def->name, ccw_addr) < 0)
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("invalid cssid value '%s' for '%s'"),
|
|
||||||
cssid, def->name);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ssid = virXPathString("string(./ssid[1])", ctxt))) {
|
ccw_dev->cssid = ccw_addr->cssid;
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
ccw_dev->ssid = ccw_addr->ssid;
|
||||||
_("missing ssid value for '%s'"), def->name);
|
ccw_dev->devno = ccw_addr->devno;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virStrToLong_uip(ssid, NULL, 0, &ccw_dev->ssid) < 0) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("invalid ssid value '%s' for '%s'"),
|
|
||||||
ssid, def->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(devno = virXPathString("string(./devno[1])", ctxt))) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("missing devno value for '%s'"), def->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virStrToLong_uip(devno, NULL, 16, &ccw_dev->devno) < 0) {
|
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
||||||
_("invalid devno value '%s' for '%s'"),
|
|
||||||
devno, def->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0)
|
if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user