On Wed, Dec 14, 2011 at 10:50:40AM +0000, Shradha Shah wrote:
The above option helps to differentiate between implicit and explicit
interface pools.
---
include/libvirt/libvirt.h.in | 4 ++++
src/conf/network_conf.c | 10 +++++++---
src/conf/network_conf.h | 2 +-
src/network/bridge_driver.c | 4 ++--
src/test/test_driver.c | 2 +-
src/vbox/vbox_tmpl.c | 2 +-
tests/networkxml2xmltest.c | 2 +-
tools/virsh.c | 13 +++++++++++--
8 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 2480add..45fe060 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1783,6 +1783,10 @@ int virNodeGetCellsFreeMemory(virConnectPtr
conn,
* Virtual Networks API
*/
+typedef enum {
+ VIR_NETWORK_XML_INACTIVE = (1 << 0), /* dump inactive network information */
+} virNetworkXMLFlags;
+
/**
* virNetwork:
*
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 9557e29..37b7454 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -1326,7 +1326,7 @@ virPortGroupDefFormat(virBufferPtr buf,
return 0;
}
-char *virNetworkDefFormat(const virNetworkDefPtr def)
+char *virNetworkDefFormat(const virNetworkDefPtr def, unsigned int flags)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
unsigned char *uuid;
@@ -1366,6 +1366,9 @@ char *virNetworkDefFormat(const virNetworkDefPtr def)
}
}
+ if (flags && def->nForwardPfs)
+ goto escape;
You'll want to be explicit about what you're checking here
'(flags & VIR_NETWORK_XML_INACTIVE) && def->nForwardPfs'
so this code doesn't break if we add more flags in the future
+
if (def->nForwardIfs) {
And rather than having a goto above, I'd just change
this to
if (def->nForwardIfs &&
!(flags & VIR_NETWORK_XML_INACTIVE) && def->nForwardPfs) {
for (ii = 0; ii < def->nForwardIfs; ii++) {
if (def->forwardIfs[ii].dev) {
@@ -1373,8 +1376,9 @@ char *virNetworkDefFormat(const virNetworkDefPtr def)
def->forwardIfs[ii].dev);
}
}
- virBufferAddLit(&buf, " </forward>\n");
}
+ escape:
+ virBufferAddLit(&buf, " </forward>\n");
}
if (def->forwardType == VIR_NETWORK_FORWARD_NONE ||
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|