[libvirt] [PATCH] qemu: Error prompt if invalid dump image format specified
by Osier Yang
"getCompressionType" trys to throw error when invalid dump image
format is specified, or the compression program for the specified
image format is not available, but at the same time, it returns
enum qemud_save_formats, as a result, upper function will think
it was successful, and disgard to check the error, this fix makes
changes so that it returns -1 on FAILURE, And to be consistent with
"save", won't use "raw" as the default dump format anymore.
* src/qemu/qemu_driver.c
- rename "getCompressionType" to "getDumpType"
- return -1 on FAILURE
---
src/qemu/qemu_driver.c | 40 +++++++++++++++++++++++++---------------
1 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 395f72f..f8c2aae 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4787,8 +4787,12 @@ cleanup:
return ret;
}
-static enum qemud_save_formats
-getCompressionType(struct qemud_driver *driver)
+/* Returns enum qemud_save_formats on SUCCESS, or returns -1 if
+ * specified dump image format is invalid or compression program
+ * for the format specified is not available on FAILURE.
+ */
+static int
+getDumpType(struct qemud_driver *driver)
{
int compress = QEMUD_SAVE_FORMAT_RAW;
@@ -4801,15 +4805,14 @@ getCompressionType(struct qemud_driver *driver)
if (compress < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Invalid dump image format specified in "
- "configuration file, using raw"));
- return QEMUD_SAVE_FORMAT_RAW;
+ "configuration file."));
+ return -1;
}
if (!qemudCompressProgramAvailable(compress)) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("Compression program for dump image format "
- "in configuration file isn't available, "
- "using raw"));
- return QEMUD_SAVE_FORMAT_RAW;
+ "in configuration file isn't available."));
+ return -1;
}
}
return compress;
@@ -4865,7 +4868,11 @@ static int qemudDomainCoreDump(virDomainPtr dom,
}
}
- ret = doCoreDump(driver, vm, path, getCompressionType(driver));
+ int compress = getDumpType(driver);
+ if (compress < 0)
+ goto endjob;
+
+ ret = doCoreDump(driver, vm, path, compress);
if (ret < 0)
goto endjob;
@@ -4937,13 +4944,16 @@ static void processWatchdogEvent(void *data, void *opaque)
break;
}
- ret = doCoreDump(driver,
- wdEvent->vm,
- dumpfile,
- getCompressionType(driver));
- if (ret < 0)
- qemuReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("Dump failed"));
+ int compress = getDumpType(driver);
+ if (compress >= 0) {
+ ret = doCoreDump(driver,
+ wdEvent->vm,
+ dumpfile,
+ compress);
+ if (ret < 0)
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ "%s", _("Dump failed"));
+ }
ret = doStartCPUs(driver, wdEvent->vm, NULL);
--
1.7.3.2
13 years, 9 months
[libvirt] [PATCH] Use VIR_ERR_OPERATION_INVALID when appropriated
by Matthias Bolte
VIR_ERR_OPERATION_INVALID means that the operation is not valid
for the current state of the involved object.
---
src/esx/esx_driver.c | 1 -
src/lxc/lxc_driver.c | 2 +-
src/network/bridge_driver.c | 2 +-
src/opennebula/one_driver.c | 2 +-
src/openvz/openvz_driver.c | 2 +-
src/qemu/qemu_driver.c | 4 ++--
src/test/test_driver.c | 34 +++++++++++++++++-----------------
src/uml/uml_driver.c | 10 +++++-----
src/vmware/vmware_driver.c | 2 +-
9 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index de3e49f..26f029c 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -1660,7 +1660,6 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
goto cleanup;
}
-
if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, uuid) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c4fe936..df693ec 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2491,7 +2491,7 @@ static int lxcDomainSetAutostart(virDomainPtr dom,
}
if (!vm->persistent) {
- lxcError(VIR_ERR_INTERNAL_ERROR,
+ lxcError(VIR_ERR_OPERATION_INVALID,
"%s", _("Cannot set autostart for transient domain"));
goto cleanup;
}
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 3f63afd..c098ab5 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1537,7 +1537,7 @@ networkStartNetworkDaemon(struct network_driver *driver,
virNetworkIpDefPtr ipdef;
if (virNetworkObjIsActive(network)) {
- networkReportError(VIR_ERR_INTERNAL_ERROR,
+ networkReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("network is already active"));
return -1;
}
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index b88f44f..4febb46 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -291,7 +291,7 @@ static int oneDomainUndefine(virDomainPtr dom)
}
if (!vm->persistent) {
- oneError(VIR_ERR_INTERNAL_ERROR, "%s",
+ oneError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot undefine transient domain"));
goto return_point;
}
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 7728981..fc6ae29 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1079,7 +1079,7 @@ openvzDomainUndefine(virDomainPtr dom)
}
if (virDomainObjIsActive(vm)) {
- openvzError(VIR_ERR_INTERNAL_ERROR, "%s",
+ openvzError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot delete active domain"));
goto cleanup;
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index be0c231..b2c99a1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6402,7 +6402,7 @@ static int qemudDomainUndefine(virDomainPtr dom) {
}
if (!vm->persistent) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot undefine transient domain"));
goto cleanup;
}
@@ -6849,7 +6849,7 @@ static int qemudDomainSetAutostart(virDomainPtr dom,
}
if (!vm->persistent) {
- qemuReportError(VIR_ERR_INTERNAL_ERROR,
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot set autostart for transient domain"));
goto cleanup;
}
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 601ecf8..7b07780 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3061,7 +3061,7 @@ static int testNetworkUndefine(virNetworkPtr network) {
}
if (virNetworkObjIsActive(privnet)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("Network '%s' is still running"), network->name);
goto cleanup;
}
@@ -3094,7 +3094,7 @@ static int testNetworkStart(virNetworkPtr network) {
}
if (virNetworkObjIsActive(privnet)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("Network '%s' is already running"), network->name);
goto cleanup;
}
@@ -3817,7 +3817,7 @@ testStoragePoolStart(virStoragePoolPtr pool,
}
if (virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"), pool->name);
goto cleanup;
}
@@ -3982,7 +3982,7 @@ testStoragePoolUndefine(virStoragePoolPtr pool) {
}
if (virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"), pool->name);
goto cleanup;
}
@@ -4015,7 +4015,7 @@ testStoragePoolBuild(virStoragePoolPtr pool,
}
if (virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"), pool->name);
goto cleanup;
}
@@ -4044,7 +4044,7 @@ testStoragePoolDestroy(virStoragePoolPtr pool) {
}
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name);
goto cleanup;
}
@@ -4083,7 +4083,7 @@ testStoragePoolDelete(virStoragePoolPtr pool,
}
if (virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is already active"), pool->name);
goto cleanup;
}
@@ -4115,7 +4115,7 @@ testStoragePoolRefresh(virStoragePoolPtr pool,
}
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name);
goto cleanup;
}
@@ -4267,7 +4267,7 @@ testStoragePoolNumVolumes(virStoragePoolPtr pool) {
}
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name);
goto cleanup;
}
@@ -4302,7 +4302,7 @@ testStoragePoolListVolumes(virStoragePoolPtr pool,
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name);
goto cleanup;
}
@@ -4348,7 +4348,7 @@ testStorageVolumeLookupByName(virStoragePoolPtr pool,
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name);
goto cleanup;
}
@@ -4459,7 +4459,7 @@ testStorageVolumeCreateXML(virStoragePoolPtr pool,
}
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name);
goto cleanup;
}
@@ -4540,7 +4540,7 @@ testStorageVolumeCreateXMLFrom(virStoragePoolPtr pool,
}
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), pool->name);
goto cleanup;
}
@@ -4640,7 +4640,7 @@ testStorageVolumeDelete(virStorageVolPtr vol,
}
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), vol->pool);
goto cleanup;
}
@@ -4718,7 +4718,7 @@ testStorageVolumeGetInfo(virStorageVolPtr vol,
}
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), vol->pool);
goto cleanup;
}
@@ -4763,7 +4763,7 @@ testStorageVolumeGetXMLDesc(virStorageVolPtr vol,
}
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), vol->pool);
goto cleanup;
}
@@ -4803,7 +4803,7 @@ testStorageVolumeGetPath(virStorageVolPtr vol) {
}
if (!virStoragePoolObjIsActive(privpool)) {
- testError(VIR_ERR_INTERNAL_ERROR,
+ testError(VIR_ERR_OPERATION_INVALID,
_("storage pool '%s' is not active"), vol->pool);
goto cleanup;
}
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index c6df0a1..57f50f6 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -819,7 +819,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
virCommandPtr cmd = NULL;
if (virDomainObjIsActive(vm)) {
- umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("VM is already active"));
return -1;
}
@@ -1462,7 +1462,7 @@ static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
}
if (virDomainObjIsActive(vm)) {
- umlReportError(VIR_ERR_NO_SUPPORT, "%s",
+ umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot set memory of an active domain"));
goto cleanup;
}
@@ -1656,13 +1656,13 @@ static int umlDomainUndefine(virDomainPtr dom) {
}
if (virDomainObjIsActive(vm)) {
- umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot delete active domain"));
goto cleanup;
}
if (!vm->persistent) {
- umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot undefine transient domain"));
goto cleanup;
}
@@ -1954,7 +1954,7 @@ static int umlDomainSetAutostart(virDomainPtr dom,
}
if (!vm->persistent) {
- umlReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ umlReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot set autostart for transient domain"));
goto cleanup;
}
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 47314f8..f176c2f 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -622,7 +622,7 @@ vmwareDomainUndefine(virDomainPtr dom)
}
if (!vm->persistent) {
- vmwareError(VIR_ERR_INTERNAL_ERROR,
+ vmwareError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot undefine transient domain"));
goto cleanup;
}
--
1.7.0.4
13 years, 9 months
[libvirt] [PATCH] Fix misuse of VIR_ERR_INVALID_* error code
by Matthias Bolte
VIR_ERR_INVALID_* is meant for invalid pointers only.
---
src/conf/nwfilter_conf.c | 6 +++---
src/conf/storage_conf.c | 2 +-
src/network/bridge_driver.c | 20 ++++++++++----------
src/nwfilter/nwfilter_driver.c | 6 +++---
src/nwfilter/nwfilter_ebiptables_driver.c | 20 ++++++++++----------
src/qemu/qemu_driver.c | 4 ++--
src/storage/storage_backend.c | 2 +-
src/test/test_driver.c | 20 ++++++++++----------
8 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 0346471..dbb72b2 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2366,7 +2366,7 @@ virNWFilterObjAssignDef(virConnectPtr conn,
if (nwfilter) {
if (!STREQ(def->name, nwfilter->def->name)) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
_("filter with same UUID but different name "
"('%s') already exists"),
nwfilter->def->name);
@@ -2377,7 +2377,7 @@ virNWFilterObjAssignDef(virConnectPtr conn,
}
if (virNWFilterDefLoopDetect(conn, nwfilters, def)) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("filter would introduce a loop"));
return NULL;
}
@@ -2442,7 +2442,7 @@ virNWFilterObjLoad(virConnectPtr conn,
}
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_XML_ERROR,
_("network filter config filename '%s' does not match name '%s'"),
path, def->name);
virNWFilterDefFree(def);
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index f7f471e..0c37dc6 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1423,7 +1423,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
}
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
- virStorageReportError(VIR_ERR_INVALID_STORAGE_POOL,
+ virStorageReportError(VIR_ERR_XML_ERROR,
_("Storage pool config filename '%s' does not match pool name '%s'"),
path, def->name);
virStoragePoolDefFree(def);
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 4c64a74..3f63afd 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2059,13 +2059,13 @@ static int networkUndefine(virNetworkPtr net) {
network = virNetworkFindByUUID(&driver->networks, net->uuid);
if (!network) {
- networkReportError(VIR_ERR_INVALID_NETWORK,
+ networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid"));
goto cleanup;
}
if (virNetworkObjIsActive(network)) {
- networkReportError(VIR_ERR_INTERNAL_ERROR,
+ networkReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("network is still active"));
goto cleanup;
}
@@ -2138,7 +2138,7 @@ static int networkStart(virNetworkPtr net) {
network = virNetworkFindByUUID(&driver->networks, net->uuid);
if (!network) {
- networkReportError(VIR_ERR_INVALID_NETWORK,
+ networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid"));
goto cleanup;
}
@@ -2161,13 +2161,13 @@ static int networkDestroy(virNetworkPtr net) {
network = virNetworkFindByUUID(&driver->networks, net->uuid);
if (!network) {
- networkReportError(VIR_ERR_INVALID_NETWORK,
+ networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid"));
goto cleanup;
}
if (!virNetworkObjIsActive(network)) {
- networkReportError(VIR_ERR_INTERNAL_ERROR,
+ networkReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("network is not active"));
goto cleanup;
}
@@ -2196,7 +2196,7 @@ static char *networkDumpXML(virNetworkPtr net, int flags ATTRIBUTE_UNUSED) {
networkDriverUnlock(driver);
if (!network) {
- networkReportError(VIR_ERR_INVALID_NETWORK,
+ networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid"));
goto cleanup;
}
@@ -2219,7 +2219,7 @@ static char *networkGetBridgeName(virNetworkPtr net) {
networkDriverUnlock(driver);
if (!network) {
- networkReportError(VIR_ERR_INVALID_NETWORK,
+ networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching id"));
goto cleanup;
}
@@ -2251,7 +2251,7 @@ static int networkGetAutostart(virNetworkPtr net,
network = virNetworkFindByUUID(&driver->networks, net->uuid);
networkDriverUnlock(driver);
if (!network) {
- networkReportError(VIR_ERR_INVALID_NETWORK,
+ networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid"));
goto cleanup;
}
@@ -2276,13 +2276,13 @@ static int networkSetAutostart(virNetworkPtr net,
network = virNetworkFindByUUID(&driver->networks, net->uuid);
if (!network) {
- networkReportError(VIR_ERR_INVALID_NETWORK,
+ networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid"));
goto cleanup;
}
if (!network->persistent) {
- networkReportError(VIR_ERR_INTERNAL_ERROR,
+ networkReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot set autostart for transient network"));
goto cleanup;
}
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index fa72a5f..f903311 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -372,13 +372,13 @@ nwfilterUndefine(virNWFilterPtr obj) {
nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
if (!nwfilter) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_NO_NWFILTER,
"%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
if (virNWFilterTestUnassignDef(obj->conn, nwfilter)) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_OPERATION_INVALID,
"%s",
_("nwfilter is in use"));
goto cleanup;
@@ -417,7 +417,7 @@ nwfilterDumpXML(virNWFilterPtr obj,
nwfilterDriverUnlock(driver);
if (!nwfilter) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_NO_NWFILTER,
"%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index 9b7a7c8..91a9159 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -157,14 +157,14 @@ printVar(virNWFilterHashTablePtr vars,
if ((item->flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) {
char *val = (char *)virHashLookup(vars->hashTable, item->var);
if (!val) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find value for '%s'"),
item->var);
return 1;
}
if (!virStrcpy(buf, val, bufsize)) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Buffer to small to print MAC address "
"'%s' into"),
item->var);
@@ -223,7 +223,7 @@ _printDataType(virNWFilterHashTablePtr vars,
case DATATYPE_MACADDR:
case DATATYPE_MACMASK:
if (bufsize < VIR_MAC_STRING_BUFLEN) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for MAC address"));
return 1;
}
@@ -235,7 +235,7 @@ _printDataType(virNWFilterHashTablePtr vars,
case DATATYPE_IPMASK:
if (snprintf(buf, bufsize, "%d",
item->u.u8) >= bufsize) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint8 type"));
return 1;
}
@@ -245,7 +245,7 @@ _printDataType(virNWFilterHashTablePtr vars,
case DATATYPE_UINT16_HEX:
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
item->u.u16) >= bufsize) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint16 type"));
return 1;
}
@@ -255,14 +255,14 @@ _printDataType(virNWFilterHashTablePtr vars,
case DATATYPE_UINT8_HEX:
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
item->u.u8) >= bufsize) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s",
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint8 type"));
return 1;
}
break;
default:
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Unhandled datatype %x"), item->datatype);
return 1;
break;
@@ -2356,7 +2356,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
case VIR_NWFILTER_RULE_PROTOCOL_IGMP:
case VIR_NWFILTER_RULE_PROTOCOL_ALL:
if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("'%s' protocol not support for net type '%s'"),
virNWFilterRuleProtocolTypeToString(rule->prtclType),
virDomainNetTypeToString(nettype));
@@ -2380,7 +2380,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
case VIR_NWFILTER_RULE_PROTOCOL_ICMPV6:
case VIR_NWFILTER_RULE_PROTOCOL_ALLoIPV6:
if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
_("'%s' protocol not support for net type '%s'"),
virNWFilterRuleProtocolTypeToString(rule->prtclType),
virDomainNetTypeToString(nettype));
@@ -2396,7 +2396,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
break;
case VIR_NWFILTER_RULE_PROTOCOL_LAST:
- virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
+ virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("illegal protocol type"));
rc = 1;
break;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 395f72f..be0c231 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -467,7 +467,7 @@ getVolumeQcowPassphrase(virConnectPtr conn,
enc->nsecrets != 1 ||
enc->secrets[0]->type !=
VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE) {
- qemuReportError(VIR_ERR_INVALID_DOMAIN,
+ qemuReportError(VIR_ERR_XML_ERROR,
_("invalid <encryption> for volume %s"), disk->src);
goto cleanup;
}
@@ -485,7 +485,7 @@ getVolumeQcowPassphrase(virConnectPtr conn,
if (memchr(data, '\0', size) != NULL) {
memset(data, 0, size);
VIR_FREE(data);
- qemuReportError(VIR_ERR_INVALID_SECRET,
+ qemuReportError(VIR_ERR_XML_ERROR,
_("format='qcow' passphrase for %s must not contain a "
"'\\0'"), disk->src);
goto cleanup;
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index ee08a4a..bfe1172 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -713,7 +713,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
return -1;
}
if (enc->nsecrets > 1) {
- virStorageReportError(VIR_ERR_INVALID_STORAGE_VOL, "%s",
+ virStorageReportError(VIR_ERR_XML_ERROR, "%s",
_("too many secrets for qcow encryption"));
return -1;
}
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ddff160..601ecf8 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -4356,7 +4356,7 @@ testStorageVolumeLookupByName(virStoragePoolPtr pool,
privvol = virStorageVolDefFindByName(privpool, name);
if (!privvol) {
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"), name);
goto cleanup;
}
@@ -4399,7 +4399,7 @@ testStorageVolumeLookupByKey(virConnectPtr conn,
testDriverUnlock(privconn);
if (!ret)
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching key '%s'"), key);
return ret;
@@ -4433,7 +4433,7 @@ testStorageVolumeLookupByPath(virConnectPtr conn,
testDriverUnlock(privconn);
if (!ret)
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching path '%s'"), path);
return ret;
@@ -4469,7 +4469,7 @@ testStorageVolumeCreateXML(virStoragePoolPtr pool,
goto cleanup;
if (virStorageVolDefFindByName(privpool, privvol->name)) {
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_OPERATION_FAILED,
"%s", _("storage vol already exists"));
goto cleanup;
}
@@ -4550,14 +4550,14 @@ testStorageVolumeCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
if (virStorageVolDefFindByName(privpool, privvol->name)) {
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_OPERATION_FAILED,
"%s", _("storage vol already exists"));
goto cleanup;
}
origvol = virStorageVolDefFindByName(privpool, clonevol->name);
if (!origvol) {
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"),
clonevol->name);
goto cleanup;
@@ -4633,7 +4633,7 @@ testStorageVolumeDelete(virStorageVolPtr vol,
privvol = virStorageVolDefFindByName(privpool, vol->name);
if (privvol == NULL) {
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"),
vol->name);
goto cleanup;
@@ -4711,7 +4711,7 @@ testStorageVolumeGetInfo(virStorageVolPtr vol,
privvol = virStorageVolDefFindByName(privpool, vol->name);
if (privvol == NULL) {
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"),
vol->name);
goto cleanup;
@@ -4756,7 +4756,7 @@ testStorageVolumeGetXMLDesc(virStorageVolPtr vol,
privvol = virStorageVolDefFindByName(privpool, vol->name);
if (privvol == NULL) {
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"),
vol->name);
goto cleanup;
@@ -4796,7 +4796,7 @@ testStorageVolumeGetPath(virStorageVolPtr vol) {
privvol = virStorageVolDefFindByName(privpool, vol->name);
if (privvol == NULL) {
- testError(VIR_ERR_INVALID_STORAGE_VOL,
+ testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"),
vol->name);
goto cleanup;
--
1.7.0.4
13 years, 9 months
[libvirt] [PATCH] Simplify "NWFilterPool" to "NWFilter"
by Matthias Bolte
The public object is called NWFilter but the corresponding private
object is called NWFilterPool. I don't see compelling reasons for this
Pool suffix. One might argue that an NWFilter is a "pool" of rules, etc.
Remove the Pool suffix from NWFilterPool. No functional change included.
---
cfg.mk | 8 +-
src/conf/nwfilter_conf.c | 237 ++++++++++++++++----------------
src/conf/nwfilter_conf.h | 60 ++++----
src/datatypes.c | 72 +++++-----
src/datatypes.h | 8 +-
src/driver.h | 4 +-
src/libvirt.c | 4 +-
src/libvirt_private.syms | 20 ++--
src/nwfilter/nwfilter_driver.c | 112 ++++++++--------
src/nwfilter/nwfilter_gentech_driver.c | 30 ++--
10 files changed, 276 insertions(+), 279 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index d4c593f..066fa3d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -116,7 +116,7 @@ useless_free_options = \
--name=virNWFilterHashTableFree \
--name=virNWFilterIPAddrLearnReqFree \
--name=virNWFilterIncludeDefFree \
- --name=virNWFilterPoolObjFree \
+ --name=virNWFilterObjFree \
--name=virNWFilterRuleDefFree \
--name=virNWFilterRuleInstFree \
--name=virNetworkDefFree \
@@ -194,9 +194,9 @@ useless_free_options = \
# y virNWFilterHashTableFree
# y virNWFilterIPAddrLearnReqFree
# y virNWFilterIncludeDefFree
-# n virNWFilterPoolFreeName (returns int)
-# y virNWFilterPoolObjFree
-# n virNWFilterPoolObjListFree FIXME
+# n virNWFilterFreeName (returns int)
+# y virNWFilterObjFree
+# n virNWFilterObjListFree FIXME
# y virNWFilterRuleDefFree
# n virNWFilterRuleFreeInstanceData (typedef)
# y virNWFilterRuleInstFree
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 6fd07d4..0346471 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -299,7 +299,8 @@ virNWFilterDefFree(virNWFilterDefPtr def) {
void
-virNWFilterPoolObjFree(virNWFilterPoolObjPtr obj) {
+virNWFilterObjFree(virNWFilterObjPtr obj)
+{
if (!obj)
return;
@@ -315,13 +316,13 @@ virNWFilterPoolObjFree(virNWFilterPoolObjPtr obj) {
void
-virNWFilterPoolObjListFree(virNWFilterPoolObjListPtr pools)
+virNWFilterObjListFree(virNWFilterObjListPtr nwfilters)
{
unsigned int i;
- for (i = 0 ; i < pools->count ; i++)
- virNWFilterPoolObjFree(pools->objs[i]);
- VIR_FREE(pools->objs);
- pools->count = 0;
+ for (i = 0 ; i < nwfilters->count ; i++)
+ virNWFilterObjFree(nwfilters->objs[i]);
+ VIR_FREE(nwfilters->objs);
+ nwfilters->count = 0;
}
@@ -382,31 +383,31 @@ virNWFilterRuleDefAddString(virNWFilterRuleDefPtr nwf,
void
-virNWFilterPoolObjRemove(virNWFilterPoolObjListPtr pools,
- virNWFilterPoolObjPtr pool)
+virNWFilterObjRemove(virNWFilterObjListPtr nwfilters,
+ virNWFilterObjPtr nwfilter)
{
unsigned int i;
- virNWFilterPoolObjUnlock(pool);
+ virNWFilterObjUnlock(nwfilter);
- for (i = 0 ; i < pools->count ; i++) {
- virNWFilterPoolObjLock(pools->objs[i]);
- if (pools->objs[i] == pool) {
- virNWFilterPoolObjUnlock(pools->objs[i]);
- virNWFilterPoolObjFree(pools->objs[i]);
+ for (i = 0 ; i < nwfilters->count ; i++) {
+ virNWFilterObjLock(nwfilters->objs[i]);
+ if (nwfilters->objs[i] == nwfilter) {
+ virNWFilterObjUnlock(nwfilters->objs[i]);
+ virNWFilterObjFree(nwfilters->objs[i]);
- if (i < (pools->count - 1))
- memmove(pools->objs + i, pools->objs + i + 1,
- sizeof(*(pools->objs)) * (pools->count - (i + 1)));
+ if (i < (nwfilters->count - 1))
+ memmove(nwfilters->objs + i, nwfilters->objs + i + 1,
+ sizeof(*(nwfilters->objs)) * (nwfilters->count - (i + 1)));
- if (VIR_REALLOC_N(pools->objs, pools->count - 1) < 0) {
+ if (VIR_REALLOC_N(nwfilters->objs, nwfilters->count - 1) < 0) {
; /* Failure to reduce memory allocation isn't fatal */
}
- pools->count--;
+ nwfilters->count--;
break;
}
- virNWFilterPoolObjUnlock(pools->objs[i]);
+ virNWFilterObjUnlock(nwfilters->objs[i]);
}
}
@@ -1998,7 +1999,7 @@ virNWFilterDefParseNode(xmlDocPtr xml,
if (STRNEQ((const char *)root->name, "filter")) {
virNWFilterReportError(VIR_ERR_XML_ERROR,
"%s",
- _("unknown root element for nw filter pool"));
+ _("unknown root element for nw filter"));
goto cleanup;
}
@@ -2089,34 +2090,33 @@ virNWFilterDefParseFile(virConnectPtr conn,
}
-virNWFilterPoolObjPtr
-virNWFilterPoolObjFindByUUID(virNWFilterPoolObjListPtr pools,
- const unsigned char *uuid)
+virNWFilterObjPtr
+virNWFilterObjFindByUUID(virNWFilterObjListPtr nwfilters,
+ const unsigned char *uuid)
{
unsigned int i;
- for (i = 0 ; i < pools->count ; i++) {
- virNWFilterPoolObjLock(pools->objs[i]);
- if (!memcmp(pools->objs[i]->def->uuid, uuid, VIR_UUID_BUFLEN))
- return pools->objs[i];
- virNWFilterPoolObjUnlock(pools->objs[i]);
+ for (i = 0 ; i < nwfilters->count ; i++) {
+ virNWFilterObjLock(nwfilters->objs[i]);
+ if (!memcmp(nwfilters->objs[i]->def->uuid, uuid, VIR_UUID_BUFLEN))
+ return nwfilters->objs[i];
+ virNWFilterObjUnlock(nwfilters->objs[i]);
}
return NULL;
}
-virNWFilterPoolObjPtr
-virNWFilterPoolObjFindByName(virNWFilterPoolObjListPtr pools,
- const char *name)
+virNWFilterObjPtr
+virNWFilterObjFindByName(virNWFilterObjListPtr nwfilters, const char *name)
{
unsigned int i;
- for (i = 0 ; i < pools->count ; i++) {
- virNWFilterPoolObjLock(pools->objs[i]);
- if (STREQ(pools->objs[i]->def->name, name))
- return pools->objs[i];
- virNWFilterPoolObjUnlock(pools->objs[i]);
+ for (i = 0 ; i < nwfilters->count ; i++) {
+ virNWFilterObjLock(nwfilters->objs[i]);
+ if (STREQ(nwfilters->objs[i]->def->name, name))
+ return nwfilters->objs[i];
+ virNWFilterObjUnlock(nwfilters->objs[i]);
}
return NULL;
@@ -2197,14 +2197,14 @@ cleanup:
static int
_virNWFilterDefLoopDetect(virConnectPtr conn,
- virNWFilterPoolObjListPtr pools,
+ virNWFilterObjListPtr nwfilters,
virNWFilterDefPtr def,
const char *filtername)
{
int rc = 0;
int i;
virNWFilterEntryPtr entry;
- virNWFilterPoolObjPtr obj;
+ virNWFilterObjPtr obj;
if (!def)
return 0;
@@ -2218,14 +2218,13 @@ _virNWFilterDefLoopDetect(virConnectPtr conn,
break;
}
- obj = virNWFilterPoolObjFindByName(pools,
- entry->include->filterref);
+ obj = virNWFilterObjFindByName(nwfilters,
+ entry->include->filterref);
if (obj) {
- rc = _virNWFilterDefLoopDetect(conn,
- pools,
+ rc = _virNWFilterDefLoopDetect(conn, nwfilters,
obj->def, filtername);
- virNWFilterPoolObjUnlock(obj);
+ virNWFilterObjUnlock(obj);
if (rc)
break;
}
@@ -2239,7 +2238,7 @@ _virNWFilterDefLoopDetect(virConnectPtr conn,
/*
* virNWFilterDefLoopDetect:
* @conn: pointer to virConnect object
- * @pools : the pools to search
+ * @nwfilters : the nwfilters to search
* @def : the filter definiton that may add a loop and is to be tested
*
* Detect a loop introduced through the filters being able to
@@ -2249,10 +2248,10 @@ _virNWFilterDefLoopDetect(virConnectPtr conn,
*/
static int
virNWFilterDefLoopDetect(virConnectPtr conn,
- virNWFilterPoolObjListPtr pools,
+ virNWFilterObjListPtr nwfilters,
virNWFilterDefPtr def)
{
- return _virNWFilterDefLoopDetect(conn, pools, def, def->name);
+ return _virNWFilterDefLoopDetect(conn, nwfilters, def, def->name);
}
int nCallbackDriver;
@@ -2339,104 +2338,104 @@ virNWFilterTriggerVMFilterRebuild(virConnectPtr conn)
int
virNWFilterTestUnassignDef(virConnectPtr conn,
- virNWFilterPoolObjPtr pool)
+ virNWFilterObjPtr nwfilter)
{
int rc = 0;
virNWFilterLockFilterUpdates();
- pool->wantRemoved = 1;
+ nwfilter->wantRemoved = 1;
// trigger the update on VMs referencing the filter
if (virNWFilterTriggerVMFilterRebuild(conn))
rc = 1;
- pool->wantRemoved = 0;
+ nwfilter->wantRemoved = 0;
virNWFilterUnlockFilterUpdates();
return rc;
}
-virNWFilterPoolObjPtr
-virNWFilterPoolObjAssignDef(virConnectPtr conn,
- virNWFilterPoolObjListPtr pools,
- virNWFilterDefPtr def)
+virNWFilterObjPtr
+virNWFilterObjAssignDef(virConnectPtr conn,
+ virNWFilterObjListPtr nwfilters,
+ virNWFilterDefPtr def)
{
- virNWFilterPoolObjPtr pool;
+ virNWFilterObjPtr nwfilter;
- pool = virNWFilterPoolObjFindByUUID(pools, def->uuid);
+ nwfilter = virNWFilterObjFindByUUID(nwfilters, def->uuid);
- if (pool) {
- if (!STREQ(def->name, pool->def->name)) {
+ if (nwfilter) {
+ if (!STREQ(def->name, nwfilter->def->name)) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
- _("filter with same UUID but different name "
- "('%s') already exists"),
- pool->def->name);
- virNWFilterPoolObjUnlock(pool);
+ _("filter with same UUID but different name "
+ "('%s') already exists"),
+ nwfilter->def->name);
+ virNWFilterObjUnlock(nwfilter);
return NULL;
}
- virNWFilterPoolObjUnlock(pool);
+ virNWFilterObjUnlock(nwfilter);
}
- if (virNWFilterDefLoopDetect(conn, pools, def)) {
+ if (virNWFilterDefLoopDetect(conn, nwfilters, def)) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
"%s", _("filter would introduce a loop"));
return NULL;
}
- if ((pool = virNWFilterPoolObjFindByName(pools, def->name))) {
+ if ((nwfilter = virNWFilterObjFindByName(nwfilters, def->name))) {
virNWFilterLockFilterUpdates();
- pool->newDef = def;
+ nwfilter->newDef = def;
// trigger the update on VMs referencing the filter
if (virNWFilterTriggerVMFilterRebuild(conn)) {
- pool->newDef = NULL;
+ nwfilter->newDef = NULL;
virNWFilterUnlockFilterUpdates();
- virNWFilterPoolObjUnlock(pool);
+ virNWFilterObjUnlock(nwfilter);
return NULL;
}
- virNWFilterDefFree(pool->def);
- pool->def = def;
- pool->newDef = NULL;
+ virNWFilterDefFree(nwfilter->def);
+ nwfilter->def = def;
+ nwfilter->newDef = NULL;
virNWFilterUnlockFilterUpdates();
- return pool;
+ return nwfilter;
}
- if (VIR_ALLOC(pool) < 0) {
+ if (VIR_ALLOC(nwfilter) < 0) {
virReportOOMError();
return NULL;
}
- if (virMutexInitRecursive(&pool->lock) < 0) {
+ if (virMutexInitRecursive(&nwfilter->lock) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot initialize mutex"));
- VIR_FREE(pool);
+ VIR_FREE(nwfilter);
return NULL;
}
- virNWFilterPoolObjLock(pool);
- pool->active = 0;
- pool->def = def;
+ virNWFilterObjLock(nwfilter);
+ nwfilter->active = 0;
+ nwfilter->def = def;
- if (VIR_REALLOC_N(pools->objs, pools->count+1) < 0) {
- pool->def = NULL;
- virNWFilterPoolObjUnlock(pool);
- virNWFilterPoolObjFree(pool);
+ if (VIR_REALLOC_N(nwfilters->objs, nwfilters->count + 1) < 0) {
+ nwfilter->def = NULL;
+ virNWFilterObjUnlock(nwfilter);
+ virNWFilterObjFree(nwfilter);
virReportOOMError();
return NULL;
}
- pools->objs[pools->count++] = pool;
+ nwfilters->objs[nwfilters->count++] = nwfilter;
- return pool;
+ return nwfilter;
}
-static virNWFilterPoolObjPtr
-virNWFilterPoolObjLoad(virConnectPtr conn,
- virNWFilterPoolObjListPtr pools,
- const char *file,
- const char *path)
+static virNWFilterObjPtr
+virNWFilterObjLoad(virConnectPtr conn,
+ virNWFilterObjListPtr nwfilters,
+ const char *file,
+ const char *path)
{
virNWFilterDefPtr def;
- virNWFilterPoolObjPtr pool;
+ virNWFilterObjPtr nwfilter;
if (!(def = virNWFilterDefParseFile(conn, path))) {
return NULL;
@@ -2444,33 +2443,33 @@ virNWFilterPoolObjLoad(virConnectPtr conn,
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
- _("network filter pool config filename '%s' does not match pool name '%s'"),
+ _("network filter config filename '%s' does not match name '%s'"),
path, def->name);
virNWFilterDefFree(def);
return NULL;
}
- if (!(pool = virNWFilterPoolObjAssignDef(conn, pools, def))) {
+ if (!(nwfilter = virNWFilterObjAssignDef(conn, nwfilters, def))) {
virNWFilterDefFree(def);
return NULL;
}
- VIR_FREE(pool->configFile); // for driver reload
- pool->configFile = strdup(path);
- if (pool->configFile == NULL) {
+ VIR_FREE(nwfilter->configFile); // for driver reload
+ nwfilter->configFile = strdup(path);
+ if (nwfilter->configFile == NULL) {
virReportOOMError();
virNWFilterDefFree(def);
return NULL;
}
- return pool;
+ return nwfilter;
}
int
-virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
- virNWFilterPoolObjListPtr pools,
- const char *configDir)
+virNWFilterLoadAllConfigs(virConnectPtr conn,
+ virNWFilterObjListPtr nwfilters,
+ const char *configDir)
{
DIR *dir;
struct dirent *entry;
@@ -2486,7 +2485,7 @@ virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
while ((entry = readdir(dir))) {
char path[PATH_MAX];
- virNWFilterPoolObjPtr pool;
+ virNWFilterObjPtr nwfilter;
if (entry->d_name[0] == '.')
continue;
@@ -2502,9 +2501,9 @@ virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
continue;
}
- pool = virNWFilterPoolObjLoad(conn, pools, entry->d_name, path);
- if (pool)
- virNWFilterPoolObjUnlock(pool);
+ nwfilter = virNWFilterObjLoad(conn, nwfilters, entry->d_name, path);
+ if (nwfilter)
+ virNWFilterObjUnlock(nwfilter);
}
closedir(dir);
@@ -2514,15 +2513,15 @@ virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
int
-virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
- virNWFilterPoolObjPtr pool,
- virNWFilterDefPtr def)
+virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver,
+ virNWFilterObjPtr nwfilter,
+ virNWFilterDefPtr def)
{
char *xml;
int fd = -1, ret = -1;
ssize_t towrite;
- if (!pool->configFile) {
+ if (!nwfilter->configFile) {
int err;
char path[PATH_MAX];
@@ -2539,7 +2538,7 @@ virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
"%s", _("cannot construct config file path"));
return -1;
}
- if (!(pool->configFile = strdup(path))) {
+ if (!(nwfilter->configFile = strdup(path))) {
virReportOOMError();
return -1;
}
@@ -2551,12 +2550,12 @@ virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
return -1;
}
- if ((fd = open(pool->configFile,
+ if ((fd = open(nwfilter->configFile,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR )) < 0) {
virReportSystemError(errno,
_("cannot create config file %s"),
- pool->configFile);
+ nwfilter->configFile);
goto cleanup;
}
@@ -2564,14 +2563,14 @@ virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
if (safewrite(fd, xml, towrite) != towrite) {
virReportSystemError(errno,
_("cannot write config file %s"),
- pool->configFile);
+ nwfilter->configFile);
goto cleanup;
}
if (VIR_CLOSE(fd) < 0) {
virReportSystemError(errno,
_("cannot save config file %s"),
- pool->configFile);
+ nwfilter->configFile);
goto cleanup;
}
@@ -2587,18 +2586,18 @@ virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
int
-virNWFilterPoolObjDeleteDef(virNWFilterPoolObjPtr pool)
+virNWFilterObjDeleteDef(virNWFilterObjPtr nwfilter)
{
- if (!pool->configFile) {
+ if (!nwfilter->configFile) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
- _("no config file for %s"), pool->def->name);
+ _("no config file for %s"), nwfilter->def->name);
return -1;
}
- if (unlink(pool->configFile) < 0) {
+ if (unlink(nwfilter->configFile) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot remove config for %s"),
- pool->def->name);
+ nwfilter->def->name);
return -1;
}
@@ -2900,12 +2899,12 @@ void virNWFilterConfLayerShutdown(void)
}
-void virNWFilterPoolObjLock(virNWFilterPoolObjPtr obj)
+void virNWFilterObjLock(virNWFilterObjPtr obj)
{
virMutexLock(&obj->lock);
}
-void virNWFilterPoolObjUnlock(virNWFilterPoolObjPtr obj)
+void virNWFilterObjUnlock(virNWFilterObjPtr obj)
{
virMutexUnlock(&obj->lock);
}
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index 4d76c4c..b21f5b9 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -441,10 +441,10 @@ struct _virNWFilterDef {
};
-typedef struct _virNWFilterPoolObj virNWFilterPoolObj;
-typedef virNWFilterPoolObj *virNWFilterPoolObjPtr;
+typedef struct _virNWFilterObj virNWFilterObj;
+typedef virNWFilterObj *virNWFilterObjPtr;
-struct _virNWFilterPoolObj {
+struct _virNWFilterObj {
virMutex lock;
char *configFile;
@@ -456,11 +456,11 @@ struct _virNWFilterPoolObj {
};
-typedef struct _virNWFilterPoolObjList virNWFilterPoolObjList;
-typedef virNWFilterPoolObjList *virNWFilterPoolObjListPtr;
-struct _virNWFilterPoolObjList {
+typedef struct _virNWFilterObjList virNWFilterObjList;
+typedef virNWFilterObjList *virNWFilterObjListPtr;
+struct _virNWFilterObjList {
unsigned int count;
- virNWFilterPoolObjPtr *objs;
+ virNWFilterObjPtr *objs;
};
@@ -469,7 +469,7 @@ typedef virNWFilterDriverState *virNWFilterDriverStatePtr;
struct _virNWFilterDriverState {
virMutex lock;
- virNWFilterPoolObjList pools;
+ virNWFilterObjList nwfilters;
char *configDir;
};
@@ -583,33 +583,31 @@ struct _virNWFilterTechDriver {
void virNWFilterRuleDefFree(virNWFilterRuleDefPtr def);
void virNWFilterDefFree(virNWFilterDefPtr def);
-void virNWFilterPoolObjListFree(virNWFilterPoolObjListPtr pools);
-void virNWFilterPoolObjRemove(virNWFilterPoolObjListPtr pools,
- virNWFilterPoolObjPtr pool);
+void virNWFilterObjListFree(virNWFilterObjListPtr nwfilters);
+void virNWFilterObjRemove(virNWFilterObjListPtr nwfilters,
+ virNWFilterObjPtr nwfilter);
-void virNWFilterPoolObjFree(virNWFilterPoolObjPtr obj);
+void virNWFilterObjFree(virNWFilterObjPtr obj);
-virNWFilterPoolObjPtr
- virNWFilterPoolObjFindByUUID(virNWFilterPoolObjListPtr pools,
- const unsigned char *uuid);
+virNWFilterObjPtr virNWFilterObjFindByUUID(virNWFilterObjListPtr nwfilters,
+ const unsigned char *uuid);
-virNWFilterPoolObjPtr
- virNWFilterPoolObjFindByName(virNWFilterPoolObjListPtr pools,
- const char *name);
+virNWFilterObjPtr virNWFilterObjFindByName(virNWFilterObjListPtr nwfilters,
+ const char *name);
-int virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
- virNWFilterPoolObjPtr pool,
- virNWFilterDefPtr def);
+int virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver,
+ virNWFilterObjPtr nwfilter,
+ virNWFilterDefPtr def);
-int virNWFilterPoolObjDeleteDef(virNWFilterPoolObjPtr pool);
+int virNWFilterObjDeleteDef(virNWFilterObjPtr nwfilter);
-virNWFilterPoolObjPtr virNWFilterPoolObjAssignDef(virConnectPtr conn,
- virNWFilterPoolObjListPtr pools,
- virNWFilterDefPtr def);
+virNWFilterObjPtr virNWFilterObjAssignDef(virConnectPtr conn,
+ virNWFilterObjListPtr nwfilters,
+ virNWFilterDefPtr def);
int virNWFilterTestUnassignDef(virConnectPtr conn,
- virNWFilterPoolObjPtr pool);
+ virNWFilterObjPtr nwfilter);
virNWFilterDefPtr virNWFilterDefParseNode(xmlDocPtr xml,
xmlNodePtr root);
@@ -623,9 +621,9 @@ int virNWFilterSaveXML(const char *configDir,
int virNWFilterSaveConfig(const char *configDir,
virNWFilterDefPtr def);
-int virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
- virNWFilterPoolObjListPtr pools,
- const char *configDir);
+int virNWFilterLoadAllConfigs(virConnectPtr conn,
+ virNWFilterObjListPtr nwfilters,
+ const char *configDir);
char *virNWFilterConfigFile(const char *dir,
const char *name);
@@ -635,8 +633,8 @@ virNWFilterDefPtr virNWFilterDefParseString(virConnectPtr conn,
virNWFilterDefPtr virNWFilterDefParseFile(virConnectPtr conn,
const char *filename);
-void virNWFilterPoolObjLock(virNWFilterPoolObjPtr obj);
-void virNWFilterPoolObjUnlock(virNWFilterPoolObjPtr obj);
+void virNWFilterObjLock(virNWFilterObjPtr obj);
+void virNWFilterObjUnlock(virNWFilterObjPtr obj);
void virNWFilterLockFilterUpdates(void);
void virNWFilterUnlockFilterUpdates(void);
diff --git a/src/datatypes.c b/src/datatypes.c
index 5197863..7f2d0c5 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -126,17 +126,17 @@ virSecretFreeName(virSecretPtr secret, const char *name ATTRIBUTE_UNUSED)
}
/**
- * virNWFilterPoolFreeName:
- * @pool: a nwfilter pool object
+ * virNWFilterFreeName:
+ * @nwfilter: a nwfilter object
*
- * Destroy the nwfilter pool object, this is just used by the nwfilter pool hash callback.
+ * Destroy the nwfilter object, this is just used by the nwfilter hash callback.
*
* Returns 0 in case of success and -1 in case of failure.
*/
static int
-virNWFilterPoolFreeName(virNWFilterPtr pool, const char *name ATTRIBUTE_UNUSED)
+virNWFilterFreeName(virNWFilterPtr nwfilter, const char *name ATTRIBUTE_UNUSED)
{
- return (virUnrefNWFilter(pool));
+ return virUnrefNWFilter(nwfilter);
}
/**
@@ -200,8 +200,8 @@ virGetConnect(void) {
ret->secrets = virHashCreate(20);
if (ret->secrets == NULL)
goto failed;
- ret->nwfilterPools = virHashCreate(20);
- if (ret->nwfilterPools == NULL)
+ ret->nwfilters = virHashCreate(20);
+ if (ret->nwfilters == NULL)
goto failed;
ret->refs = 1;
@@ -223,8 +223,8 @@ failed:
virHashFree(ret->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
if (ret->secrets != NULL)
virHashFree(ret->secrets, (virHashDeallocator) virSecretFreeName);
- if (ret->nwfilterPools != NULL)
- virHashFree(ret->nwfilterPools, (virHashDeallocator) virNWFilterPoolFreeName);
+ if (ret->nwfilters != NULL)
+ virHashFree(ret->nwfilters, (virHashDeallocator) virNWFilterFreeName);
virMutexDestroy(&ret->lock);
VIR_FREE(ret);
@@ -281,8 +281,8 @@ virReleaseConnect(virConnectPtr conn) {
virHashFree(conn->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
if (conn->secrets != NULL)
virHashFree(conn->secrets, (virHashDeallocator) virSecretFreeName);
- if (conn->nwfilterPools != NULL)
- virHashFree(conn->nwfilterPools, (virHashDeallocator) virNWFilterPoolFreeName);
+ if (conn->nwfilters != NULL)
+ virHashFree(conn->nwfilters, (virHashDeallocator) virNWFilterFreeName);
virResetError(&conn->err);
@@ -1466,7 +1466,7 @@ int virUnrefStream(virStreamPtr st) {
* Lookup if the network filter is already registered for that connection,
* if yes return a new pointer to it, if no allocate a new structure,
* and register it in the table. In any case a corresponding call to
- * virFreeNWFilterPool() is needed to not leak data.
+ * virUnrefNWFilter() is needed to not leak data.
*
* Returns a pointer to the network, or NULL in case of failure
*/
@@ -1491,7 +1491,7 @@ virGetNWFilter(virConnectPtr conn, const char *name, const unsigned char *uuid)
virUUIDFormat(uuid, uuidstr);
- ret = (virNWFilterPtr) virHashLookup(conn->nwfilterPools, uuidstr);
+ ret = (virNWFilterPtr) virHashLookup(conn->nwfilters, uuidstr);
if (ret == NULL) {
if (VIR_ALLOC(ret) < 0) {
virMutexUnlock(&conn->lock);
@@ -1508,10 +1508,10 @@ virGetNWFilter(virConnectPtr conn, const char *name, const unsigned char *uuid)
ret->conn = conn;
memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
- if (virHashAddEntry(conn->nwfilterPools, uuidstr, ret) < 0) {
+ if (virHashAddEntry(conn->nwfilters, uuidstr, ret) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to add network filter pool to connection hash table"));
+ _("failed to add network filter to connection hash table"));
goto error;
}
conn->refs++;
@@ -1530,35 +1530,36 @@ error:
/**
- * virReleaseNWFilterPool:
- * @pool: the pool to release
+ * virReleaseNWFilter:
+ * @nwfilter: the nwfilter to release
*
- * Unconditionally release all memory associated with a pool.
+ * Unconditionally release all memory associated with a nwfilter.
* The conn.lock mutex must be held prior to calling this, and will
- * be released prior to this returning. The pool obj must not
+ * be released prior to this returning. The nwfilter obj must not
* be used once this method returns.
*
* It will also unreference the associated connection object,
* which may also be released if its ref count hits zero.
*/
static void
-virReleaseNWFilterPool(virNWFilterPtr pool) {
- virConnectPtr conn = pool->conn;
+virReleaseNWFilter(virNWFilterPtr nwfilter)
+{
+ virConnectPtr conn = nwfilter->conn;
char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(pool->uuid, uuidstr);
- DEBUG("release pool %p %s %s", pool, pool->name, uuidstr);
+ virUUIDFormat(nwfilter->uuid, uuidstr);
+ DEBUG("release nwfilter %p %s %s", nwfilter, nwfilter->name, uuidstr);
- if (virHashRemoveEntry(conn->nwfilterPools, uuidstr, NULL) < 0) {
+ if (virHashRemoveEntry(conn->nwfilters, uuidstr, NULL) < 0) {
virMutexUnlock(&conn->lock);
virLibConnError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pool missing from connection hash table"));
conn = NULL;
}
- pool->magic = -1;
- VIR_FREE(pool->name);
- VIR_FREE(pool);
+ nwfilter->magic = -1;
+ VIR_FREE(nwfilter->name);
+ VIR_FREE(nwfilter);
if (conn) {
DEBUG("unref connection %p %d", conn, conn->refs);
@@ -1583,25 +1584,26 @@ virReleaseNWFilterPool(virNWFilterPtr pool) {
* Returns the reference count or -1 in case of failure.
*/
int
-virUnrefNWFilter(virNWFilterPtr pool) {
+virUnrefNWFilter(virNWFilterPtr nwfilter)
+{
int refs;
- if (!VIR_IS_CONNECTED_NWFILTER(pool)) {
+ if (!VIR_IS_CONNECTED_NWFILTER(nwfilter)) {
virLibConnError(VIR_ERR_INVALID_ARG,
_("bad nwfilter or no connection"));
return -1;
}
- virMutexLock(&pool->conn->lock);
- DEBUG("unref pool %p %s %d", pool, pool->name, pool->refs);
- pool->refs--;
- refs = pool->refs;
+ virMutexLock(&nwfilter->conn->lock);
+ DEBUG("unref pool %p %s %d", nwfilter, nwfilter->name, nwfilter->refs);
+ nwfilter->refs--;
+ refs = nwfilter->refs;
if (refs == 0) {
- virReleaseNWFilterPool(pool);
+ virReleaseNWFilter(nwfilter);
/* Already unlocked mutex */
return (0);
}
- virMutexUnlock(&pool->conn->lock);
+ virMutexUnlock(&nwfilter->conn->lock);
return (refs);
}
diff --git a/src/datatypes.h b/src/datatypes.h
index 07fa582..38f76a7 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -194,8 +194,8 @@ struct _virConnect {
virHashTablePtr storagePools;/* hash table for known storage pools */
virHashTablePtr storageVols;/* hash table for known storage vols */
virHashTablePtr nodeDevices; /* hash table for known node devices */
- virHashTablePtr secrets; /* hash taboe for known secrets */
- virHashTablePtr nwfilterPools; /* hash tables ofr known nw filter pools */
+ virHashTablePtr secrets; /* hash table for known secrets */
+ virHashTablePtr nwfilters; /* hash table for known nw filters */
int refs; /* reference count */
};
@@ -387,10 +387,10 @@ struct _virNWFilter {
virNWFilterPtr virGetNWFilter(virConnectPtr conn,
const char *name,
const unsigned char *uuid);
-int virUnrefNWFilter(virNWFilterPtr pool);
+int virUnrefNWFilter(virNWFilterPtr nwfilter);
virDomainSnapshotPtr virGetDomainSnapshot(virDomainPtr domain,
const char *name);
-int virUnrefDomainSnapshot(virDomainSnapshotPtr pool);
+int virUnrefDomainSnapshot(virDomainSnapshotPtr snapshot);
#endif
diff --git a/src/driver.h b/src/driver.h
index 03a388a..114002d 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1138,10 +1138,10 @@ typedef virNWFilterPtr
const char *xmlDesc,
unsigned int flags);
typedef int
- (*virDrvNWFilterUndefine) (virNWFilterPtr pool);
+ (*virDrvNWFilterUndefine) (virNWFilterPtr nwfilter);
typedef char *
- (*virDrvNWFilterGetXMLDesc) (virNWFilterPtr pool,
+ (*virDrvNWFilterGetXMLDesc) (virNWFilterPtr nwfilter,
unsigned int flags);
diff --git a/src/libvirt.c b/src/libvirt.c
index 52d3278..757d76e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -705,7 +705,7 @@ virLibSecretError(virSecretPtr secret, virErrorNumber error, const char *info)
* Handle an error at the connection level
*/
static void
-virLibNWFilterError(virNWFilterPtr pool, virErrorNumber error,
+virLibNWFilterError(virNWFilterPtr nwfilter, virErrorNumber error,
const char *info)
{
virConnectPtr conn = NULL;
@@ -716,7 +716,7 @@ virLibNWFilterError(virNWFilterPtr pool, virErrorNumber error,
errmsg = virErrorMsg(error, info);
if (error != VIR_ERR_INVALID_NWFILTER)
- conn = pool->conn;
+ conn = nwfilter->conn;
virRaiseError(conn, NULL, NULL, VIR_FROM_NWFILTER, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2ce4bed..f60489c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -637,17 +637,17 @@ virNWFilterDefFormat;
virNWFilterDefFree;
virNWFilterDefParseString;
virNWFilterJumpTargetTypeToString;
+virNWFilterLoadAllConfigs;
virNWFilterLockFilterUpdates;
-virNWFilterPoolLoadAllConfigs;
-virNWFilterPoolObjAssignDef;
-virNWFilterPoolObjDeleteDef;
-virNWFilterPoolObjFindByName;
-virNWFilterPoolObjFindByUUID;
-virNWFilterPoolObjListFree;
-virNWFilterPoolObjLock;
-virNWFilterPoolObjRemove;
-virNWFilterPoolObjSaveDef;
-virNWFilterPoolObjUnlock;
+virNWFilterObjAssignDef;
+virNWFilterObjDeleteDef;
+virNWFilterObjFindByName;
+virNWFilterObjFindByUUID;
+virNWFilterObjListFree;
+virNWFilterObjLock;
+virNWFilterObjRemove;
+virNWFilterObjSaveDef;
+virNWFilterObjUnlock;
virNWFilterPrintStateMatchFlags;
virNWFilterRegisterCallbackDriver;
virNWFilterRuleActionTypeToString;
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index a305de6..fa72a5f 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -105,9 +105,9 @@ nwfilterDriverStartup(int privileged) {
VIR_FREE(base);
- if (virNWFilterPoolLoadAllConfigs(NULL,
- &driverState->pools,
- driverState->configDir) < 0)
+ if (virNWFilterLoadAllConfigs(NULL,
+ &driverState->nwfilters,
+ driverState->configDir) < 0)
goto error;
nwfilterDriverUnlock(driverState);
@@ -155,9 +155,9 @@ nwfilterDriverReload(void) {
nwfilterDriverLock(driverState);
virNWFilterCallbackDriversLock();
- virNWFilterPoolLoadAllConfigs(conn,
- &driverState->pools,
- driverState->configDir);
+ virNWFilterLoadAllConfigs(conn,
+ &driverState->nwfilters,
+ driverState->configDir);
virNWFilterCallbackDriversUnlock();
nwfilterDriverUnlock(driverState);
@@ -171,7 +171,7 @@ nwfilterDriverReload(void) {
/**
* virNWFilterActive:
*
- * Checks if the nwfilter driver is active, i.e. has an active pool
+ * Checks if the nwfilter driver is active, i.e. has an active nwfilter
*
* Returns 1 if active, 0 otherwise
*/
@@ -183,7 +183,7 @@ nwfilterDriverActive(void) {
return 0;
nwfilterDriverLock(driverState);
- ret = driverState->pools.count ? 1 : 0;
+ ret = driverState->nwfilters.count ? 1 : 0;
nwfilterDriverUnlock(driverState);
return ret;
@@ -192,7 +192,7 @@ nwfilterDriverActive(void) {
/**
* virNWFilterShutdown:
*
- * Shutdown the nwfilter driver, it will stop all active nwfilter pools
+ * Shutdown the nwfilter driver, it will stop all active nwfilters
*/
static int
nwfilterDriverShutdown(void) {
@@ -203,8 +203,8 @@ nwfilterDriverShutdown(void) {
nwfilterDriverLock(driverState);
- /* free inactive pools */
- virNWFilterPoolObjListFree(&driverState->pools);
+ /* free inactive nwfilters */
+ virNWFilterObjListFree(&driverState->nwfilters);
VIR_FREE(driverState->configDir);
nwfilterDriverUnlock(driverState);
@@ -219,24 +219,24 @@ static virNWFilterPtr
nwfilterLookupByUUID(virConnectPtr conn,
const unsigned char *uuid) {
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
- virNWFilterPoolObjPtr pool;
+ virNWFilterObjPtr nwfilter;
virNWFilterPtr ret = NULL;
nwfilterDriverLock(driver);
- pool = virNWFilterPoolObjFindByUUID(&driver->pools, uuid);
+ nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, uuid);
nwfilterDriverUnlock(driver);
- if (!pool) {
+ if (!nwfilter) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
- "%s", _("no pool with matching uuid"));
+ "%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
- ret = virGetNWFilter(conn, pool->def->name, pool->def->uuid);
+ ret = virGetNWFilter(conn, nwfilter->def->name, nwfilter->def->uuid);
cleanup:
- if (pool)
- virNWFilterPoolObjUnlock(pool);
+ if (nwfilter)
+ virNWFilterObjUnlock(nwfilter);
return ret;
}
@@ -245,24 +245,24 @@ static virNWFilterPtr
nwfilterLookupByName(virConnectPtr conn,
const char *name) {
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
- virNWFilterPoolObjPtr pool;
+ virNWFilterObjPtr nwfilter;
virNWFilterPtr ret = NULL;
nwfilterDriverLock(driver);
- pool = virNWFilterPoolObjFindByName(&driver->pools, name);
+ nwfilter = virNWFilterObjFindByName(&driver->nwfilters, name);
nwfilterDriverUnlock(driver);
- if (!pool) {
+ if (!nwfilter) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
- _("no pool with matching name '%s'"), name);
+ _("no nwfilter with matching name '%s'"), name);
goto cleanup;
}
- ret = virGetNWFilter(conn, pool->def->name, pool->def->uuid);
+ ret = virGetNWFilter(conn, nwfilter->def->name, nwfilter->def->uuid);
cleanup:
- if (pool)
- virNWFilterPoolObjUnlock(pool);
+ if (nwfilter)
+ virNWFilterObjUnlock(nwfilter);
return ret;
}
@@ -289,7 +289,7 @@ nwfilterClose(virConnectPtr conn) {
static int
nwfilterNumNWFilters(virConnectPtr conn) {
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
- return driver->pools.count;
+ return driver->nwfilters.count;
}
@@ -301,15 +301,15 @@ nwfilterListNWFilters(virConnectPtr conn,
int got = 0, i;
nwfilterDriverLock(driver);
- for (i = 0 ; i < driver->pools.count && got < nnames ; i++) {
- virNWFilterPoolObjLock(driver->pools.objs[i]);
- if (!(names[got] = strdup(driver->pools.objs[i]->def->name))) {
- virNWFilterPoolObjUnlock(driver->pools.objs[i]);
+ for (i = 0 ; i < driver->nwfilters.count && got < nnames ; i++) {
+ virNWFilterObjLock(driver->nwfilters.objs[i]);
+ if (!(names[got] = strdup(driver->nwfilters.objs[i]->def->name))) {
+ virNWFilterObjUnlock(driver->nwfilters.objs[i]);
virReportOOMError();
goto cleanup;
}
got++;
- virNWFilterPoolObjUnlock(driver->pools.objs[i]);
+ virNWFilterObjUnlock(driver->nwfilters.objs[i]);
}
nwfilterDriverUnlock(driver);
return got;
@@ -329,7 +329,7 @@ nwfilterDefine(virConnectPtr conn,
unsigned int flags ATTRIBUTE_UNUSED) {
virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
virNWFilterDefPtr def;
- virNWFilterPoolObjPtr pool = NULL;
+ virNWFilterObjPtr nwfilter = NULL;
virNWFilterPtr ret = NULL;
nwfilterDriverLock(driver);
@@ -338,22 +338,22 @@ nwfilterDefine(virConnectPtr conn,
if (!(def = virNWFilterDefParseString(conn, xml)))
goto cleanup;
- if (!(pool = virNWFilterPoolObjAssignDef(conn, &driver->pools, def)))
+ if (!(nwfilter = virNWFilterObjAssignDef(conn, &driver->nwfilters, def)))
goto cleanup;
- if (virNWFilterPoolObjSaveDef(driver, pool, def) < 0) {
- virNWFilterPoolObjRemove(&driver->pools, pool);
+ if (virNWFilterObjSaveDef(driver, nwfilter, def) < 0) {
+ virNWFilterObjRemove(&driver->nwfilters, nwfilter);
def = NULL;
goto cleanup;
}
def = NULL;
- ret = virGetNWFilter(conn, pool->def->name, pool->def->uuid);
+ ret = virGetNWFilter(conn, nwfilter->def->name, nwfilter->def->uuid);
cleanup:
virNWFilterDefFree(def);
- if (pool)
- virNWFilterPoolObjUnlock(pool);
+ if (nwfilter)
+ virNWFilterObjUnlock(nwfilter);
virNWFilterCallbackDriversUnlock();
nwfilterDriverUnlock(driver);
@@ -364,38 +364,38 @@ cleanup:
static int
nwfilterUndefine(virNWFilterPtr obj) {
virNWFilterDriverStatePtr driver = obj->conn->nwfilterPrivateData;
- virNWFilterPoolObjPtr pool;
+ virNWFilterObjPtr nwfilter;
int ret = -1;
nwfilterDriverLock(driver);
virNWFilterCallbackDriversLock();
- pool = virNWFilterPoolObjFindByUUID(&driver->pools, obj->uuid);
- if (!pool) {
+ nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
+ if (!nwfilter) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
- "%s", _("no nwfilter pool with matching uuid"));
+ "%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
- if (virNWFilterTestUnassignDef(obj->conn, pool)) {
+ if (virNWFilterTestUnassignDef(obj->conn, nwfilter)) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
"%s",
_("nwfilter is in use"));
goto cleanup;
}
- if (virNWFilterPoolObjDeleteDef(pool) < 0)
+ if (virNWFilterObjDeleteDef(nwfilter) < 0)
goto cleanup;
- VIR_FREE(pool->configFile);
+ VIR_FREE(nwfilter->configFile);
- virNWFilterPoolObjRemove(&driver->pools, pool);
- pool = NULL;
+ virNWFilterObjRemove(&driver->nwfilters, nwfilter);
+ nwfilter = NULL;
ret = 0;
cleanup:
- if (pool)
- virNWFilterPoolObjUnlock(pool);
+ if (nwfilter)
+ virNWFilterObjUnlock(nwfilter);
virNWFilterCallbackDriversUnlock();
nwfilterDriverUnlock(driver);
@@ -407,26 +407,26 @@ static char *
nwfilterDumpXML(virNWFilterPtr obj,
unsigned int flags) {
virNWFilterDriverStatePtr driver = obj->conn->nwfilterPrivateData;
- virNWFilterPoolObjPtr pool;
+ virNWFilterObjPtr nwfilter;
char *ret = NULL;
virCheckFlags(0, NULL);
nwfilterDriverLock(driver);
- pool = virNWFilterPoolObjFindByUUID(&driver->pools, obj->uuid);
+ nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
nwfilterDriverUnlock(driver);
- if (!pool) {
+ if (!nwfilter) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
- "%s", _("no nwfilter pool with matching uuid"));
+ "%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
- ret = virNWFilterDefFormat(pool->def);
+ ret = virNWFilterDefFormat(nwfilter->def);
cleanup:
- if (pool)
- virNWFilterPoolObjUnlock(pool);
+ if (nwfilter)
+ virNWFilterObjUnlock(nwfilter);
return ret;
}
diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c
index fcd479c..4361c8a 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -284,7 +284,7 @@ err_exit:
/**
- * _virNWFilterPoolInstantiateRec:
+ * _virNWFilterInstantiateRec:
* @conn: pointer to virConnect object
* @techdriver: The driver to use for instantiation
* @filter: The filter to instantiate
@@ -319,7 +319,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
enum instCase useNewFilter, bool *foundNewFilter,
virNWFilterDriverStatePtr driver)
{
- virNWFilterPoolObjPtr obj;
+ virNWFilterObjPtr obj;
int rc = 0;
int i;
virNWFilterRuleInstPtr inst;
@@ -351,8 +351,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
} else if (inc) {
VIR_DEBUG("Instantiating filter %s", inc->filterref);
- obj = virNWFilterPoolObjFindByName(&driver->pools,
- inc->filterref);
+ obj = virNWFilterObjFindByName(&driver->nwfilters, inc->filterref);
if (obj) {
if (obj->wantRemoved) {
@@ -360,7 +359,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
_("Filter '%s' is in use."),
inc->filterref);
rc = 1;
- virNWFilterPoolObjUnlock(obj);
+ virNWFilterObjUnlock(obj);
break;
}
@@ -371,7 +370,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
if (!tmpvars) {
virReportOOMError();
rc = 1;
- virNWFilterPoolObjUnlock(obj);
+ virNWFilterObjUnlock(obj);
break;
}
@@ -401,7 +400,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
virNWFilterHashTableFree(tmpvars);
- virNWFilterPoolObjUnlock(obj);
+ virNWFilterObjUnlock(obj);
if (rc)
break;
} else {
@@ -425,7 +424,7 @@ virNWFilterDetermineMissingVarsRec(virConnectPtr conn,
int useNewFilter,
virNWFilterDriverStatePtr driver)
{
- virNWFilterPoolObjPtr obj;
+ virNWFilterObjPtr obj;
int rc = 0;
int i, j;
virNWFilterDefPtr next_filter;
@@ -443,8 +442,7 @@ virNWFilterDetermineMissingVarsRec(virConnectPtr conn,
}
} else if (inc) {
VIR_DEBUG("Following filter %s\n", inc->filterref);
- obj = virNWFilterPoolObjFindByName(&driver->pools,
- inc->filterref);
+ obj = virNWFilterObjFindByName(&driver->nwfilters, inc->filterref);
if (obj) {
if (obj->wantRemoved) {
@@ -452,7 +450,7 @@ virNWFilterDetermineMissingVarsRec(virConnectPtr conn,
_("Filter '%s' is in use."),
inc->filterref);
rc = 1;
- virNWFilterPoolObjUnlock(obj);
+ virNWFilterObjUnlock(obj);
break;
}
@@ -463,7 +461,7 @@ virNWFilterDetermineMissingVarsRec(virConnectPtr conn,
if (!tmpvars) {
virReportOOMError();
rc = 1;
- virNWFilterPoolObjUnlock(obj);
+ virNWFilterObjUnlock(obj);
break;
}
@@ -488,7 +486,7 @@ virNWFilterDetermineMissingVarsRec(virConnectPtr conn,
virNWFilterHashTableFree(tmpvars);
- virNWFilterPoolObjUnlock(obj);
+ virNWFilterObjUnlock(obj);
if (rc)
break;
} else {
@@ -700,7 +698,7 @@ __virNWFilterInstantiateFilter(virConnectPtr conn,
int rc;
const char *drvname = EBIPTABLES_DRIVER_ID;
virNWFilterTechDriverPtr techdriver;
- virNWFilterPoolObjPtr obj;
+ virNWFilterObjPtr obj;
virNWFilterHashTablePtr vars, vars1;
virNWFilterDefPtr filter;
char vmmacaddr[VIR_MAC_STRING_BUFLEN] = {0};
@@ -720,7 +718,7 @@ __virNWFilterInstantiateFilter(virConnectPtr conn,
VIR_DEBUG("filter name: %s", filtername);
- obj = virNWFilterPoolObjFindByName(&driver->pools, filtername);
+ obj = virNWFilterObjFindByName(&driver->nwfilters, filtername);
if (!obj) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
_("Could not find filter '%s'"),
@@ -804,7 +802,7 @@ err_exit_vars1:
virNWFilterHashTableFree(vars1);
err_exit:
- virNWFilterPoolObjUnlock(obj);
+ virNWFilterObjUnlock(obj);
VIR_FREE(str_ipaddr);
VIR_FREE(str_macaddr);
--
1.7.0.4
13 years, 9 months
[libvirt] [PATCH] datatypes: Fix outdated function names in the documentation
by Matthias Bolte
---
src/datatypes.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/datatypes.c b/src/datatypes.c
index b43a571..5197863 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -821,7 +821,7 @@ virUnrefInterface(virInterfacePtr iface) {
* Lookup if the storage pool is already registered for that connection,
* if yes return a new pointer to it, if no allocate a new structure,
* and register it in the table. In any case a corresponding call to
- * virFreeStoragePool() is needed to not leak data.
+ * virUnrefStoragePool() is needed to not leak data.
*
* Returns a pointer to the network, or NULL in case of failure
*/
@@ -972,7 +972,7 @@ virUnrefStoragePool(virStoragePoolPtr pool) {
* Lookup if the storage vol is already registered for that connection,
* if yes return a new pointer to it, if no allocate a new structure,
* and register it in the table. In any case a corresponding call to
- * virFreeStorageVol() is needed to not leak data.
+ * virUnrefStorageVol() is needed to not leak data.
*
* Returns a pointer to the storage vol, or NULL in case of failure
*/
@@ -1128,7 +1128,7 @@ virUnrefStorageVol(virStorageVolPtr vol) {
* Lookup if the device is already registered for that connection,
* if yes return a new pointer to it, if no allocate a new structure,
* and register it in the table. In any case a corresponding call to
- * virFreeNodeDevice() is needed to not leak data.
+ * virUnrefNodeDevice() is needed to not leak data.
*
* Returns a pointer to the node device, or NULL in case of failure
*/
@@ -1261,7 +1261,7 @@ virUnrefNodeDevice(virNodeDevicePtr dev) {
*
* Lookup if the secret is already registered for that connection, if so return
* a pointer to it, otherwise allocate a new structure, and register it in the
- * table. In any case a corresponding call to virFreeSecret() is needed to not
+ * table. In any case a corresponding call to virUnrefSecret() is needed to not
* leak data.
*
* Returns a pointer to the secret, or NULL in case of failure
--
1.7.0.4
13 years, 9 months
[libvirt] [PATCH] Add documentation for VIR_DOMAIN_MEMORY_PARAM_UNLIMITED
by Matthias Bolte
Otherwise apibuild.py complains about it.
---
include/libvirt/libvirt.h.in | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 055eb2e..7ecbeb6 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -696,6 +696,13 @@ typedef enum {
*/
#define VIR_DOMAIN_MEMORY_FIELD_LENGTH 80
+
+/**
+ * VIR_DOMAIN_MEMORY_PARAM_UNLIMITED:
+ *
+ * Macro providing the virMemoryParameter value that indicates "unlimited"
+ */
+
#define VIR_DOMAIN_MEMORY_PARAM_UNLIMITED (INT64_MAX >> 10)
/**
--
1.7.0.4
13 years, 9 months
[libvirt] [PATCH] datatypes: Get virSecretFreeName in sync with the other free functions
by Matthias Bolte
---
src/datatypes.c | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/datatypes.c b/src/datatypes.c
index c549c74..b43a571 100644
--- a/src/datatypes.c
+++ b/src/datatypes.c
@@ -113,19 +113,16 @@ virStorageVolFreeName(virStorageVolPtr vol, const char *name ATTRIBUTE_UNUSED)
/**
* virSecretFreeName:
- * @secret_: a secret object
+ * @secret: a secret object
*
* Destroy the secret object, this is just used by the secret hash callback.
*
* Returns 0 in case of success and -1 in case of failure.
*/
-static void
-virSecretFreeName(void *secret_, const char *name ATTRIBUTE_UNUSED)
+static int
+virSecretFreeName(virSecretPtr secret, const char *name ATTRIBUTE_UNUSED)
{
- virSecretPtr secret;
-
- secret = secret_;
- virUnrefSecret(secret);
+ return virUnrefSecret(secret);
}
/**
@@ -225,7 +222,7 @@ failed:
if (ret->nodeDevices != NULL)
virHashFree(ret->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
if (ret->secrets != NULL)
- virHashFree(ret->secrets, virSecretFreeName);
+ virHashFree(ret->secrets, (virHashDeallocator) virSecretFreeName);
if (ret->nwfilterPools != NULL)
virHashFree(ret->nwfilterPools, (virHashDeallocator) virNWFilterPoolFreeName);
@@ -283,7 +280,7 @@ virReleaseConnect(virConnectPtr conn) {
if (conn->nodeDevices != NULL)
virHashFree(conn->nodeDevices, (virHashDeallocator) virNodeDeviceFree);
if (conn->secrets != NULL)
- virHashFree(conn->secrets, virSecretFreeName);
+ virHashFree(conn->secrets, (virHashDeallocator) virSecretFreeName);
if (conn->nwfilterPools != NULL)
virHashFree(conn->nwfilterPools, (virHashDeallocator) virNWFilterPoolFreeName);
--
1.7.0.4
13 years, 9 months
[libvirt] [PATCH] docs: Move the "Network Filtering" page one level up in the hierarchy
by Matthias Bolte
"Network Filtering" is not directly related to "Networks".
Suggested by Daniel P. Berrange.
---
docs/sitemap.html.in | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/docs/sitemap.html.in b/docs/sitemap.html.in
index 490450e..7077038 100644
--- a/docs/sitemap.html.in
+++ b/docs/sitemap.html.in
@@ -111,12 +111,10 @@
<li>
<a href="formatnetwork.html">Networks</a>
<span>The virtual network XML format</span>
- <ul>
- <li>
- <a href="formatnwfilter.html">Network Filtering</a>
- <span>Network filter XML format</span>
- </li>
- </ul>
+ </li>
+ <li>
+ <a href="formatnwfilter.html">Network Filtering</a>
+ <span>Network filter XML format</span>
</li>
<li>
<a href="formatstorage.html">Storage</a>
--
1.7.0.4
13 years, 9 months
[libvirt] [PATCH] tests: Remove obsolete secaatest
by Matthias Bolte
Before the security driver was refactored in d6623003 seclabeltest and
secaatest were basically the same. seclabeltest was meant for SELinux
and secaatest for AppArmor. Both tests exited early when the specific
security driver backend wasn't enabled.
With the new security manager trying to initialize a disabled security
driver backend is an error that can't be distinguished from other errors
anymore. Therefore, the updated seclabeltest just asks for the first
available backend as this will always work even with SELinux and AppArmor
backend being disabled due to the new Nop backend.
Remove the obsolete secaatest and compile and run the seclabeltest
unconditional.
This fixes make check on systems that support AppArmor.
---
tests/Makefile.am | 24 ------------------------
tests/secaatest.c | 45 ---------------------------------------------
2 files changed, 0 insertions(+), 69 deletions(-)
delete mode 100644 tests/secaatest.c
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 345cf46..72beb23 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -98,13 +98,7 @@ if WITH_VMX
check_PROGRAMS += vmx2xmltest xml2vmxtest
endif
-if WITH_SECDRIVER_SELINUX
check_PROGRAMS += seclabeltest
-endif
-
-if WITH_SECDRIVER_APPARMOR
-check_PROGRAMS += secaatest
-endif
if WITH_CIL
check_PROGRAMS += object-locking
@@ -191,13 +185,7 @@ if WITH_VMX
TESTS += vmx2xmltest xml2vmxtest
endif
-if WITH_SECDRIVER_SELINUX
TESTS += seclabeltest
-endif
-
-if WITH_SECDRIVER_APPARMOR
-TESTS += secaatest
-endif
if WITH_LIBVIRTD
check_PROGRAMS += eventtest
@@ -376,21 +364,9 @@ commandhelper_SOURCES = \
commandhelper_CFLAGS = -Dabs_builddir="\"`pwd`\""
commandhelper_LDADD = $(LDADDS)
-if WITH_SECDRIVER_SELINUX
seclabeltest_SOURCES = \
seclabeltest.c
seclabeltest_LDADD = ../src/libvirt_driver_security.la $(LDADDS)
-else
-EXTRA_DIST += seclabeltest.c
-endif
-
-if WITH_SECDRIVER_APPARMOR
-secaatest_SOURCES = \
- secaatest.c
-secaatest_LDADD = ../src/libvirt_driver_security.la $(LDADDS)
-else
-EXTRA_DIST += secaatest.c
-endif
qparamtest_SOURCES = \
qparamtest.c testutils.h testutils.c
diff --git a/tests/secaatest.c b/tests/secaatest.c
deleted file mode 100644
index d9d6b4a..0000000
--- a/tests/secaatest.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <config.h>
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include "security/security_driver.h"
-
-int
-main (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
-{
- int ret;
-
- const char *doi, *model;
- virSecurityDriverPtr security_drv;
-
- ret = virSecurityDriverStartup (&security_drv, "apparmor", false);
- if (ret == -1)
- {
- fprintf (stderr, "Failed to start security driver");
- exit (-1);
- }
- /* No security driver wanted to be enabled: just return */
- if (ret == -2)
- return 0;
-
- model = virSecurityDriverGetModel (security_drv);
- if (!model)
- {
- fprintf (stderr, "Failed to copy secModel model: %s",
- strerror (errno));
- exit (-1);
- }
-
- doi = virSecurityDriverGetDOI (security_drv);
- if (!doi)
- {
- fprintf (stderr, "Failed to copy secModel DOI: %s",
- strerror (errno));
- exit (-1);
- }
-
- return 0;
-}
--
1.7.0.4
13 years, 9 months