File default-net-source.patch of Package libvirt-cim

Index: libvirt-cim-0.5.2/libxkutil/device_parsing.c
===================================================================
--- libvirt-cim-0.5.2.orig/libxkutil/device_parsing.c
+++ libvirt-cim-0.5.2/libxkutil/device_parsing.c
@@ -308,27 +308,8 @@ static int parse_net_device(xmlNode *ino
         if (ndev->mac == NULL)
                 goto err;
 
-        if (ndev->source == NULL) {
-                if (STREQC(ndev->type, "bridge")) {
-                        ndev->source = strdup(DEFAULT_BRIDGE);
-                        CU_DEBUG("No bridge, taking default of `%s'\n",
-                                 ndev->source);
-                } else if (STREQC(ndev->type, "network")) {
-                        ndev->source = strdup(DEFAULT_NETWORK);
-                        CU_DEBUG("No network, taking default of `%s'\n",
-                                 ndev->source);
-                } else if (STREQC(ndev->type, "user")){
-                        CU_DEBUG("Leaving source blank for user net type");
-                } else if (STREQC(ndev->type, "ethernet")){
-                        CU_DEBUG("Leaving source blank for ethernet net type");
-                } else {
-                        /* This likely indicates an unsupported
-                         * network configuration
-                         */
-                        CU_DEBUG("No network source, and no known default");
-                        goto err;
-                }
-        }
+        if (ndev->source == NULL)
+                CU_DEBUG("No network source defined, leaving blank\n");
 
         vdev->type = CIM_RES_TYPE_NET;
         vdev->id = strdup(ndev->mac);
Index: libvirt-cim-0.5.2/libxkutil/xmlgen.c
===================================================================
--- libvirt-cim-0.5.2.orig/libxkutil/xmlgen.c
+++ libvirt-cim-0.5.2/libxkutil/xmlgen.c
@@ -206,16 +206,26 @@ static bool bridge_net_to_xml(char **xml
         char *script = "vif-bridge";
         struct net_device *net = &dev->dev.net;
 
-        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);
+        if (net->source == NULL)
+                ret = asprintf(&_xml,
+                               "<interface type='%s'>\n"
+                               "  <mac address='%s'/>\n"
+                               "  <script path='%s'/>\n"
+                               "</interface>\n",
+                               net->type,
+                               net->mac,
+                               script);
+        else
+                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);
 
         if (ret == -1)
                 return false;
@@ -234,16 +244,22 @@ static bool network_net_to_xml(char **xm
         struct net_device *net = &dev->dev.net;
 
         if (net->source == NULL)
-                net->source = strdup("default");
+                ret = asprintf(&_xml,
+                               "<interface type='%s'>\n"
+                               "  <mac address='%s'/>\n"
+                               "</interface>\n",
+                               net->type,
+                               net->mac);
+        else
+                ret = asprintf(&_xml,
+                               "<interface type='%s'>\n"
+                               "  <mac address='%s'/>\n"
+                               "  <source network='%s'/>\n"
+                               "</interface>\n",
+                               net->type,
+                               net->mac,
+                               net->source);
 
-        ret = asprintf(&_xml,
-                       "<interface type='%s'>\n"
-                       "  <mac address='%s'/>\n"
-                       "  <source network='%s'/>\n"
-                       "</interface>\n",
-                       net->type,
-                       net->mac,
-                       net->source);
         if (ret == -1)
                 return false;
         else
Index: libvirt-cim-0.5.2/src/Virt_DevicePool.c
===================================================================
--- libvirt-cim-0.5.2.orig/src/Virt_DevicePool.c
+++ libvirt-cim-0.5.2/src/Virt_DevicePool.c
@@ -389,6 +389,12 @@ static char *_netpool_member_of(virConne
         const char *netname;
         char *pool = NULL;
 
+        if (ndev->source == NULL) {
+                CU_DEBUG("Unable to determine pool since no network "
+                         "source defined");
+                goto out;
+        }
+
         if (STREQ(ndev->type, "bridge"))
                 net = bridge_to_network(conn, ndev->source);
         else if (STREQ(ndev->type, "network"))
openSUSE Build Service is sponsored by