mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
This patch removes the virConnectPtr parameter from all functions where it's not necessary starting out with removing it as a parameter to the error reporting function.
This commit is contained in:
parent
88151c7cbc
commit
45274d4121
@ -310,8 +310,7 @@ virNWFilterPoolObjListFree(virNWFilterPoolObjListPtr pools)
|
||||
|
||||
|
||||
static int
|
||||
virNWFilterRuleDefAddVar(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virNWFilterRuleDefPtr nwf,
|
||||
virNWFilterRuleDefAddVar(virNWFilterRuleDefPtr nwf,
|
||||
nwItemDesc *item,
|
||||
const char *var)
|
||||
{
|
||||
@ -1112,8 +1111,7 @@ virNWIPv6AddressParser(const char *input,
|
||||
|
||||
|
||||
static int
|
||||
virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
xmlNodePtr node,
|
||||
virNWFilterRuleDetailsParse(xmlNodePtr node,
|
||||
virNWFilterRuleDefPtr nwf,
|
||||
const virXMLAttr2Struct *att)
|
||||
{
|
||||
@ -1152,8 +1150,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
flags_set |= NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR;
|
||||
storage_ptr = NULL;
|
||||
|
||||
if (virNWFilterRuleDefAddVar(conn,
|
||||
nwf,
|
||||
if (virNWFilterRuleDefAddVar(nwf,
|
||||
item,
|
||||
&prop[1]))
|
||||
rc = -1;
|
||||
@ -1325,7 +1322,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
if (!found || rc) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("%s has illegal value %s"),
|
||||
att[idx].name, prop);
|
||||
rc = -1;
|
||||
@ -1348,8 +1345,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
|
||||
|
||||
static virNWFilterIncludeDefPtr
|
||||
virNWFilterIncludeParse(virConnectPtr conn,
|
||||
xmlNodePtr cur)
|
||||
virNWFilterIncludeParse(xmlNodePtr cur)
|
||||
{
|
||||
virNWFilterIncludeDefPtr ret;
|
||||
|
||||
@ -1360,7 +1356,7 @@ virNWFilterIncludeParse(virConnectPtr conn,
|
||||
|
||||
ret->filterref = virXMLPropString(cur, "filter");
|
||||
if (!ret->filterref) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s",
|
||||
_("rule node requires action attribute"));
|
||||
goto err_exit;
|
||||
@ -1548,8 +1544,7 @@ virNWFilterRuleDefFixup(virNWFilterRuleDefPtr rule)
|
||||
|
||||
|
||||
static virNWFilterRuleDefPtr
|
||||
virNWFilterRuleParse(virConnectPtr conn,
|
||||
xmlNodePtr node)
|
||||
virNWFilterRuleParse(xmlNodePtr node)
|
||||
{
|
||||
char *action;
|
||||
char *direction;
|
||||
@ -1571,28 +1566,28 @@ virNWFilterRuleParse(virConnectPtr conn,
|
||||
prio = virXMLPropString(node, "priority");
|
||||
|
||||
if (!action) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s",
|
||||
_("rule node requires action attribute"));
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
if ((ret->action = virNWFilterRuleActionTypeFromString(action)) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s",
|
||||
_("unknown rule action attribute value"));
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
if (!direction) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s",
|
||||
_("rule node requires direction attribute"));
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
if ((ret->tt = virNWFilterRuleDirectionTypeFromString(direction)) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s",
|
||||
_("unknown rule direction attribute value"));
|
||||
goto err_exit;
|
||||
@ -1624,8 +1619,7 @@ virNWFilterRuleParse(virConnectPtr conn,
|
||||
found = 1;
|
||||
ret->prtclType = virAttr[i].prtclType;
|
||||
|
||||
if (virNWFilterRuleDetailsParse(conn,
|
||||
cur,
|
||||
if (virNWFilterRuleDetailsParse(cur,
|
||||
ret,
|
||||
virAttr[i].att) < 0) {
|
||||
/* we ignore malformed rules
|
||||
@ -1663,8 +1657,7 @@ err_exit:
|
||||
|
||||
|
||||
static virNWFilterDefPtr
|
||||
virNWFilterDefParseXML(virConnectPtr conn,
|
||||
xmlXPathContextPtr ctxt) {
|
||||
virNWFilterDefParseXML(xmlXPathContextPtr ctxt) {
|
||||
virNWFilterDefPtr ret;
|
||||
xmlNodePtr curr = ctxt->node;
|
||||
char *uuid = NULL;
|
||||
@ -1678,7 +1671,7 @@ virNWFilterDefParseXML(virConnectPtr conn,
|
||||
|
||||
ret->name = virXPathString("string(./@name)", ctxt);
|
||||
if (!ret->name) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("filter has no name"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1688,7 +1681,7 @@ virNWFilterDefParseXML(virConnectPtr conn,
|
||||
if (chain) {
|
||||
if ((ret->chainsuffix =
|
||||
virNWFilterChainSuffixTypeFromString(chain)) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unknown chain suffix '%s'"), chain);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1697,13 +1690,13 @@ virNWFilterDefParseXML(virConnectPtr conn,
|
||||
uuid = virXPathString("string(./uuid)", ctxt);
|
||||
if (uuid == NULL) {
|
||||
if (virUUIDGenerate(ret->uuid) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("unable to generate uuid"));
|
||||
goto cleanup;
|
||||
}
|
||||
} else {
|
||||
if (virUUIDParse(uuid, ret->uuid) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_XML_ERROR,
|
||||
"%s", _("malformed uuid element"));
|
||||
goto cleanup;
|
||||
}
|
||||
@ -1721,9 +1714,9 @@ virNWFilterDefParseXML(virConnectPtr conn,
|
||||
|
||||
/* ignore malformed rule and include elements */
|
||||
if (xmlStrEqual(curr->name, BAD_CAST "rule"))
|
||||
entry->rule = virNWFilterRuleParse(conn, curr);
|
||||
entry->rule = virNWFilterRuleParse(curr);
|
||||
else if (xmlStrEqual(curr->name, BAD_CAST "filterref"))
|
||||
entry->include = virNWFilterIncludeParse(conn, curr);
|
||||
entry->include = virNWFilterIncludeParse(curr);
|
||||
|
||||
if (entry->rule || entry->include) {
|
||||
if (VIR_REALLOC_N(ret->filterEntries, ret->nentries+1) < 0) {
|
||||
@ -1762,7 +1755,7 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
|
||||
conn->err.code == VIR_ERR_NONE &&
|
||||
ctxt->lastError.level == XML_ERR_FATAL &&
|
||||
ctxt->lastError.message != NULL) {
|
||||
virNWFilterReportError(conn, VIR_ERR_XML_DETAIL,
|
||||
virNWFilterReportError(VIR_ERR_XML_DETAIL,
|
||||
_("at line %d: %s"),
|
||||
ctxt->lastError.line,
|
||||
ctxt->lastError.message);
|
||||
@ -1772,14 +1765,13 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
|
||||
|
||||
|
||||
virNWFilterDefPtr
|
||||
virNWFilterDefParseNode(virConnectPtr conn,
|
||||
xmlDocPtr xml,
|
||||
virNWFilterDefParseNode(xmlDocPtr xml,
|
||||
xmlNodePtr root) {
|
||||
xmlXPathContextPtr ctxt = NULL;
|
||||
virNWFilterDefPtr def = NULL;
|
||||
|
||||
if (STRNEQ((const char *)root->name, "filter")) {
|
||||
virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_XML_ERROR,
|
||||
"%s",
|
||||
_("unknown root element for nw filter pool"));
|
||||
goto cleanup;
|
||||
@ -1792,7 +1784,7 @@ virNWFilterDefParseNode(virConnectPtr conn,
|
||||
}
|
||||
|
||||
ctxt->node = root;
|
||||
def = virNWFilterDefParseXML(conn, ctxt);
|
||||
def = virNWFilterDefParseXML(ctxt);
|
||||
|
||||
cleanup:
|
||||
xmlXPathFreeContext(ctxt);
|
||||
@ -1802,8 +1794,8 @@ cleanup:
|
||||
|
||||
static virNWFilterDefPtr
|
||||
virNWFilterDefParse(virConnectPtr conn,
|
||||
const char *xmlStr,
|
||||
const char *filename) {
|
||||
const char *xmlStr,
|
||||
const char *filename) {
|
||||
virNWFilterDefPtr ret = NULL;
|
||||
xmlParserCtxtPtr pctxt;
|
||||
xmlDocPtr xml = NULL;
|
||||
@ -1830,19 +1822,19 @@ virNWFilterDefParse(virConnectPtr conn,
|
||||
|
||||
if (!xml) {
|
||||
if (conn && conn->err.code == VIR_ERR_NONE)
|
||||
virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_XML_ERROR,
|
||||
"%s",_("failed to parse xml document"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
node = xmlDocGetRootElement(xml);
|
||||
if (node == NULL) {
|
||||
virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_XML_ERROR,
|
||||
"%s", _("missing root element"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = virNWFilterDefParseNode(conn, xml, node);
|
||||
ret = virNWFilterDefParseNode(xml, node);
|
||||
|
||||
xmlFreeParserCtxt (pctxt);
|
||||
xmlFreeDoc(xml);
|
||||
@ -1858,7 +1850,7 @@ virNWFilterDefParse(virConnectPtr conn,
|
||||
|
||||
virNWFilterDefPtr
|
||||
virNWFilterDefParseString(virConnectPtr conn,
|
||||
const char *xmlStr)
|
||||
const char *xmlStr)
|
||||
{
|
||||
return virNWFilterDefParse(conn, xmlStr, NULL);
|
||||
}
|
||||
@ -1874,7 +1866,7 @@ virNWFilterDefParseFile(virConnectPtr conn,
|
||||
|
||||
virNWFilterPoolObjPtr
|
||||
virNWFilterPoolObjFindByUUID(virNWFilterPoolObjListPtr pools,
|
||||
const unsigned char *uuid)
|
||||
const unsigned char *uuid)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@ -1891,7 +1883,7 @@ virNWFilterPoolObjFindByUUID(virNWFilterPoolObjListPtr pools,
|
||||
|
||||
virNWFilterPoolObjPtr
|
||||
virNWFilterPoolObjFindByName(virNWFilterPoolObjListPtr pools,
|
||||
const char *name)
|
||||
const char *name)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@ -1906,8 +1898,7 @@ virNWFilterPoolObjFindByName(virNWFilterPoolObjListPtr pools,
|
||||
}
|
||||
|
||||
|
||||
int virNWFilterSaveXML(virConnectPtr conn,
|
||||
const char *configDir,
|
||||
int virNWFilterSaveXML(const char *configDir,
|
||||
virNWFilterDefPtr def,
|
||||
const char *xml)
|
||||
{
|
||||
@ -1916,7 +1907,7 @@ int virNWFilterSaveXML(virConnectPtr conn,
|
||||
size_t towrite;
|
||||
int err;
|
||||
|
||||
if ((configFile = virNWFilterConfigFile(conn, configDir, def->name)) == NULL)
|
||||
if ((configFile = virNWFilterConfigFile(configDir, def->name)) == NULL)
|
||||
goto cleanup;
|
||||
|
||||
if ((err = virFileMakePath(configDir))) {
|
||||
@ -1962,17 +1953,16 @@ int virNWFilterSaveXML(virConnectPtr conn,
|
||||
}
|
||||
|
||||
|
||||
int virNWFilterSaveConfig(virConnectPtr conn,
|
||||
const char *configDir,
|
||||
int virNWFilterSaveConfig(const char *configDir,
|
||||
virNWFilterDefPtr def)
|
||||
{
|
||||
int ret = -1;
|
||||
char *xml;
|
||||
|
||||
if (!(xml = virNWFilterDefFormat(conn, def)))
|
||||
if (!(xml = virNWFilterDefFormat(def)))
|
||||
goto cleanup;
|
||||
|
||||
if (virNWFilterSaveXML(conn, configDir, def, xml))
|
||||
if (virNWFilterSaveXML(configDir, def, xml))
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
@ -2119,13 +2109,13 @@ virNWFilterTestUnassignDef(virConnectPtr conn,
|
||||
|
||||
virNWFilterPoolObjPtr
|
||||
virNWFilterPoolObjAssignDef(virConnectPtr conn,
|
||||
virNWFilterPoolObjListPtr pools,
|
||||
virNWFilterDefPtr def)
|
||||
virNWFilterPoolObjListPtr pools,
|
||||
virNWFilterDefPtr def)
|
||||
{
|
||||
virNWFilterPoolObjPtr pool;
|
||||
|
||||
if (virNWFilterDefLoopDetect(conn, pools, def)) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
|
||||
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
|
||||
"%s", _("filter would introduce a loop"));
|
||||
return NULL;
|
||||
}
|
||||
@ -2154,7 +2144,7 @@ virNWFilterPoolObjAssignDef(virConnectPtr conn,
|
||||
}
|
||||
|
||||
if (virMutexInitRecursive(&pool->lock) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("cannot initialize mutex"));
|
||||
VIR_FREE(pool);
|
||||
return NULL;
|
||||
@ -2178,9 +2168,9 @@ virNWFilterPoolObjAssignDef(virConnectPtr conn,
|
||||
|
||||
static virNWFilterPoolObjPtr
|
||||
virNWFilterPoolObjLoad(virConnectPtr conn,
|
||||
virNWFilterPoolObjListPtr pools,
|
||||
const char *file,
|
||||
const char *path)
|
||||
virNWFilterPoolObjListPtr pools,
|
||||
const char *file,
|
||||
const char *path)
|
||||
{
|
||||
virNWFilterDefPtr def;
|
||||
virNWFilterPoolObjPtr pool;
|
||||
@ -2190,7 +2180,7 @@ virNWFilterPoolObjLoad(virConnectPtr conn,
|
||||
}
|
||||
|
||||
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
|
||||
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
|
||||
_("network filter pool config filename '%s' does not match pool name '%s'"),
|
||||
path, def->name);
|
||||
virNWFilterDefFree(def);
|
||||
@ -2215,8 +2205,8 @@ virNWFilterPoolObjLoad(virConnectPtr conn,
|
||||
|
||||
int
|
||||
virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
|
||||
virNWFilterPoolObjListPtr pools,
|
||||
const char *configDir)
|
||||
virNWFilterPoolObjListPtr pools,
|
||||
const char *configDir)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
@ -2242,7 +2232,7 @@ virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
|
||||
|
||||
if (virFileBuildPath(configDir, entry->d_name,
|
||||
NULL, path, PATH_MAX) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("config filename '%s/%s' is too long"),
|
||||
configDir, entry->d_name);
|
||||
continue;
|
||||
@ -2260,10 +2250,9 @@ virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
|
||||
|
||||
|
||||
int
|
||||
virNWFilterPoolObjSaveDef(virConnectPtr conn,
|
||||
virNWFilterDriverStatePtr driver,
|
||||
virNWFilterPoolObjPtr pool,
|
||||
virNWFilterDefPtr def)
|
||||
virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
|
||||
virNWFilterPoolObjPtr pool,
|
||||
virNWFilterDefPtr def)
|
||||
{
|
||||
char *xml;
|
||||
int fd = -1, ret = -1;
|
||||
@ -2282,7 +2271,7 @@ virNWFilterPoolObjSaveDef(virConnectPtr conn,
|
||||
|
||||
if (virFileBuildPath(driver->configDir, def->name, ".xml",
|
||||
path, sizeof(path)) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("cannot construct config file path"));
|
||||
return -1;
|
||||
}
|
||||
@ -2292,8 +2281,8 @@ virNWFilterPoolObjSaveDef(virConnectPtr conn,
|
||||
}
|
||||
}
|
||||
|
||||
if (!(xml = virNWFilterDefFormat(conn, def))) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
if (!(xml = virNWFilterDefFormat(def))) {
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("failed to generate XML"));
|
||||
return -1;
|
||||
}
|
||||
@ -2335,19 +2324,18 @@ virNWFilterPoolObjSaveDef(virConnectPtr conn,
|
||||
|
||||
|
||||
int
|
||||
virNWFilterPoolObjDeleteDef(virConnectPtr conn,
|
||||
virNWFilterPoolObjPtr pool)
|
||||
virNWFilterPoolObjDeleteDef(virNWFilterPoolObjPtr pool)
|
||||
{
|
||||
if (!pool->configFile) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
_("no config file for %s"), pool->def->name);
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("no config file for %s"), pool->def->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (unlink(pool->configFile) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot remove config for %s"),
|
||||
pool->def->name);
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot remove config for %s"),
|
||||
pool->def->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2369,8 +2357,7 @@ virNWIPAddressFormat(virBufferPtr buf, nwIPAddressPtr ipaddr)
|
||||
|
||||
|
||||
static void
|
||||
virNWFilterRuleDefDetailsFormat(virConnectPtr conn,
|
||||
virBufferPtr buf,
|
||||
virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
|
||||
const char *type,
|
||||
const virXMLAttr2Struct *att,
|
||||
virNWFilterRuleDefPtr def)
|
||||
@ -2420,7 +2407,7 @@ virNWFilterRuleDefDetailsFormat(virConnectPtr conn,
|
||||
att[i].name);
|
||||
if (att[i].formatter) {
|
||||
if (!att[i].formatter(buf, def)) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("formatter for %s %s reported error"),
|
||||
type,
|
||||
att[i].name);
|
||||
@ -2484,8 +2471,7 @@ err_exit:
|
||||
|
||||
|
||||
static char *
|
||||
virNWFilterRuleDefFormat(virConnectPtr conn,
|
||||
virNWFilterRuleDefPtr def)
|
||||
virNWFilterRuleDefFormat(virNWFilterRuleDefPtr def)
|
||||
{
|
||||
int i;
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
@ -2500,8 +2486,7 @@ virNWFilterRuleDefFormat(virConnectPtr conn,
|
||||
i = 0;
|
||||
while (virAttr[i].id) {
|
||||
if (virAttr[i].prtclType == def->prtclType) {
|
||||
virNWFilterRuleDefDetailsFormat(conn,
|
||||
&buf2,
|
||||
virNWFilterRuleDefDetailsFormat(&buf2,
|
||||
virAttr[i].id,
|
||||
virAttr[i].att,
|
||||
def);
|
||||
@ -2563,18 +2548,16 @@ virNWFilterIncludeDefFormat(virNWFilterIncludeDefPtr inc)
|
||||
|
||||
|
||||
static char *
|
||||
virNWFilterEntryFormat(virConnectPtr conn,
|
||||
virNWFilterEntryPtr entry)
|
||||
virNWFilterEntryFormat(virNWFilterEntryPtr entry)
|
||||
{
|
||||
if (entry->rule)
|
||||
return virNWFilterRuleDefFormat(conn, entry->rule);
|
||||
return virNWFilterRuleDefFormat(entry->rule);
|
||||
return virNWFilterIncludeDefFormat(entry->include);
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
virNWFilterDefFormat(virConnectPtr conn,
|
||||
virNWFilterDefPtr def)
|
||||
virNWFilterDefFormat(virNWFilterDefPtr def)
|
||||
{
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
char uuid[VIR_UUID_STRING_BUFLEN];
|
||||
@ -2590,7 +2573,7 @@ virNWFilterDefFormat(virConnectPtr conn,
|
||||
virBufferVSprintf(&buf," <uuid>%s</uuid>\n", uuid);
|
||||
|
||||
for (i = 0; i < def->nentries; i++) {
|
||||
xml = virNWFilterEntryFormat(conn, def->filterEntries[i]);
|
||||
xml = virNWFilterEntryFormat(def->filterEntries[i]);
|
||||
if (!xml)
|
||||
goto err_exit;
|
||||
virBufferVSprintf(&buf, "%s", xml);
|
||||
@ -2613,8 +2596,7 @@ virNWFilterDefFormat(virConnectPtr conn,
|
||||
}
|
||||
|
||||
|
||||
char *virNWFilterConfigFile(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
const char *dir,
|
||||
char *virNWFilterConfigFile(const char *dir,
|
||||
const char *name)
|
||||
{
|
||||
char *ret = NULL;
|
||||
|
@ -518,13 +518,11 @@ virNWFilterPoolObjPtr
|
||||
const char *name);
|
||||
|
||||
|
||||
int virNWFilterPoolObjSaveDef(virConnectPtr conn,
|
||||
virNWFilterDriverStatePtr driver,
|
||||
int virNWFilterPoolObjSaveDef(virNWFilterDriverStatePtr driver,
|
||||
virNWFilterPoolObjPtr pool,
|
||||
virNWFilterDefPtr def);
|
||||
|
||||
int virNWFilterPoolObjDeleteDef(virConnectPtr conn,
|
||||
virNWFilterPoolObjPtr pool);
|
||||
int virNWFilterPoolObjDeleteDef(virNWFilterPoolObjPtr pool);
|
||||
|
||||
virNWFilterPoolObjPtr virNWFilterPoolObjAssignDef(virConnectPtr conn,
|
||||
virNWFilterPoolObjListPtr pools,
|
||||
@ -533,28 +531,23 @@ virNWFilterPoolObjPtr virNWFilterPoolObjAssignDef(virConnectPtr conn,
|
||||
int virNWFilterTestUnassignDef(virConnectPtr conn,
|
||||
virNWFilterPoolObjPtr pool);
|
||||
|
||||
virNWFilterDefPtr virNWFilterDefParseNode(virConnectPtr conn,
|
||||
xmlDocPtr xml,
|
||||
virNWFilterDefPtr virNWFilterDefParseNode(xmlDocPtr xml,
|
||||
xmlNodePtr root);
|
||||
|
||||
char *virNWFilterDefFormat(virConnectPtr conn,
|
||||
virNWFilterDefPtr def);
|
||||
char *virNWFilterDefFormat(virNWFilterDefPtr def);
|
||||
|
||||
int virNWFilterSaveXML(virConnectPtr conn,
|
||||
const char *configDir,
|
||||
int virNWFilterSaveXML(const char *configDir,
|
||||
virNWFilterDefPtr def,
|
||||
const char *xml);
|
||||
|
||||
int virNWFilterSaveConfig(virConnectPtr conn,
|
||||
const char *configDir,
|
||||
int virNWFilterSaveConfig(const char *configDir,
|
||||
virNWFilterDefPtr def);
|
||||
|
||||
int virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
|
||||
virNWFilterPoolObjListPtr pools,
|
||||
const char *configDir);
|
||||
|
||||
char *virNWFilterConfigFile(virConnectPtr conn,
|
||||
const char *dir,
|
||||
char *virNWFilterConfigFile(const char *dir,
|
||||
const char *name);
|
||||
|
||||
virNWFilterDefPtr virNWFilterDefParseString(virConnectPtr conn,
|
||||
@ -568,8 +561,7 @@ void virNWFilterPoolObjUnlock(virNWFilterPoolObjPtr obj);
|
||||
int virNWFilterConfLayerInit(virHashIterator domUpdateCB);
|
||||
void virNWFilterConfLayerShutdown(void);
|
||||
|
||||
# define virNWFilterReportError(conn, code, fmt...) \
|
||||
(void)conn; \
|
||||
# define virNWFilterReportError(code, fmt...) \
|
||||
virReportErrorHelper(NULL, VIR_FROM_NWFILTER, code, __FILE__, \
|
||||
__FUNCTION__, __LINE__, fmt)
|
||||
|
||||
|
@ -153,7 +153,6 @@ virNWFilterHashTableRemoveEntry(virNWFilterHashTablePtr ht,
|
||||
struct addToTableStruct {
|
||||
virNWFilterHashTablePtr target;
|
||||
int errOccurred;
|
||||
virConnectPtr conn;
|
||||
};
|
||||
|
||||
|
||||
@ -174,7 +173,7 @@ addToTable(void *payload, const char *name, void *data)
|
||||
}
|
||||
|
||||
if (virNWFilterHashTablePut(atts->target, name, val, 1) != 0) {
|
||||
virNWFilterReportError(atts->conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not put variable '%s' into hashmap"),
|
||||
name);
|
||||
atts->errOccurred = 1;
|
||||
@ -184,14 +183,12 @@ addToTable(void *payload, const char *name, void *data)
|
||||
|
||||
|
||||
int
|
||||
virNWFilterHashTablePutAll(virConnectPtr conn,
|
||||
virNWFilterHashTablePtr src,
|
||||
virNWFilterHashTablePutAll(virNWFilterHashTablePtr src,
|
||||
virNWFilterHashTablePtr dest)
|
||||
{
|
||||
struct addToTableStruct atts = {
|
||||
.target = dest,
|
||||
.errOccurred = 0,
|
||||
.conn = conn,
|
||||
};
|
||||
|
||||
virHashForEach(src->hashTable, addToTable, &atts);
|
||||
|
@ -46,8 +46,7 @@ int virNWFilterHashTablePut(virNWFilterHashTablePtr table,
|
||||
int freeName);
|
||||
int virNWFilterHashTableRemoveEntry(virNWFilterHashTablePtr table,
|
||||
const char *name);
|
||||
int virNWFilterHashTablePutAll(virConnectPtr conn,
|
||||
virNWFilterHashTablePtr src,
|
||||
int virNWFilterHashTablePutAll(virNWFilterHashTablePtr src,
|
||||
virNWFilterHashTablePtr dest);
|
||||
|
||||
# define VALID_VARNAME \
|
||||
|
@ -194,8 +194,8 @@ nwfilterLookupByUUID(virConnectPtr conn,
|
||||
nwfilterDriverUnlock(driver);
|
||||
|
||||
if (!pool) {
|
||||
virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
|
||||
"%s", _("no pool with matching uuid"));
|
||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
||||
"%s", _("no pool with matching uuid"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -220,8 +220,8 @@ nwfilterLookupByName(virConnectPtr conn,
|
||||
nwfilterDriverUnlock(driver);
|
||||
|
||||
if (!pool) {
|
||||
virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
|
||||
_("no pool with matching name '%s'"), name);
|
||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
||||
_("no pool with matching name '%s'"), name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ nwfilterDefine(virConnectPtr conn,
|
||||
if (!(pool = virNWFilterPoolObjAssignDef(conn, &driver->pools, def)))
|
||||
goto cleanup;
|
||||
|
||||
if (virNWFilterPoolObjSaveDef(conn, driver, pool, def) < 0) {
|
||||
if (virNWFilterPoolObjSaveDef(driver, pool, def) < 0) {
|
||||
virNWFilterPoolObjRemove(&driver->pools, pool);
|
||||
def = NULL;
|
||||
goto cleanup;
|
||||
@ -333,19 +333,19 @@ nwfilterUndefine(virNWFilterPtr obj) {
|
||||
nwfilterDriverLock(driver);
|
||||
pool = virNWFilterPoolObjFindByUUID(&driver->pools, obj->uuid);
|
||||
if (!pool) {
|
||||
virNWFilterReportError(obj->conn, VIR_ERR_INVALID_NWFILTER,
|
||||
"%s", _("no nwfilter pool with matching uuid"));
|
||||
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
|
||||
"%s", _("no nwfilter pool with matching uuid"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virNWFilterTestUnassignDef(obj->conn, pool)) {
|
||||
virNWFilterReportError(obj->conn, VIR_ERR_INVALID_NWFILTER,
|
||||
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
|
||||
"%s",
|
||||
_("nwfilter is in use"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virNWFilterPoolObjDeleteDef(obj->conn, pool) < 0)
|
||||
if (virNWFilterPoolObjDeleteDef(pool) < 0)
|
||||
goto cleanup;
|
||||
|
||||
VIR_FREE(pool->configFile);
|
||||
@ -374,12 +374,12 @@ nwfilterDumpXML(virNWFilterPtr obj,
|
||||
nwfilterDriverUnlock(driver);
|
||||
|
||||
if (!pool) {
|
||||
virNWFilterReportError(obj->conn, VIR_ERR_INVALID_NWFILTER,
|
||||
"%s", _("no nwfilter pool with matching uuid"));
|
||||
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER,
|
||||
"%s", _("no nwfilter pool with matching uuid"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = virNWFilterDefFormat(obj->conn, pool->def);
|
||||
ret = virNWFilterDefFormat(pool->def);
|
||||
|
||||
cleanup:
|
||||
if (pool)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -62,7 +62,6 @@ virNWFilterTechDriverForName(const char *name) {
|
||||
|
||||
/**
|
||||
* virNWFilterRuleInstAddData:
|
||||
* @conn : pointer to virConnect object
|
||||
* @res : pointer to virNWFilterRuleInst object collecting the instantiation
|
||||
* data of a single firewall rule.
|
||||
* @data : the opaque data that the driver wants to add
|
||||
@ -77,8 +76,7 @@ virNWFilterTechDriverForName(const char *name) {
|
||||
* message attached to the virConnect object.
|
||||
*/
|
||||
int
|
||||
virNWFilterRuleInstAddData(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virNWFilterRuleInstPtr res,
|
||||
virNWFilterRuleInstAddData(virNWFilterRuleInstPtr res,
|
||||
void *data)
|
||||
{
|
||||
if (VIR_REALLOC_N(res->data, res->ndata+1) < 0) {
|
||||
@ -107,7 +105,6 @@ virNWFilterRuleInstFree(virNWFilterRuleInstPtr inst)
|
||||
|
||||
/**
|
||||
* virNWFilterVarHashmapAddStdValues:
|
||||
* @conn: Poijter to virConnect object
|
||||
* @tables: pointer to hash tabel to add values to
|
||||
* @macaddr: The string of the MAC address to add to the hash table,
|
||||
* may be NULL
|
||||
@ -118,15 +115,14 @@ virNWFilterRuleInstFree(virNWFilterRuleInstPtr inst)
|
||||
* Adds a couple of standard keys (MAC, IP) to the hash table.
|
||||
*/
|
||||
static int
|
||||
virNWFilterVarHashmapAddStdValues(virConnectPtr conn,
|
||||
virNWFilterHashTablePtr table,
|
||||
virNWFilterVarHashmapAddStdValues(virNWFilterHashTablePtr table,
|
||||
char *macaddr)
|
||||
{
|
||||
if (macaddr) {
|
||||
if (virHashAddEntry(table->hashTable,
|
||||
NWFILTER_STD_VAR_MAC,
|
||||
macaddr) < 0) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Could not add variable 'MAC' to hashmap"));
|
||||
return 1;
|
||||
}
|
||||
@ -138,7 +134,6 @@ virNWFilterVarHashmapAddStdValues(virConnectPtr conn,
|
||||
|
||||
/**
|
||||
* virNWFilterCreateVarHashmap:
|
||||
* @conn: pointer to virConnect object
|
||||
* @macaddr: pointer to string containing formatted MAC address of interface
|
||||
*
|
||||
* Create a hashmap used for evaluating the firewall rules. Initializes
|
||||
@ -148,15 +143,14 @@ virNWFilterVarHashmapAddStdValues(virConnectPtr conn,
|
||||
* is attached to the virConnect object.
|
||||
*/
|
||||
virNWFilterHashTablePtr
|
||||
virNWFilterCreateVarHashmap(virConnectPtr conn,
|
||||
char *macaddr) {
|
||||
virNWFilterCreateVarHashmap(char *macaddr) {
|
||||
virNWFilterHashTablePtr table = virNWFilterHashTableCreate(0);
|
||||
if (!table) {
|
||||
virReportOOMError();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (virNWFilterVarHashmapAddStdValues(conn, table, macaddr)) {
|
||||
if (virNWFilterVarHashmapAddStdValues(table, macaddr)) {
|
||||
virNWFilterHashTableFree(table);
|
||||
return NULL;
|
||||
}
|
||||
@ -216,7 +210,6 @@ virNWFilterRuleInstantiate(virConnectPtr conn,
|
||||
|
||||
/**
|
||||
* virNWFilterCreateVarsFrom:
|
||||
* @conn: pointer to virConnect object
|
||||
* @vars1: pointer to hash table
|
||||
* @vars2: pointer to hash table
|
||||
*
|
||||
@ -227,8 +220,7 @@ virNWFilterRuleInstantiate(virConnectPtr conn,
|
||||
* contents of var2 will overwrite those of var1.
|
||||
*/
|
||||
static virNWFilterHashTablePtr
|
||||
virNWFilterCreateVarsFrom(virConnectPtr conn,
|
||||
virNWFilterHashTablePtr vars1,
|
||||
virNWFilterCreateVarsFrom(virNWFilterHashTablePtr vars1,
|
||||
virNWFilterHashTablePtr vars2)
|
||||
{
|
||||
virNWFilterHashTablePtr res = virNWFilterHashTableCreate(0);
|
||||
@ -237,10 +229,10 @@ virNWFilterCreateVarsFrom(virConnectPtr conn,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (virNWFilterHashTablePutAll(conn, vars1, res))
|
||||
if (virNWFilterHashTablePutAll(vars1, res))
|
||||
goto err_exit;
|
||||
|
||||
if (virNWFilterHashTablePutAll(conn, vars2, res))
|
||||
if (virNWFilterHashTablePutAll(vars2, res))
|
||||
goto err_exit;
|
||||
|
||||
return res;
|
||||
@ -324,7 +316,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
|
||||
if (obj) {
|
||||
|
||||
if (obj->wantRemoved) {
|
||||
virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
|
||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
||||
_("Filter '%s' is in use."),
|
||||
inc->filterref);
|
||||
rc = 1;
|
||||
@ -334,8 +326,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
|
||||
|
||||
// create a temporary hashmap for depth-first tree traversal
|
||||
virNWFilterHashTablePtr tmpvars =
|
||||
virNWFilterCreateVarsFrom(conn,
|
||||
inc->params,
|
||||
virNWFilterCreateVarsFrom(inc->params,
|
||||
vars);
|
||||
if (!tmpvars) {
|
||||
virReportOOMError();
|
||||
@ -373,7 +364,7 @@ _virNWFilterInstantiateRec(virConnectPtr conn,
|
||||
if (rc)
|
||||
break;
|
||||
} else {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("referenced filter '%s' is missing"),
|
||||
inc->filterref);
|
||||
rc = 1;
|
||||
@ -516,7 +507,7 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
|
||||
techdriver = virNWFilterTechDriverForName(drvname);
|
||||
|
||||
if (!techdriver) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not get access to ACL tech "
|
||||
"driver '%s'"),
|
||||
drvname);
|
||||
@ -527,14 +518,14 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
|
||||
|
||||
obj = virNWFilterPoolObjFindByName(&driver->pools, net->filter);
|
||||
if (!obj) {
|
||||
virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
|
||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
||||
_("Could not find filter '%s'"),
|
||||
net->filter);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (obj->wantRemoved) {
|
||||
virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
|
||||
virNWFilterReportError(VIR_ERR_NO_NWFILTER,
|
||||
_("Filter '%s' is in use."),
|
||||
net->filter);
|
||||
rc = 1;
|
||||
@ -549,8 +540,7 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
vars1 = virNWFilterCreateVarHashmap(conn,
|
||||
str_macaddr);
|
||||
vars1 = virNWFilterCreateVarHashmap(str_macaddr);
|
||||
if (!vars1) {
|
||||
rc = 1;
|
||||
goto err_exit;
|
||||
@ -558,8 +548,7 @@ _virNWFilterInstantiateFilter(virConnectPtr conn,
|
||||
|
||||
str_macaddr = NULL;
|
||||
|
||||
vars = virNWFilterCreateVarsFrom(conn,
|
||||
vars1,
|
||||
vars = virNWFilterCreateVarsFrom(vars1,
|
||||
net->filterparams);
|
||||
if (!vars) {
|
||||
rc = 1;
|
||||
@ -630,7 +619,7 @@ int virNWFilterRollbackUpdateFilter(virConnectPtr conn,
|
||||
virNWFilterTechDriverPtr techdriver;
|
||||
techdriver = virNWFilterTechDriverForName(drvname);
|
||||
if (!techdriver) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not get access to ACL tech "
|
||||
"driver '%s'"),
|
||||
drvname);
|
||||
@ -649,7 +638,7 @@ virNWFilterTearOldFilter(virConnectPtr conn,
|
||||
virNWFilterTechDriverPtr techdriver;
|
||||
techdriver = virNWFilterTechDriverForName(drvname);
|
||||
if (!techdriver) {
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not get access to ACL tech "
|
||||
"driver '%s'"),
|
||||
drvname);
|
||||
@ -668,12 +657,10 @@ virNWFilterTeardownFilter(const virDomainNetDefPtr net)
|
||||
techdriver = virNWFilterTechDriverForName(drvname);
|
||||
|
||||
if (!techdriver) {
|
||||
#if 0
|
||||
virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Could not get access to ACL tech "
|
||||
"driver '%s'"),
|
||||
drvname);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,7 @@
|
||||
|
||||
virNWFilterTechDriverPtr virNWFilterTechDriverForName(const char *name);
|
||||
|
||||
int virNWFilterRuleInstAddData(virConnectPtr conn,
|
||||
virNWFilterRuleInstPtr res,
|
||||
int virNWFilterRuleInstAddData(virNWFilterRuleInstPtr res,
|
||||
void *data);
|
||||
|
||||
|
||||
@ -48,8 +47,7 @@ int virNWFilterTearOldFilter(virConnectPtr conn,
|
||||
|
||||
int virNWFilterTeardownFilter(const virDomainNetDefPtr net);
|
||||
|
||||
virNWFilterHashTablePtr virNWFilterCreateVarHashmap(virConnectPtr conn,
|
||||
char *macaddr);
|
||||
virNWFilterHashTablePtr virNWFilterCreateVarHashmap(char *macaddr);
|
||||
|
||||
void virNWFilterDomainFWUpdateCB(void *payload,
|
||||
const char *name ATTRIBUTE_UNUSED,
|
||||
|
@ -39,7 +39,7 @@ static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml) {
|
||||
if (!(dev = virNWFilterDefParseString(NULL, inXmlData)))
|
||||
goto fail;
|
||||
|
||||
if (!(actual = virNWFilterDefFormat(NULL, dev)))
|
||||
if (!(actual = virNWFilterDefFormat(dev)))
|
||||
goto fail;
|
||||
|
||||
if (STRNEQ(outXmlData, actual)) {
|
||||
|
Loading…
Reference in New Issue
Block a user