]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix ifname= passing to QEMU for type=ethernet network config
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 30 Jan 2009 17:17:58 +0000 (17:17 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 30 Jan 2009 17:17:58 +0000 (17:17 +0000)
ChangeLog
src/qemu_conf.c
tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-net-eth.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c

index 34ead5eadafcf609e0a1189feecf6a79594ff47f..fac7ab593e82836e7c447762d5417ebbce76cee8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Jan 30 17:16:22 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
+
+       * 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 <berrange@redhat.com>
 
        Support <driver cache='none|writeback|writethrough'/> cache
index ca213839f920e69931a2fbe1e7e3080791e2bf35..d86b18946e79187d04996022e02404ddaa635a86 100644 (file)
@@ -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 (file)
index 0000000..89daa99
--- /dev/null
@@ -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 (file)
index 0000000..9ca4295
--- /dev/null
@@ -0,0 +1,27 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219200</memory>
+  <currentMemory>219200</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+    </disk>
+    <interface type='ethernet'>
+      <mac address='00:11:22:33:44:55'/>
+      <script path='/etc/qemu-ifup'/>
+      <target dev='nic02'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args
new file mode 100644 (file)
index 0000000..9aa0e13
--- /dev/null
@@ -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,script=/etc/qemu-ifup,vlan=0 -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml
new file mode 100644 (file)
index 0000000..5856c3d
--- /dev/null
@@ -0,0 +1,26 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219200</memory>
+  <currentMemory>219200</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+    </disk>
+    <interface type='ethernet'>
+      <mac address='00:11:22:33:44:55'/>
+      <script path='/etc/qemu-ifup'/>
+    </interface>
+  </devices>
+</domain>
index dd477ae19e59e6146fc0829a7f420619765e6f39..90b474018c16ea7268c74ca76c60ec6f17a70142 100644 (file)
@@ -224,6 +224,8 @@ mymain(int argc, char **argv)
         QEMUD_CMD_FLAG_UUID | QEMUD_CMD_FLAG_DOMID);
     DO_TEST("net-user", 0);
     DO_TEST("net-virtio", 0);
+    DO_TEST("net-eth", 0);
+    DO_TEST("net-eth-ifname", 0);
 
     DO_TEST("serial-vc", 0);
     DO_TEST("serial-pty", 0);
index 41cdc8b49705d72af6599a1eb21b8a6344d03ef7..ab9943d6ec38c4d73f3c483064b03db3b07cc878 100644 (file)
@@ -111,6 +111,8 @@ mymain(int argc, char **argv)
     DO_TEST("misc-no-reboot");
     DO_TEST("net-user");
     DO_TEST("net-virtio");
+    DO_TEST("net-eth");
+    DO_TEST("net-eth-ifname");
     DO_TEST("sound");
 
     DO_TEST("serial-vc");