From 6df29d0816895b2bf55d6d438afeca7bc71646d2 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 16 Aug 2017 15:44:35 +0200
Subject: [PATCH] qemu: capabilities: Tolerate missing @qemuCaps in
 virQEMUCapsSupportsGICVersion

Report the given GIC version as unsupported if @qemuCapsi is NULL. This
will be helpful to run post parse callbacks even if qemu is not
currently installed.
---
 src/qemu/qemu_capabilities.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f05e7650a2..38a9f09f53 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5676,7 +5676,8 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
  * @version: GIC version
  *
  * Checks the QEMU binary with capabilities @qemuCaps supports a specific
- * GIC version for a domain of type @virtType.
+ * GIC version for a domain of type @virtType. If @qemuCaps is NULL, the GIC
+ * @version is considered unsupported.
  *
  * Returns: true if the binary supports the requested GIC version, false
  *          otherwise
@@ -5688,6 +5689,9 @@ virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps,
 {
     size_t i;
 
+    if (!qemuCaps)
+        return false;
+
     for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
         virGICCapabilityPtr cap = &(qemuCaps->gicCapabilities[i]);