[Libvirt-cim] [PATCH] Allow KVM and Xen to parse both network and bridge interfaces

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Jun 2 16:58:28 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1212155823 25200
# Node ID 0c8d4baf3ee1f6eb96f7d1d49276fa6cc44c4685
# Parent  5b89d6aa5816613627a2869d8c72bde37a9f2e2c
Allow KVM and Xen to parse both network and bridge interfaces.

Since KVM and Xen guests are both created with network interfaces, there no longer needs to be a seperate function for KVM and Xen.

This change allow fixes an error seen when attempting to modify a KVM guest that was created with a non-network inteface (created using a method other than the providers).  Even though we don't create guests with bridge type interfaces, we should be able to parse their xmls.

This bit of code will probably need to be updated to support other interface types.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 5b89d6aa5816 -r 0c8d4baf3ee1 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c	Fri May 30 06:57:03 2008 -0700
+++ b/libxkutil/xmlgen.c	Fri May 30 06:57:03 2008 -0700
@@ -189,7 +189,7 @@
         return true;
 }
 
-static bool xen_net_to_xml(char **xml, struct virt_device *dev)
+static bool bridge_net_to_xml(char **xml, struct virt_device *dev)
 {
         int ret;
         char *_xml;
@@ -198,10 +198,12 @@
 
         ret = asprintf(&_xml,
                        "<interface type='%s'>\n"
+                       "  <source bridge='%s'/>\n"
                        "  <mac address='%s'/>\n"
                        "  <script path='%s'/>\n"
                        "</interface>\n",
                        net->type,
+                       net->source,
                        net->mac,
                        script);
 
@@ -215,7 +217,7 @@
         return true;
 }
 
-static bool kvm_net_to_xml(char **xml, struct virt_device *dev)
+static bool network_net_to_xml(char **xml, struct virt_device *dev)
 {
         int ret;
         char *_xml;
@@ -245,9 +247,9 @@
 static bool net_to_xml(char **xml, struct virt_device *dev)
 {
         if (STREQ(dev->dev.net.type, "network"))
-                return kvm_net_to_xml(xml, dev);
+                return network_net_to_xml(xml, dev);
         else if (STREQ(dev->dev.net.type, "bridge"))
-                return xen_net_to_xml(xml, dev);
+                return bridge_net_to_xml(xml, dev);
         else
                 return false;
 }




More information about the Libvirt-cim mailing list