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. --- tools/Makefile.am | 2 +- tools/virsh-nodedev.c | 16 +++++++++++++++- tools/virsh-nodedev.h | 33 +++++++++++++++++++++++++++++++++ tools/virsh.c | 8 ++------ tools/virsh.h | 6 ++++++ 5 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 tools/virsh-nodedev.h diff --git a/tools/Makefile.am b/tools/Makefile.am index 595d64a..0b3e080 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -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 \ diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 1398fbd..bcdc3d8 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -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, diff --git a/tools/virsh-nodedev.h b/tools/virsh-nodedev.h new file mode 100644 index 0000000..fa3cf4f --- /dev/null +++ b/tools/virsh-nodedev.h @@ -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@xxxxxxxxxx> + * Karel Zak <kzak@xxxxxxxxxx> + * Daniel P. Berrange <berrange@xxxxxxxxxx> + * + */ + +#ifndef VIRSH_NODEDEV_H +# define VIRSH_NODEDEV_H + +# include "virsh.h" + +extern const vshCmdDef nodedevCmds[]; + +#endif /* VIRSH_NODEDEV_H */ diff --git a/tools/virsh.c b/tools/virsh.c index 2a9c673..364ca25 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -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" diff --git a/tools/virsh.h b/tools/virsh.h index 818d515..698899d 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -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, ...) -- 1.7.11.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list