mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Add support for vifname= in XM config files
This commit is contained in:
parent
3ad8a273b5
commit
83a618f807
@ -1,3 +1,12 @@
|
||||
Wed Apr 1 11:16:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/xm_internal.c: Add support for vifname= parameter in
|
||||
VIF config
|
||||
* tests/xmconfigtest.c: Add test for vifname= handling
|
||||
* tests/xmconfigdata/test-paravirt-net-vifname.cfg,
|
||||
tests/xmconfigdata/test-paravirt-net-vifname.xml: Data file
|
||||
for new test
|
||||
|
||||
Wed Apr 1 10:58:22 BST 2009 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
Improve error reporting in SEXPR generation
|
||||
|
@ -989,6 +989,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
|
||||
char ip[16];
|
||||
char mac[18];
|
||||
char bridge[50];
|
||||
char vifname[50];
|
||||
char *key;
|
||||
|
||||
bridge[0] = '\0';
|
||||
@ -996,6 +997,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
|
||||
script[0] = '\0';
|
||||
ip[0] = '\0';
|
||||
model[0] = '\0';
|
||||
vifname[0] = '\0';
|
||||
|
||||
if ((list->type != VIR_CONF_STRING) || (list->str == NULL))
|
||||
goto skipnic;
|
||||
@ -1034,6 +1036,12 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
|
||||
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)
|
||||
@ -1103,6 +1111,10 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
|
||||
!(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;
|
||||
@ -1910,6 +1922,10 @@ static int xenXMDomainConfigFormatNet(virConnectPtr conn,
|
||||
virBufferVSprintf(&buf, ",model=%s",
|
||||
net->model);
|
||||
|
||||
if (net->ifname)
|
||||
virBufferVSprintf(&buf, ",vifname=%s",
|
||||
net->ifname);
|
||||
|
||||
if (VIR_ALLOC(val) < 0) {
|
||||
virReportOOMError(conn);
|
||||
goto cleanup;
|
||||
|
12
tests/xmconfigdata/test-paravirt-net-vifname.cfg
Normal file
12
tests/xmconfigdata/test-paravirt-net-vifname.cfg
Normal file
@ -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" ]
|
33
tests/xmconfigdata/test-paravirt-net-vifname.xml
Normal file
33
tests/xmconfigdata/test-paravirt-net-vifname.xml
Normal file
@ -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>
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user