Re: [PATCH v5 2/5] Network: Add regression tests for the command-line arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/14/2011 09:02 AM, Michal Novotny wrote:
The regression testing done by comparison of command-line
generated from the network XML file and the expected
command-line arguments (read from file).

For the tests the pidfile should be set to NULL string, i.e.
(null) since no real invocation of the command is being done,
just the command-line is being generated and compared to the
expected one.


It's really just a happy coincidence of glib's printf that the NULL pointer ends up producing the string (null). If this code were ever used somewhere without glib (I know, that's extremely unlikely), this could lead to a segfault instead. Better to fix the networkBuildDnsmasqArgv() to just not include --pidfile if that arg is NULL.


Signed-off-by: Michal Novotny<minovotn@xxxxxxxxxx>
---
  docs/formatnetwork.html.in                         |    4 +-
  src/Makefile.am                                    |   11 ++-
  src/network/bridge_driver.c                        |   36 +++++--
  src/network/bridge_driver.h                        |    3 +
  tests/Makefile.am                                  |   10 ++
  tests/networkxml2argvdata/isolated-network.argv    |    1 +
  tests/networkxml2argvdata/isolated-network.xml     |   11 ++
  .../nat-network-dns-txt-record.argv                |    1 +
  .../nat-network-dns-txt-record.xml                 |   24 +++++
  tests/networkxml2argvdata/nat-network.argv         |    1 +
  tests/networkxml2argvdata/nat-network.xml          |   21 ++++
  tests/networkxml2argvdata/netboot-network.argv     |    1 +
  tests/networkxml2argvdata/netboot-network.xml      |   14 +++
  .../networkxml2argvdata/netboot-proxy-network.argv |    1 +
  .../networkxml2argvdata/netboot-proxy-network.xml  |   13 +++
  tests/networkxml2argvdata/routed-network.argv      |    1 +
  tests/networkxml2argvdata/routed-network.xml       |    9 ++
  tests/networkxml2argvtest.c                        |  108 ++++++++++++++++++++
  18 files changed, 260 insertions(+), 10 deletions(-)
  create mode 100644 tests/networkxml2argvdata/isolated-network.argv
  create mode 100644 tests/networkxml2argvdata/isolated-network.xml
  create mode 100644 tests/networkxml2argvdata/nat-network-dns-txt-record.argv
  create mode 100644 tests/networkxml2argvdata/nat-network-dns-txt-record.xml
  create mode 100644 tests/networkxml2argvdata/nat-network.argv
  create mode 100644 tests/networkxml2argvdata/nat-network.xml
  create mode 100644 tests/networkxml2argvdata/netboot-network.argv
  create mode 100644 tests/networkxml2argvdata/netboot-network.xml
  create mode 100644 tests/networkxml2argvdata/netboot-proxy-network.argv
  create mode 100644 tests/networkxml2argvdata/netboot-proxy-network.xml
  create mode 100644 tests/networkxml2argvdata/routed-network.argv
  create mode 100644 tests/networkxml2argvdata/routed-network.xml
  create mode 100644 tests/networkxml2argvtest.c

diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index 1cf7636..62e1e08 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -183,8 +183,8 @@
        or commas. value is a single string that can contain multiple values
        separated by commas.<span class="since">Since 0.9.3</span>
        </dd>
-
-</dd><dt><code>dhcp</code></dt><dd>Also within the<code>ip</code>  element there is an
+<dt><code>dhcp</code></dt>
+<dd>Also within the<code>ip</code>  element there is an


As I commented in 1/5 - this chunk (which just fixes a problem introduced in 1/5) should be squashed into 1/5 rather than tacked on here.


          optional<code>dhcp</code>  element. The presence of this element
          enables DHCP services on the virtual network. It will further
          contain one or more<code>range</code>  elements. The
diff --git a/src/Makefile.am b/src/Makefile.am
index 4f9bfc9..edaedec 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -530,6 +530,10 @@ libvirt_driver_la_LIBADD = $(NUMACTL_LIBS) $(GNUTLS_LIBS) $(DLOPEN_LIBS)

  USED_SYM_FILES = libvirt_private.syms

+if WITH_NETWORK
+USED_SYM_FILES += libvirt_network.syms
+endif
+


Looks like you hadn't yet seen my earlier review of 2/5 when you reposted - this is duplicate code (you do the same thing down below).

BTW, although you had included it in earlier versions of your patchset, for some reason libvirt_network.syms was left out this time.

  if WITH_TEST
  if WITH_DRIVER_MODULES
  mod_LTLIBRARIES += libvirt_driver_test.la
@@ -1089,6 +1093,10 @@ if WITH_XENXS
  USED_SYM_FILES += libvirt_xenxs.syms
  endif

+if WITH_NETWORK
+USED_SYM_FILES += libvirt_network.syms
+endif
+
  EXTRA_DIST += \
    libvirt_public.syms		\
    libvirt_private.syms		\
@@ -1099,7 +1107,8 @@ EXTRA_DIST += \
    libvirt_daemon.syms		\
    libvirt_nwfilter.syms	\
    libvirt_vmx.syms		\
-  libvirt_xenxs.syms
+  libvirt_xenxs.syms		\
+  libvirt_network.syms

  BUILT_SOURCES += libvirt.syms libvirt.def libvirt_qemu.def

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index a2cba05..1fad160 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -631,12 +631,12 @@ cleanup:
      return ret;
  }

-static int
-networkStartDhcpDaemon(virNetworkObjPtr network)
+int
+networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, virCommandPtr *cmdout,
+                                  char *pidfile)
  {
      virCommandPtr cmd = NULL;
-    char *pidfile = NULL;
-    int ret = -1, err, ii;
+    int ret = -1, ii;
      virNetworkIpDefPtr ipdef;

      network->dnsmasqPid = -1;
@@ -661,6 +661,29 @@ networkStartDhcpDaemon(virNetworkObjPtr network)
      if (!virNetworkDefGetIpByIndex(network->def, AF_UNSPEC, 0))
          return 0;

+    cmd = virCommandNew(DNSMASQ);
+    if (networkBuildDnsmasqArgv(network, ipdef, pidfile, cmd)<  0) {
+        goto cleanup;
+    }
+
+    if (cmdout)
+        *cmdout = cmd;
+
+    ret = 0;
+cleanup:
+    if (ret<  0)
+        virCommandFree(cmd);
+    return ret;
+}
+
+static int
+networkStartDhcpDaemon(virNetworkObjPtr network)
+{
+    virCommandPtr cmd = NULL;
+    char *pidfile = NULL;
+    int ret = -1;
+    int err;
+
      if ((err = virFileMakePath(NETWORK_PID_DIR)) != 0) {
          virReportSystemError(err,
                               _("cannot create directory %s"),
@@ -686,10 +709,9 @@ networkStartDhcpDaemon(virNetworkObjPtr network)
          goto cleanup;
      }

-    cmd = virCommandNew(DNSMASQ);
-    if (networkBuildDnsmasqArgv(network, ipdef, pidfile, cmd)<  0) {
+    ret = networkBuildDhcpDaemonCommandLine(network,&cmd, pidfile);
+    if (ret<  0)
          goto cleanup;
-    }

      if (virCommandRun(cmd, NULL)<  0)
          goto cleanup;


As you discovered, and fixed in Patch 3/5, make check with your new tests will now fail if run as non-root, because the test will try to write a hosts file in /var. Because "make check" should pass at any random point in git history, I think this change to bridge_driver.c should be combined with the fix in 3/5 into a separate patch that comes before this one that's adding the new tests.


diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
index 32d2ae7..8d82b67 100644
--- a/src/network/bridge_driver.h
+++ b/src/network/bridge_driver.h
@@ -28,7 +28,10 @@
  # include<config.h>

  # include "internal.h"
+# include "network_conf.h"
+# include "command.h"

  int networkRegister(void);
+int networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network, virCommandPtr *cmdout, char *pidfile);

  #endif /* __VIR_NETWORK__DRIVER_H */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7ae50a2..40eb71e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -50,6 +50,7 @@ EXTRA_DIST =		\
  	networkschematest \
  	networkxml2xmlin \
  	networkxml2xmlout \
+	networkxml2argvdata \
  	nodedevschemadata \
  	nodedevschematest \
  	nodeinfodata     \
@@ -109,6 +110,8 @@ endif

  check_PROGRAMS += networkxml2xmltest

+check_PROGRAMS += networkxml2argvtest
+
  check_PROGRAMS += nwfilterxml2xmltest

  check_PROGRAMS += storagevolxml2xmltest storagepoolxml2xmltest
@@ -220,6 +223,8 @@ endif

  TESTS += networkxml2xmltest

+TESTS += networkxml2argvtest
+
  TESTS += storagevolxml2xmltest storagepoolxml2xmltest

  TESTS += nodedevxml2xmltest
@@ -347,6 +352,11 @@ networkxml2xmltest_SOURCES = \
  	testutils.c testutils.h
  networkxml2xmltest_LDADD = $(LDADDS)

+networkxml2argvtest_SOURCES = \
+	networkxml2argvtest.c \
+	testutils.c testutils.h
+networkxml2argvtest_LDADD = ../src/libvirt_driver_network.la $(LDADDS)
+
  nwfilterxml2xmltest_SOURCES = \
  	nwfilterxml2xmltest.c \
  	testutils.c testutils.h
diff --git a/tests/networkxml2argvdata/isolated-network.argv b/tests/networkxml2argvdata/isolated-network.argv
new file mode 100644
index 0000000..dce6034
--- /dev/null
+++ b/tests/networkxml2argvdata/isolated-network.argv
@@ -0,0 +1 @@
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=(null) --conf-file= --except-interface lo --dhcp-option=3 --listen-address 192.168.152.1 --dhcp-range 192.168.152.2,192.168.152.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/private.leases --dhcp-lease-max=253 --dhcp-no-override
\ No newline at end of file
diff --git a/tests/networkxml2argvdata/isolated-network.xml b/tests/networkxml2argvdata/isolated-network.xml
new file mode 100644
index 0000000..cc320a9
--- /dev/null
+++ b/tests/networkxml2argvdata/isolated-network.xml
@@ -0,0 +1,11 @@
+<network>
+<name>private</name>
+<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+<bridge name='virbr2' stp='on' delay='0' />
+<mac address='52:54:00:17:3F:37'/>
+<ip address='192.168.152.1' netmask='255.255.255.0'>
+<dhcp>
+<range start='192.168.152.2' end='192.168.152.254' />
+</dhcp>
+</ip>
+</network>
diff --git a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
new file mode 100644
index 0000000..96fde34
--- /dev/null
+++ b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
@@ -0,0 +1 @@
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=(null) --conf-file= --except-interface lo --txt-record=example,example value --listen-address 192.168.122.1 --listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
\ No newline at end of file
diff --git a/tests/networkxml2argvdata/nat-network-dns-txt-record.xml b/tests/networkxml2argvdata/nat-network-dns-txt-record.xml
new file mode 100644
index 0000000..bd16976
--- /dev/null
+++ b/tests/networkxml2argvdata/nat-network-dns-txt-record.xml
@@ -0,0 +1,24 @@
+<network>
+<name>default</name>
+<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+<forward dev='eth1' mode='nat'/>
+<bridge name='virbr0' stp='on' delay='0' />
+<dns>
+<txt name='example' value='example value' />
+</dns>
+<ip address='192.168.122.1' netmask='255.255.255.0'>
+<dhcp>
+<range start='192.168.122.2' end='192.168.122.254' />
+<host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10' />
+<host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11' />
+</dhcp>
+</ip>
+<ip family='ipv4' address='192.168.123.1' netmask='255.255.255.0'>
+</ip>
+<ip family='ipv6' address='2001:db8:ac10:fe01::1' prefix='64'>
+</ip>
+<ip family='ipv6' address='2001:db8:ac10:fd01::1' prefix='64'>
+</ip>
+<ip family='ipv4' address='10.24.10.1'>
+</ip>
+</network>
diff --git a/tests/networkxml2argvdata/nat-network.argv b/tests/networkxml2argvdata/nat-network.argv
new file mode 100644
index 0000000..ccffa67
--- /dev/null
+++ b/tests/networkxml2argvdata/nat-network.argv
@@ -0,0 +1 @@
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=(null) --conf-file= --except-interface lo --listen-address 192.168.122.1 --listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
\ No newline at end of file
diff --git a/tests/networkxml2argvdata/nat-network.xml b/tests/networkxml2argvdata/nat-network.xml
new file mode 100644
index 0000000..eb71d9e
--- /dev/null
+++ b/tests/networkxml2argvdata/nat-network.xml
@@ -0,0 +1,21 @@
+<network>
+<name>default</name>
+<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+<forward dev='eth1' mode='nat'/>
+<bridge name='virbr0' stp='on' delay='0' />
+<ip address='192.168.122.1' netmask='255.255.255.0'>
+<dhcp>
+<range start='192.168.122.2' end='192.168.122.254' />
+<host mac='00:16:3e:77:e2:ed' name='a.example.com' ip='192.168.122.10' />
+<host mac='00:16:3e:3e:a9:1a' name='b.example.com' ip='192.168.122.11' />
+</dhcp>
+</ip>
+<ip family='ipv4' address='192.168.123.1' netmask='255.255.255.0'>
+</ip>
+<ip family='ipv6' address='2001:db8:ac10:fe01::1' prefix='64'>
+</ip>
+<ip family='ipv6' address='2001:db8:ac10:fd01::1' prefix='64'>
+</ip>
+<ip family='ipv4' address='10.24.10.1'>
+</ip>
+</network>
diff --git a/tests/networkxml2argvdata/netboot-network.argv b/tests/networkxml2argvdata/netboot-network.argv
new file mode 100644
index 0000000..565c41b
--- /dev/null
+++ b/tests/networkxml2argvdata/netboot-network.argv
@@ -0,0 +1 @@
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com --pid-file=(null) --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases --dhcp-lease-max=253 --dhcp-no-override --enable-tftp --tftp-root /var/lib/tftproot --dhcp-boot pxeboot.img
\ No newline at end of file
diff --git a/tests/networkxml2argvdata/netboot-network.xml b/tests/networkxml2argvdata/netboot-network.xml
new file mode 100644
index 0000000..b8a4d99
--- /dev/null
+++ b/tests/networkxml2argvdata/netboot-network.xml
@@ -0,0 +1,14 @@
+<network>
+<name>netboot</name>
+<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+<forward mode='nat'/>
+<bridge name='virbr1' stp='off' delay='1' />
+<domain name='example.com'/>
+<ip address='192.168.122.1' netmask='255.255.255.0'>
+<tftp root='/var/lib/tftproot' />
+<dhcp>
+<range start='192.168.122.2' end='192.168.122.254' />
+<bootp file='pxeboot.img' />
+</dhcp>
+</ip>
+</network>
diff --git a/tests/networkxml2argvdata/netboot-proxy-network.argv b/tests/networkxml2argvdata/netboot-proxy-network.argv
new file mode 100644
index 0000000..019367d
--- /dev/null
+++ b/tests/networkxml2argvdata/netboot-proxy-network.argv
@@ -0,0 +1 @@
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com --pid-file=(null) --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-boot pxeboot.img,,10.20.30.40
\ No newline at end of file
diff --git a/tests/networkxml2argvdata/netboot-proxy-network.xml b/tests/networkxml2argvdata/netboot-proxy-network.xml
new file mode 100644
index 0000000..e11c50b
--- /dev/null
+++ b/tests/networkxml2argvdata/netboot-proxy-network.xml
@@ -0,0 +1,13 @@
+<network>
+<name>netboot</name>
+<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+<forward mode='nat'/>
+<bridge name='virbr1' stp='off' delay='1' />
+<domain name='example.com'/>
+<ip address='192.168.122.1' netmask='255.255.255.0'>
+<dhcp>
+<range start='192.168.122.2' end='192.168.122.254' />
+<bootp file='pxeboot.img' server='10.20.30.40' />
+</dhcp>
+</ip>
+</network>
diff --git a/tests/networkxml2argvdata/routed-network.argv b/tests/networkxml2argvdata/routed-network.argv
new file mode 100644
index 0000000..2b51d90
--- /dev/null
+++ b/tests/networkxml2argvdata/routed-network.argv
@@ -0,0 +1 @@
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=(null) --conf-file= --except-interface lo --listen-address 192.168.122.1
\ No newline at end of file
diff --git a/tests/networkxml2argvdata/routed-network.xml b/tests/networkxml2argvdata/routed-network.xml
new file mode 100644
index 0000000..3aa8109
--- /dev/null
+++ b/tests/networkxml2argvdata/routed-network.xml
@@ -0,0 +1,9 @@
+<network>
+<name>local</name>
+<uuid>81ff0d90-c91e-6742-64da-4a736edb9a9b</uuid>
+<forward dev='eth1' mode='route'/>
+<bridge name='virbr1' stp='on' delay='0' />
+<mac address='12:34:56:78:9A:BC'/>
+<ip address='192.168.122.1' netmask='255.255.255.0'>
+</ip>
+</network>
diff --git a/tests/networkxml2argvtest.c b/tests/networkxml2argvtest.c
new file mode 100644
index 0000000..a0e5fd3
--- /dev/null
+++ b/tests/networkxml2argvtest.c
@@ -0,0 +1,108 @@
+#include<config.h>
+
+#include<stdio.h>
+#include<stdlib.h>
+#include<unistd.h>
+#include<string.h>
+
+#include<sys/types.h>
+#include<fcntl.h>
+
+#include "internal.h"
+#include "testutils.h"
+#include "network_conf.h"
+#include "command.h"
+#include "memory.h"
+#include "network/bridge_driver.h"
+
+static int testCompareXMLToArgvFiles(const char *inxml, const char *outargv) {
+    char *inXmlData = NULL;
+    char *outArgvData = NULL;
+    char *actual = NULL;
+    int ret = -1;
+    virNetworkDefPtr dev = NULL;
+    virNetworkObjPtr obj = NULL;
+    virCommandPtr cmd = NULL;
+    char *pidfile = NULL;
+
+    if (virtTestLoadFile(inxml,&inXmlData)<  0)
+        goto fail;
+
+    if (virtTestLoadFile(outargv,&outArgvData)<  0)
+        goto fail;
+
+    if (!(dev = virNetworkDefParseString(inXmlData)))
+        goto fail;
+
+    if (VIR_ALLOC(obj)<  0)
+        goto fail;
+
+    obj->def = dev;
+
+    if (networkBuildDhcpDaemonCommandLine(obj,&cmd, pidfile) != 0)


Standard practice in libvirt code is to check "< 0" rather than "!= 0".


+        goto fail;
+
+    if (!(actual = virCommandToString(cmd)))
+        goto fail;
+
+    if (STRNEQ(outArgvData, actual)) {
+        virtTestDifference(stderr, outArgvData, actual);
+        goto fail;
+    }
+
+    ret = 0;
+
+ fail:
+    free(inXmlData);
+    free(outArgvData);
+    free(actual);
+    VIR_FREE(pidfile);
+    virCommandFree(cmd);
+    virNetworkObjFree(obj);
+    return ret;
+}
+
+static int
+testCompareXMLToArgvHelper(const void *data)
+{
+    int result = -1;
+    char *inxml = NULL;
+    char *outxml = NULL;
+
+    if (virAsprintf(&inxml, "%s/networkxml2argvdata/%s.xml",
+                    abs_srcdir, (const char*)data)<  0 ||
+        virAsprintf(&outxml, "%s/networkxml2argvdata/%s.argv",
+                    abs_srcdir, (const char*)data)<  0) {
+        goto cleanup;
+    }
+
+    result = testCompareXMLToArgvFiles(inxml, outxml);
+
+cleanup:
+    free(inxml);
+    free(outxml);
+
+    return result;
+}
+
+static int
+mymain(void)
+{
+    int ret = 0;
+
+#define DO_TEST(name) \
+    if (virtTestRun("Network XML-2-Argv " name, \
+                    1, testCompareXMLToArgvHelper, (name))<  0) \
+        ret = -1
+
+    DO_TEST("isolated-network");
+    DO_TEST("routed-network");
+    DO_TEST("nat-network");
+    DO_TEST("netboot-network");
+    DO_TEST("netboot-proxy-network");
+    DO_TEST("nat-network-dns-txt-record");
+
+    return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+VIRT_TEST_MAIN(mymain)

I'm attaching a patch you can squash in that addresses all the issues I noted above *except* the part about merging the bridge_driver.c changes from 3/5 with the bridge_driver.c changes from this patch to create a new 2/5, then merging the test program changes from this patch with the test data changes from patch 3/5 to create a new 3/5. Once you've done that, the new 2/5 and 3/5 will be ACKable.
>From 57a66688c0e26a01c1d1945899e779e2ede9549b Mon Sep 17 00:00:00 2001
From: Laine Stump <laine@xxxxxxxxx>
Date: Sun, 19 Jun 2011 09:00:41 -0400
Subject: [PATCH] squash into 2/5

---
 src/Makefile.am                                    |    4 ----
 src/libvirt_network.syms                           |    6 ++++++
 src/network/bridge_driver.c                        |    3 ++-
 tests/networkxml2argvdata/isolated-network.argv    |    2 +-
 .../nat-network-dns-txt-record.argv                |    2 +-
 tests/networkxml2argvdata/nat-network.argv         |    2 +-
 tests/networkxml2argvdata/netboot-network.argv     |    2 +-
 .../networkxml2argvdata/netboot-proxy-network.argv |    2 +-
 tests/networkxml2argvdata/routed-network.argv      |    2 +-
 tests/networkxml2argvtest.c                        |    2 +-
 10 files changed, 15 insertions(+), 12 deletions(-)
 create mode 100644 src/libvirt_network.syms

diff --git a/src/Makefile.am b/src/Makefile.am
index edaedec..cba8cae 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -530,10 +530,6 @@ libvirt_driver_la_LIBADD = $(NUMACTL_LIBS) $(GNUTLS_LIBS) $(DLOPEN_LIBS)
 
 USED_SYM_FILES = libvirt_private.syms
 
-if WITH_NETWORK
-USED_SYM_FILES += libvirt_network.syms
-endif
-
 if WITH_TEST
 if WITH_DRIVER_MODULES
 mod_LTLIBRARIES += libvirt_driver_test.la
diff --git a/src/libvirt_network.syms b/src/libvirt_network.syms
new file mode 100644
index 0000000..6be5e45
--- /dev/null
+++ b/src/libvirt_network.syms
@@ -0,0 +1,6 @@
+#
+# Network-specific symbols
+#
+
+# bridge_driver.h
+networkBuildDhcpDaemonCommandLine;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index a03c0a3..9375ffe 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -494,7 +494,8 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
     if (network->def->domain)
         virCommandAddArgList(cmd, "--domain", network->def->domain, NULL);
 
-    virCommandAddArgPair(cmd, "--pid-file", pidfile);
+    if (pidfile)
+       virCommandAddArgPair(cmd, "--pid-file", pidfile);
 
     /* *no* conf file */
     virCommandAddArg(cmd, "--conf-file=");
diff --git a/tests/networkxml2argvdata/isolated-network.argv b/tests/networkxml2argvdata/isolated-network.argv
index dce6034..e0993fb 100644
--- a/tests/networkxml2argvdata/isolated-network.argv
+++ b/tests/networkxml2argvdata/isolated-network.argv
@@ -1 +1 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=(null) --conf-file= --except-interface lo --dhcp-option=3 --listen-address 192.168.152.1 --dhcp-range 192.168.152.2,192.168.152.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/private.leases --dhcp-lease-max=253 --dhcp-no-override
\ No newline at end of file
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= --except-interface lo --dhcp-option=3 --listen-address 192.168.152.1 --dhcp-range 192.168.152.2,192.168.152.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/private.leases --dhcp-lease-max=253 --dhcp-no-override
\ No newline at end of file
diff --git a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
index 96fde34..27149b7 100644
--- a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
@@ -1 +1 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=(null) --conf-file= --except-interface lo --txt-record=example,example value --listen-address 192.168.122.1 --listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
\ No newline at end of file
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= --except-interface lo --txt-record=example,example value --listen-address 192.168.122.1 --listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
diff --git a/tests/networkxml2argvdata/nat-network.argv b/tests/networkxml2argvdata/nat-network.argv
index ccffa67..e67e2db 100644
--- a/tests/networkxml2argvdata/nat-network.argv
+++ b/tests/networkxml2argvdata/nat-network.argv
@@ -1 +1 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=(null) --conf-file= --except-interface lo --listen-address 192.168.122.1 --listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
\ No newline at end of file
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= --except-interface lo --listen-address 192.168.122.1 --listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 --listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile
diff --git a/tests/networkxml2argvdata/netboot-network.argv b/tests/networkxml2argvdata/netboot-network.argv
index 565c41b..c5db9e0 100644
--- a/tests/networkxml2argvdata/netboot-network.argv
+++ b/tests/networkxml2argvdata/netboot-network.argv
@@ -1 +1 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com --pid-file=(null) --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases --dhcp-lease-max=253 --dhcp-no-override --enable-tftp --tftp-root /var/lib/tftproot --dhcp-boot pxeboot.img
\ No newline at end of file
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases --dhcp-lease-max=253 --dhcp-no-override --enable-tftp --tftp-root /var/lib/tftproot --dhcp-boot pxeboot.img
\ No newline at end of file
diff --git a/tests/networkxml2argvdata/netboot-proxy-network.argv b/tests/networkxml2argvdata/netboot-proxy-network.argv
index 019367d..06e5b08 100644
--- a/tests/networkxml2argvdata/netboot-proxy-network.argv
+++ b/tests/networkxml2argvdata/netboot-proxy-network.argv
@@ -1 +1 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com --pid-file=(null) --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-boot pxeboot.img,,10.20.30.40
\ No newline at end of file
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-boot pxeboot.img,,10.20.30.40
\ No newline at end of file
diff --git a/tests/networkxml2argvdata/routed-network.argv b/tests/networkxml2argvdata/routed-network.argv
index 2b51d90..bf5f579 100644
--- a/tests/networkxml2argvdata/routed-network.argv
+++ b/tests/networkxml2argvdata/routed-network.argv
@@ -1 +1 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=(null) --conf-file= --except-interface lo --listen-address 192.168.122.1
\ No newline at end of file
+/usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= --except-interface lo --listen-address 192.168.122.1
\ No newline at end of file
diff --git a/tests/networkxml2argvtest.c b/tests/networkxml2argvtest.c
index a0e5fd3..98c84ad 100644
--- a/tests/networkxml2argvtest.c
+++ b/tests/networkxml2argvtest.c
@@ -39,7 +39,7 @@ static int testCompareXMLToArgvFiles(const char *inxml, const char *outargv) {
 
     obj->def = dev;
 
-    if (networkBuildDhcpDaemonCommandLine(obj, &cmd, pidfile) != 0)
+    if (networkBuildDhcpDaemonCommandLine(obj, &cmd, pidfile) < 0)
         goto fail;
 
     if (!(actual = virCommandToString(cmd)))
-- 
1.7.3.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]