提交 fa7ebc17 编写于 作者: D Daniel P. Berrange

Replace use of virNWFilterReportError with virReportError

Update the network filter driver to use virReportError instead
of the virNWFilterReportError custom macro
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 6d964bcf
......@@ -541,7 +541,6 @@ msg_gen_function += virLibNWFilterError
msg_gen_function += virLibSecretError
msg_gen_function += virLibStoragePoolError
msg_gen_function += virLibStorageVolError
msg_gen_function += virNWFilterReportError
msg_gen_function += virRaiseError
msg_gen_function += virReportError
msg_gen_function += virReportErrorHelper
......
......@@ -69,10 +69,6 @@
#define VIR_FROM_THIS VIR_FROM_NWFILTER
#define virNWFilterReportError(code, fmt...) \
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
#ifdef HAVE_LIBPCAP
# define LEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.leases"
......@@ -576,7 +572,7 @@ virNWFilterSnoopReqNew(const char *ifkey)
virNWFilterSnoopReqPtr req;
if (ifkey == NULL || strlen(ifkey) != VIR_IFKEY_LEN - 1) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterSnoopReqNew called with invalid "
"key \"%s\" (%zu)"),
ifkey ? ifkey : "",
......@@ -890,7 +886,7 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req,
if (req->techdriver &&
req->techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
dhcpsrvrs, false) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterSnoopListDel failed"));
ret = -1;
}
......@@ -1097,7 +1093,7 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac,
handle = pcap_create(ifname, pcap_errbuf);
if (handle == NULL) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("pcap_create failed"));
goto cleanup_nohandle;
}
......@@ -1105,25 +1101,25 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac,
if (pcap_set_snaplen(handle, PCAP_PBUFSIZE) < 0 ||
pcap_set_buffer_size(handle, PCAP_BUFFERSIZE) < 0 ||
pcap_activate(handle) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("setup of pcap handle failed"));
goto cleanup;
}
if (pcap_compile(handle, &fp, ext_filter, 1, PCAP_NETMASK_UNKNOWN) != 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("pcap_compile: %s"), pcap_geterr(handle));
goto cleanup;
}
if (pcap_setfilter(handle, &fp) != 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("pcap_setfilter: %s"), pcap_geterr(handle));
goto cleanup_freecode;
}
if (pcap_setdirection(handle, dir) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("pcap_setdirection: %s"),
pcap_geterr(handle));
goto cleanup_freecode;
......@@ -1158,7 +1154,7 @@ static void virNWFilterDHCPDecodeWorker(void *jobdata, void *opaque)
job->caplen, job->fromVM) == -1) {
req->jobCompletionStatus = -1;
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Instantiation of rules failed on "
"interface '%s'"), req->ifname);
}
......@@ -1465,7 +1461,7 @@ virNWFilterDHCPSnoopThread(void *req0)
/* protect req->ifname */
virNWFilterSnoopReqLock(req);
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("interface '%s' failing; "
"reopening"),
req->ifname);
......@@ -1519,7 +1515,7 @@ virNWFilterDHCPSnoopThread(void *req0)
hdr->caplen,
pcapConf[i].dir,
&pcapConf[i].qCtr) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Job submission failed on "
"interface '%s'"), req->ifname);
error = true;
......@@ -1625,7 +1621,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
/* check that all tools are available for applying the filters (late) */
if ( !techdriver->canApplyBasicRules()) {
virNWFilterReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("IP parameter must be provided since "
"snooping the IP address does not work "
"possibly due to missing tools"));
......@@ -1637,13 +1633,14 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
if (techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr,
dhcpsrvrs, false) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, _("applyDHCPOnlyRules "
virReportError(VIR_ERR_INTERNAL_ERROR,
_("applyDHCPOnlyRules "
"failed - spoofing not protected!"));
goto exit_snoopreqput;
}
if (virNWFilterHashTablePutAll(filterparams, req->vars) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterDHCPSnoopReq: can't copy variables"
" on if %s"), ifkey);
goto exit_snoopreqput;
......@@ -1653,7 +1650,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
if (virHashAddEntry(virNWFilterSnoopState.ifnameToKey, ifname,
req->ifkey) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterDHCPSnoopReq ifname map failed"
" on interface \"%s\" key \"%s\""), ifname,
ifkey);
......@@ -1662,7 +1659,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
if (isnewreq &&
virHashAddEntry(virNWFilterSnoopState.snoopReqs, ifkey, req) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterDHCPSnoopReq req add failed on"
" interface \"%s\" ifkey \"%s\""), ifname,
ifkey);
......@@ -1674,7 +1671,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
if (virThreadCreate(&thread, false, virNWFilterDHCPSnoopThread,
req) != 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterDHCPSnoopReq virThreadCreate "
"failed on interface '%s'"), ifname);
goto exit_snoopreq_unlock;
......@@ -1684,14 +1681,14 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
req->threadkey = virNWFilterSnoopActivate(req);
if (!req->threadkey) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Activation of snoop request failed on "
"interface '%s'"), req->ifname);
goto exit_snoopreq_unlock;
}
if (virNWFilterSnoopReqRestore(req) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Restoring of leases failed on "
"interface '%s'"), req->ifname);
goto exit_snoop_cancel;
......@@ -1932,7 +1929,7 @@ virNWFilterSnoopLeaseFileLoad(void)
time(&now);
while (fp && fgets(line, sizeof(line), fp)) {
if (line[strlen(line)-1] != '\n') {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterSnoopLeaseFileLoad lease file "
"line %d corrupt"), ln);
break;
......@@ -1941,7 +1938,7 @@ virNWFilterSnoopLeaseFileLoad(void)
/* key len 55 = "VMUUID"+'-'+"MAC" */
if (sscanf(line, "%u %55s %16s %16s", &ipl.timeout,
ifkey, ipstr, srvstr) < 4) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterSnoopLeaseFileLoad lease file "
"line %d corrupt"), ln);
break;
......@@ -1958,7 +1955,7 @@ virNWFilterSnoopLeaseFileLoad(void)
if (tmp < 0) {
virNWFilterSnoopReqPut(req);
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterSnoopLeaseFileLoad req add"
" failed on interface \"%s\""), ifkey);
continue;
......@@ -1966,7 +1963,7 @@ virNWFilterSnoopLeaseFileLoad(void)
}
if (virSocketAddrParseIPv4(&ipl.ipAddress, ipstr) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("line %d corrupt ipaddr \"%s\""),
ln, ipstr);
virNWFilterSnoopReqPut(req);
......@@ -2113,7 +2110,7 @@ virNWFilterDHCPSnoopEnd(const char *ifname)
ifkey = (char *)virHashLookup(virNWFilterSnoopState.ifnameToKey,
ifname);
if (!ifkey) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("ifname \"%s\" not in key map"), ifname);
goto cleanup;
}
......@@ -2127,7 +2124,7 @@ virNWFilterDHCPSnoopEnd(const char *ifname)
req = virNWFilterSnoopReqGetByIFKey(ifkey);
if (!req) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("ifkey \"%s\" has no req"), ifkey);
goto cleanup;
}
......@@ -2209,7 +2206,7 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED,
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED)
{
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("libvirt was not compiled with libpcap and \""
NWFILTER_VARNAME_CTRL_IP_LEARNING
"='dhcp'\" requires it."));
......
......@@ -44,9 +44,6 @@
#include "nwfilter_learnipaddr.h"
#define VIR_FROM_THIS VIR_FROM_NWFILTER
#define virNWFilterReportError(code, fmt...) \
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
static virNWFilterDriverStatePtr driverState;
......@@ -239,7 +236,7 @@ nwfilterLookupByUUID(virConnectPtr conn,
nwfilterDriverUnlock(driver);
if (!nwfilter) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
virReportError(VIR_ERR_NO_NWFILTER,
"%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
......@@ -265,7 +262,7 @@ nwfilterLookupByName(virConnectPtr conn,
nwfilterDriverUnlock(driver);
if (!nwfilter) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
virReportError(VIR_ERR_NO_NWFILTER,
_("no nwfilter with matching name '%s'"), name);
goto cleanup;
}
......@@ -389,13 +386,13 @@ nwfilterUndefine(virNWFilterPtr obj) {
nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
if (!nwfilter) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
virReportError(VIR_ERR_NO_NWFILTER,
"%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
if (virNWFilterTestUnassignDef(obj->conn, nwfilter) < 0) {
virNWFilterReportError(VIR_ERR_OPERATION_INVALID,
virReportError(VIR_ERR_OPERATION_INVALID,
"%s",
_("nwfilter is in use"));
goto cleanup;
......@@ -437,7 +434,7 @@ nwfilterGetXMLDesc(virNWFilterPtr obj,
nwfilterDriverUnlock(driver);
if (!nwfilter) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
virReportError(VIR_ERR_NO_NWFILTER,
"%s", _("no nwfilter with matching uuid"));
goto cleanup;
}
......
......@@ -45,9 +45,6 @@
#define VIR_FROM_THIS VIR_FROM_NWFILTER
#define virNWFilterReportError(code, fmt...) \
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
#define EBTABLES_CHAIN_INCOMING "PREROUTING"
#define EBTABLES_CHAIN_OUTGOING "POSTROUTING"
......@@ -242,7 +239,7 @@ printVar(virNWFilterVarCombIterPtr vars,
const char *varName;
varName = virNWFilterVarAccessGetVarName(item->varAccess);
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Buffer too small to print variable "
"'%s' into"), varName);
return -1;
......@@ -278,7 +275,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
if (!data)
return -1;
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("buffer too small for IP address"));
VIR_FREE(data);
return -1;
......@@ -292,7 +289,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
return -1;
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("buffer too small for IPv6 address"));
VIR_FREE(data);
return -1;
......@@ -303,7 +300,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_MACADDR:
case DATATYPE_MACMASK:
if (bufsize < VIR_MAC_STRING_BUFLEN) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for MAC address"));
return -1;
}
......@@ -315,7 +312,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_IPMASK:
if (snprintf(buf, bufsize, "%d",
item->u.u8) >= bufsize) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint8 type"));
return -1;
}
......@@ -325,7 +322,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_UINT32_HEX:
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%u",
item->u.u32) >= bufsize) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint32 type"));
return -1;
}
......@@ -335,7 +332,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_UINT16_HEX:
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
item->u.u16) >= bufsize) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint16 type"));
return -1;
}
......@@ -345,7 +342,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_UINT8_HEX:
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
item->u.u8) >= bufsize) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint8 type"));
return -1;
}
......@@ -353,7 +350,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_IPSETNAME:
if (virStrcpy(buf, item->u.ipset.setname, bufsize) == NULL) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer to small for ipset name"));
return -1;
}
......@@ -385,7 +382,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
flags = virBufferContentAndReset(&vb);
if (virStrcpy(buf, flags, bufsize) == NULL) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for IPSETFLAGS type"));
VIR_FREE(flags);
return -1;
......@@ -394,7 +391,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
break;
default:
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unhandled datatype %x"), item->datatype);
return -1;
break;
......@@ -1297,7 +1294,7 @@ _iptablesCreateRuleInstance(int directionIn,
bool hasICMPType = false;
if (!iptables_cmd) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot create rule since %s tool is "
"missing."),
isIPv6 ? "ip6tables" : "iptables");
......@@ -2015,7 +2012,7 @@ ebtablesCreateRuleInstance(char chainPrefix,
const char *target;
if (!ebtables_cmd_path) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot create rule since ebtables tool is "
"missing."));
goto err_exit;
......@@ -2116,7 +2113,7 @@ ebtablesCreateRuleInstance(char chainPrefix,
since this clashes with -d below... */
if (reverse &&
HAS_ENTRY_ITEM(&rule->p.stpHdrFilter.ethHdr.dataSrcMACAddr)) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("STP filtering in %s direction with "
"source MAC address set is not supported"),
virNWFilterRuleDirectionTypeToString(
......@@ -2683,7 +2680,7 @@ ebiptablesCreateRuleInstance(enum virDomainNetType nettype ATTRIBUTE_UNUSED,
break;
case VIR_NWFILTER_RULE_PROTOCOL_LAST:
virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
virReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("illegal protocol type"));
rc = -1;
break;
......@@ -3199,7 +3196,7 @@ ebtablesApplyBasicRules(const char *ifname,
char macaddr_str[VIR_MAC_STRING_BUFLEN];
if (!ebtables_cmd_path) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot create rules since ebtables tool is "
"missing."));
return -1;
......@@ -3257,7 +3254,7 @@ ebtablesApplyBasicRules(const char *ifname,
tear_down_tmpebchains:
ebtablesCleanAll(ifname);
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
virReportError(VIR_ERR_BUILD_FIREWALL,
"%s",
_("Some rules could not be created."));
......@@ -3296,7 +3293,7 @@ ebtablesApplyDHCPOnlyRules(const char *ifname,
unsigned int num_dhcpsrvrs;
if (!ebtables_cmd_path) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot create rules since ebtables tool is "
"missing."));
return -1;
......@@ -3400,7 +3397,7 @@ ebtablesApplyDHCPOnlyRules(const char *ifname,
tear_down_tmpebchains:
ebtablesCleanAll(ifname);
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
virReportError(VIR_ERR_BUILD_FIREWALL,
"%s",
_("Some rules could not be created."));
......@@ -3425,7 +3422,7 @@ ebtablesApplyDropAllRules(const char *ifname)
chain_out[MAX_CHAINNAME_LENGTH];
if (!ebtables_cmd_path) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot create rules since ebtables tool is "
"missing."));
return -1;
......@@ -3470,7 +3467,7 @@ ebtablesApplyDropAllRules(const char *ifname)
tear_down_tmpebchains:
ebtablesCleanAll(ifname);
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
virReportError(VIR_ERR_BUILD_FIREWALL,
"%s",
_("Some rules could not be created."));
......@@ -3903,7 +3900,7 @@ tear_down_tmpebchains:
ebiptablesExecCLI(&buf, &cli_status, NULL);
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
virReportError(VIR_ERR_BUILD_FIREWALL,
_("Some rules could not be created for "
"interface %s%s%s"),
ifname,
......@@ -4042,7 +4039,7 @@ ebiptablesRemoveRules(const char *ifname ATTRIBUTE_UNUSED,
goto err_exit;
if (cli_status) {
virNWFilterReportError(VIR_ERR_BUILD_FIREWALL,
virReportError(VIR_ERR_BUILD_FIREWALL,
"%s",
_("error while executing CLI commands"));
rc = -1;
......
......@@ -39,9 +39,6 @@
#include "datatypes.h"
#define VIR_FROM_THIS VIR_FROM_NWFILTER
#define virNWFilterReportError(code, fmt...) \
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
#define NWFILTER_STD_VAR_MAC NWFILTER_VARNAME_MAC
......@@ -164,7 +161,7 @@ virNWFilterVarHashmapAddStdValues(virNWFilterHashTablePtr table,
if (virHashAddEntry(table->hashTable,
NWFILTER_STD_VAR_MAC,
val) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Could not add variable 'MAC' to hashmap"));
return -1;
}
......@@ -178,7 +175,7 @@ virNWFilterVarHashmapAddStdValues(virNWFilterHashTablePtr table,
if (virHashAddEntry(table->hashTable,
NWFILTER_STD_VAR_IP,
val) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Could not add variable 'IP' to hashmap"));
return -1;
}
......@@ -430,7 +427,7 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver,
if (obj) {
if (obj->wantRemoved) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
virReportError(VIR_ERR_NO_NWFILTER,
_("Filter '%s' is in use."),
inc->filterref);
rc = -1;
......@@ -478,7 +475,7 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver,
if (rc < 0)
break;
} else {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("referenced filter '%s' is missing"),
inc->filterref);
rc = -1;
......@@ -542,7 +539,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
if (obj) {
if (obj->wantRemoved) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
virReportError(VIR_ERR_NO_NWFILTER,
_("Filter '%s' is in use."),
inc->filterref);
rc = -1;
......@@ -585,7 +582,7 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter,
if (rc < 0)
break;
} else {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("referenced filter '%s' is missing"),
inc->filterref);
rc = -1;
......@@ -724,7 +721,8 @@ virNWFilterInstantiate(const unsigned char *vmuuid ATTRIBUTE_UNUSED,
goto err_exit;
} else {
rc = -1;
virNWFilterReportError(VIR_ERR_PARSE_FAILED, _("filter '%s' "
virReportError(VIR_ERR_PARSE_FAILED,
_("filter '%s' "
"learning value '%s' invalid."),
filter->name, learning);
}
......@@ -799,7 +797,7 @@ err_unresolvable_vars:
buf = virNWFilterPrintVars(missing_vars->hashTable, ", ", false, reportIP);
if (buf) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot instantiate filter due to unresolvable "
"variables or unavailable list elements: %s"), buf);
VIR_FREE(buf);
......@@ -842,7 +840,7 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid,
techdriver = virNWFilterTechDriverForName(drvname);
if (!techdriver) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get access to ACL tech "
"driver '%s'"),
drvname);
......@@ -853,14 +851,14 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid,
obj = virNWFilterObjFindByName(&driver->nwfilters, filtername);
if (!obj) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
virReportError(VIR_ERR_NO_NWFILTER,
_("Could not find filter '%s'"),
filtername);
return -1;
}
if (obj->wantRemoved) {
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
virReportError(VIR_ERR_NO_NWFILTER,
_("Filter '%s' is in use."),
filtername);
rc = -1;
......@@ -1070,7 +1068,7 @@ virNWFilterRollbackUpdateFilter(const virDomainNetDefPtr net)
techdriver = virNWFilterTechDriverForName(drvname);
if (!techdriver) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get access to ACL tech "
"driver '%s'"),
drvname);
......@@ -1096,7 +1094,7 @@ virNWFilterTearOldFilter(virDomainNetDefPtr net)
techdriver = virNWFilterTechDriverForName(drvname);
if (!techdriver) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get access to ACL tech "
"driver '%s'"),
drvname);
......@@ -1121,7 +1119,7 @@ _virNWFilterTeardownFilter(const char *ifname)
techdriver = virNWFilterTechDriverForName(drvname);
if (!techdriver) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not get access to ACL tech "
"driver '%s'"),
drvname);
......@@ -1200,7 +1198,7 @@ virNWFilterDomainFWUpdateCB(void *payload,
vm->uuid,
net);
if (err)
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failure while applying current filter on "
"VM %s"), vm->name);
break;
......
......@@ -56,9 +56,6 @@
#include "nwfilter_learnipaddr.h"
#define VIR_FROM_THIS VIR_FROM_NWFILTER
#define virNWFilterReportError(code, fmt...) \
virReportErrorHelper(VIR_FROM_NWFILTER, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
#define IFINDEX2STR(VARNAME, ifindex) \
char VARNAME[INT_BUFSIZE_BOUND(ifindex)]; \
......@@ -151,14 +148,14 @@ virNWFilterLockIface(const char *ifname) {
}
if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("mutex initialization failed"));
VIR_FREE(ifaceLock);
goto err_exit;
}
if (virStrcpyStatic(ifaceLock->ifname, ifname) == NULL) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("interface name %s does not fit into "
"buffer "),
ifaceLock->ifname);
......@@ -675,7 +672,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
return -1;
if ( !techdriver->canApplyBasicRules()) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("IP parameter must be provided since "
"snooping the IP address does not work "
"possibly due to missing tools"));
......@@ -703,7 +700,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
}
if (virStrcpyStatic(req->ifname, ifname) == NULL) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Destination buffer for ifname ('%s') "
"not large enough"), ifname);
goto err_free_ht;
......@@ -711,7 +708,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
if (linkdev) {
if (virStrcpyStatic(req->linkdev, linkdev) == NULL) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Destination buffer for linkdev ('%s') "
"not large enough"), linkdev);
goto err_free_ht;
......@@ -763,7 +760,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED,
virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED,
virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED,
enum howDetect howDetect ATTRIBUTE_UNUSED) {
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("IP parameter must be given since libvirt "
"was not compiled with IP address learning "
"support"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册