[RESEND PATCH] qemu: Add support for virt machine type with virtio-mmio devices on armv7

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These changes allow the correct virtio-blk-device and virtio-net-device
devices to be used for the 'virt' machine type for armv7 rather than the
PCI virtio devices.

A test case was added to qemuxml2argvtest for this change.

Signed-off-by: Clark Laughlin <clark.laughlin@xxxxxxxxxx>
---
Resend with test case added
---
 src/qemu/qemu_command.c                            |  4 +-
 src/qemu/qemu_domain.c                             |  3 ++
 .../qemuxml2argv-arm-virt-virtio.args              | 14 +++++++
 .../qemuxml2argv-arm-virt-virtio.xml               | 45 ++++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |  5 +++
 5 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 63e235d..901120e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1335,12 +1335,14 @@ cleanup:
 
     return ret;
 }
+
 static int
 qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def,
                                        virQEMUCapsPtr qemuCaps)
 {
     if (def->os.arch == VIR_ARCH_ARMV7L &&
-        STRPREFIX(def->os.machine, "vexpress-") &&
+        (STRPREFIX(def->os.machine, "vexpress-") ||
+            STREQ(def->os.machine, "virt")) &&
         virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO)) {
         qemuDomainPrimeVirtioDeviceAddresses(
             def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 81d0ba9..346fec3 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -797,6 +797,9 @@ qemuDomainDefaultNetModel(const virDomainDef *def)
         if (STREQ(def->os.machine, "versatilepb"))
             return "smc91c111";
 
+        if (STREQ(def->os.machine, "virt"))
+            return "virtio";
+
         /* Incomplete. vexpress (and a few others) use this, but not all
          * arm boards */
         return "lan9118";
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args
new file mode 100644
index 0000000..5206ad8
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.args
@@ -0,0 +1,14 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-arm -S -M virt -m 1024 -smp 1 -nographic \
+-nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
+-boot c -kernel /arm.kernel -initrd /arm.initrd -append \
+'console=ttyAMA0,115200n8 rw root=/dev/vda rootwait physmap.enabled=0' \
+-dtb /arm.dtb -device virtio-serial-device,id=virtio-serial0 -usb \
+-drive file=/arm.raw,if=none,id=drive-virtio-disk0 \
+-device virtio-blk-device,drive=drive-virtio-disk0,id=virtio-disk0 \
+-device virtio-net-device,vlan=0,id=net0,mac=52:54:00:09:a4:37 \
+-net user,vlan=0,name=hostnet0 -serial pty -chardev pty,id=charconsole1 \
+-device virtconsole,chardev=charconsole1,id=console1 \
+-device virtio-balloon-device,id=balloon0 \
+-object rng-random,id=rng0,filename=/dev/random \
+-device virtio-rng-device,rng=rng0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.xml
new file mode 100644
index 0000000..913c96e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-arm-virt-virtio.xml
@@ -0,0 +1,45 @@
+<domain type="qemu">
+  <name>armtest</name>
+  <uuid>496d7ea8-9739-544b-4ebd-ef08be936e6a</uuid>
+  <memory>1048576</memory>
+  <currentMemory>1048576</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch="armv7l" machine="virt">hvm</type>
+    <kernel>/arm.kernel</kernel>
+    <initrd>/arm.initrd</initrd>
+    <dtb>/arm.dtb</dtb>
+    <cmdline>console=ttyAMA0,115200n8 rw root=/dev/vda rootwait physmap.enabled=0</cmdline>
+  </os>
+  <features>
+    <acpi/>
+    <apic/>
+    <pae/>
+  </features>
+  <clock offset="utc"/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>restart</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-arm</emulator>
+    <disk type='file' device='disk'>
+      <source file='/arm.raw'/>
+      <target dev='vda' bus='virtio'/>
+    </disk>
+    <interface type='user'>
+      <mac address='52:54:00:09:a4:37'/>
+      <model type='virtio'/>
+    </interface>
+    <console type='pty'/>
+    <console type='pty'>
+      <target type='virtio' port='0'/>
+    </console>
+    <memballoon model='virtio'/>
+    <!--
+      This actually doesn't work in practice because vexpress only has
+      4 virtio slots available, rng makes 5 -->
+    <rng model='virtio'>
+      <backend model='random'>/dev/random</backend>
+    </rng>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b14e713..fde78bc 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1103,6 +1103,11 @@ mymain(void)
             QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
 
+    DO_TEST("arm-virt-virtio",
+            QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
+            QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE_VIRTIO_MMIO,
+            QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
+
     virObjectUnref(driver.config);
     virObjectUnref(driver.caps);
     virObjectUnref(driver.xmlopt);
-- 
1.8.1.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]