mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
util: make virFirewallRuleToString() global
Although the next commit will eliminate the one current use of virFirewallRuleToString(), a future commit will once again have a use for it, but in a different source file so it will need to be a global function rather than static. Make that change now so that we don't get a compile error from having an unused static function in the next commit. (The arg list is also changed to include the name of the command as a separate argument rather than just assuming that it can be derived from the rule's layer (which is correct for iptables, but won't be correct for nftables)). Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2d1c22a015
commit
4dce6eee5c
@ -2352,6 +2352,7 @@ virFirewallRuleAddArgFormat;
|
|||||||
virFirewallRuleAddArgList;
|
virFirewallRuleAddArgList;
|
||||||
virFirewallRuleAddArgSet;
|
virFirewallRuleAddArgSet;
|
||||||
virFirewallRuleGetArgCount;
|
virFirewallRuleGetArgCount;
|
||||||
|
virFirewallRuleToString;
|
||||||
virFirewallStartRollback;
|
virFirewallStartRollback;
|
||||||
virFirewallStartTransaction;
|
virFirewallStartTransaction;
|
||||||
|
|
||||||
|
@ -461,14 +461,14 @@ void virFirewallStartRollback(virFirewall *firewall,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *
|
char *
|
||||||
virFirewallRuleToString(virFirewallRule *rule)
|
virFirewallRuleToString(const char *cmd,
|
||||||
|
virFirewallRule *rule)
|
||||||
{
|
{
|
||||||
const char *bin = virFirewallLayerCommandTypeToString(rule->layer);
|
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
virBufferAdd(&buf, bin, -1);
|
virBufferAdd(&buf, cmd, -1);
|
||||||
for (i = 0; i < rule->argsLen; i++) {
|
for (i = 0; i < rule->argsLen; i++) {
|
||||||
virBufferAddLit(&buf, " ");
|
virBufferAddLit(&buf, " ");
|
||||||
virBufferAdd(&buf, rule->args[i], -1);
|
virBufferAdd(&buf, rule->args[i], -1);
|
||||||
@ -477,6 +477,7 @@ virFirewallRuleToString(virFirewallRule *rule)
|
|||||||
return virBufferContentAndReset(&buf);
|
return virBufferContentAndReset(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virFirewallApplyRuleDirect(virFirewallRule *rule,
|
virFirewallApplyRuleDirect(virFirewallRule *rule,
|
||||||
bool ignoreErrors,
|
bool ignoreErrors,
|
||||||
@ -529,8 +530,10 @@ virFirewallApplyRule(virFirewall *firewall,
|
|||||||
bool ignoreErrors)
|
bool ignoreErrors)
|
||||||
{
|
{
|
||||||
g_autofree char *output = NULL;
|
g_autofree char *output = NULL;
|
||||||
g_autofree char *str = virFirewallRuleToString(rule);
|
|
||||||
g_auto(GStrv) lines = NULL;
|
g_auto(GStrv) lines = NULL;
|
||||||
|
g_autofree char *str
|
||||||
|
= virFirewallRuleToString(virFirewallLayerCommandTypeToString(rule->layer), rule);
|
||||||
|
|
||||||
VIR_INFO("Applying rule '%s'", NULLSTR(str));
|
VIR_INFO("Applying rule '%s'", NULLSTR(str));
|
||||||
|
|
||||||
if (rule->ignoreErrors)
|
if (rule->ignoreErrors)
|
||||||
|
@ -89,6 +89,9 @@ void virFirewallRuleAddArgList(virFirewall *firewall,
|
|||||||
|
|
||||||
size_t virFirewallRuleGetArgCount(virFirewallRule *rule);
|
size_t virFirewallRuleGetArgCount(virFirewallRule *rule);
|
||||||
|
|
||||||
|
char *virFirewallRuleToString(const char *cmd,
|
||||||
|
virFirewallRule *rule);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* Ignore all errors when applying rules, so no
|
/* Ignore all errors when applying rules, so no
|
||||||
* rollback block will be required */
|
* rollback block will be required */
|
||||||
|
Loading…
Reference in New Issue
Block a user