These patches fix minor annoyances.
David
Show replies by date
---
data/xml/interface.rng | 4 ++--
tests/initscripts/bridge-empty.xml | 10 ++++++++++
tests/interface/bridge-empty.xml | 5 +++++
tests/test-initscripts.c | 1 +
4 files changed, 18 insertions(+), 2 deletions(-)
create mode 100644 tests/initscripts/bridge-empty.xml
create mode 100644 tests/interface/bridge-empty.xml
diff --git a/data/xml/interface.rng b/data/xml/interface.rng
index dc367f3..e5e25fe 100644
--- a/data/xml/interface.rng
+++ b/data/xml/interface.rng
@@ -119,12 +119,12 @@
<optional v:since="2">
<attribute name="delay"><ref
name="timeval"/></attribute>
</optional>
- <oneOrMore>
+ <zeroOrMore>
<choice>
<ref name="bare-ethernet-interface"/>
<ref name="bare-vlan-interface"/>
</choice>
- </oneOrMore>
+ </zeroOrMore>
</element>
</element>
</define>
diff --git a/tests/initscripts/bridge-empty.xml b/tests/initscripts/bridge-empty.xml
new file mode 100644
index 0000000..17d9764
--- /dev/null
+++ b/tests/initscripts/bridge-empty.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<forest>
+ <tree path="/files/etc/sysconfig/network-scripts/ifcfg-br0">
+ <node label="DEVICE" value="br0"/>
+ <node label="ONBOOT" value="yes"/>
+ <node label="MTU" value="1500"/>
+ <node label="TYPE" value="Bridge"/>
+ <node label="STP" value="off"/>
+ </tree>
+</forest>
diff --git a/tests/interface/bridge-empty.xml b/tests/interface/bridge-empty.xml
new file mode 100644
index 0000000..5b4523e
--- /dev/null
+++ b/tests/interface/bridge-empty.xml
@@ -0,0 +1,5 @@
+<interface type="bridge" name="br0">
+ <start mode="onboot"/>
+ <mtu size="1500"/>
+ <bridge stp="off"/>
+</interface>
diff --git a/tests/test-initscripts.c b/tests/test-initscripts.c
index cd95e6a..39d0865 100644
--- a/tests/test-initscripts.c
+++ b/tests/test-initscripts.c
@@ -177,6 +177,7 @@ static void testTransforms(CuTest *tc) {
assert_transforms(tc, "bridge");
assert_transforms(tc, "bridge-no-address");
assert_transforms(tc, "bridge-vlan");
+ assert_transforms(tc, "bridge-empty");
assert_transforms(tc, "ethernet-static");
assert_transforms(tc, "ethernet-static-no-prefix");
assert_transforms(tc, "ethernet-dhcp");
--
1.6.2.5
---
src/drv_initscripts.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/drv_initscripts.c b/src/drv_initscripts.c
index e17d834..e928962 100644
--- a/src/drv_initscripts.c
+++ b/src/drv_initscripts.c
@@ -978,6 +978,7 @@ int drv_if_up(struct netcf_if *nif) {
}
}
run1(ncf, ifup, nif->name);
+ ERR_BAIL(ncf);
result = 0;
error:
free_matches(nslaves, &slaves);
@@ -992,6 +993,7 @@ int drv_if_down(struct netcf_if *nif) {
int result = -1;
run1(ncf, ifdown, nif->name);
+ ERR_BAIL(ncf);
if (is_bridge(ncf, nif->name)) {
/* Bring up bridge slaves after the bridge */
nslaves = bridge_slaves(ncf, nif->name, &slaves);
--
1.6.2.5
---
src/netcf.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/netcf.c b/src/netcf.c
index 2907349..ad88c62 100644
--- a/src/netcf.c
+++ b/src/netcf.c
@@ -244,21 +244,21 @@ int ncf_put_aug(struct netcf *ncf, const char *aug_xml, char
**ncf_xml) {
int run_program(struct netcf *ncf, const char *const *argv) {
- int command_return;
+ int status, success;
char *argv_str = argv_to_string(argv);
int ret = -1;
- ERR_NOMEM(argv_str == NULL, ncf);
-
/* BIG FIXME!!! Before any general release, this *must* be
* replaced with a call to a function similar to libVirt's
* virRun(), and if there is an error returned, anything the
* program produced on stderr or stdout should be placed in
* ncf->errdetails.
*/
- command_return = system(argv_str);
-
- ERR_COND_BAIL(command_return != WEXITSTATUS (0), ncf, EEXEC);
+ status = system(argv_str);
+ success = WIFEXITED(status) && WEXITSTATUS(status) == 0;
+ ERR_THROW(!success, ncf, EEXEC,
+ "Running '%s' failed with error code %d",
+ argv_str == NULL ? argv[0] : argv_str, WEXITSTATUS(status));
ret = 0;
error:
--
1.6.2.5
Allow calling ncf_if_free after an error in another ncf_* function happened
without losing that error. That makes unwinding from an error simpler for
application.
---
src/netcf.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/netcf.c b/src/netcf.c
index ad88c62..7ca4fd9 100644
--- a/src/netcf.c
+++ b/src/netcf.c
@@ -207,7 +207,6 @@ void ncf_if_free(struct netcf_if *nif) {
if (nif == NULL)
return;
- API_ENTRY(nif->ncf);
unref(nif, netcf_if);
}
--
1.6.2.5