Converting ENUMS to str can be user friendly though it can be problematic between libvirt versions. In particular when some translated type will introduce a new constant to the ENUM libvirt-dbus will fail with: size of array ‘_GStaticAssertCompileTimeAssertion_5’ is negative Since it's not main use case of livirt-dbus API to be invoked interactively by user, having all ENUM types passed as unsigned int is preferable to avoid the previous issue. Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Connect.xml | 2 +- src/connect.c | 18 +----------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index ee7bfdc..7249fa4 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -37,7 +37,7 @@ value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectCompareCPU"/> <arg name="xmlDesc" type="s" direction="in"/> <arg name="flags" type="u" direction="in"/> - <arg name="compareResult" type="s" direction="out"/> + <arg name="compareResult" type="u" direction="out"/> </method> <method name="DomainCreateXML"> <annotation name="org.gtk.GDBus.DocString" diff --git a/src/connect.c b/src/connect.c index 5e577e4..e21bfab 100644 --- a/src/connect.c +++ b/src/connect.c @@ -6,13 +6,6 @@ #include <glib/gprintf.h> -VIRT_DBUS_ENUM_DECL(virtDBusConnectCPUCompareResult) -VIRT_DBUS_ENUM_IMPL(virtDBusConnectCPUCompareResult, - VIR_CPU_COMPARE_LAST, - "incompatible", - "identical", - "superset") - static gint virtDBusConnectCredType[] = { VIR_CRED_AUTHNAME, VIR_CRED_ECHOPROMPT, @@ -263,7 +256,6 @@ virtDBusConnectCompareCPU(GVariant *inArgs, const gchar *xmlDesc; guint flags; gint compareResult; - const gchar* compareResultStr; g_variant_get(inArgs, "(&su)", &xmlDesc, &flags); @@ -274,15 +266,7 @@ virtDBusConnectCompareCPU(GVariant *inArgs, if (compareResult < 0) return virtDBusUtilSetLastVirtError(error); - compareResultStr = virtDBusConnectCPUCompareResultTypeToString(compareResult); - if (!compareResultStr) { - g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT, - "Can't format virCPUCompareResult '%d' to string.", - compareResult); - return; - } - - *outArgs = g_variant_new("(s)", compareResultStr); + *outArgs = g_variant_new("(u)", compareResult); } static void -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list