Another relatively easy file split.
* tools/virsh-network.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh.c: Use new header.
* tools/virsh-network.c: Likewise.
(vshCommandOptNetworkBy): Update signature.
virsh-domain-monitor.c virsh-domain-monitor.h \
virsh-host.c virsh-host.h \
virsh-interface.c virsh-interface.h \
+ virsh-network.c virsh-network.h \
$(NULL)
-# virsh-network.c virsh-network.h \
# virsh-nodedev.c virsh-nodedev.h \
# virsh-nwfilter.c virsh-nwfilter.h \
# virsh-pool.c virsh-pool.h \
*
*/
-/* default is lookup by Name and UUID */
-#define vshCommandOptNetwork(_ctl, _cmd, _name) \
- vshCommandOptNetworkBy(_ctl, _cmd, _name, \
- VSH_BYUUID|VSH_BYNAME)
+#include <config.h>
+#include "virsh-network.h"
-static virNetworkPtr
+#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"
+
+virNetworkPtr
vshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
- const char **name, int flag)
+ const char **name, unsigned int flags)
{
virNetworkPtr network = NULL;
const char *n = NULL;
const char *optname = "network";
+ virCheckFlags(VSH_BYUUID | VSH_BYNAME, NULL);
+
if (!vshCmdHasOption(ctl, cmd, optname))
return NULL;
*name = n;
/* 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 network UUID\n",
cmd->def->name, optname);
network = virNetworkLookupByUUIDString(ctl->conn, n);
}
/* try it by NAME */
- if (network==NULL && (flag & VSH_BYNAME)) {
+ if (!network && (flags & VSH_BYNAME)) {
vshDebug(ctl, VSH_ERR_DEBUG, "%s: <%s> trying as network NAME\n",
cmd->def->name, optname);
network = virNetworkLookupByName(ctl->conn, n);
return ret;
}
-static const vshCmdDef networkCmds[] = {
+const vshCmdDef networkCmds[] = {
{"net-autostart", cmdNetworkAutostart, opts_network_autostart,
info_network_autostart, 0},
{"net-create", cmdNetworkCreate, opts_network_create,
--- /dev/null
+/*
+ * virsh-network.c: Commands to manage network
+ *
+ * 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_NETWORK_H
+# define VIRSH_NETWORK_H
+
+# include "virsh.h"
+
+virNetworkPtr
+vshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
+ const char **name, unsigned int flags);
+
+/* default is lookup by Name and UUID */
+# define vshCommandOptNetwork(_ctl, _cmd, _name) \
+ vshCommandOptNetworkBy(_ctl, _cmd, _name, \
+ VSH_BYUUID|VSH_BYNAME)
+
+extern const vshCmdDef networkCmds[];
+
+#endif /* VIRSH_NETWORK_H */
#include "virsh-domain-monitor.h"
#include "virsh-host.h"
#include "virsh-interface.h"
+#include "virsh-network.h"
static char *progname;
return true;
}
-#include "virsh-network.c"
#include "virsh-nodedev.c"
#include "virsh-nwfilter.c"
#include "virsh-pool.c"