From: Daniel P. Berrange Date: Fri, 30 Jan 2009 17:17:58 +0000 (+0000) Subject: Fix ifname= passing to QEMU for type=ethernet network config X-Git-Tag: LIBVIRT_0_6_0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6ef2e0055398135c88934f9d0a5f89d468a6534;p=thirdparty%2Flibvirt.git Fix ifname= passing to QEMU for type=ethernet network config --- diff --git a/ChangeLog b/ChangeLog index 34ead5eada..fac7ab593e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Jan 30 17:16:22 GMT 2009 Daniel P. Berrange + + * src/qemu_conf.c: Fix ifname= handling for type=ethernet + networking config to avoid literal (null) + * tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c, + tests/qemuxml2argvdata/: Add test case for ethernet + interface config + Fri Jan 30 17:12:22 GMT 2009 Daniel P. Berrange Support cache diff --git a/src/qemu_conf.c b/src/qemu_conf.c index ca213839f9..d86b18946e 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -1147,11 +1147,18 @@ int qemudBuildCommandLine(virConnectPtr conn, case VIR_DOMAIN_NET_TYPE_ETHERNET: { char arg[PATH_MAX]; - if (snprintf(arg, PATH_MAX-1, "tap,ifname=%s,script=%s,vlan=%d", - net->ifname, - net->data.ethernet.script, - vlan) >= (PATH_MAX-1)) - goto error; + if (net->ifname) { + if (snprintf(arg, PATH_MAX-1, "tap,ifname=%s,script=%s,vlan=%d", + net->ifname, + net->data.ethernet.script, + vlan) >= (PATH_MAX-1)) + goto error; + } else { + if (snprintf(arg, PATH_MAX-1, "tap,script=%s,vlan=%d", + net->data.ethernet.script, + vlan) >= (PATH_MAX-1)) + goto error; + } ADD_ARG_LIT(arg); } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args new file mode 100644 index 0000000000..89daa9911c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args @@ -0,0 +1 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net tap,ifname=nic02,script=/etc/qemu-ifup,vlan=0 -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml new file mode 100644 index 0000000000..9ca4295866 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml @@ -0,0 +1,27 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219200 + 219200 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + +