mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virsh: Add wrapper for virNWFilterFree
Similarly to virshDomainFree add a wrapper for the snapshot object freeing function. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
parent
40a3a5b608
commit
d39bd3998e
@ -868,7 +868,7 @@ sc_gettext_init:
|
||||
$(_sc_search_regexp)
|
||||
|
||||
sc_prohibit_obj_free_apis_in_virsh:
|
||||
@prohibit='\bvir(Domain|DomainSnapshot|Interface|Network|NodeDevice|Secret|StoragePool|StorageVol)Free\b' \
|
||||
@prohibit='\bvir(Domain|DomainSnapshot|Interface|Network|NodeDevice|NWFilter|Secret|StoragePool|StorageVol)Free\b' \
|
||||
in_vc_files='virsh.*\.[ch]$$' \
|
||||
exclude='sc_prohibit_obj_free_apis_in_virsh' \
|
||||
halt='avoid using public virXXXFree in virsh, use virsh-prefixed wrappers instead' \
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "virsh-completer-nwfilter.h"
|
||||
#include "virsh-util.h"
|
||||
#include "viralloc.h"
|
||||
#include "virsh.h"
|
||||
#include "virstring.h"
|
||||
@ -56,7 +57,7 @@ virshNWFilterNameCompleter(vshControl *ctl,
|
||||
ret = g_steal_pointer(&tmp);
|
||||
|
||||
for (i = 0; i < nnwfilters; i++)
|
||||
virNWFilterFree(nwfilters[i]);
|
||||
virshNWFilterFree(nwfilters[i]);
|
||||
g_free(nwfilters);
|
||||
return ret;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <config.h>
|
||||
#include "virsh-nwfilter.h"
|
||||
#include "virsh-util.h"
|
||||
|
||||
#include "internal.h"
|
||||
#include "viralloc.h"
|
||||
@ -91,7 +92,7 @@ static const vshCmdOptDef opts_nwfilter_define[] = {
|
||||
static bool
|
||||
cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
virNWFilterPtr nwfilter;
|
||||
g_autoptr(virshNWFilter) nwfilter = NULL;
|
||||
const char *from = NULL;
|
||||
bool ret = true;
|
||||
g_autofree char *buffer = NULL;
|
||||
@ -115,7 +116,6 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd)
|
||||
if (nwfilter != NULL) {
|
||||
vshPrintExtra(ctl, _("Network filter %s defined from %s\n"),
|
||||
virNWFilterGetName(nwfilter), from);
|
||||
virNWFilterFree(nwfilter);
|
||||
} else {
|
||||
vshError(ctl, _("Failed to define network filter from %s"), from);
|
||||
ret = false;
|
||||
@ -149,7 +149,7 @@ static const vshCmdOptDef opts_nwfilter_undefine[] = {
|
||||
static bool
|
||||
cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
virNWFilterPtr nwfilter;
|
||||
g_autoptr(virshNWFilter) nwfilter = NULL;
|
||||
bool ret = true;
|
||||
const char *name;
|
||||
|
||||
@ -163,7 +163,6 @@ cmdNWFilterUndefine(vshControl *ctl, const vshCmd *cmd)
|
||||
ret = false;
|
||||
}
|
||||
|
||||
virNWFilterFree(nwfilter);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -193,7 +192,7 @@ static const vshCmdOptDef opts_nwfilter_dumpxml[] = {
|
||||
static bool
|
||||
cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
virNWFilterPtr nwfilter;
|
||||
g_autoptr(virshNWFilter) nwfilter = NULL;
|
||||
bool ret = true;
|
||||
g_autofree char *dump = NULL;
|
||||
|
||||
@ -207,7 +206,6 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd)
|
||||
ret = false;
|
||||
}
|
||||
|
||||
virNWFilterFree(nwfilter);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -239,8 +237,7 @@ virshNWFilterListFree(struct virshNWFilterList *list)
|
||||
|
||||
if (list && list->filters) {
|
||||
for (i = 0; i < list->nfilters; i++) {
|
||||
if (list->filters[i])
|
||||
virNWFilterFree(list->filters[i]);
|
||||
virshNWFilterFree(list->filters[i]);
|
||||
}
|
||||
g_free(list->filters);
|
||||
}
|
||||
@ -418,8 +415,8 @@ static bool
|
||||
cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd)
|
||||
{
|
||||
bool ret = false;
|
||||
virNWFilterPtr nwfilter = NULL;
|
||||
virNWFilterPtr nwfilter_edited = NULL;
|
||||
g_autoptr(virshNWFilter) nwfilter = NULL;
|
||||
g_autoptr(virshNWFilter) nwfilter_edited = NULL;
|
||||
virshControl *priv = ctl->privData;
|
||||
|
||||
nwfilter = virshCommandOptNWFilter(ctl, cmd, NULL);
|
||||
@ -445,11 +442,6 @@ cmdNWFilterEdit(vshControl *ctl, const vshCmd *cmd)
|
||||
ret = true;
|
||||
|
||||
cleanup:
|
||||
if (nwfilter)
|
||||
virNWFilterFree(nwfilter);
|
||||
if (nwfilter_edited)
|
||||
virNWFilterFree(nwfilter_edited);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -318,6 +318,17 @@ virshNodeDeviceFree(virNodeDevicePtr device)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virshNWFilterFree(virNWFilterPtr nwfilter)
|
||||
{
|
||||
if (!nwfilter)
|
||||
return;
|
||||
|
||||
vshSaveLibvirtHelperError();
|
||||
virNWFilterFree(nwfilter); /* sc_prohibit_obj_free_apis_in_virsh */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virshSecretFree(virSecretPtr secret)
|
||||
{
|
||||
|
@ -69,6 +69,11 @@ void
|
||||
virshNodeDeviceFree(virNodeDevicePtr device);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virshNodeDevice, virshNodeDeviceFree);
|
||||
|
||||
typedef virNWFilter virshNWFilter;
|
||||
void
|
||||
virshNWFilterFree(virNWFilterPtr nwfilter);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virshNWFilter, virshNWFilterFree);
|
||||
|
||||
typedef virSecret virshSecret;
|
||||
void
|
||||
virshSecretFree(virSecretPtr secret);
|
||||
|
Loading…
Reference in New Issue
Block a user