render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From 56208ffe874c42274add74ba412059345e5c018d Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <56208ffe874c42274add74ba412059345e5c018d@dist-git>
3e5111
From: Andrea Bolognani <abologna@redhat.com>
3e5111
Date: Tue, 4 Apr 2017 14:59:27 +0200
3e5111
Subject: [PATCH] qemu: Split virQEMUCapsInitArchQMPBasic()
3e5111
3e5111
Instead of having a single function that probes the
3e5111
architecture from the monitor and then sets a bunch of
3e5111
basic capabilities based on it, have a separate function
3e5111
for each part: virQEMUCapsInitQMPArch() only sets the
3e5111
architecture, and virQEMUCapsInitQMPBasicArch() only sets
3e5111
the capabilities.
3e5111
3e5111
This split will be useful later on, when we will want to
3e5111
set basic capabilities from the test suite without having
3e5111
to go through the pain of mocking the monitor.
3e5111
3e5111
(cherry picked from commit a8fc7ef83439c235a3b1115cf6d7b80e096f4af2)
3e5111
3e5111
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
3e5111
3e5111
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
3e5111
---
3e5111
 src/qemu/qemu_capabilities.c | 42 +++++++++++++++++++++++++++++++-----------
3e5111
 1 file changed, 31 insertions(+), 11 deletions(-)
3e5111
3e5111
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
3e5111
index 83ebcd020..b568a0f5e 100644
3e5111
--- a/src/qemu/qemu_capabilities.c
3e5111
+++ b/src/qemu/qemu_capabilities.c
3e5111
@@ -4262,18 +4262,25 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps)
3e5111
     virQEMUCapsSet(qemuCaps, QEMU_CAPS_DISPLAY);
3e5111
 }
3e5111
 
3e5111
-/* Capabilities that are architecture depending
3e5111
- * initialized for QEMU.
3e5111
+
3e5111
+/**
3e5111
+ * virQEMUCapsInitQMPArch:
3e5111
+ * @qemuCaps: QEMU capabilities
3e5111
+ * @mon: QEMU monitor
3e5111
+ *
3e5111
+ * Initialize the architecture for @qemuCaps by asking @mon.
3e5111
+ *
3e5111
+ * Returns: 0 on success, <0 on failure
3e5111
  */
3e5111
 static int
3e5111
-virQEMUCapsInitArchQMPBasic(virQEMUCapsPtr qemuCaps,
3e5111
+virQEMUCapsInitQMPArch(virQEMUCapsPtr qemuCaps,
3e5111
                             qemuMonitorPtr mon)
3e5111
 {
3e5111
     char *archstr = NULL;
3e5111
     int ret = -1;
3e5111
 
3e5111
     if (!(archstr = qemuMonitorGetTargetArch(mon)))
3e5111
-        return -1;
3e5111
+        goto cleanup;
3e5111
 
3e5111
     if ((qemuCaps->arch = virQEMUCapsArchFromString(archstr)) == VIR_ARCH_NONE) {
3e5111
         virReportError(VIR_ERR_INTERNAL_ERROR,
3e5111
@@ -4281,18 +4288,29 @@ virQEMUCapsInitArchQMPBasic(virQEMUCapsPtr qemuCaps,
3e5111
         goto cleanup;
3e5111
     }
3e5111
 
3e5111
+    ret = 0;
3e5111
+
3e5111
+ cleanup:
3e5111
+    VIR_FREE(archstr);
3e5111
+    return ret;
3e5111
+}
3e5111
+
3e5111
+
3e5111
+/**
3e5111
+ * virQEMUCapsInitQMPBasicArch:
3e5111
+ * @qemuCaps: QEMU capabilities
3e5111
+ *
3e5111
+ * Initialize @qemuCaps with basic architecture-dependent capabilities.
3e5111
+ */
3e5111
+static void
3e5111
+virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps)
3e5111
+{
3e5111
     /* ACPI/HPET/KVM PIT are x86 specific */
3e5111
     if (ARCH_IS_X86(qemuCaps->arch)) {
3e5111
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI);
3e5111
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_HPET);
3e5111
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT);
3e5111
     }
3e5111
-
3e5111
-    ret = 0;
3e5111
-
3e5111
- cleanup:
3e5111
-    VIR_FREE(archstr);
3e5111
-    return ret;
3e5111
 }
3e5111
 
3e5111
 
3e5111
@@ -4517,9 +4535,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
3e5111
 
3e5111
     virQEMUCapsInitQMPBasic(qemuCaps);
3e5111
 
3e5111
-    if (virQEMUCapsInitArchQMPBasic(qemuCaps, mon) < 0)
3e5111
+    if (virQEMUCapsInitQMPArch(qemuCaps, mon) < 0)
3e5111
         goto cleanup;
3e5111
 
3e5111
+    virQEMUCapsInitQMPBasicArch(qemuCaps);
3e5111
+
3e5111
     /* USB option is supported v1.3.0 onwards */
3e5111
     if (qemuCaps->version >= 1003000)
3e5111
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_USB_OPT);
3e5111
-- 
3e5111
2.12.2
3e5111