From 27e32e0f3d4d5840cee7e361bdff94c68ae181e2 Mon Sep 17 00:00:00 2001 From: Pranavkumar Sawargaonkar Date: Thu, 2 Jan 2014 16:12:56 +0530 Subject: [PATCH] AArch64: Porting of armv7l conditons to run qemu for aarch64. AArch64 qemu has similar behavior as armv7l, like use of mmio etc. This patch adds similar bypass checks what we have for armv7l to aarch64. E.g. we are enabling mmio transport for Nicdev. Making addDefaultUSB and addDefaultMemballoon to false etc. V3: - Adding missing domain rng schema for aarcg64 and test case in testutilsqemu.c which was causing test suite failure while running make check. V2: - Added testcase to qemuxml2argvtest as suggested during review comments of V1. V1: - Initial patch. Signed-off-by: Anup Patel Signed-off-by: Pranavkumar Sawargaonkar --- docs/schemas/domaincommon.rng | 19 ++++++++ src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_command.c | 8 ++-- src/qemu/qemu_domain.c | 4 ++ .../qemuxml2argv-aarch64-virt-virtio.args | 14 ++++++ .../qemuxml2argv-aarch64-virt-virtio.xml | 45 +++++++++++++++++++ tests/qemuxml2argvtest.c | 5 +++ tests/testutilsqemu.c | 30 +++++++++++++ 8 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index be32c6bc6e..86a60c9fb3 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -305,6 +305,7 @@ + hvm @@ -432,6 +433,24 @@ + + + + + + aarch64 + + + + + + + [a-zA-Z0-9_\.\-]+ + + + + + diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 4f64f878e5..ed182e0022 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2917,7 +2917,7 @@ virQEMUCapsSupportsChardev(virDomainDefPtr def, !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) return false; - if (def->os.arch != VIR_ARCH_ARMV7L) + if ((def->os.arch != VIR_ARCH_ARMV7L) && (def->os.arch != VIR_ARCH_AARCH64)) return true; /* This may not be true for all ARM machine types, but at least diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2a64cd1f2e..35b7c6759a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -427,7 +427,8 @@ qemuDomainSupportsNicdev(virDomainDefPtr def, return false; /* non-virtio ARM nics require legacy -net nic */ - if (def->os.arch == VIR_ARCH_ARMV7L && + if (((def->os.arch == VIR_ARCH_ARMV7L) || + (def->os.arch == VIR_ARCH_AARCH64)) && net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO) return false; @@ -1340,7 +1341,8 @@ static int qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { - if (def->os.arch == VIR_ARCH_ARMV7L && + if (((def->os.arch == VIR_ARCH_ARMV7L) || + (def->os.arch == VIR_ARCH_AARCH64)) && (STRPREFIX(def->os.machine, "vexpress-") || STREQ(def->os.machine, "virt")) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_MMIO)) { @@ -1872,7 +1874,7 @@ cleanup: static bool qemuDomainSupportsPCI(virDomainDefPtr def) { - if (def->os.arch != VIR_ARCH_ARMV7L) + if ((def->os.arch != VIR_ARCH_ARMV7L) && (def->os.arch != VIR_ARCH_AARCH64)) return true; if (STREQ(def->os.machine, "versatilepb")) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e964c752bc..c947e2e956 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -727,6 +727,10 @@ qemuDomainDefPostParse(virDomainDefPtr def, addDefaultUSB = false; addDefaultMemballoon = false; break; + case VIR_ARCH_AARCH64: + addDefaultUSB = false; + addDefaultMemballoon = false; + break; case VIR_ARCH_ALPHA: case VIR_ARCH_PPC: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.args new file mode 100644 index 0000000000..afd6e41a5d --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-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-aarch64 -S -M virt -m 1024 -smp 1 -nographic \ +-nodefconfig -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \ +-boot c -kernel /aarch64.kernel -initrd /aarch64.initrd -append \ +'earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait' \ +-dtb /aarch64.dtb -device virtio-serial-device,id=virtio-serial0 -usb \ +-drive file=/aarch64.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-aarch64-virt-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml new file mode 100644 index 0000000000..184b62cd45 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-virt-virtio.xml @@ -0,0 +1,45 @@ + + aarch64test + 496d7ea8-9739-544b-4ebd-ef08be936e8b + 1048576 + 1048576 + 1 + + hvm + /aarch64.kernel + /aarch64.initrd + /aarch64.dtb + earlyprintk console=ttyAMA0,115200n8 rw root=/dev/vda rootwait + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-aarch64 + + + + + + + + + + + + + + + + /dev/random + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5a2bfccf19..b90f0e79c2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1302,6 +1302,11 @@ mymain(void) QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE_VIRTIO_MMIO, QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM); + DO_TEST("aarch64-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); + DO_TEST("kvm-pit-device", QEMU_CAPS_KVM_PIT_TICK_POLICY); DO_TEST("kvm-pit-delay", QEMU_CAPS_NO_KVM_PIT); DO_TEST("kvm-pit-device", QEMU_CAPS_NO_KVM_PIT, diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 92433efacf..44e7e9d922 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -175,6 +175,33 @@ error: return -1; } +static int testQemuAddAARCH64Guest(virCapsPtr caps) +{ + static const char *machines[] = { "virt"}; + virCapsGuestMachinePtr *capsmachines = NULL; + virCapsGuestPtr guest; + + capsmachines = virCapabilitiesAllocMachines(machines, + ARRAY_CARDINALITY(machines)); + if (!capsmachines) + goto error; + + guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_AARCH64, + "/usr/bin/qemu-system-aarch64", NULL, + ARRAY_CARDINALITY(machines), + capsmachines); + if (!guest) + goto error; + + if (!virCapabilitiesAddGuestDomain(guest, "qemu", NULL, NULL, 0, NULL)) + goto error; + + return 0; + +error: + virCapabilitiesFreeMachines(capsmachines, ARRAY_CARDINALITY(machines)); + return -1; +} virCapsPtr testQemuCapsInit(void) { virCapsPtr caps; @@ -303,6 +330,9 @@ virCapsPtr testQemuCapsInit(void) { if (testQemuAddArmGuest(caps)) goto cleanup; + if (testQemuAddAARCH64Guest(caps)) + goto cleanup; + if (virTestGetDebug()) { char *caps_str;