898951
From 4b31aeaaa431a2a0a85bedf205358c2499a8f35d Mon Sep 17 00:00:00 2001
898951
Message-Id: <4b31aeaaa431a2a0a85bedf205358c2499a8f35d@dist-git>
898951
From: Michal Privoznik <mprivozn@redhat.com>
898951
Date: Mon, 19 Jan 2015 12:43:42 +0100
898951
Subject: [PATCH] conf: Format interface's driver more frequently
898951
898951
RHEL-7.0.z: https://bugzilla.redhat.com/show_bug.cgi?id=1183447
898951
RHEL-7.1:   https://bugzilla.redhat.com/show_bug.cgi?id=1128751
898951
898951
There's this <driver/> element under <interface/> which can have
898951
several attributes. However, the driver element is currently formated
898951
only if the driver's name or txmode has been specified. This makes
898951
only a little sense as we parse even partial <driver/>, for instance:
898951
898951
    <interface type='user'>
898951
      <mac address='52:54:00:e5:48:58'/>
898951
      <model type='virtio'/>
898951
      <driver ioeventfd='on' event_idx='on' queues='5'/>
898951
    </interface>
898951
898951
But such XML would never get formatted back.
898951
898951
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
898951
(cherry picked from commit 3085702b5461d3b0b057c37cf5fbff432244f529)
898951
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
898951
---
898951
 src/conf/domain_conf.c                             |  4 +-
898951
 .../qemuxml2argv-interface-driver.xml              | 51 ++++++++++++++++++++++
898951
 tests/qemuxml2xmltest.c                            |  1 +
898951
 3 files changed, 55 insertions(+), 1 deletion(-)
898951
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-interface-driver.xml
898951
898951
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
898951
index bb2e7ef..922c5e6 100644
898951
--- a/src/conf/domain_conf.c
898951
+++ b/src/conf/domain_conf.c
898951
@@ -15387,7 +15387,9 @@ virDomainNetDefFormat(virBufferPtr buf,
898951
         virBufferEscapeString(buf, "<model type='%s'/>\n",
898951
                               def->model);
898951
         if (STREQ(def->model, "virtio") &&
898951
-            (def->driver.virtio.name || def->driver.virtio.txmode)) {
898951
+            (def->driver.virtio.name || def->driver.virtio.txmode ||
898951
+             def->driver.virtio.ioeventfd || def->driver.virtio.event_idx ||
898951
+             def->driver.virtio.queues)) {
898951
             virBufferAddLit(buf, "
898951
             if (def->driver.virtio.name) {
898951
                 virBufferAsprintf(buf, " name='%s'",
898951
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-interface-driver.xml b/tests/qemuxml2argvdata/qemuxml2argv-interface-driver.xml
898951
new file mode 100644
898951
index 0000000..ec5ab61
898951
--- /dev/null
898951
+++ b/tests/qemuxml2argvdata/qemuxml2argv-interface-driver.xml
898951
@@ -0,0 +1,51 @@
898951
+<domain type='qemu'>
898951
+  <name>test</name>
898951
+  <uuid>15d091de-0181-456b-9554-e4382dc1f1ab</uuid>
898951
+  <memory unit='KiB'>1048576</memory>
898951
+  <currentMemory unit='KiB'>1048576</currentMemory>
898951
+  <vcpu placement='static'>1</vcpu>
898951
+  <os>
898951
+    <type arch='x86_64' machine='pc-0.13'>hvm</type>
898951
+    <boot dev='cdrom'/>
898951
+    <boot dev='hd'/>
898951
+    <bootmenu enable='yes'/>
898951
+  </os>
898951
+  <clock offset='utc'/>
898951
+  <on_poweroff>destroy</on_poweroff>
898951
+  <on_reboot>restart</on_reboot>
898951
+  <on_crash>restart</on_crash>
898951
+  <devices>
898951
+    <emulator>/usr/bin/qemu</emulator>
898951
+    <disk type='file' device='disk'>
898951
+      <driver name='qemu' type='qcow2' event_idx='on'/>
898951
+      <source file='/var/lib/libvirt/images/f14.img'/>
898951
+      <target dev='vda' bus='virtio'/>
898951
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
898951
+    </disk>
898951
+    <disk type='file' device='cdrom'>
898951
+      <driver name='qemu' type='raw'/>
898951
+      <source file='/var/lib/libvirt/Fedora-14-x86_64-Live-KDE.iso'/>
898951
+      <target dev='hdc' bus='ide'/>
898951
+      <readonly/>
898951
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
898951
+    </disk>
898951
+    <controller type='usb' index='0'/>
898951
+    <controller type='virtio-serial' index='0'>
898951
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
898951
+    </controller>
898951
+    <controller type='ide' index='0'/>
898951
+    <controller type='pci' index='0' model='pci-root'/>
898951
+    <interface type='user'>
898951
+      <mac address='52:54:00:e5:48:58'/>
898951
+      <model type='virtio'/>
898951
+      <driver ioeventfd='on' event_idx='on' queues='5'/>
898951
+    </interface>
898951
+    <serial type='pty'>
898951
+      <target port='0'/>
898951
+    </serial>
898951
+    <console type='pty'>
898951
+      <target type='serial' port='0'/>
898951
+    </console>
898951
+    <memballoon model='virtio'/>
898951
+  </devices>
898951
+</domain>
898951
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
898951
index d16fdc3..11ac108 100644
898951
--- a/tests/qemuxml2xmltest.c
898951
+++ b/tests/qemuxml2xmltest.c
898951
@@ -255,6 +255,7 @@ mymain(void)
898951
     DO_TEST("lease");
898951
     DO_TEST("event_idx");
898951
     DO_TEST("vhost_queues");
898951
+    DO_TEST("interface-driver");
898951
     DO_TEST("virtio-lun");
898951
 
898951
     DO_TEST("usb-redir");
898951
-- 
898951
2.2.1
898951