# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1200504973 28800
# Node ID c505a88eb5e25f5e3b2418312dc48b6602857946
# Parent be7f34a7f1a879dc220eaa8f5e2eab6dd3a04420
Add network interface parsing for KVM domains
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r be7f34a7f1a8 -r c505a88eb5e2 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Wed Jan 16 09:07:38 2008 -0800
+++ b/libxkutil/device_parsing.c Wed Jan 16 09:36:13 2008 -0800
@@ -61,7 +61,7 @@ static void cleanup_net_device(struct ne
{
free(dev->type);
free(dev->mac);
- free(dev->bridge);
+ free(dev->source);
}
static void cleanup_emu_device(struct emu_device *dev)
@@ -216,18 +216,22 @@ static int parse_net_device(xmlNode *ino
if (ndev->mac == NULL)
goto err;
} else if (XSTREQ(child->name, "source")) {
- ndev->bridge = get_attr_value(child, "bridge");
- if (ndev->bridge == NULL)
- goto err;
+ ndev->source = get_attr_value(child, "bridge");
+ if (ndev->source != NULL)
+ continue;
+ ndev->source = get_attr_value(child, "network");
+ if (ndev->source != NULL)
+ continue;
+ goto err;
}
}
if (ndev->mac == NULL)
goto err;
- if (ndev->bridge == NULL) {
- ndev->bridge = strdup(DEFAULT_BRIDGE);
- printf("No bridge, taking default of `%s'\n",
ndev->bridge);
+ if ((STREQC(ndev->type, "bridge")) && (ndev->source ==
NULL)) {
+ ndev->source = strdup(DEFAULT_BRIDGE);
+ printf("No bridge, taking default of `%s'\n",
ndev->source);
}
vdev->type = VIRT_DEV_NET;
@@ -517,7 +521,7 @@ struct virt_device *virt_device_dup(stru
if (dev->type == VIRT_DEV_NET) {
DUP_FIELD(dev, _dev, dev.net.mac);
DUP_FIELD(dev, _dev, dev.net.type);
- DUP_FIELD(dev, _dev, dev.net.bridge);
+ DUP_FIELD(dev, _dev, dev.net.source);
} else if (dev->type == VIRT_DEV_DISK) {
DUP_FIELD(dev, _dev, dev.disk.type);
DUP_FIELD(dev, _dev, dev.disk.device);
diff -r be7f34a7f1a8 -r c505a88eb5e2 libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Wed Jan 16 09:07:38 2008 -0800
+++ b/libxkutil/device_parsing.h Wed Jan 16 09:36:13 2008 -0800
@@ -41,7 +41,7 @@ struct net_device {
struct net_device {
char *type;
char *mac;
- char *bridge;
+ char *source;
};
struct mem_device {
diff -r be7f34a7f1a8 -r c505a88eb5e2 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Wed Jan 16 09:07:38 2008 -0800
+++ b/src/Virt_DevicePool.c Wed Jan 16 09:36:13 2008 -0800
@@ -295,7 +295,7 @@ static char *netpool_member_of(const CMP
for (i = 0; i < count; i++) {
if (STREQ((devs[i].id), dev)) {
result = _netpool_member_of(conn,
- devs[i].dev.net.bridge);
+ devs[i].dev.net.source);
break;
}
}