[PATCH 2/4] qemu: Add virQEMUCapsSetGICCapabilities()

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

 



For use in the test suite.
---
 src/qemu/qemu_capabilities.c | 29 +++++++++++++++++++++++++----
 src/qemu/qemu_capabilities.h |  5 +++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 1bddf43..f0f641d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2387,6 +2387,30 @@ int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
 }
 
 
+/**
+ * virQEMUCapsSetGICCapabilities:
+ * @qemuCaps: QEMU capabilities
+ * @capabilities: GIC capabilities
+ * @ncapabilities: number of GIC capabilities
+ *
+ * Set the GIC capabilities for @qemuCaps.
+ *
+ * The ownership of @capabilities is taken away from the caller, ie. this
+ * function will not make a copy of @capabilities, so releasing that memory
+ * after it's been called is a bug.
+ */
+void
+virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,
+                              virGICCapability *capabilities,
+                              size_t ncapabilities)
+{
+    VIR_FREE(qemuCaps->gicCapabilities);
+
+    qemuCaps->gicCapabilities = capabilities;
+    qemuCaps->ngicCapabilities = ncapabilities;
+}
+
+
 static int
 virQEMUCapsProbeQMPCommands(virQEMUCapsPtr qemuCaps,
                             qemuMonitorPtr mon)
@@ -2738,10 +2762,7 @@ virQEMUCapsProbeQMPGICCapabilities(virQEMUCapsPtr qemuCaps,
     if ((ncaps = qemuMonitorGetGICCapabilities(mon, &caps)) < 0)
         return -1;
 
-    VIR_FREE(qemuCaps->gicCapabilities);
-
-    qemuCaps->gicCapabilities = caps;
-    qemuCaps->ngicCapabilities = ncaps;
+    virQEMUCapsSetGICCapabilities(qemuCaps, caps, ncaps);
 
     return 0;
 }
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index e7d0a60..3562c44 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -426,6 +426,11 @@ bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps);
 void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
                                     const char *machineType);
 
+/* Only for use by test suite */
+void virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,
+                                   virGICCapability *capabilities,
+                                   size_t ncapabilities);
+
 virQEMUCapsCachePtr virQEMUCapsCacheNew(const char *libDir,
                                         const char *cacheDir,
                                         uid_t uid, gid_t gid);
-- 
2.5.5

--
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]