From fa7ebc174f5ac28bf832876db50f0ffeb1783a2a Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 18 Jul 2012 12:45:15 +0100 Subject: [PATCH] Replace use of virNWFilterReportError with virReportError Update the network filter driver to use virReportError instead of the virNWFilterReportError custom macro Signed-off-by: Daniel P. Berrange --- cfg.mk | 1 - src/nwfilter/nwfilter_dhcpsnoop.c | 153 +++++++++++----------- src/nwfilter/nwfilter_driver.c | 25 ++-- src/nwfilter/nwfilter_ebiptables_driver.c | 131 +++++++++--------- src/nwfilter/nwfilter_gentech_driver.c | 98 +++++++------- src/nwfilter/nwfilter_learnipaddr.c | 43 +++--- 6 files changed, 218 insertions(+), 233 deletions(-) diff --git a/cfg.mk b/cfg.mk index f2a7e29a81..2f02562994 100644 --- a/cfg.mk +++ b/cfg.mk @@ -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 diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index 7e258cf0d1..0a12be5114 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -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,11 +572,11 @@ virNWFilterSnoopReqNew(const char *ifkey) virNWFilterSnoopReqPtr req; if (ifkey == NULL || strlen(ifkey) != VIR_IFKEY_LEN - 1) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopReqNew called with invalid " - "key \"%s\" (%zu)"), - ifkey ? ifkey : "", - strlen(ifkey)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopReqNew called with invalid " + "key \"%s\" (%zu)"), + ifkey ? ifkey : "", + strlen(ifkey)); return NULL; } @@ -890,8 +886,8 @@ virNWFilterSnoopReqLeaseDel(virNWFilterSnoopReqPtr req, if (req->techdriver && req->techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr, dhcpsrvrs, false) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopListDel failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopListDel failed")); ret = -1; } @@ -1097,35 +1093,35 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac, handle = pcap_create(ifname, pcap_errbuf); if (handle == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("pcap_create failed")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("pcap_create failed")); goto cleanup_nohandle; } 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", - _("setup of pcap handle failed")); + 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, - _("pcap_compile: %s"), pcap_geterr(handle)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pcap_compile: %s"), pcap_geterr(handle)); goto cleanup; } if (pcap_setfilter(handle, &fp) != 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("pcap_setfilter: %s"), pcap_geterr(handle)); + 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, - _("pcap_setdirection: %s"), - pcap_geterr(handle)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("pcap_setdirection: %s"), + pcap_geterr(handle)); goto cleanup_freecode; } @@ -1158,9 +1154,9 @@ static void virNWFilterDHCPDecodeWorker(void *jobdata, void *opaque) job->caplen, job->fromVM) == -1) { req->jobCompletionStatus = -1; - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Instantiation of rules failed on " - "interface '%s'"), req->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Instantiation of rules failed on " + "interface '%s'"), req->ifname); } virAtomicIntDec(job->qCtr); VIR_FREE(job); @@ -1465,10 +1461,10 @@ virNWFilterDHCPSnoopThread(void *req0) /* protect req->ifname */ virNWFilterSnoopReqLock(req); - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("interface '%s' failing; " - "reopening"), - req->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("interface '%s' failing; " + "reopening"), + req->ifname); if (req->ifname) pcapConf[i].handle = virNWFilterSnoopDHCPOpen(req->ifname, &req->macaddr, @@ -1519,9 +1515,9 @@ virNWFilterDHCPSnoopThread(void *req0) hdr->caplen, pcapConf[i].dir, &pcapConf[i].qCtr) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Job submission failed on " - "interface '%s'"), req->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Job submission failed on " + "interface '%s'"), req->ifname); error = true; break; } @@ -1625,10 +1621,10 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, /* check that all tools are available for applying the filters (late) */ if ( !techdriver->canApplyBasicRules()) { - virNWFilterReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("IP parameter must be provided since " - "snooping the IP address does not work " - "possibly due to missing tools")); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IP parameter must be provided since " + "snooping the IP address does not work " + "possibly due to missing tools")); goto exit_snoopreqput; } @@ -1637,15 +1633,16 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, if (techdriver->applyDHCPOnlyRules(req->ifname, &req->macaddr, dhcpsrvrs, false) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, _("applyDHCPOnlyRules " - "failed - spoofing not protected!")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("applyDHCPOnlyRules " + "failed - spoofing not protected!")); goto exit_snoopreqput; } if (virNWFilterHashTablePutAll(filterparams, req->vars) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterDHCPSnoopReq: can't copy variables" - " on if %s"), ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterDHCPSnoopReq: can't copy variables" + " on if %s"), ifkey); goto exit_snoopreqput; } @@ -1653,19 +1650,19 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, if (virHashAddEntry(virNWFilterSnoopState.ifnameToKey, ifname, req->ifkey) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterDHCPSnoopReq ifname map failed" - " on interface \"%s\" key \"%s\""), ifname, - ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterDHCPSnoopReq ifname map failed" + " on interface \"%s\" key \"%s\""), ifname, + ifkey); goto exit_snoopunlock; } if (isnewreq && virHashAddEntry(virNWFilterSnoopState.snoopReqs, ifkey, req) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterDHCPSnoopReq req add failed on" - " interface \"%s\" ifkey \"%s\""), ifname, - ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterDHCPSnoopReq req add failed on" + " interface \"%s\" ifkey \"%s\""), ifname, + ifkey); goto exit_rem_ifnametokey; } @@ -1674,9 +1671,9 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, if (virThreadCreate(&thread, false, virNWFilterDHCPSnoopThread, req) != 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterDHCPSnoopReq virThreadCreate " - "failed on interface '%s'"), ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterDHCPSnoopReq virThreadCreate " + "failed on interface '%s'"), ifname); goto exit_snoopreq_unlock; } @@ -1684,16 +1681,16 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver, req->threadkey = virNWFilterSnoopActivate(req); if (!req->threadkey) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Activation of snoop request failed on " - "interface '%s'"), req->ifname); + 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, - _("Restoring of leases failed on " - "interface '%s'"), req->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Restoring of leases failed on " + "interface '%s'"), req->ifname); goto exit_snoop_cancel; } @@ -1932,18 +1929,18 @@ virNWFilterSnoopLeaseFileLoad(void) time(&now); while (fp && fgets(line, sizeof(line), fp)) { if (line[strlen(line)-1] != '\n') { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopLeaseFileLoad lease file " - "line %d corrupt"), ln); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopLeaseFileLoad lease file " + "line %d corrupt"), ln); break; } ln++; /* key len 55 = "VMUUID"+'-'+"MAC" */ if (sscanf(line, "%u %55s %16s %16s", &ipl.timeout, ifkey, ipstr, srvstr) < 4) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopLeaseFileLoad lease file " - "line %d corrupt"), ln); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopLeaseFileLoad lease file " + "line %d corrupt"), ln); break; } if (ipl.timeout && ipl.timeout < now) @@ -1958,17 +1955,17 @@ virNWFilterSnoopLeaseFileLoad(void) if (tmp < 0) { virNWFilterSnoopReqPut(req); - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("virNWFilterSnoopLeaseFileLoad req add" - " failed on interface \"%s\""), ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("virNWFilterSnoopLeaseFileLoad req add" + " failed on interface \"%s\""), ifkey); continue; } } if (virSocketAddrParseIPv4(&ipl.ipAddress, ipstr) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("line %d corrupt ipaddr \"%s\""), - ln, ipstr); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("line %d corrupt ipaddr \"%s\""), + ln, ipstr); virNWFilterSnoopReqPut(req); continue; } @@ -2113,8 +2110,8 @@ virNWFilterDHCPSnoopEnd(const char *ifname) ifkey = (char *)virHashLookup(virNWFilterSnoopState.ifnameToKey, ifname); if (!ifkey) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("ifname \"%s\" not in key map"), ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("ifname \"%s\" not in key map"), ifname); goto cleanup; } @@ -2127,8 +2124,8 @@ virNWFilterDHCPSnoopEnd(const char *ifname) req = virNWFilterSnoopReqGetByIFKey(ifkey); if (!req) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("ifkey \"%s\" has no req"), ifkey); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("ifkey \"%s\" has no req"), ifkey); goto cleanup; } @@ -2209,10 +2206,10 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED, virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED, virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("libvirt was not compiled with libpcap and \"" - NWFILTER_VARNAME_CTRL_IP_LEARNING - "='dhcp'\" requires it.")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("libvirt was not compiled with libpcap and \"" + NWFILTER_VARNAME_CTRL_IP_LEARNING + "='dhcp'\" requires it.")); return -1; } #endif /* HAVE_LIBPCAP */ diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index 52560b7f53..58d91f9d69 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -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,8 +236,8 @@ nwfilterLookupByUUID(virConnectPtr conn, nwfilterDriverUnlock(driver); if (!nwfilter) { - virNWFilterReportError(VIR_ERR_NO_NWFILTER, - "%s", _("no nwfilter with matching uuid")); + virReportError(VIR_ERR_NO_NWFILTER, + "%s", _("no nwfilter with matching uuid")); goto cleanup; } @@ -265,8 +262,8 @@ nwfilterLookupByName(virConnectPtr conn, nwfilterDriverUnlock(driver); if (!nwfilter) { - virNWFilterReportError(VIR_ERR_NO_NWFILTER, - _("no nwfilter with matching name '%s'"), name); + virReportError(VIR_ERR_NO_NWFILTER, + _("no nwfilter with matching name '%s'"), name); goto cleanup; } @@ -389,15 +386,15 @@ nwfilterUndefine(virNWFilterPtr obj) { nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid); if (!nwfilter) { - virNWFilterReportError(VIR_ERR_NO_NWFILTER, - "%s", _("no nwfilter with matching uuid")); + virReportError(VIR_ERR_NO_NWFILTER, + "%s", _("no nwfilter with matching uuid")); goto cleanup; } if (virNWFilterTestUnassignDef(obj->conn, nwfilter) < 0) { - virNWFilterReportError(VIR_ERR_OPERATION_INVALID, - "%s", - _("nwfilter is in use")); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", + _("nwfilter is in use")); goto cleanup; } @@ -437,8 +434,8 @@ nwfilterGetXMLDesc(virNWFilterPtr obj, nwfilterDriverUnlock(driver); if (!nwfilter) { - virNWFilterReportError(VIR_ERR_NO_NWFILTER, - "%s", _("no nwfilter with matching uuid")); + virReportError(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 cbf6d14741..18195c310f 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -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,9 +239,9 @@ printVar(virNWFilterVarCombIterPtr vars, const char *varName; varName = virNWFilterVarAccessGetVarName(item->varAccess); - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Buffer too small to print variable " - "'%s' into"), varName); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Buffer too small to print variable " + "'%s' into"), varName); return -1; } @@ -278,8 +275,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, if (!data) return -1; if (snprintf(buf, bufsize, "%s", data) >= bufsize) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("buffer too small for IP address")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("buffer too small for IP address")); VIR_FREE(data); return -1; } @@ -292,8 +289,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, return -1; if (snprintf(buf, bufsize, "%s", data) >= bufsize) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("buffer too small for IPv6 address")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("buffer too small for IPv6 address")); VIR_FREE(data); return -1; } @@ -303,8 +300,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, case DATATYPE_MACADDR: case DATATYPE_MACMASK: if (bufsize < VIR_MAC_STRING_BUFLEN) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer too small for MAC address")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for MAC address")); return -1; } @@ -315,8 +312,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, case DATATYPE_IPMASK: if (snprintf(buf, bufsize, "%d", item->u.u8) >= bufsize) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer too small for uint8 type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for uint8 type")); return -1; } break; @@ -325,8 +322,8 @@ _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", - _("Buffer too small for uint32 type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for uint32 type")); return -1; } break; @@ -335,8 +332,8 @@ _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", - _("Buffer too small for uint16 type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for uint16 type")); return -1; } break; @@ -345,16 +342,16 @@ _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", - _("Buffer too small for uint8 type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for uint8 type")); return -1; } break; case DATATYPE_IPSETNAME: if (virStrcpy(buf, item->u.ipset.setname, bufsize) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer to small for ipset name")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer to small for ipset name")); return -1; } break; @@ -385,8 +382,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, flags = virBufferContentAndReset(&vb); if (virStrcpy(buf, flags, bufsize) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Buffer too small for IPSETFLAGS type")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Buffer too small for IPSETFLAGS type")); VIR_FREE(flags); return -1; } @@ -394,8 +391,8 @@ _printDataType(virNWFilterVarCombIterPtr vars, break; default: - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Unhandled datatype %x"), item->datatype); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unhandled datatype %x"), item->datatype); return -1; break; } @@ -1297,10 +1294,10 @@ _iptablesCreateRuleInstance(int directionIn, bool hasICMPType = false; if (!iptables_cmd) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot create rule since %s tool is " - "missing."), - isIPv6 ? "ip6tables" : "iptables"); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot create rule since %s tool is " + "missing."), + isIPv6 ? "ip6tables" : "iptables"); goto err_exit; } @@ -2015,9 +2012,9 @@ ebtablesCreateRuleInstance(char chainPrefix, const char *target; if (!ebtables_cmd_path) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create rule since ebtables tool is " - "missing.")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create rule since ebtables tool is " + "missing.")); goto err_exit; } @@ -2116,11 +2113,11 @@ ebtablesCreateRuleInstance(char chainPrefix, since this clashes with -d below... */ if (reverse && HAS_ENTRY_ITEM(&rule->p.stpHdrFilter.ethHdr.dataSrcMACAddr)) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("STP filtering in %s direction with " - "source MAC address set is not supported"), - virNWFilterRuleDirectionTypeToString( - VIR_NWFILTER_RULE_DIRECTION_INOUT)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("STP filtering in %s direction with " + "source MAC address set is not supported"), + virNWFilterRuleDirectionTypeToString( + VIR_NWFILTER_RULE_DIRECTION_INOUT)); return -1; } @@ -2683,8 +2680,8 @@ ebiptablesCreateRuleInstance(enum virDomainNetType nettype ATTRIBUTE_UNUSED, break; case VIR_NWFILTER_RULE_PROTOCOL_LAST: - virNWFilterReportError(VIR_ERR_OPERATION_FAILED, - "%s", _("illegal protocol type")); + virReportError(VIR_ERR_OPERATION_FAILED, + "%s", _("illegal protocol type")); rc = -1; break; } @@ -3199,9 +3196,9 @@ ebtablesApplyBasicRules(const char *ifname, char macaddr_str[VIR_MAC_STRING_BUFLEN]; if (!ebtables_cmd_path) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create rules since ebtables tool is " - "missing.")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create rules since ebtables tool is " + "missing.")); return -1; } @@ -3257,9 +3254,9 @@ ebtablesApplyBasicRules(const char *ifname, tear_down_tmpebchains: ebtablesCleanAll(ifname); - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - "%s", - _("Some rules could not be created.")); + virReportError(VIR_ERR_BUILD_FIREWALL, + "%s", + _("Some rules could not be created.")); return -1; } @@ -3296,9 +3293,9 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, unsigned int num_dhcpsrvrs; if (!ebtables_cmd_path) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create rules since ebtables tool is " - "missing.")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create rules since ebtables tool is " + "missing.")); return -1; } @@ -3400,9 +3397,9 @@ ebtablesApplyDHCPOnlyRules(const char *ifname, tear_down_tmpebchains: ebtablesCleanAll(ifname); - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - "%s", - _("Some rules could not be created.")); + virReportError(VIR_ERR_BUILD_FIREWALL, + "%s", + _("Some rules could not be created.")); return -1; } @@ -3425,9 +3422,9 @@ ebtablesApplyDropAllRules(const char *ifname) chain_out[MAX_CHAINNAME_LENGTH]; if (!ebtables_cmd_path) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create rules since ebtables tool is " - "missing.")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create rules since ebtables tool is " + "missing.")); return -1; } @@ -3470,9 +3467,9 @@ ebtablesApplyDropAllRules(const char *ifname) tear_down_tmpebchains: ebtablesCleanAll(ifname); - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - "%s", - _("Some rules could not be created.")); + virReportError(VIR_ERR_BUILD_FIREWALL, + "%s", + _("Some rules could not be created.")); return -1; } @@ -3903,12 +3900,12 @@ tear_down_tmpebchains: ebiptablesExecCLI(&buf, &cli_status, NULL); - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - _("Some rules could not be created for " - "interface %s%s%s"), - ifname, - errmsg ? ": " : "", - errmsg ? errmsg : ""); + virReportError(VIR_ERR_BUILD_FIREWALL, + _("Some rules could not be created for " + "interface %s%s%s"), + ifname, + errmsg ? ": " : "", + errmsg ? errmsg : ""); exit_free_sets: virHashFree(chains_in_set); @@ -4042,9 +4039,9 @@ ebiptablesRemoveRules(const char *ifname ATTRIBUTE_UNUSED, goto err_exit; if (cli_status) { - virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, - "%s", - _("error while executing CLI commands")); + virReportError(VIR_ERR_BUILD_FIREWALL, + "%s", + _("error while executing CLI commands")); rc = -1; } diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index fb13fbe5de..48fc440066 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -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,8 +161,8 @@ virNWFilterVarHashmapAddStdValues(virNWFilterHashTablePtr table, if (virHashAddEntry(table->hashTable, NWFILTER_STD_VAR_MAC, val) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Could not add variable 'MAC' to hashmap")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Could not add variable 'MAC' to hashmap")); return -1; } } @@ -178,8 +175,8 @@ virNWFilterVarHashmapAddStdValues(virNWFilterHashTablePtr table, if (virHashAddEntry(table->hashTable, NWFILTER_STD_VAR_IP, val) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Could not add variable 'IP' to hashmap")); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Could not add variable 'IP' to hashmap")); return -1; } } @@ -430,9 +427,9 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver, if (obj) { if (obj->wantRemoved) { - virNWFilterReportError(VIR_ERR_NO_NWFILTER, - _("Filter '%s' is in use."), - inc->filterref); + virReportError(VIR_ERR_NO_NWFILTER, + _("Filter '%s' is in use."), + inc->filterref); rc = -1; virNWFilterObjUnlock(obj); break; @@ -478,9 +475,9 @@ _virNWFilterInstantiateRec(virNWFilterTechDriverPtr techdriver, if (rc < 0) break; } else { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("referenced filter '%s' is missing"), - inc->filterref); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("referenced filter '%s' is missing"), + inc->filterref); rc = -1; break; } @@ -542,9 +539,9 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter, if (obj) { if (obj->wantRemoved) { - virNWFilterReportError(VIR_ERR_NO_NWFILTER, - _("Filter '%s' is in use."), - inc->filterref); + virReportError(VIR_ERR_NO_NWFILTER, + _("Filter '%s' is in use."), + inc->filterref); rc = -1; virNWFilterObjUnlock(obj); break; @@ -585,9 +582,9 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter, if (rc < 0) break; } else { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("referenced filter '%s' is missing"), - inc->filterref); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("referenced filter '%s' is missing"), + inc->filterref); rc = -1; break; } @@ -724,9 +721,10 @@ virNWFilterInstantiate(const unsigned char *vmuuid ATTRIBUTE_UNUSED, goto err_exit; } else { rc = -1; - virNWFilterReportError(VIR_ERR_PARSE_FAILED, _("filter '%s' " - "learning value '%s' invalid."), - filter->name, learning); + virReportError(VIR_ERR_PARSE_FAILED, + _("filter '%s' " + "learning value '%s' invalid."), + filter->name, learning); } } else goto err_unresolvable_vars; @@ -799,9 +797,9 @@ err_unresolvable_vars: buf = virNWFilterPrintVars(missing_vars->hashTable, ", ", false, reportIP); if (buf) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot instantiate filter due to unresolvable " - "variables or unavailable list elements: %s"), buf); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot instantiate filter due to unresolvable " + "variables or unavailable list elements: %s"), buf); VIR_FREE(buf); } @@ -842,10 +840,10 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid, techdriver = virNWFilterTechDriverForName(drvname); if (!techdriver) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get access to ACL tech " - "driver '%s'"), - drvname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get access to ACL tech " + "driver '%s'"), + drvname); return -1; } @@ -853,16 +851,16 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid, obj = virNWFilterObjFindByName(&driver->nwfilters, filtername); if (!obj) { - virNWFilterReportError(VIR_ERR_NO_NWFILTER, - _("Could not find filter '%s'"), - filtername); + virReportError(VIR_ERR_NO_NWFILTER, + _("Could not find filter '%s'"), + filtername); return -1; } if (obj->wantRemoved) { - virNWFilterReportError(VIR_ERR_NO_NWFILTER, - _("Filter '%s' is in use."), - filtername); + virReportError(VIR_ERR_NO_NWFILTER, + _("Filter '%s' is in use."), + filtername); rc = -1; goto err_exit; } @@ -1070,10 +1068,10 @@ virNWFilterRollbackUpdateFilter(const virDomainNetDefPtr net) techdriver = virNWFilterTechDriverForName(drvname); if (!techdriver) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get access to ACL tech " - "driver '%s'"), - drvname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get access to ACL tech " + "driver '%s'"), + drvname); return -1; } @@ -1096,10 +1094,10 @@ virNWFilterTearOldFilter(virDomainNetDefPtr net) techdriver = virNWFilterTechDriverForName(drvname); if (!techdriver) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get access to ACL tech " - "driver '%s'"), - drvname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get access to ACL tech " + "driver '%s'"), + drvname); return -1; } @@ -1121,10 +1119,10 @@ _virNWFilterTeardownFilter(const char *ifname) techdriver = virNWFilterTechDriverForName(drvname); if (!techdriver) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get access to ACL tech " - "driver '%s'"), - drvname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get access to ACL tech " + "driver '%s'"), + drvname); return -1; } @@ -1200,9 +1198,9 @@ virNWFilterDomainFWUpdateCB(void *payload, vm->uuid, net); if (err) - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Failure while applying current filter on " - "VM %s"), vm->name); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failure while applying current filter on " + "VM %s"), vm->name); break; } if (cb->err) diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index d5005ebd6e..f86fc97228 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -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,17 +148,17 @@ virNWFilterLockIface(const char *ifname) { } if (virMutexInitRecursive(&ifaceLock->lock) < 0) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("mutex initialization failed")); + 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, - _("interface name %s does not fit into " - "buffer "), - ifaceLock->ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("interface name %s does not fit into " + "buffer "), + ifaceLock->ifname); VIR_FREE(ifaceLock); goto err_exit; } @@ -675,10 +672,10 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver, return -1; if ( !techdriver->canApplyBasicRules()) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("IP parameter must be provided since " - "snooping the IP address does not work " - "possibly due to missing tools")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("IP parameter must be provided since " + "snooping the IP address does not work " + "possibly due to missing tools")); return -1; } @@ -703,17 +700,17 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver, } if (virStrcpyStatic(req->ifname, ifname) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Destination buffer for ifname ('%s') " - "not large enough"), ifname); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Destination buffer for ifname ('%s') " + "not large enough"), ifname); goto err_free_ht; } if (linkdev) { if (virStrcpyStatic(req->linkdev, linkdev) == NULL) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, - _("Destination buffer for linkdev ('%s') " - "not large enough"), linkdev); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Destination buffer for linkdev ('%s') " + "not large enough"), linkdev); goto err_free_ht; } } @@ -763,10 +760,10 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver ATTRIBUTE_UNUSED, virNWFilterHashTablePtr filterparams ATTRIBUTE_UNUSED, virNWFilterDriverStatePtr driver ATTRIBUTE_UNUSED, enum howDetect howDetect ATTRIBUTE_UNUSED) { - virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("IP parameter must be given since libvirt " - "was not compiled with IP address learning " - "support")); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("IP parameter must be given since libvirt " + "was not compiled with IP address learning " + "support")); return -1; } #endif /* HAVE_LIBPCAP */ -- GitLab