Change virDomainHostdevInsert() and virDomainNetInsert() functions
type to void, since not returning anything usefull at this point.
Also, remove all checks, which test return values of those functions.
Fixes: 98f6f2081d ("util: alloc: Reimplement VIR_APPEND_ELEMENT using
virAppendElement")
Signed-off-by: Artem Chernyshev <artem.chernyshev(a)red-soft.ru>
---
src/conf/domain_conf.c | 25 ++++++-------------------
src/conf/domain_conf.h | 4 ++--
src/libxl/libxl_domain.c | 3 +--
src/libxl/libxl_driver.c | 6 ++----
src/lxc/lxc_driver.c | 6 ++----
src/qemu/qemu_driver.c | 6 ++----
src/qemu/qemu_process.c | 3 +--
7 files changed, 16 insertions(+), 37 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 82672b30a0..3ea70fc051 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14099,12 +14099,10 @@ virDomainChrTargetTypeToString(int deviceType,
return type;
}
-int
+void
virDomainHostdevInsert(virDomainDef *def, virDomainHostdevDef *hostdev)
{
VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, hostdev);
-
- return 0;
}
virDomainHostdevDef *
@@ -14517,15 +14515,11 @@ virDomainDiskRemoveByName(virDomainDef *def, const char *name)
return virDomainDiskRemove(def, idx);
}
-int virDomainNetInsert(virDomainDef *def, virDomainNetDef *net)
+void virDomainNetInsert(virDomainDef *def, virDomainNetDef *net)
{
- /* hostdev net devices must also exist in the hostdevs array */
- if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
- virDomainHostdevInsert(def, &net->data.hostdev.def) < 0)
- return -1;
-
+ if (net->type == VIR_DOMAIN_NET_TYPE_HOSTDEV)
+ virDomainHostdevInsert(def, &net->data.hostdev.def);
VIR_APPEND_ELEMENT(def->nets, def->nnets, net);
- return 0;
}
/**
@@ -18886,15 +18880,8 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt,
return NULL;
def->nets[def->nnets++] = net;
-
- /* <interface type='hostdev'> (and <interface
type='net'>
- * where the actual network type is already known to be
- * hostdev) must also be in the hostdevs array.
- */
- if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV &&
- virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net)) < 0) {
- return NULL;
- }
+ if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV)
+ virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net));
}
VIR_FREE(nodes);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 14901b37ba..6152d464f3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3890,7 +3890,7 @@ int virDomainNetFindIdx(virDomainDef *def, virDomainNetDef *net);
virDomainNetDef *virDomainNetFind(virDomainDef *def, const char *device);
virDomainNetDef *virDomainNetFindByName(virDomainDef *def, const char *ifname);
bool virDomainHasNet(virDomainDef *def, virDomainNetDef *net);
-int virDomainNetInsert(virDomainDef *def, virDomainNetDef *net);
+void virDomainNetInsert(virDomainDef *def, virDomainNetDef *net);
int virDomainNetUpdate(virDomainDef *def, size_t netidx, virDomainNetDef *newnet);
bool virDomainNetBackendIsEqual(virDomainNetBackend *src,
virDomainNetBackend *dst);
@@ -3900,7 +3900,7 @@ virDomainNetDef *virDomainNetRemove(virDomainDef *def, size_t i);
virDomainNetDef *virDomainNetRemoveByObj(virDomainDef *def, virDomainNetDef *net);
void virDomainNetRemoveHostdev(virDomainDef *def, virDomainNetDef *net);
-int virDomainHostdevInsert(virDomainDef *def, virDomainHostdevDef *hostdev);
+void virDomainHostdevInsert(virDomainDef *def, virDomainHostdevDef *hostdev);
virDomainHostdevDef *
virDomainHostdevRemove(virDomainDef *def, size_t i);
int virDomainHostdevFind(virDomainDef *def, virDomainHostdevDef *match,
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 0c4beffd6a..19cbdd9e82 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -999,8 +999,7 @@ libxlNetworkPrepareDevices(virDomainDef *def)
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
- if (virDomainHostdevInsert(def, hostdev) < 0)
- return -1;
+ virDomainHostdevInsert(def, hostdev);
}
}
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index c98d2d737a..691e9b3517 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -3552,8 +3552,7 @@ libxlDomainAttachDeviceConfig(virDomainDef *vmdef,
virDomainDeviceDef *dev)
virMacAddrFormat(&net->mac, mac));
return -1;
}
- if (virDomainNetInsert(vmdef, net))
- return -1;
+ virDomainNetInsert(vmdef, net);
dev->data.net = NULL;
break;
@@ -3577,8 +3576,7 @@ libxlDomainAttachDeviceConfig(virDomainDef *vmdef,
virDomainDeviceDef *dev)
return -1;
}
- if (virDomainHostdevInsert(vmdef, hostdev) < 0)
- return -1;
+ virDomainHostdevInsert(vmdef, hostdev);
dev->data.hostdev = NULL;
break;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 25cbfc57c9..d47e0b4295 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -3010,8 +3010,7 @@ lxcDomainAttachDeviceConfig(virDomainDef *vmdef,
case VIR_DOMAIN_DEVICE_NET:
net =
dev->data.net;
- if (virDomainNetInsert(vmdef, net) < 0)
- return -1;
+ virDomainNetInsert(vmdef, net);
dev->data.net = NULL;
ret = 0;
break;
@@ -3023,8 +3022,7 @@ lxcDomainAttachDeviceConfig(virDomainDef *vmdef,
_("device is already in the domain
configuration"));
return -1;
}
- if (virDomainHostdevInsert(vmdef, hostdev) < 0)
- return -1;
+ virDomainHostdevInsert(vmdef, hostdev);
dev->data.hostdev = NULL;
ret = 0;
break;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2d75357939..4b6068be04 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6697,8 +6697,7 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef,
case VIR_DOMAIN_DEVICE_NET:
net =
dev->data.net;
- if (virDomainNetInsert(vmdef, net))
- return -1;
+ virDomainNetInsert(vmdef, net);
dev->data.net = NULL;
break;
@@ -6715,8 +6714,7 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef,
_("device is already in the domain
configuration"));
return -1;
}
- if (virDomainHostdevInsert(vmdef, hostdev))
- return -1;
+ virDomainHostdevInsert(vmdef, hostdev);
dev->data.hostdev = NULL;
break;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index fc05b4b24f..5926acf7ad 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5760,8 +5760,7 @@ qemuProcessNetworkPrepareDevices(virQEMUDriver *driver,
if (qemuDomainPrepareHostdev(hostdev, priv) < 0)
return -1;
- if (virDomainHostdevInsert(def, hostdev) < 0)
- return -1;
+ virDomainHostdevInsert(def, hostdev);
} else if (actualType == VIR_DOMAIN_NET_TYPE_USER &&
net->backend.type == VIR_DOMAIN_NET_BACKEND_DEFAULT &&
!priv->disableSlirp &&
--
2.43.0