[PATCH] qemu: Make probing for events declarative

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

 



---
 src/qemu/qemu_capabilities.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 406dca9..7cac6e4 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1316,6 +1316,11 @@ struct virQEMUCapsStringFlags {
 };
 
 
+struct virQEMUCapsStringFlags virQEMUCapsEvents[] = {
+    { "BALLOON_CHANGE", QEMU_CAPS_BALLOON_EVENT },
+    { "SPICE_MIGRATE_COMPLETED", QEMU_CAPS_SEAMLESS_MIGRATION },
+};
+
 struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "hda-duplex", QEMU_CAPS_HDA_DUPLEX },
     { "hda-micro", QEMU_CAPS_HDA_MICRO },
@@ -2014,21 +2019,15 @@ virQEMUCapsProbeQMPEvents(virQEMUCapsPtr qemuCaps,
 {
     char **events = NULL;
     int nevents;
-    size_t i;
 
     if ((nevents = qemuMonitorGetEvents(mon, &events)) < 0)
         return -1;
 
-    for (i = 0; i < nevents; i++) {
-        char *name = events[i];
-
-        if (STREQ(name, "BALLOON_CHANGE"))
-            virQEMUCapsSet(qemuCaps, QEMU_CAPS_BALLOON_EVENT);
-        if (STREQ(name, "SPICE_MIGRATE_COMPLETED"))
-            virQEMUCapsSet(qemuCaps, QEMU_CAPS_SEAMLESS_MIGRATION);
-        VIR_FREE(name);
-    }
-    VIR_FREE(events);
+    virQEMUCapsProcessStringFlags(qemuCaps,
+                                  ARRAY_CARDINALITY(virQEMUCapsEvents),
+                                  virQEMUCapsEvents,
+                                  nevents, events);
+    virQEMUCapsFreeStringList(nevents, events);
 
     return 0;
 }
-- 
1.8.2.1

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