virNodeDevCapDRMPtr drm)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- int ret = -1, val;
+ int val;
g_autofree char *type = NULL;
ctxt->node = node;
if ((val = virNodeDevDRMTypeFromString(type)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown drm type '%s' for '%s'"), type, def->name);
- goto out;
+ return -1;
}
drm->type = val;
- ret = 0;
-
- out:
- return ret;
+ return 0;
}
VIR_XPATH_NODE_AUTORESTORE(ctxt)
g_autofree xmlNodePtr *nodes = NULL;
size_t i;
- int n, ret = -1;
+ int n;
unsigned long long val;
ctxt->node = node;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no block device path supplied for '%s'"),
def->name);
- goto out;
+ return -1;
}
storage->bus = virXPathString("string(./bus[1])", ctxt);
storage->serial = virXPathString("string(./serial[1])", ctxt);
if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0)
- goto out;
+ return -1;
for (i = 0; i < n; i++) {
g_autofree char *type = virXMLPropString(nodes[i], "type");
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing storage capability type for '%s'"),
def->name);
- goto out;
+ return -1;
}
if (STREQ(type, "hotpluggable")) {
if (virNodeDevCapsDefParseULongLong("number(./media_size[1])", ctxt, &val, def,
_("no removable media size supplied for '%s'"),
_("invalid removable media size supplied for '%s'")) < 0) {
- goto out;
+ return -1;
}
storage->removable_media_size = val;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown storage capability type '%s' for '%s'"),
type, def->name);
- goto out;
+ return -1;
}
}
if (virNodeDevCapsDefParseULongLong("number(./size[1])", ctxt, &val, def,
_("no size supplied for '%s'"),
_("invalid size supplied for '%s'")) < 0)
- goto out;
+ return -1;
storage->size = val;
}
- ret = 0;
- out:
- return ret;
+ return 0;
}
virNodeDevCapSCSIPtr scsi)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- int ret = -1;
ctxt->node = node;
&scsi->host, def,
_("no SCSI host ID supplied for '%s'"),
_("invalid SCSI host ID supplied for '%s'")) < 0)
- goto out;
+ return -1;
if (virNodeDevCapsDefParseULong("number(./bus[1])", ctxt,
&scsi->bus, def,
_("no SCSI bus ID supplied for '%s'"),
_("invalid SCSI bus ID supplied for '%s'")) < 0)
- goto out;
+ return -1;
if (virNodeDevCapsDefParseULong("number(./target[1])", ctxt,
&scsi->target, def,
_("no SCSI target ID supplied for '%s'"),
_("invalid SCSI target ID supplied for '%s'")) < 0)
- goto out;
+ return -1;
if (virNodeDevCapsDefParseULong("number(./lun[1])", ctxt,
&scsi->lun, def,
_("no SCSI LUN ID supplied for '%s'"),
_("invalid SCSI LUN ID supplied for '%s'")) < 0)
- goto out;
+ return -1;
scsi->type = virXPathString("string(./type[1])", ctxt);
- ret = 0;
- out:
- return ret;
+ return 0;
}
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
g_autofree xmlNodePtr *nodes = NULL;
- int ret = -1, n = 0;
+ int n = 0;
size_t i;
ctxt->node = node;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no target name supplied for '%s'"),
def->name);
- goto out;
+ return -1;
}
if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0)
- goto out;
+ return -1;
for (i = 0; i < n; ++i) {
g_autofree char *type = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing type for SCSI target capability for '%s'"),
def->name);
- goto out;
+ return -1;
}
if (STREQ(type, "fc_remote_port")) {
&scsi_target->rport) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing rport name for '%s'"), def->name);
- goto out;
+ return -1;
}
if (virNodeDevCapsDefParseString("string(./wwpn[1])",
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing wwpn identifier for '%s'"),
def->name);
- goto out;
+ return -1;
}
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown SCSI target capability type '%s' for '%s'"),
type, def->name);
- goto out;
+ return -1;
}
}
- ret = 0;
-
- out:
- return ret;
+ return 0;
}
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
g_autofree xmlNodePtr *nodes = NULL;
- int ret = -1, n = 0;
+ int n = 0;
size_t i;
ctxt->node = node;
&scsi_host->host, def,
_("no SCSI host ID supplied for '%s'"),
_("invalid SCSI host ID supplied for '%s'")) < 0) {
- goto out;
+ return -1;
}
/* Optional unique_id value */
scsi_host->unique_id = -1;
if (virNodeDevCapsDefParseIntOptional("number(./unique_id[1])", ctxt,
&scsi_host->unique_id, def,
_("invalid unique_id supplied for '%s'")) < 0) {
- goto out;
+ return -1;
}
}
if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0)
- goto out;
+ return -1;
for (i = 0; i < n; i++) {
g_autofree char *type = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing SCSI host capability type for '%s'"),
def->name);
- goto out;
+ return -1;
}
if (STREQ(type, "vport_ops")) {
_("no WWNN supplied for '%s', and "
"auto-generation failed"),
def->name);
- goto out;
+ return -1;
}
}
_("no WWPN supplied for '%s', and "
"auto-generation failed"),
def->name);
- goto out;
+ return -1;
}
}
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown SCSI host capability type '%s' for '%s'"),
type, def->name);
- goto out;
+ return -1;
}
}
- ret = 0;
-
- out:
- return ret;
+ return 0;
}
VIR_XPATH_NODE_AUTORESTORE(ctxt)
xmlNodePtr lnk;
size_t i = -1;
- int ret = -1, n = -1;
+ int n = -1;
g_autofree char *type = NULL;
g_autofree xmlNodePtr *nodes = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no network interface supplied for '%s'"),
def->name);
- goto out;
+ return -1;
}
net->address = virXPathString("string(./address[1])", ctxt);
if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0)
- goto out;
+ return -1;
if (n > 0)
net->features = virBitmapNew(VIR_NET_DEV_FEAT_LAST);
if (!(tmp = virXMLPropString(nodes[i], "name"))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing network device feature name"));
- goto out;
+ return -1;
}
if ((val = virNetDevFeatureTypeFromString(tmp)) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("unknown network device feature '%s'"),
tmp);
- goto out;
+ return -1;
}
ignore_value(virBitmapSetBit(net->features, val));
}
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("invalid network type supplied for '%s'"),
def->name);
- goto out;
+ return -1;
}
net->subtype = val;
}
lnk = virXPathNode("./link", ctxt);
if (lnk && virInterfaceLinkParseXML(lnk, &net->lnk) < 0)
- goto out;
+ return -1;
- ret = 0;
- out:
- return ret;
+ return 0;
}
virNodeDevCapUSBIfPtr usb_if)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- int ret = -1;
ctxt->node = node;
&usb_if->number, def,
_("no USB interface number supplied for '%s'"),
_("invalid USB interface number supplied for '%s'")) < 0)
- goto out;
+ return -1;
if (virNodeDevCapsDefParseULong("number(./class[1])", ctxt,
&usb_if->klass, def,
_("no USB interface class supplied for '%s'"),
_("invalid USB interface class supplied for '%s'")) < 0)
- goto out;
+ return -1;
if (virNodeDevCapsDefParseULong("number(./subclass[1])", ctxt,
&usb_if->subclass, def,
_("no USB interface subclass supplied for '%s'"),
_("invalid USB interface subclass supplied for '%s'")) < 0)
- goto out;
+ return -1;
if (virNodeDevCapsDefParseULong("number(./protocol[1])", ctxt,
&usb_if->protocol, def,
_("no USB interface protocol supplied for '%s'"),
_("invalid USB interface protocol supplied for '%s'")) < 0)
- goto out;
+ return -1;
usb_if->description = virXPathString("string(./description[1])", ctxt);
- ret = 0;
- out:
- return ret;
+ return 0;
}
virNodeDevCapUSBDevPtr usb_dev)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- int ret = -1;
ctxt->node = node;
&usb_dev->bus, def,
_("no USB bus number supplied for '%s'"),
_("invalid USB bus number supplied for '%s'")) < 0)
- goto out;
+ return -1;
if (virNodeDevCapsDefParseULong("number(./device[1])", ctxt,
&usb_dev->device, def,
_("no USB device number supplied for '%s'"),
_("invalid USB device number supplied for '%s'")) < 0)
- goto out;
+ return -1;
if (virNodeDevCapsDefParseHexId("string(./vendor[1]/@id)", ctxt,
&usb_dev->vendor, def,
_("no USB vendor ID supplied for '%s'"),
_("invalid USB vendor ID supplied for '%s'")) < 0)
- goto out;
+ return -1;
if (virNodeDevCapsDefParseHexId("string(./product[1]/@id)", ctxt,
&usb_dev->product, def,
_("no USB product ID supplied for '%s'"),
_("invalid USB product ID supplied for '%s'")) < 0)
- goto out;
+ return -1;
usb_dev->vendor_name = virXPathString("string(./vendor[1])", ctxt);
usb_dev->product_name = virXPathString("string(./product[1])", ctxt);
- ret = 0;
- out:
- return ret;
+ return 0;
}
VIR_XPATH_NODE_AUTORESTORE(ctxt)
g_autofree xmlNodePtr *addrNodes = NULL;
g_autofree char *numberStr = NULL;
- int nAddrNodes, ret = -1;
+ int nAddrNodes;
size_t i;
ctxt->node = iommuGroupNode;
if (!numberStr) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("missing iommuGroup number attribute"));
- goto cleanup;
+ return -1;
}
if (virStrToLong_ui(numberStr, NULL, 10,
&pci_dev->iommuGroupNumber) < 0) {
virReportError(VIR_ERR_XML_ERROR,
_("invalid iommuGroup number attribute '%s'"),
numberStr);
- goto cleanup;
+ return -1;
}
if ((nAddrNodes = virXPathNodeSet("./address", ctxt, &addrNodes)) < 0)
- goto cleanup;
+ return -1;
for (i = 0; i < nAddrNodes; i++) {
g_autoptr(virPCIDeviceAddress) pciAddr = g_new0(virPCIDeviceAddress, 1);
if (VIR_APPEND_ELEMENT(pci_dev->iommuGroupDevices,
pci_dev->nIommuGroupDevices,
pciAddr) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virPCIELinkPtr lnk)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- int ret = -1, speed;
+ int speed;
g_autofree char *speedStr = NULL;
g_autofree char *portStr = NULL;
if (virXPathUInt("number(./@width)", ctxt, &lnk->width) < 0) {
virReportError(VIR_ERR_XML_DETAIL, "%s",
_("mandatory attribute 'width' is missing or malformed"));
- goto cleanup;
+ return -1;
}
if ((speedStr = virXPathString("string(./@speed)", ctxt))) {
virReportError(VIR_ERR_XML_DETAIL,
_("malformed 'speed' attribute: %s"),
speedStr);
- goto cleanup;
+ return -1;
}
lnk->speed = speed;
}
virReportError(VIR_ERR_XML_DETAIL,
_("malformed 'port' attribute: %s"),
portStr);
- goto cleanup;
+ return -1;
}
} else {
lnk->port = -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
xmlNodePtr lnk;
- int ret = -1;
ctxt->node = pciExpressNode;
if (virPCIEDeviceInfoLinkParseXML(ctxt, lnk,
pci_express->link_cap) < 0)
- goto cleanup;
+ return -1;
}
if ((lnk = virXPathNode("./link[@validity='sta']", ctxt))) {
if (virPCIEDeviceInfoLinkParseXML(ctxt, lnk,
pci_express->link_sta) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt,
virNodeDevCapPCIDevPtr pci_dev)
{
- int ret = -1;
g_autofree xmlNodePtr *addresses = NULL;
int naddresses = virXPathNodeSet("./address", ctxt, &addresses);
g_autofree char *maxFuncsStr = virXPathString("string(./@maxCount)", ctxt);
size_t i;
if (naddresses < 0)
- goto cleanup;
+ return -1;
if (maxFuncsStr &&
virStrToLong_uip(maxFuncsStr, NULL, 10,
&pci_dev->max_virtual_functions) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Malformed 'maxCount' parameter"));
- goto cleanup;
+ return -1;
}
pci_dev->virtual_functions = g_new0(virPCIDeviceAddressPtr, naddresses);
addr = g_new0(virPCIDeviceAddress, 1);
if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0)
- goto cleanup;
+ return -1;
if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions,
pci_dev->num_virtual_functions,
addr) < 0)
- goto cleanup;
+ return -1;
}
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
{
g_autofree char *type = virXMLPropString(node, "type");
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- int ret = -1;
ctxt->node = node;
if (!type) {
virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing capability type"));
- goto cleanup;
+ return -1;
}
if (STREQ(type, "phys_function") &&
virNodeDevPCICapSRIOVPhysicalParseXML(ctxt, pci_dev) < 0) {
- goto cleanup;
+ return -1;
} else if (STREQ(type, "virt_functions") &&
virNodeDevPCICapSRIOVVirtualParseXML(ctxt, pci_dev) < 0) {
- goto cleanup;
+ return -1;
} else if (STREQ(type, "mdev_types")) {
if (virNodeDevCapMdevTypesParseXML(ctxt,
&pci_dev->mdev_types,
&pci_dev->nmdev_types) < 0)
- goto cleanup;
+ return -1;
pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_MDEV;
} else {
int hdrType = virPCIHeaderTypeFromString(type);
pci_dev->hdrType = hdrType;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virNodeDevCapSystemHardwarePtr hardware = &syscap->hardware;
virNodeDevCapSystemFirmwarePtr firmware = &syscap->firmware;
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- int ret = -1;
g_autofree char *tmp = NULL;
ctxt->node = node;
if (!tmp) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no system UUID supplied for '%s'"), def->name);
- goto out;
+ return -1;
}
if (virUUIDParse(tmp, hardware->uuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("malformed uuid element for '%s'"), def->name);
- goto out;
+ return -1;
}
firmware->vendor_name = virXPathString("string(./firmware/vendor[1])", ctxt);
firmware->version = virXPathString("string(./firmware/version[1])", ctxt);
firmware->release_date = virXPathString("string(./firmware/release_date[1])", ctxt);
- ret = 0;
- out:
- return ret;
+ return 0;
}
static int
virNodeDevCapMdevPtr mdev)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt)
- int ret = -1;
int nattrs = 0;
g_autofree xmlNodePtr *attrs = NULL;
size_t i;
if (!(mdev->type = virXPathString("string(./type[1]/@id)", ctxt))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("missing type id attribute for '%s'"), def->name);
- goto out;
+ return -1;
}
/* 'iommuGroup' is optional, only report an error if the supplied value is
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid iommuGroup number attribute for '%s'"),
def->name);
- goto out;
+ return -1;
}
if ((nattrs = virXPathNodeSet("./attr", ctxt, &attrs)) < 0)
- goto out;
+ return -1;
for (i = 0; i < nattrs; i++)
virNodeDevCapMdevAttributeParseXML(ctxt, attrs[i], mdev);
- ret = 0;
- out:
- return ret;
+ return 0;
}
g_autofree virNodeDevCapType *tmp = NULL;
bool want_list = !!list;
int ncaps = 0;
- int ret = -1;
#define MAYBE_ADD_CAP(cap) \
do { \
} while (0)
if (virNodeDeviceUpdateCaps(def) < 0)
- goto cleanup;
+ return -1;
if (want_list)
tmp = g_new0(virNodeDevCapType, VIR_NODE_DEV_CAP_LAST - 1);
if (want_list)
*list = g_steal_pointer(&tmp);
- ret = ncaps;
- cleanup:
- return ret;
+
+ return ncaps;
}