The XM driver is not currently handling the vifname= parameter for
network devices in /etc/xen config files. This patch fixes that
ommision
Daniel
diff -r e396919fa59e src/xm_internal.c
--- a/src/xm_internal.c Tue Mar 31 16:35:42 2009 +0100
+++ b/src/xm_internal.c Tue Mar 31 16:58:11 2009 +0100
@@ -991,6 +991,7 @@ xenXMDomainConfigParse(virConnectPtr con
char ip[16];
char mac[18];
char bridge[50];
+ char vifname[50];
char *key;
bridge[0] = '\0';
@@ -998,6 +999,7 @@ xenXMDomainConfigParse(virConnectPtr con
script[0] = '\0';
ip[0] = '\0';
model[0] = '\0';
+ vifname[0] = '\0';
if ((list->type != VIR_CONF_STRING) || (list->str == NULL))
goto skipnic;
@@ -1036,6 +1038,12 @@ xenXMDomainConfigParse(virConnectPtr con
len = sizeof(model)-1;
strncpy(model, data, len);
model[len] = '\0';
+ } else if (STRPREFIX(key, "vifname=")) {
+ int len = nextkey ? (nextkey - data) : sizeof(vifname)-1;
+ if (len > (sizeof(vifname)-1))
+ len = sizeof(vifname)-1;
+ strncpy(vifname, data, len);
+ vifname[len] = '\0';
} else if (STRPREFIX(key, "ip=")) {
int len = nextkey ? (nextkey - data) : 15;
if (len > 15)
@@ -1105,6 +1113,10 @@ xenXMDomainConfigParse(virConnectPtr con
!(net->model = strdup(model)))
goto no_memory;
+ if (vifname[0] &&
+ !(net->ifname = strdup(vifname)))
+ goto no_memory;
+
if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0)
goto no_memory;
def->nets[def->nnets++] = net;
@@ -1994,6 +2006,10 @@ static int xenXMDomainConfigFormatNet(vi
virBufferVSprintf(&buf, ",model=%s",
net->model);
+ if (net->ifname)
+ virBufferVSprintf(&buf, ",vifname=%s",
+ net->ifname);
+
if (VIR_ALLOC(val) < 0) {
virReportOOMError(conn);
goto cleanup;
diff -r e396919fa59e tests/xmconfigdata/test-paravirt-net-vifname.cfg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xmconfigdata/test-paravirt-net-vifname.cfg Tue Mar 31 16:58:11 2009 +0100
@@ -0,0 +1,12 @@
+name = "XenGuest1"
+uuid = "c7a5fdb0-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+bootloader = "/usr/bin/pygrub"
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+vfb = [ "type=vnc,vncunused=1,vnclisten=127.0.0.1,vncpasswd=123poi" ]
+disk = [ "phy:/dev/HostVG/XenGuest1,xvda,w" ]
+vif = [ "mac=00:16:3e:66:94:9c,bridge=br0,model=e1000,vifname=net0" ]
diff -r e396919fa59e tests/xmconfigdata/test-paravirt-net-vifname.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xmconfigdata/test-paravirt-net-vifname.xml Tue Mar 31 16:58:11 2009 +0100
@@ -0,0 +1,33 @@
+<domain type='xen'>
+ <name>XenGuest1</name>
+ <uuid>c7a5fdb0-cdaf-9455-926a-d65c16db1809</uuid>
+ <memory>592896</memory>
+ <currentMemory>403456</currentMemory>
+ <vcpu>1</vcpu>
+ <bootloader>/usr/bin/pygrub</bootloader>
+ <os>
+ <type arch='i686' machine='xenpv'>linux</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <disk type='block' device='disk'>
+ <driver name='phy'/>
+ <source dev='/dev/HostVG/XenGuest1'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:16:3e:66:94:9c'/>
+ <source bridge='br0'/>
+ <target dev='net0'/>
+ <model type='e1000'/>
+ </interface>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <input type='mouse' bus='xen'/>
+ <graphics type='vnc' port='-1' autoport='yes'
listen='127.0.0.1' passwd='123poi'/>
+ </devices>
+</domain>
diff -r e396919fa59e tests/xmconfigtest.c
--- a/tests/xmconfigtest.c Tue Mar 31 16:35:42 2009 +0100
+++ b/tests/xmconfigtest.c Tue Mar 31 16:58:11 2009 +0100
@@ -209,6 +209,7 @@ mymain(int argc, char **argv)
DO_TEST("paravirt-new-pvfb", 3);
DO_TEST("paravirt-new-pvfb-vncdisplay", 3);
DO_TEST("paravirt-net-e1000", 3);
+ DO_TEST("paravirt-net-vifname", 3);
DO_TEST("fullvirt-old-cdrom", 1);
DO_TEST("fullvirt-new-cdrom", 2);
DO_TEST("fullvirt-utc", 2);
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|