[libvirt] [dbus PATCH 08/15] Implement GetHostname method for Domain Interface

Katerina Koukiou posted 15 patches 7 years, 7 months ago
[libvirt] [dbus PATCH 08/15] Implement GetHostname method for Domain Interface
Posted by Katerina Koukiou 7 years, 7 months ago
Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
---
 data/org.libvirt.Domain.xml |  6 ++++++
 src/domain.c                | 28 ++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 343fc08..1324db8 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -209,6 +209,12 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="vcpus" type="a{sv}" direction="out"/>
     </method>
+    <method name="GetHostname">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetHostname"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="hostname" type="s" direction="out"/>
+    </method>
     <method name="GetJobInfo">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo"/>
diff --git a/src/domain.c b/src/domain.c
index 7b0d6c4..18ca7aa 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -1152,6 +1152,33 @@ virtDBusDomainGetGuestVcpus(GVariant *inArgs,
     *outArgs = g_variant_new_tuple(&grecords, 1);
 }
 
+static void
+virtDBusDomainGetHostname(GVariant *inArgs,
+                          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 gchar *hostname = NULL;
+    guint flags;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    hostname = virDomainGetHostname(domain, flags);
+    if (!hostname)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *outArgs = g_variant_new("(s)", hostname);
+}
+
 static void
 virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED,
                          GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -2233,6 +2260,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "GetDiskErrors", virtDBusDomainGetDiskErrors },
     { "GetFSInfo", virtDBusDomainGetFSInfo },
     { "GetGuestVcpus", virtDBusDomainGetGuestVcpus },
+    { "GetHostname", virtDBusDomainGetHostname },
     { "GetJobInfo", virtDBusDomainGetJobInfo },
     { "GetMemoryParameters", virtDBusDomainGetMemoryParameters },
     { "GetSchedulerParameters", virtDBusDomainGetSchedulerParameters },
-- 
2.15.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 08/15] Implement GetHostname method for Domain Interface
Posted by Ján Tomko 7 years, 7 months ago
On Wed, Apr 25, 2018 at 12:20:23PM +0200, Katerina Koukiou wrote:
>Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
>---
> data/org.libvirt.Domain.xml |  6 ++++++
> src/domain.c                | 28 ++++++++++++++++++++++++++++
> 2 files changed, 34 insertions(+)
>
>diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
>index 343fc08..1324db8 100644
>--- a/data/org.libvirt.Domain.xml
>+++ b/data/org.libvirt.Domain.xml
>@@ -209,6 +209,12 @@
>       <arg name="flags" type="u" direction="in"/>
>       <arg name="vcpus" type="a{sv}" direction="out"/>
>     </method>
>+    <method name="GetHostname">
>+      <annotation name="org.gtk.GDBus.DocString"
>+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetHostname"/>
>+      <arg name="flags" type="u" direction="in"/>
>+      <arg name="hostname" type="s" direction="out"/>
>+    </method>
>     <method name="GetJobInfo">
>       <annotation name="org.gtk.GDBus.DocString"
>         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo"/>

The code looks good to me, but the API is only supported by the openvz
driver: https://libvirt.org/hvsupport.html
Is it worth exposing?

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 08/15] Implement GetHostname method for Domain Interface
Posted by Peter Krempa 7 years, 7 months ago
On Wed, Apr 25, 2018 at 13:15:06 +0200, Ján Tomko wrote:
> On Wed, Apr 25, 2018 at 12:20:23PM +0200, Katerina Koukiou wrote:
> > Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
> > ---
> > data/org.libvirt.Domain.xml |  6 ++++++
> > src/domain.c                | 28 ++++++++++++++++++++++++++++
> > 2 files changed, 34 insertions(+)
> > 
> > diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
> > index 343fc08..1324db8 100644
> > --- a/data/org.libvirt.Domain.xml
> > +++ b/data/org.libvirt.Domain.xml
> > @@ -209,6 +209,12 @@
> >       <arg name="flags" type="u" direction="in"/>
> >       <arg name="vcpus" type="a{sv}" direction="out"/>
> >     </method>
> > +    <method name="GetHostname">
> > +      <annotation name="org.gtk.GDBus.DocString"
> > +        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetHostname"/>
> > +      <arg name="flags" type="u" direction="in"/>
> > +      <arg name="hostname" type="s" direction="out"/>
> > +    </method>
> >     <method name="GetJobInfo">
> >       <annotation name="org.gtk.GDBus.DocString"
> >         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo"/>
> 
> The code looks good to me, but the API is only supported by the openvz
> driver: https://libvirt.org/hvsupport.html
> Is it worth exposing?

It might:
https://bugzilla.redhat.com/show_bug.cgi?id=1515831
  [RFE] Add API to access guest-get-hostname from QEMU-GA
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 08/15] Implement GetHostname method for Domain Interface
Posted by Ján Tomko 7 years, 7 months ago
On Wed, Apr 25, 2018 at 01:22:40PM +0200, Peter Krempa wrote:
>On Wed, Apr 25, 2018 at 13:15:06 +0200, Ján Tomko wrote:
>> On Wed, Apr 25, 2018 at 12:20:23PM +0200, Katerina Koukiou wrote:
>> > Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
>> > ---
>> > data/org.libvirt.Domain.xml |  6 ++++++
>> > src/domain.c                | 28 ++++++++++++++++++++++++++++
>> > 2 files changed, 34 insertions(+)
>> >
>> > diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
>> > index 343fc08..1324db8 100644
>> > --- a/data/org.libvirt.Domain.xml
>> > +++ b/data/org.libvirt.Domain.xml
>> > @@ -209,6 +209,12 @@
>> >       <arg name="flags" type="u" direction="in"/>
>> >       <arg name="vcpus" type="a{sv}" direction="out"/>
>> >     </method>
>> > +    <method name="GetHostname">
>> > +      <annotation name="org.gtk.GDBus.DocString"
>> > +        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetHostname"/>
>> > +      <arg name="flags" type="u" direction="in"/>
>> > +      <arg name="hostname" type="s" direction="out"/>
>> > +    </method>
>> >     <method name="GetJobInfo">
>> >       <annotation name="org.gtk.GDBus.DocString"
>> >         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo"/>
>>
>> The code looks good to me, but the API is only supported by the openvz
>> driver: https://libvirt.org/hvsupport.html
>> Is it worth exposing?
>
>It might:
>https://bugzilla.redhat.com/show_bug.cgi?id=1515831
>  [RFE] Add API to access guest-get-hostname from QEMU-GA

Okay then:

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list