From ea3cf921f2fde12d054d70e254147aaa54642321 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 20 Aug 2012 16:23:10 -0600 Subject: [PATCH] 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. --- 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 595d64a666..0b3e08048b 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 1398fbdfc3..bcdc3d8f9d 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -23,6 +23,20 @@ * */ +#include +#include "virsh-nodedev.h" + +#include +#include +#include +#include + +#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 0000000000..fa3cf4f89f --- /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 + * . + * + * Daniel Veillard + * Karel Zak + * Daniel P. Berrange + * + */ + +#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 2a9c673a24..364ca25863 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 818d51546a..698899d0df 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, ...)