[libvirt] [PATCH v2 3/5] qemu: Advertise ACPI support for aarch64 guests

Andrea Bolognani posted 5 patches 8 years, 10 months ago
[libvirt] [PATCH v2 3/5] qemu: Advertise ACPI support for aarch64 guests
Posted by Andrea Bolognani 8 years, 10 months ago
So far, libvirt has assumed that only x86 supports ACPI,
but that's inaccurate since aarch64 supports it too.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
---
 src/qemu/qemu_capabilities.c                       | 28 ++++++++++++++++------
 .../caps_2.6.0-gicv2.aarch64.xml                   |  1 +
 .../caps_2.6.0-gicv3.aarch64.xml                   |  1 +
 .../qemuxml2argv-aarch64-gic-host.args             |  1 +
 .../qemuxml2argv-aarch64-gic-v2.args               |  1 +
 .../qemuxml2argv-aarch64-gic-v3.args               |  1 +
 6 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index d9a1f8b..d8ed88b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1043,13 +1043,17 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
 
         machines = NULL;
         nmachines = 0;
+    }
 
+    if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64) &&
+        virCapabilitiesAddGuestFeature(guest, "acpi", true, true) == NULL) {
+        goto cleanup;
     }
 
     if (ARCH_IS_X86(guestarch) &&
-        (virCapabilitiesAddGuestFeature(guest, "acpi", true, true) == NULL ||
-         virCapabilitiesAddGuestFeature(guest, "apic", true, false) == NULL))
+        virCapabilitiesAddGuestFeature(guest, "apic", true, false) == NULL) {
         goto cleanup;
+    }
 
     if ((guestarch == VIR_ARCH_I686) &&
         (virCapabilitiesAddGuestFeature(guest, "pae", true, false) == NULL ||
@@ -4096,10 +4100,15 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid, const c
                                 qmperr) < 0)
         goto cleanup;
 
-    /* -no-acpi is not supported on non-x86
-     * even if qemu reports it in -help */
-    if (!ARCH_IS_X86(qemuCaps->arch))
+    /* Older QEMU versions reported -no-acpi in the output of -help even
+     * though it was not supported by the architecture. The issue has since
+     * been fixed, but to maintain compatibility with all release we still
+     * need to filter out the capability for architectures that we know
+     * don't support the feature, eg. anything but x86 and aarch64 */
+    if (!ARCH_IS_X86(qemuCaps->arch) &&
+        qemuCaps->arch != VIR_ARCH_AARCH64) {
         virQEMUCapsClear(qemuCaps, QEMU_CAPS_NO_ACPI);
+    }
 
     /* virQEMUCapsExtractDeviceStr will only set additional caps if qemu
      * understands the 0.13.0+ notion of "-device driver,".  */
@@ -4220,9 +4229,14 @@ virQEMUCapsInitQMPArch(virQEMUCapsPtr qemuCaps,
 void
 virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps)
 {
-    /* ACPI/HPET/KVM PIT are x86 specific */
-    if (ARCH_IS_X86(qemuCaps->arch)) {
+    /* ACPI only works on x86 and aarch64 */
+    if (ARCH_IS_X86(qemuCaps->arch) ||
+        qemuCaps->arch == VIR_ARCH_AARCH64) {
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI);
+    }
+
+    /* HPET and KVM PIT are x86 specific */
+    if (ARCH_IS_X86(qemuCaps->arch)) {
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_HPET);
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT);
     }
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
index c1e4679..af3a8e7 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml
@@ -40,6 +40,7 @@
   <flag name='no-shutdown'/>
   <flag name='cache-unsafe'/>
   <flag name='ich9-ahci'/>
+  <flag name='no-acpi'/>
   <flag name='fsdev-readonly'/>
   <flag name='virtio-blk-pci.scsi'/>
   <flag name='drive-copy-on-read'/>
diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
index 20dfda2..4402ffa 100644
--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml
@@ -40,6 +40,7 @@
   <flag name='no-shutdown'/>
   <flag name='cache-unsafe'/>
   <flag name='ich9-ahci'/>
+  <flag name='no-acpi'/>
   <flag name='fsdev-readonly'/>
   <flag name='virtio-blk-pci.scsi'/>
   <flag name='drive-copy-on-read'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args
index 5fdaa08..23276ad 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args
@@ -15,4 +15,5 @@ QEMU_AUDIO_DRV=none \
 -nographic \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args
index 2caf1b9..f79c1c6 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args
@@ -15,4 +15,5 @@ QEMU_AUDIO_DRV=none \
 -nographic \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args
index 3ae8e5f..fce9308 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args
@@ -15,4 +15,5 @@ QEMU_AUDIO_DRV=none \
 -nographic \
 -nodefaults \
 -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \
+-no-acpi \
 -boot c
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 3/5] qemu: Advertise ACPI support for aarch64 guests
Posted by John Ferlan 8 years, 10 months ago

On 03/29/2017 10:08 AM, Andrea Bolognani wrote:
> So far, libvirt has assumed that only x86 supports ACPI,
> but that's inaccurate since aarch64 supports it too.
> 
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
> ---
>  src/qemu/qemu_capabilities.c                       | 28 ++++++++++++++++------
>  .../caps_2.6.0-gicv2.aarch64.xml                   |  1 +
>  .../caps_2.6.0-gicv3.aarch64.xml                   |  1 +
>  .../qemuxml2argv-aarch64-gic-host.args             |  1 +
>  .../qemuxml2argv-aarch64-gic-v2.args               |  1 +
>  .../qemuxml2argv-aarch64-gic-v3.args               |  1 +
>  6 files changed, 26 insertions(+), 7 deletions(-)
> 

ACK

John


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 3/5] qemu: Advertise ACPI support for aarch64 guests
Posted by Ján Tomko 8 years, 10 months ago
On Wed, Mar 29, 2017 at 04:08:54PM +0200, Andrea Bolognani wrote:
>So far, libvirt has assumed that only x86 supports ACPI,
>but that's inaccurate since aarch64 supports it too.
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
>---
> src/qemu/qemu_capabilities.c                       | 28 ++++++++++++++++------
> .../caps_2.6.0-gicv2.aarch64.xml                   |  1 +
> .../caps_2.6.0-gicv3.aarch64.xml                   |  1 +
> .../qemuxml2argv-aarch64-gic-host.args             |  1 +
> .../qemuxml2argv-aarch64-gic-v2.args               |  1 +
> .../qemuxml2argv-aarch64-gic-v3.args               |  1 +
> 6 files changed, 26 insertions(+), 7 deletions(-)
>

>@@ -4096,10 +4100,15 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid, const c
>                                 qmperr) < 0)
>         goto cleanup;
>
>-    /* -no-acpi is not supported on non-x86
>-     * even if qemu reports it in -help */
>-    if (!ARCH_IS_X86(qemuCaps->arch))
>+    /* Older QEMU versions reported -no-acpi in the output of -help even
>+     * though it was not supported by the architecture. The issue has since
>+     * been fixed, but to maintain compatibility with all release we still
>+     * need to filter out the capability for architectures that we know
>+     * don't support the feature, eg. anything but x86 and aarch64 */
>+    if (!ARCH_IS_X86(qemuCaps->arch) &&
>+        qemuCaps->arch != VIR_ARCH_AARCH64) {
>         virQEMUCapsClear(qemuCaps, QEMU_CAPS_NO_ACPI);
>+    }

This adjustment is dead code.

aarch64 was introduced in QEMU 1.6.0, but we stopped parsing help
since QEMU 1.2.0.

Jan
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 3/5] qemu: Advertise ACPI support for aarch64 guests
Posted by Andrea Bolognani 8 years, 10 months ago
On Wed, 2017-04-05 at 12:00 +0200, Ján Tomko wrote:
[...]
> > @@ -4096,10 +4100,15 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid, const c
> >                                 qmperr) < 0)
> >         goto cleanup;
> > 
> > -    /* -no-acpi is not supported on non-x86
> > -     * even if qemu reports it in -help */
> > -    if (!ARCH_IS_X86(qemuCaps->arch))
> > +    /* Older QEMU versions reported -no-acpi in the output of -help even
> > +     * though it was not supported by the architecture. The issue has since
> > +     * been fixed, but to maintain compatibility with all release we still
> > +     * need to filter out the capability for architectures that we know
> > +     * don't support the feature, eg. anything but x86 and aarch64 */
> > +    if (!ARCH_IS_X86(qemuCaps->arch) &&
> > +        qemuCaps->arch != VIR_ARCH_AARCH64) {
> >         virQEMUCapsClear(qemuCaps, QEMU_CAPS_NO_ACPI);
> > +    }
> 
> This adjustment is dead code.
> 
> aarch64 was introduced in QEMU 1.6.0, but we stopped parsing help
> since QEMU 1.2.0.

As mentioned in response to John's review of v1, I changed
this so that there are no inconsistencies between the QMP
and non-QMP codepaths that could confuse people as to which
behavior is the correct one down the line, but if you want
me to get rid of it I can revert the code change and settle
with fleshing out the comment further.

-- 
Andrea Bolognani / Red Hat / Virtualization

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