]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: split out virsh-network.c
authorEric Blake <eblake@redhat.com>
Mon, 20 Aug 2012 21:43:25 +0000 (15:43 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 21 Aug 2012 06:02:09 +0000 (00:02 -0600)
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.

tools/Makefile.am
tools/virsh-network.c
tools/virsh-network.h [new file with mode: 0644]
tools/virsh.c

index 4d46a98fb66446742ed52511ac370201f4664a4d..595d64a666213c40ff4b17bdf44abd89f072b272 100644 (file)
@@ -110,8 +110,8 @@ virsh_SOURCES =                                                     \
                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                       \
index b891c910689258137665d767a2e1ec6e8ad33f4c..37fa3bad71c2da2d506a82b374277d12c4919d6c 100644 (file)
  *
  */
 
-/* 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;
 
@@ -48,13 +59,13 @@ vshCommandOptNetworkBy(vshControl *ctl, const vshCmd *cmd,
         *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);
@@ -686,7 +697,7 @@ cmdNetworkEdit(vshControl *ctl, const vshCmd *cmd)
     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,
diff --git a/tools/virsh-network.h b/tools/virsh-network.h
new file mode 100644 (file)
index 0000000..b5d151c
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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 */
index d7fd408a9e9060867375f6a5999402a8f6155735..2a9c673a241a3331d8945533c39dd88e132d160a 100644 (file)
@@ -78,6 +78,7 @@
 #include "virsh-domain-monitor.h"
 #include "virsh-host.h"
 #include "virsh-interface.h"
+#include "virsh-network.h"
 
 static char *progname;
 
@@ -2816,7 +2817,6 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
     return true;
 }
 
-#include "virsh-network.c"
 #include "virsh-nodedev.c"
 #include "virsh-nwfilter.c"
 #include "virsh-pool.c"