mirror of https://gitee.com/openkylin/libvirt.git
virsh: split out virsh-nodedev.c
Another worthwhile split, needed one more public function. * tools/virsh-nodedev.h: New file. * tools/Makefile.am (virsh_SOURCES): Build it. * tools/virsh-nodedev.c: Use new header. * tools/virsh.c: Likewise. (vshTreePrint): Export. * tools/virsh.h (vshTreePrint): Declare.
This commit is contained in:
parent
dcff981a70
commit
ea3cf921f2
|
@ -111,8 +111,8 @@ virsh_SOURCES = \
|
|||
virsh-host.c virsh-host.h \
|
||||
virsh-interface.c virsh-interface.h \
|
||||
virsh-network.c virsh-network.h \
|
||||
virsh-nodedev.c virsh-nodedev.h \
|
||||
$(NULL)
|
||||
# virsh-nodedev.c virsh-nodedev.h \
|
||||
# virsh-nwfilter.c virsh-nwfilter.h \
|
||||
# virsh-pool.c virsh-pool.h \
|
||||
# virsh-secret.c virsh-secret.h \
|
||||
|
|
|
@ -23,6 +23,20 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "virsh-nodedev.h"
|
||||
|
||||
#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"
|
||||
|
||||
/*
|
||||
* "nodedev-create" command
|
||||
*/
|
||||
|
@ -381,7 +395,7 @@ cmdNodeDeviceReset(vshControl *ctl, const vshCmd *cmd)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static const vshCmdDef nodedevCmds[] = {
|
||||
const vshCmdDef nodedevCmds[] = {
|
||||
{"nodedev-create", cmdNodeDeviceCreate, opts_node_device_create,
|
||||
info_node_device_create, 0},
|
||||
{"nodedev-destroy", cmdNodeDeviceDestroy, opts_node_device_destroy,
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* virsh-nodedev.h: Commands in node device group
|
||||
*
|
||||
* 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_NODEDEV_H
|
||||
# define VIRSH_NODEDEV_H
|
||||
|
||||
# include "virsh.h"
|
||||
|
||||
extern const vshCmdDef nodedevCmds[];
|
||||
|
||||
#endif /* VIRSH_NODEDEV_H */
|
|
@ -79,6 +79,7 @@
|
|||
#include "virsh-host.h"
|
||||
#include "virsh-interface.h"
|
||||
#include "virsh-network.h"
|
||||
#include "virsh-nodedev.h"
|
||||
|
||||
static char *progname;
|
||||
|
||||
|
@ -416,10 +417,6 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
|
|||
|
||||
/* Tree listing helpers. */
|
||||
|
||||
/* Given an index, return either the name of that device (non-NULL) or
|
||||
* of its parent (NULL if a root). */
|
||||
typedef const char * (*vshTreeLookup)(int devid, bool parent, void *opaque);
|
||||
|
||||
static int
|
||||
vshTreePrintInternal(vshControl *ctl,
|
||||
vshTreeLookup lookup,
|
||||
|
@ -487,7 +484,7 @@ cleanup:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
vshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque,
|
||||
int num_devices, int devid)
|
||||
{
|
||||
|
@ -2817,7 +2814,6 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
|
|||
return true;
|
||||
}
|
||||
|
||||
#include "virsh-nodedev.c"
|
||||
#include "virsh-nwfilter.c"
|
||||
#include "virsh-pool.c"
|
||||
#include "virsh-secret.c"
|
||||
|
|
|
@ -296,6 +296,12 @@ typedef enum {
|
|||
VSH_BYMAC = (1 << 4),
|
||||
} vshLookupByFlags;
|
||||
|
||||
/* Given an index, return either the name of that device (non-NULL) or
|
||||
* of its parent (NULL if a root). */
|
||||
typedef const char * (*vshTreeLookup)(int devid, bool parent, void *opaque);
|
||||
int vshTreePrint(vshControl *ctl, vshTreeLookup lookup, void *opaque,
|
||||
int num_devices, int devid);
|
||||
|
||||
void vshPrintExtra(vshControl *ctl, const char *format, ...)
|
||||
ATTRIBUTE_FMT_PRINTF(2, 3);
|
||||
void vshDebug(vshControl *ctl, int level, const char *format, ...)
|
||||
|
|
Loading…
Reference in New Issue