mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: split out virsh-nwfilter.c
Yet another split file. * tools/virsh-nwfilter.h: New file. * tools/Makefile.am (virsh_SOURCES): Build it. * tools/virsh.c: Use new header. * tools/virsh-nwfilter.c: Likewise.
This commit is contained in:
parent
ea3cf921f2
commit
69af4f7cb8
@ -112,8 +112,8 @@ virsh_SOURCES = \
|
|||||||
virsh-interface.c virsh-interface.h \
|
virsh-interface.c virsh-interface.h \
|
||||||
virsh-network.c virsh-network.h \
|
virsh-network.c virsh-network.h \
|
||||||
virsh-nodedev.c virsh-nodedev.h \
|
virsh-nodedev.c virsh-nodedev.h \
|
||||||
|
virsh-nwfilter.c virsh-nwfilter.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
# virsh-nwfilter.c virsh-nwfilter.h \
|
|
||||||
# virsh-pool.c virsh-pool.h \
|
# virsh-pool.c virsh-pool.h \
|
||||||
# virsh-secret.c virsh-secret.h \
|
# virsh-secret.c virsh-secret.h \
|
||||||
# virsh-snapshot.c virsh-snapshot.h \
|
# virsh-snapshot.c virsh-snapshot.h \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* virsh-domain.c: Commands to manage network filters
|
* virsh-nwfilter.c: Commands to manage network filters
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005, 2007-2012 Red Hat, Inc.
|
* Copyright (C) 2005, 2007-2012 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
@ -23,18 +23,29 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* default is lookup by Name and UUID */
|
#include <config.h>
|
||||||
#define vshCommandOptNWFilter(_ctl, _cmd, _name) \
|
#include "virsh-nwfilter.h"
|
||||||
vshCommandOptNWFilterBy(_ctl, _cmd, _name, \
|
|
||||||
VSH_BYUUID|VSH_BYNAME)
|
|
||||||
|
|
||||||
static virNWFilterPtr
|
#include <libxml/parser.h>
|
||||||
|
#include <libxml/tree.h>
|
||||||
|
#include <libxml/xpath.h>
|
||||||
|
#include <libxml/xmlsave.h>
|
||||||
|
|
||||||
|
#include "internal.h"
|
||||||
|
#include "buf.h"
|
||||||
|
#include "memory.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "xml.h"
|
||||||
|
|
||||||
|
virNWFilterPtr
|
||||||
vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
|
vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
|
||||||
const char **name, int flag)
|
const char **name, unsigned int flags)
|
||||||
{
|
{
|
||||||
virNWFilterPtr nwfilter = NULL;
|
virNWFilterPtr nwfilter = NULL;
|
||||||
const char *n = NULL;
|
const char *n = NULL;
|
||||||
const char *optname = "nwfilter";
|
const char *optname = "nwfilter";
|
||||||
|
virCheckFlags(VSH_BYUUID | VSH_BYNAME, NULL);
|
||||||
|
|
||||||
if (!vshCmdHasOption(ctl, cmd, optname))
|
if (!vshCmdHasOption(ctl, cmd, optname))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -48,13 +59,13 @@ vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
|
|||||||
*name = n;
|
*name = n;
|
||||||
|
|
||||||
/* try it by UUID */
|
/* try it by UUID */
|
||||||
if ((flag & VSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) {
|
if ((flags & VSH_BYUUID) && strlen(n) == VIR_UUID_STRING_BUFLEN-1) {
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as nwfilter UUID\n",
|
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as nwfilter UUID\n",
|
||||||
cmd->def->name, optname);
|
cmd->def->name, optname);
|
||||||
nwfilter = virNWFilterLookupByUUIDString(ctl->conn, n);
|
nwfilter = virNWFilterLookupByUUIDString(ctl->conn, n);
|
||||||
}
|
}
|
||||||
/* try it by NAME */
|
/* try it by NAME */
|
||||||
if (nwfilter == NULL && (flag & VSH_BYNAME)) {
|
if (!nwfilter && (flags & VSH_BYNAME)) {
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as nwfilter NAME\n",
|
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as nwfilter NAME\n",
|
||||||
cmd->def->name, optname);
|
cmd->def->name, optname);
|
||||||
nwfilter = virNWFilterLookupByName(ctl->conn, n);
|
nwfilter = virNWFilterLookupByName(ctl->conn, n);
|
||||||
@ -309,7 +320,7 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const vshCmdDef nwfilterCmds[] = {
|
const vshCmdDef nwfilterCmds[] = {
|
||||||
{"nwfilter-define", cmdNWFilterDefine, opts_nwfilter_define,
|
{"nwfilter-define", cmdNWFilterDefine, opts_nwfilter_define,
|
||||||
info_nwfilter_define, 0},
|
info_nwfilter_define, 0},
|
||||||
{"nwfilter-dumpxml", cmdNWFilterDumpXML, opts_nwfilter_dumpxml,
|
{"nwfilter-dumpxml", cmdNWFilterDumpXML, opts_nwfilter_dumpxml,
|
||||||
|
42
tools/virsh-nwfilter.h
Normal file
42
tools/virsh-nwfilter.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* virsh-nwfilter.h: Commands to manage network filters
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005, 2007-2012 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; If not, see
|
||||||
|
* <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Daniel Veillard <veillard@redhat.com>
|
||||||
|
* Karel Zak <kzak@redhat.com>
|
||||||
|
* Daniel P. Berrange <berrange@redhat.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef VIRSH_NWFILTER_H
|
||||||
|
# define VIRSH_NWFILTER_H
|
||||||
|
|
||||||
|
# include "virsh.h"
|
||||||
|
|
||||||
|
virNWFilterPtr
|
||||||
|
vshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd,
|
||||||
|
const char **name, unsigned int flags);
|
||||||
|
|
||||||
|
/* default is lookup by Name and UUID */
|
||||||
|
# define vshCommandOptNWFilter(_ctl, _cmd, _name) \
|
||||||
|
vshCommandOptNWFilterBy(_ctl, _cmd, _name, \
|
||||||
|
VSH_BYUUID|VSH_BYNAME)
|
||||||
|
|
||||||
|
extern const vshCmdDef nwfilterCmds[];
|
||||||
|
|
||||||
|
#endif /* VIRSH_NWFILTER_H */
|
@ -80,6 +80,7 @@
|
|||||||
#include "virsh-interface.h"
|
#include "virsh-interface.h"
|
||||||
#include "virsh-network.h"
|
#include "virsh-network.h"
|
||||||
#include "virsh-nodedev.h"
|
#include "virsh-nodedev.h"
|
||||||
|
#include "virsh-nwfilter.h"
|
||||||
|
|
||||||
static char *progname;
|
static char *progname;
|
||||||
|
|
||||||
@ -2814,7 +2815,6 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "virsh-nwfilter.c"
|
|
||||||
#include "virsh-pool.c"
|
#include "virsh-pool.c"
|
||||||
#include "virsh-secret.c"
|
#include "virsh-secret.c"
|
||||||
#include "virsh-snapshot.c"
|
#include "virsh-snapshot.c"
|
||||||
|
Loading…
Reference in New Issue
Block a user