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