Re: [dbus PATCH v2 1/9] Abandon usage of all *TypeToString functions in domain.c

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

 



On Fri, May 04, 2018 at 10:38:27AM +0200, Katerina Koukiou wrote:
> Converting ENUMS to str can be user friendly though
> it can be problematic in matters of backward compatibility.
> 
> In particular when some ENUM in libvirt API will introduce a
> new constant, libvirt-dbus will fail with:
> 
> size of array ‘_GStaticAssertCompileTimeAssertion_5’ is negative
> 
> So using ints is preferable to avoid the previous issue.
> 
> Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
> ---
>  data/org.libvirt.Domain.xml |  14 ++--
>  src/domain.c                | 172 ++++----------------------------------------
>  tests/test_domain.py        |   6 +-
>  3 files changed, 25 insertions(+), 167 deletions(-)

[...]

> diff --git a/src/domain.c b/src/domain.c
> index e305fa3..40cf2f7 100644
> --- a/src/domain.c
> +++ b/src/domain.c

[...]

> @@ -137,12 +68,8 @@ virtDBusDomainMemoryStatsToGVariant(virDomainMemoryStatPtr stats,
>  
>      g_variant_builder_init(&builder, G_VARIANT_TYPE("a{st}"));
>  
> -    for (gint i = 0; i < nr_stats; i++) {
> -        const gchar *memoryStat = virtDBusDomainMemoryStatTypeToString(stats[i].tag);
> -        if (!memoryStat)
> -            continue;
> -        g_variant_builder_add(&builder, "{st}", memoryStat, stats[i].val);
> -    }
> +    for (gint i = 0; i < nr_stats; i++)
> +        g_variant_builder_add(&builder, "{ut}", stats[i].tag, stats[i].val);

MemoryStats method needs to be updated in the introspection file.

>  
>      return g_variant_builder_end(&builder);
>  }

[...]

> @@ -1355,7 +1252,6 @@ virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED,
>      virtDBusConnect *connect = userData;
>      g_autoptr(virDomain) domain = NULL;
>      g_autofree virDomainJobInfoPtr jobInfo = NULL;
> -    const gchar *jobTypeStr;
>  
>      domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
>      if (!domain)
> @@ -1365,13 +1261,7 @@ virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED,
>      if (virDomainGetJobInfo(domain, jobInfo) < 0)
>          return virtDBusUtilSetLastVirtError(error);
>  
> -    jobTypeStr = virtDBusDomainJobTypeToString(jobInfo->type);
> -    if (!jobTypeStr) {
> -        g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
> -                    "Can't format virDomainJobType '%d' to string.", jobInfo->type);
> -        return;
> -    }
> -    *outArgs = g_variant_new("((sttttttttttt))", jobTypeStr,
> +    *outArgs = g_variant_new("((uttttttttttt))", jobInfo->type,

GetJobInfo method needs to be updated in the introspection file.

>                               jobInfo->timeElapsed, jobInfo->timeRemaining,
>                               jobInfo->dataTotal, jobInfo->dataProcessed,
>                               jobInfo->dataRemaining, jobInfo->memTotal,

Reviewed-by: Pavel Hrdina <phrdina@xxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature

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

  Powered by Linux