[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libvir] PATCH: Fix bridge device handling with xm config files



The code for parsing xm config files & generating XML forgot to add in the
<source bridge='xenbr0'> elements if an explicit bridge is requested. The
reverse direction was already implemeneted. This patch fixes the missing
handling of bridge devices & adds a test case

Dan
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
? foo
? docs/APIchunk5.html
? docs/APIchunk6.html
? docs/apibuild.pyc
? docs/examples/.deps
? docs/examples/.libs
? tests/foo
Index: src/xm_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xm_internal.c,v
retrieving revision 1.28
diff -u -p -r1.28 xm_internal.c
--- src/xm_internal.c	7 Jun 2007 14:08:35 -0000	1.28
+++ src/xm_internal.c	7 Jun 2007 14:53:06 -0000
@@ -824,8 +824,10 @@ char *xenXMDomainFormatXML(virConnectPtr
             char script[PATH_MAX];
             char ip[16];
             char mac[18];
+            char bridge[50];
             char *key;
 
+            bridge[0] = '\0';
             mac[0] = '\0';
             script[0] = '\0';
             ip[0] = '\0';
@@ -849,7 +851,12 @@ char *xenXMDomainFormatXML(virConnectPtr
                     strncpy(mac, data, len);
                     mac[len] = '\0';
                 } else if (!strncmp(key, "bridge=", 7)) {
+                    int len = nextkey ? (nextkey - data) : sizeof(bridge)-1;
                     type = 1;
+                    if (len > (sizeof(bridge)-1))
+                        len = sizeof(bridge)-1;
+                    strncpy(bridge, data, len);
+                    bridge[len] = '\0';
                 } else if (!strncmp(key, "script=", 7)) {
                     int len = nextkey ? (nextkey - data) : PATH_MAX-1;
                     if (len > (PATH_MAX-1))
@@ -879,6 +886,8 @@ char *xenXMDomainFormatXML(virConnectPtr
             virBufferAdd(buf, "    <interface type='bridge'>\n", -1);
             if (mac[0])
                 virBufferVSprintf(buf, "      <mac address='%s'/>\n", mac);
+            if (type == 1 && bridge[0])
+                virBufferVSprintf(buf, "      <source bridge='%s'/>\n", bridge);
             if (script[0])
                 virBufferVSprintf(buf, "      <script path='%s'/>\n", script);
             if (ip[0])
Index: tests/xmconfigdata/test-fullvirt-new-cdrom.cfg
===================================================================
RCS file: /data/cvs/libvirt/tests/xmconfigdata/test-fullvirt-new-cdrom.cfg,v
retrieving revision 1.1
diff -u -p -r1.1 test-fullvirt-new-cdrom.cfg
--- tests/xmconfigdata/test-fullvirt-new-cdrom.cfg	19 Jan 2007 20:30:05 -0000	1.1
+++ tests/xmconfigdata/test-fullvirt-new-cdrom.cfg	7 Jun 2007 14:53:06 -0000
@@ -19,4 +19,4 @@ vncunused = 1
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,hda,w", "file:/root/boot.iso,hdc:cdrom,r" ]
-vif = [ "mac=00:16:3E:66:92:9C,type=ioemu" ]
+vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr1,type=ioemu" ]
Index: tests/xmconfigdata/test-fullvirt-new-cdrom.xml
===================================================================
RCS file: /data/cvs/libvirt/tests/xmconfigdata/test-fullvirt-new-cdrom.xml,v
retrieving revision 1.2
diff -u -p -r1.2 test-fullvirt-new-cdrom.xml
--- tests/xmconfigdata/test-fullvirt-new-cdrom.xml	7 Jun 2007 14:08:35 -0000	1.2
+++ tests/xmconfigdata/test-fullvirt-new-cdrom.xml	7 Jun 2007 14:53:06 -0000
@@ -32,6 +32,7 @@
     </disk>
     <interface type='bridge'>
       <mac address='00:16:3E:66:92:9C'/>
+      <source bridge='xenbr1'/>
     </interface>
     <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
   </devices>
Index: tests/xmconfigdata/test-fullvirt-old-cdrom.cfg
===================================================================
RCS file: /data/cvs/libvirt/tests/xmconfigdata/test-fullvirt-old-cdrom.cfg,v
retrieving revision 1.1
diff -u -p -r1.1 test-fullvirt-old-cdrom.cfg
--- tests/xmconfigdata/test-fullvirt-old-cdrom.cfg	19 Jan 2007 20:30:05 -0000	1.1
+++ tests/xmconfigdata/test-fullvirt-old-cdrom.cfg	7 Jun 2007 14:53:06 -0000
@@ -20,4 +20,4 @@ vncunused = 1
 vnclisten = "127.0.0.1"
 vncpasswd = "123poi"
 disk = [ "phy:/dev/HostVG/XenGuest2,ioemu:hda,w" ]
-vif = [ "mac=00:16:3E:66:92:9C,type=ioemu" ]
+vif = [ "mac=00:16:3E:66:92:9C,bridge=xenbr0,type=ioemu" ]
Index: tests/xmconfigdata/test-fullvirt-old-cdrom.xml
===================================================================
RCS file: /data/cvs/libvirt/tests/xmconfigdata/test-fullvirt-old-cdrom.xml,v
retrieving revision 1.2
diff -u -p -r1.2 test-fullvirt-old-cdrom.xml
--- tests/xmconfigdata/test-fullvirt-old-cdrom.xml	7 Jun 2007 14:08:35 -0000	1.2
+++ tests/xmconfigdata/test-fullvirt-old-cdrom.xml	7 Jun 2007 14:53:06 -0000
@@ -32,6 +32,7 @@
     </disk>
     <interface type='bridge'>
       <mac address='00:16:3E:66:92:9C'/>
+      <source bridge='xenbr0'/>
     </interface>
     <graphics type='vnc' port='-1' listen='127.0.0.1' passwd='123poi'/>
   </devices>

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]