Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/conf/domain_conf.c | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c1ed206119..eaa1398de1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7027,9 +7027,6 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
virDomainXMLOption *xmlopt)
{
virDomainHostdevSubsysSCSIHost *scsihostsrc = &scsisrc->u.host;
- g_autofree char *bus = NULL;
- g_autofree char *target = NULL;
- g_autofree char *unit = NULL;
xmlNodePtr addressnode = NULL;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
@@ -7041,32 +7038,17 @@ virDomainHostdevSubsysSCSIHostDefParseXML(xmlNodePtr sourcenode,
return -1;
}
- if (!(bus = virXMLPropString(addressnode, "bus")) ||
- !(target = virXMLPropString(addressnode, "target")) ||
- !(unit = virXMLPropString(addressnode, "unit"))) {
- virReportError(VIR_ERR_XML_ERROR, "%s",
- _("'bus', 'target', and 'unit' must
be specified "
- "for scsi hostdev source address"));
- return -1;
- }
-
- if (virStrToLong_uip(bus, NULL, 0, &scsihostsrc->bus) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse bus '%s'"), bus);
+ if (virXMLPropUInt(addressnode, "bus", 0, VIR_XML_PROP_REQUIRED,
+ &scsihostsrc->bus) < 0)
return -1;
- }
- if (virStrToLong_uip(target, NULL, 0, &scsihostsrc->target) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse target '%s'"), target);
+ if (virXMLPropUInt(addressnode, "target", 0, VIR_XML_PROP_REQUIRED,
+ &scsihostsrc->target) < 0)
return -1;
- }
- if (virStrToLong_ullp(unit, NULL, 0, &scsihostsrc->unit) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse unit '%s'"), unit);
+ if (virXMLPropULongLong(addressnode, "unit", 0, VIR_XML_PROP_REQUIRED,
+ &scsihostsrc->unit) < 0)
return -1;
- }
if (!(scsihostsrc->adapter = virXPathString("string(./adapter/@name)",
ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
--
2.26.3