Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- data/org.libvirt.Domain.xml | 5 +++++ src/domain.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index b0b7678..6c48e9d 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -294,6 +294,11 @@ <arg name="flags" type="u" direction="in"/> <arg name="SchedulerParameters" type="a{sv}" direction="out"/> </method> + <method name="GetSecurityLabelList"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetSecurityLabelList"/> + <arg name="securityLabels" type="a(sb)" direction="out"/> + </method> <method name="GetStats"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainListGetStats"/> diff --git a/src/domain.c b/src/domain.c index bbf2759..d07e0a7 100644 --- a/src/domain.c +++ b/src/domain.c @@ -1590,6 +1590,40 @@ virtDBusDomainGetSchedulerParameters(GVariant *inArgs, *outArgs = g_variant_new_tuple(&grecords, 1); } +static void +virtDBusDomainGetSecurityLabelList(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virDomain) domain = NULL; + g_autofree virSecurityLabelPtr seclabels = NULL; + gint nseclabels; + GVariantBuilder builder; + GVariant *gret; + + domain = virtDBusDomainGetVirDomain(connect, objectPath, error); + if (!domain) + return; + + nseclabels = virDomainGetSecurityLabelList(domain, &seclabels); + if (nseclabels < 0) + return virtDBusUtilSetLastVirtError(error); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sb)")); + for (gint i = 0; i < nseclabels; i++) { + g_variant_builder_add(&builder, "(sb)", seclabels[i].label, + !!seclabels[i].enforcing); + } + gret = g_variant_builder_end(&builder); + + *outArgs = g_variant_new_tuple(&gret, 1); +} + static void virtDBusDomainGetStats(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -2987,6 +3021,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = { { "GetNumaParameters", virtDBusDomainGetNumaParameters }, { "GetPerfEvents", virtDBusDomainGetPerfEvents }, { "GetSchedulerParameters", virtDBusDomainGetSchedulerParameters }, + { "GetSecurityLabelList", virtDBusDomainGetSecurityLabelList }, { "GetStats", virtDBusDomainGetStats }, { "GetTime", virtDBusDomainGetTime }, { "GetVcpus", virtDBusDomainGetVcpus }, -- 2.17.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list