|
|
43fe83 |
From 5315fe88fe6ca28ad50c2229b08f2bb914f938c9 Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <5315fe88fe6ca28ad50c2229b08f2bb914f938c9.1377873641.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
43fe83 |
Date: Mon, 26 Aug 2013 15:11:19 +0200
|
|
|
43fe83 |
Subject: [PATCH] Reverse logic allowing partial DHCP host XML
|
|
|
43fe83 |
|
|
|
43fe83 |
Before, missing attributes were only OK when parsing entries
|
|
|
43fe83 |
for adding (but then rejected by the network def <-> XML round
|
|
|
43fe83 |
trip verification). Entries for modification and deletion
|
|
|
43fe83 |
required all of them.
|
|
|
43fe83 |
|
|
|
43fe83 |
Now, deletion works with missing attributes, as long as
|
|
|
43fe83 |
the host is uniquely identified.
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1001078
|
|
|
43fe83 |
|
|
|
43fe83 |
(cherry picked from commit cf602e7c597830a2d949017fe71f06b5f542c805)
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/conf/network_conf.c | 21 +++++----------------
|
|
|
43fe83 |
1 file changed, 5 insertions(+), 16 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
|
|
|
43fe83 |
index b903df9..b358393 100644
|
|
|
43fe83 |
--- a/src/conf/network_conf.c
|
|
|
43fe83 |
+++ b/src/conf/network_conf.c
|
|
|
43fe83 |
@@ -3297,6 +3297,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
|
|
|
43fe83 |
int ret = -1;
|
|
|
43fe83 |
virNetworkIpDefPtr ipdef = virNetworkIpDefByIndex(def, parentIndex);
|
|
|
43fe83 |
virNetworkDHCPHostDef host;
|
|
|
43fe83 |
+ bool partialOkay = (command == VIR_NETWORK_UPDATE_COMMAND_DELETE);
|
|
|
43fe83 |
|
|
|
43fe83 |
memset(&host, 0, sizeof(host));
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -3307,13 +3308,11 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
|
|
|
43fe83 |
if (!ipdef)
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
|
|
|
43fe83 |
- /* parse the xml into a virNetworkDHCPHostDef */
|
|
|
43fe83 |
- if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) {
|
|
|
43fe83 |
+ if (virNetworkDHCPHostDefParseXML(def->name, ipdef, ctxt->node,
|
|
|
43fe83 |
+ &host, partialOkay) < 0)
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
|
|
|
43fe83 |
- if (virNetworkDHCPHostDefParseXML(def->name, ipdef,
|
|
|
43fe83 |
- ctxt->node, &host, false) < 0) {
|
|
|
43fe83 |
- goto cleanup;
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
+ if (command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) {
|
|
|
43fe83 |
|
|
|
43fe83 |
/* search for the entry with this (mac|name),
|
|
|
43fe83 |
* and update the IP+(mac|name) */
|
|
|
43fe83 |
@@ -3345,11 +3344,6 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
|
|
|
43fe83 |
} else if ((command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST) ||
|
|
|
43fe83 |
(command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST)) {
|
|
|
43fe83 |
|
|
|
43fe83 |
- if (virNetworkDHCPHostDefParseXML(def->name, ipdef,
|
|
|
43fe83 |
- ctxt->node, &host, true) < 0) {
|
|
|
43fe83 |
- goto cleanup;
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
-
|
|
|
43fe83 |
/* log error if an entry with same name/address/ip already exists */
|
|
|
43fe83 |
for (i = 0; i < ipdef->nhosts; i++) {
|
|
|
43fe83 |
if ((host.mac &&
|
|
|
43fe83 |
@@ -3379,11 +3373,6 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
} else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
|
|
|
43fe83 |
|
|
|
43fe83 |
- if (virNetworkDHCPHostDefParseXML(def->name, ipdef,
|
|
|
43fe83 |
- ctxt->node, &host, false) < 0) {
|
|
|
43fe83 |
- goto cleanup;
|
|
|
43fe83 |
- }
|
|
|
43fe83 |
-
|
|
|
43fe83 |
/* find matching entry - all specified attributes must match */
|
|
|
43fe83 |
for (i = 0; i < ipdef->nhosts; i++) {
|
|
|
43fe83 |
if ((!host.mac ||
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|