From nobody Sat May 4 11:46:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082264039168.8406167869673; Fri, 15 Jun 2018 10:04:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88B743002739; Fri, 15 Jun 2018 17:04:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 54EC510A33DE; Fri, 15 Jun 2018 17:04:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E04B34CA87; Fri, 15 Jun 2018 17:04:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3rW4029778 for ; Fri, 15 Jun 2018 13:03:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2F1902026609; Fri, 15 Jun 2018 17:03:53 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7055202660C for ; Fri, 15 Jun 2018 17:03:52 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:37 +0200 Message-Id: <20180615170350.20851-2-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 01/14] Introduce NodeDevice Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 15 Jun 2018 17:04:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/Makefile.am | 1 + data/org.libvirt.NodeDevice.xml | 7 +++++ src/Makefile.am | 1 + src/connect.c | 6 ++++ src/connect.h | 1 + src/nodedev.c | 65 +++++++++++++++++++++++++++++++++++++= ++++ src/nodedev.h | 9 ++++++ src/util.c | 35 ++++++++++++++++++++++ src/util.h | 15 ++++++++++ 9 files changed, 140 insertions(+) create mode 100644 data/org.libvirt.NodeDevice.xml create mode 100644 src/nodedev.c create mode 100644 src/nodedev.h diff --git a/data/Makefile.am b/data/Makefile.am index 721b874..b3fa614 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -22,6 +22,7 @@ interfaces_files =3D \ org.libvirt.Connect.xml \ org.libvirt.Domain.xml \ org.libvirt.Network.xml \ + org.libvirt.NodeDevice.xml \ org.libvirt.NWFilter.xml \ org.libvirt.Secret.xml \ org.libvirt.StoragePool.xml \ diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.= xml new file mode 100644 index 0000000..7ca26d0 --- /dev/null +++ b/data/org.libvirt.NodeDevice.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/src/Makefile.am b/src/Makefile.am index 53d1a23..3ef3472 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,6 +10,7 @@ DAEMON_SOURCES =3D \ events.c events.h \ gdbus.c gdbus.h \ network.c network.h \ + nodedev.c nodedev.h \ nwfilter.c nwfilter.h \ secret.c secret.h \ storagepool.c storagepool.h \ diff --git a/src/connect.c b/src/connect.c index 4f2bdb6..08898c8 100644 --- a/src/connect.c +++ b/src/connect.c @@ -2,6 +2,7 @@ #include "domain.h" #include "events.h" #include "network.h" +#include "nodedev.h" #include "nwfilter.h" #include "secret.h" #include "storagepool.h" @@ -1668,6 +1669,7 @@ virtDBusConnectFree(virtDBusConnect *connect) if (connect->connection) virtDBusConnectClose(connect, TRUE); =20 + g_free(connect->devPath); g_free(connect->domainPath); g_free(connect->networkPath); g_free(connect->nwfilterPath); @@ -1729,6 +1731,10 @@ virtDBusConnectNew(virtDBusConnect **connectp, if (error && *error) return; =20 + virtDBusNodeDeviceRegister(connect, error); + if (error && *error) + return; + virtDBusNWFilterRegister(connect, error); if (error && *error) return; diff --git a/src/connect.h b/src/connect.h index 341dfc4..3b62edd 100644 --- a/src/connect.h +++ b/src/connect.h @@ -12,6 +12,7 @@ struct virtDBusConnect { GDBusConnection *bus; const gchar *uri; const gchar *connectPath; + gchar *devPath; gchar *domainPath; gchar *networkPath; gchar *nwfilterPath; diff --git a/src/nodedev.c b/src/nodedev.c new file mode 100644 index 0000000..188df74 --- /dev/null +++ b/src/nodedev.c @@ -0,0 +1,65 @@ +#include "nodedev.h" +#include "util.h" + +#include + +static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] =3D { + { 0 } +}; + +static virtDBusGDBusMethodTable virtDBusNodeDeviceMethodTable[] =3D { + { 0 } +}; + +static gchar ** +virtDBusNodeDeviceEnumerate(gpointer userData) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevicePtr) devs =3D NULL; + gint num =3D 0; + gchar **ret =3D NULL; + + if (!virtDBusConnectOpen(connect, NULL)) + return NULL; + + num =3D virConnectListAllNodeDevices(connect->connection, &devs, 0); + if (num < 0) + return NULL; + + if (num =3D=3D 0) + return NULL; + + ret =3D g_new0(gchar *, num + 1); + + for (gint i =3D 0; i < num; i++) { + ret[i] =3D virtDBusUtilBusPathForVirNodeDevice(devs[i], + connect->devPath); + } + + return ret; +} + +static GDBusInterfaceInfo *interfaceInfo; + +void +virtDBusNodeDeviceRegister(virtDBusConnect *connect, + GError **error) +{ + connect->devPath =3D g_strdup_printf("%s/nodedev", + connect->connectPath); + + if (!interfaceInfo) { + interfaceInfo =3D virtDBusGDBusLoadIntrospectData(VIRT_DBUS_NODEDE= V_INTERFACE, + error); + if (!interfaceInfo) + return; + } + + virtDBusGDBusRegisterSubtree(connect->bus, + connect->devPath, + interfaceInfo, + virtDBusNodeDeviceEnumerate, + virtDBusNodeDeviceMethodTable, + virtDBusNodeDevicePropertyTable, + connect); +} diff --git a/src/nodedev.h b/src/nodedev.h new file mode 100644 index 0000000..3cd2bdf --- /dev/null +++ b/src/nodedev.h @@ -0,0 +1,9 @@ +#pragma once + +#include "connect.h" + +#define VIRT_DBUS_NODEDEV_INTERFACE "org.libvirt.NodeDevice" + +void +virtDBusNodeDeviceRegister(virtDBusConnect *connect, + GError **error); diff --git a/src/util.c b/src/util.c index ac6d11b..e736ac1 100644 --- a/src/util.c +++ b/src/util.c @@ -311,6 +311,41 @@ virtDBusUtilVirNetworkListFree(virNetworkPtr *networks) g_free(networks); } =20 +virNodeDevicePtr +virtDBusUtilVirNodeDeviceFromBusPath(virConnectPtr connection, + const gchar *path, + const gchar *devPath) +{ + g_autofree gchar *name =3D NULL; + gsize prefixLen =3D strlen(devPath) + 1; + + name =3D virtDBusUtilDecodeStr(path + prefixLen); + + return virNodeDeviceLookupByName(connection, name); +} + +gchar * +virtDBusUtilBusPathForVirNodeDevice(virNodeDevicePtr dev, + const gchar *devPath) +{ + const gchar *name =3D NULL; + g_autofree const gchar *encodedName =3D NULL; + + name =3D virNodeDeviceGetName(dev); + encodedName =3D virtDBusUtilEncodeStr(name); + + return g_strdup_printf("%s/%s", devPath, encodedName); +} + +void +virtDBusUtilVirNodeDeviceListFree(virNodeDevicePtr *devs) +{ + for (gint i =3D 0; devs[i] !=3D NULL; i++) + virNodeDeviceFree(devs[i]); + + g_free(devs); +} + virNWFilterPtr virtDBusUtilVirNWFilterFromBusPath(virConnectPtr connection, const gchar *path, diff --git a/src/util.h b/src/util.h index bf08d5d..81372df 100644 --- a/src/util.h +++ b/src/util.h @@ -80,6 +80,21 @@ virtDBusUtilVirNetworkListFree(virNetworkPtr *networks); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetwork, virNetworkFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetworkPtr, virtDBusUtilVirNetworkListFre= e); =20 +virNodeDevicePtr +virtDBusUtilVirNodeDeviceFromBusPath(virConnectPtr connection, + const gchar *path, + const gchar *devPath); + +gchar * +virtDBusUtilBusPathForVirNodeDevice(virNodeDevicePtr NodeDevice, + const gchar *devPath); + +void +virtDBusUtilVirNodeDeviceListFree(virNodeDevicePtr *devs); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNodeDevice, virNodeDeviceFree); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNodeDevicePtr, virtDBusUtilVirNodeDeviceL= istFree); + virNWFilterPtr virtDBusUtilVirNWFilterFromBusPath(virConnectPtr connection, const gchar *path, --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082242163714.3337419022914; Fri, 15 Jun 2018 10:04:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E104D307D870; Fri, 15 Jun 2018 17:03:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D86B10ADCCA; Fri, 15 Jun 2018 17:03:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 82B9A1800539; Fri, 15 Jun 2018 17:03:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3rlc029784 for ; Fri, 15 Jun 2018 13:03:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id C52222026990; Fri, 15 Jun 2018 17:03:53 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68BFA2026DEF for ; Fri, 15 Jun 2018 17:03:53 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:38 +0200 Message-Id: <20180615170350.20851-3-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 02/14] Implement ListNodeDevices method for Connect Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 15 Jun 2018 17:04:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 37daed0..137e67b 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -160,6 +160,12 @@ + + + + + diff --git a/src/connect.c b/src/connect.c index 08898c8..919172a 100644 --- a/src/connect.c +++ b/src/connect.c @@ -798,6 +798,43 @@ virtDBusConnectListNetworks(GVariant *inArgs, *outArgs =3D g_variant_new_tuple(&gnetworks, 1); } =20 +static void +virtDBusConnectListNodeDevices(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevicePtr) devs =3D NULL; + guint flags; + GVariantBuilder builder; + GVariant *gdevs; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + if (virConnectListAllNodeDevices(connect->connection, &devs, flags) < = 0) + return virtDBusUtilSetLastVirtError(error); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("ao")); + + for (gint i =3D 0; devs[i]; i++) { + g_autofree gchar *path =3D NULL; + path =3D virtDBusUtilBusPathForVirNodeDevice(devs[i], + connect->devPath); + + g_variant_builder_add(&builder, "o", path); + } + + gdevs =3D g_variant_builder_end(&builder); + *outArgs =3D g_variant_new_tuple(&gdevs, 1); +} + static void virtDBusConnectListNWFilters(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1632,6 +1669,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "GetSysinfo", virtDBusConnectGetSysinfo }, { "ListDomains", virtDBusConnectListDomains }, { "ListNetworks", virtDBusConnectListNetworks }, + { "ListNodeDevices", virtDBusConnectListNodeDevices }, { "ListNWFilters", virtDBusConnectListNWFilters }, { "ListSecrets", virtDBusConnectListSecrets }, { "ListStoragePools", virtDBusConnectListStoragePools }, --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082269238879.4219839993383; Fri, 15 Jun 2018 10:04:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7EF461B9C; Fri, 15 Jun 2018 17:04:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7172BBC588; Fri, 15 Jun 2018 17:04:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 206C918037F0; Fri, 15 Jun 2018 17:04:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3sDE029791 for ; Fri, 15 Jun 2018 13:03:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 66444202660C; Fri, 15 Jun 2018 17:03:54 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A7522026609 for ; Fri, 15 Jun 2018 17:03:53 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:39 +0200 Message-Id: <20180615170350.20851-4-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 03/14] Register NodeDevice Lifecycle Events X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 15 Jun 2018 17:04:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.Connect.xml | 7 +++++++ src/connect.c | 13 +++++++++++++ src/connect.h | 1 + src/events.c | 42 ++++++++++++++++++++++++++++++++++++++++= ++ 4 files changed, 63 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 137e67b..3828832 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -339,6 +339,13 @@ + + + + + + diff --git a/src/connect.c b/src/connect.c index 919172a..1c27768 100644 --- a/src/connect.c +++ b/src/connect.c @@ -65,6 +65,16 @@ virtDBusConnectClose(virtDBusConnect *connect, } } =20 + for (gint i =3D 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) { + if (connect->devCallbackIds[i] >=3D 0) { + if (deregisterEvents) { + virConnectNetworkEventDeregisterAny(connect->connection, + connect->devCallbackId= s[i]); + } + connect->devCallbackIds[i] =3D -1; + } + } + for (gint i =3D 0; i < VIR_SECRET_EVENT_ID_LAST; i++) { if (connect->secretCallbackIds[i] >=3D 0) { if (deregisterEvents) { @@ -1744,6 +1754,9 @@ virtDBusConnectNew(virtDBusConnect **connectp, for (gint i =3D 0; i < VIR_NETWORK_EVENT_ID_LAST; i++) connect->networkCallbackIds[i] =3D -1; =20 + for (gint i =3D 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) + connect->devCallbackIds[i] =3D -1; + for (gint i =3D 0; i < VIR_SECRET_EVENT_ID_LAST; i++) connect->secretCallbackIds[i] =3D -1; =20 diff --git a/src/connect.h b/src/connect.h index 3b62edd..a864041 100644 --- a/src/connect.h +++ b/src/connect.h @@ -24,6 +24,7 @@ struct virtDBusConnect { =20 gint domainCallbackIds[VIR_DOMAIN_EVENT_ID_LAST]; gint networkCallbackIds[VIR_NETWORK_EVENT_ID_LAST]; + gint devCallbackIds[VIR_NODE_DEVICE_EVENT_ID_LAST]; gint secretCallbackIds[VIR_SECRET_EVENT_ID_LAST]; gint storagePoolCallbackIds[VIR_STORAGE_POOL_EVENT_ID_LAST]; }; diff --git a/src/events.c b/src/events.c index b51664f..60cbecd 100644 --- a/src/events.c +++ b/src/events.c @@ -567,6 +567,29 @@ virtDBusEventsNetworkEvent(virConnectPtr connection G_= GNUC_UNUSED, return 0; } =20 +static gint +virtDBusEventsNodeDeviceEvent(virConnectPtr connection G_GNUC_UNUSED, + virNodeDevicePtr dev, + gint event, + gint detail, + gpointer opaque) +{ + virtDBusConnect *connect =3D opaque; + g_autofree gchar *path =3D NULL; + + path =3D virtDBusUtilBusPathForVirNodeDevice(dev, connect->devPath); + + g_dbus_connection_emit_signal(connect->bus, + NULL, + connect->connectPath, + VIRT_DBUS_CONNECT_INTERFACE, + "NodeDeviceEvent", + g_variant_new("(oii)", path, event, deta= il), + NULL); + + return 0; +} + static gint virtDBusEventsSecretEvent(virConnectPtr connection G_GNUC_UNUSED, virSecretPtr secret, @@ -666,6 +689,21 @@ virtDBusEventsRegisterNetworkEvent(virtDBusConnect *co= nnect, NU= LL); } =20 +static void +virtDBusEventsRegisterNodeDeviceEvent(virtDBusConnect *connect, + gint id, + virConnectNodeDeviceEventGenericCall= back callback) +{ + g_assert(connect->devCallbackIds[id] =3D=3D -1); + + connect->devCallbackIds[id] =3D virConnectNodeDeviceEventRegisterAny(c= onnect->connection, + NUL= L, + id, + VIR= _NODE_DEVICE_EVENT_CALLBACK(callback), + con= nect, + NUL= L); +} + static void virtDBusEventsRegisterSecretEvent(virtDBusConnect *connect, gint id, @@ -791,6 +829,10 @@ virtDBusEventsRegister(virtDBusConnect *connect) VIR_NETWORK_EVENT_ID_LIFECYCLE, VIR_NETWORK_EVENT_CALLBACK(virtDBus= EventsNetworkEvent)); =20 + virtDBusEventsRegisterNodeDeviceEvent(connect, + VIR_NODE_DEVICE_EVENT_ID_LIFECYC= LE, + VIR_NODE_DEVICE_EVENT_CALLBACK(v= irtDBusEventsNodeDeviceEvent)); + virtDBusEventsRegisterSecretEvent(connect, VIR_SECRET_EVENT_ID_LIFECYCLE, VIR_SECRET_EVENT_CALLBACK(virtDBusEv= entsSecretEvent)); --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082246932616.0915989006995; Fri, 15 Jun 2018 10:04:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 331C81A9E43; Fri, 15 Jun 2018 17:04:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF8A230001E3; Fri, 15 Jun 2018 17:04:01 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 902A54CA81; Fri, 15 Jun 2018 17:04:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3tt8029807 for ; Fri, 15 Jun 2018 13:03:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 08599202660C; Fri, 15 Jun 2018 17:03:55 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id A05AD2026609 for ; Fri, 15 Jun 2018 17:03:54 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:40 +0200 Message-Id: <20180615170350.20851-5-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 04/14] Implement NodeDeviceCreateXML method for Connect Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 15 Jun 2018 17:04:06 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.Connect.xml | 7 +++++++ src/connect.c | 30 ++++++++++++++++++++++++++++++ tests/libvirttest.py | 3 +++ tests/test_connect.py | 14 ++++++++++++++ tests/xmldata.py | 16 ++++++++++++++++ 5 files changed, 70 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 3828832..d8b0d9e 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -208,6 +208,13 @@ + + + + + + diff --git a/src/connect.c b/src/connect.c index 1c27768..5e146a6 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1069,6 +1069,35 @@ virtDBusConnectNetworkLookupByUUID(GVariant *inArgs, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusConnectNodeDeviceCreateXML(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + g_autofree gchar *path =3D NULL; + gchar *xml; + guint flags; + + g_variant_get(inArgs, "(&su)", &xml, &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + dev =3D virNodeDeviceCreateXML(connect->connection, xml, flags); + if (!dev) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirNodeDevice(dev, connect->devPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static void virtDBusConnectNWFilterDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1687,6 +1716,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NetworkDefineXML", virtDBusConnectNetworkDefineXML }, { "NetworkLookupByName", virtDBusConnectNetworkLookupByName }, { "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID }, + { "NodeDeviceCreateXML", virtDBusConnectNodeDeviceCreateXML }, { "NWFilterDefineXML", virtDBusConnectNWFilterDefineXML }, { "NWFilterLookupByName", virtDBusConnectNWFilterLookupByName }, { "NWFilterLookupByUUID", virtDBusConnectNWFilterLookupByUUID }, diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 6d1a9d0..6b6cb4c 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -217,6 +217,9 @@ class NetworkEvent(IntEnum): STARTED =3D 2 STOPPED =3D 3 =20 +class NodeDeviceEvent(IntEnum): + CREATED =3D 0 + DELETED =3D 1 =20 class StoragePoolBuildFlags(IntEnum): NEW =3D 0 diff --git a/tests/test_connect.py b/tests/test_connect.py index 57b385e..e532016 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -155,6 +155,20 @@ class TestConnect(libvirttest.BaseTestClass): path =3D getattr(self.connect, lookup_method_name)(prop) assert original_path =3D=3D path =20 + def test_connect_node_device_create_xml(self): + def node_device_created(path, event, _detail): + if event !=3D libvirttest.NodeDeviceEvent.CREATED: + return + assert isinstance(path, dbus.ObjectPath) + self.loop.quit() + + self.connect.connect_to_signal('NodeDeviceEvent', node_device_crea= ted) + + path =3D self.connect.NodeDeviceCreateXML(xmldata.minimal_node_dev= ice_xml, 0) + assert isinstance(path, dbus.ObjectPath) + + self.main_loop() + def test_connect_node_get_cpu_stats(self): stats =3D self.connect.NodeGetCPUStats(0, 0) assert isinstance(stats, dbus.Dictionary) diff --git a/tests/xmldata.py b/tests/xmldata.py index 926bd2c..25bb089 100644 --- a/tests/xmldata.py +++ b/tests/xmldata.py @@ -26,6 +26,22 @@ minimal_network_xml =3D ''' ''' =20 +minimal_node_device_xml =3D ''' + + scsi_host22 + scsi_host2 + + 22 + 22 + + 2000000098765432 + 1000000098765432 + 2000000098769876 + + + +''' + minimal_storage_pool_xml =3D ''' foo --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082264174768.5138405198609; Fri, 15 Jun 2018 10:04:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8B47CC0587F1; Fri, 15 Jun 2018 17:04:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50F0210A33C3; Fri, 15 Jun 2018 17:04:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EB77C1800536; Fri, 15 Jun 2018 17:04:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3t3e029812 for ; Fri, 15 Jun 2018 13:03:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9DCE2202660C; Fri, 15 Jun 2018 17:03:55 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 424782026609 for ; Fri, 15 Jun 2018 17:03:55 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:41 +0200 Message-Id: <20180615170350.20851-6-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 05/14] Implement Destroy method for NodeDevice Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 15 Jun 2018 17:04:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- Some note about the test: 1: The previous test should not use the node_device_create fixture introduc= ed here=20 for the following reason: The fixture is creating the device in the setup of the test since the device creation is not supposed to be tested in other tests apart from the CreateXML test. Only that test should not have the creation in the setup, but in the actual test `call` part. 2: I didn't create the get_test_node_device function as other entities have because ListNodeDevices method is not supported by the test driver data/org.libvirt.NodeDevice.xml | 4 ++++ src/nodedev.c | 42 +++++++++++++++++++++++++++++++++++++= ++++ tests/Makefile.am | 1 + tests/libvirttest.py | 10 ++++++++++ tests/test_nodedev.py | 31 ++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100755 tests/test_nodedev.py diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.= xml index 7ca26d0..4ca2e11 100644 --- a/data/org.libvirt.NodeDevice.xml +++ b/data/org.libvirt.NodeDevice.xml @@ -3,5 +3,9 @@ =20 + + + diff --git a/src/nodedev.c b/src/nodedev.c index 188df74..ec87bd8 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -3,11 +3,53 @@ =20 #include =20 +static virNodeDevicePtr +virtDBusNodeDeviceGetVirNodeDevice(virtDBusConnect *connect, + const gchar *objectPath, + GError **error) +{ + virNodeDevicePtr dev; + + if (virtDBusConnectOpen(connect, error) < 0) + return NULL; + + dev =3D virtDBusUtilVirNodeDeviceFromBusPath(connect->connection, + objectPath, + connect->devPath); + if (!dev) { + virtDBusUtilSetLastVirtError(error); + return NULL; + } + + return dev; +} + +static void +virtDBusNodeDeviceDestroy(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + + dev =3D virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error); + if (!dev) + return; + + if (virNodeDeviceDestroy(dev) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] =3D { { 0 } }; =20 static virtDBusGDBusMethodTable virtDBusNodeDeviceMethodTable[] =3D { + { "Destroy", virtDBusNodeDeviceDestroy }, { 0 } }; =20 diff --git a/tests/Makefile.am b/tests/Makefile.am index 4cae303..e841627 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,6 +7,7 @@ test_programs =3D \ test_connect.py \ test_domain.py \ test_network.py \ + test_nodedev.py \ test_storage.py =20 check_PROGRAMS =3D \ diff --git a/tests/libvirttest.py b/tests/libvirttest.py index 6b6cb4c..06e52c0 100644 --- a/tests/libvirttest.py +++ b/tests/libvirttest.py @@ -71,6 +71,16 @@ class BaseTestClass(): if self.timeout: raise TimeoutError() =20 + @pytest.fixture + def node_device_create(self): + """ Fixture to create dummy node device on the test driver + + This fixture should be used in the setup of every test manipulating + with node devices. + """ + path =3D self.connect.NodeDeviceCreateXML(xmldata.minimal_node_dev= ice_xml, 0) + return path + @pytest.fixture def storage_volume_create(self): """ Fixture to create dummy storage volume on the test driver diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py new file mode 100755 index 0000000..8ef8e32 --- /dev/null +++ b/tests/test_nodedev.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import dbus +import libvirttest +import pytest + + +@pytest.mark.usefixtures("node_device_create") +class TestNodeDevice(libvirttest.BaseTestClass): + """ Tests for methods and properties of the NodeDevice interface + """ + + def test_node_device_destroy(self): + def node_device_deleted(path, event, _detail): + if event !=3D libvirttest.NodeDeviceEvent.DELETED: + return + assert isinstance(path, dbus.ObjectPath) + self.loop.quit() + + self.connect.connect_to_signal('NodeDeviceEvent', node_device_dele= ted) + + test_node_device_path =3D self.node_device_create() + obj =3D self.bus.get_object('org.libvirt', test_node_device_path) + interface_obj =3D dbus.Interface(obj, 'org.libvirt.NodeDevice') + interface_obj.Destroy() + + self.main_loop() + + +if __name__ =3D=3D '__main__': + libvirttest.run() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082279370729.0209943631742; Fri, 15 Jun 2018 10:04:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF17F82DC; Fri, 15 Jun 2018 17:04:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA70330A7601; Fri, 15 Jun 2018 17:04:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6CDAA1800537; Fri, 15 Jun 2018 17:04:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3uNN029820 for ; Fri, 15 Jun 2018 13:03:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F9272026990; Fri, 15 Jun 2018 17:03:56 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id D82CF2026DEF for ; Fri, 15 Jun 2018 17:03:55 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:42 +0200 Message-Id: <20180615170350.20851-7-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 06/14] Implement Detach method for NodeDevice Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 15 Jun 2018 17:04:38 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.NodeDevice.xml | 5 +++++ src/nodedev.c | 25 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.= xml index 4ca2e11..ea9bd7c 100644 --- a/data/org.libvirt.NodeDevice.xml +++ b/data/org.libvirt.NodeDevice.xml @@ -7,5 +7,10 @@ + + + + diff --git a/src/nodedev.c b/src/nodedev.c index ec87bd8..e8551b8 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -44,12 +44,37 @@ virtDBusNodeDeviceDestroy(GVariant *inArgs G_GNUC_UNUSE= D, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusNodeDeviceDetach(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + const gchar *driverName; + guint flags; + + g_variant_get(inArgs, "(&su)", &driverName, &flags); + + dev =3D virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error); + if (!dev) + return; + + if (virNodeDeviceDetachFlags(dev, driverName, flags) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] =3D { { 0 } }; =20 static virtDBusGDBusMethodTable virtDBusNodeDeviceMethodTable[] =3D { { "Destroy", virtDBusNodeDeviceDestroy }, + { "Detach", virtDBusNodeDeviceDetach }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082284059350.91803423961153; Fri, 15 Jun 2018 10:04:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11D3930001DF; Fri, 15 Jun 2018 17:04:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D29C610ADCCA; Fri, 15 Jun 2018 17:04:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 892A34CA92; Fri, 15 Jun 2018 17:04:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3u9m029830 for ; Fri, 15 Jun 2018 13:03:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5487202660C; Fri, 15 Jun 2018 17:03:56 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79B5F2026609 for ; Fri, 15 Jun 2018 17:03:56 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:43 +0200 Message-Id: <20180615170350.20851-8-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 07/14] Implement Name property for NodeDevice Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 15 Jun 2018 17:04:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.NodeDevice.xml | 5 +++++ src/nodedev.c | 22 ++++++++++++++++++++++ tests/test_nodedev.py | 8 ++++++++ 3 files changed, 35 insertions(+) diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.= xml index ea9bd7c..b4caac3 100644 --- a/data/org.libvirt.NodeDevice.xml +++ b/data/org.libvirt.NodeDevice.xml @@ -3,6 +3,11 @@ =20 + + + + diff --git a/src/nodedev.c b/src/nodedev.c index e8551b8..9647fb6 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -24,6 +24,27 @@ virtDBusNodeDeviceGetVirNodeDevice(virtDBusConnect *conn= ect, return dev; } =20 +static void +virtDBusNodeDeviceGetName(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + const gchar *name; + + dev =3D virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error); + if (!dev) + return; + + name =3D virNodeDeviceGetName(dev); + if (!name) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("s", name); +} + static void virtDBusNodeDeviceDestroy(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -69,6 +90,7 @@ virtDBusNodeDeviceDetach(GVariant *inArgs, } =20 static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] =3D { + { "Name", virtDBusNodeDeviceGetName, NULL }, { 0 } }; =20 diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py index 8ef8e32..cc7199a 100755 --- a/tests/test_nodedev.py +++ b/tests/test_nodedev.py @@ -26,6 +26,14 @@ class TestNodeDevice(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_node_device_properties_type(self): + """ Ensure correct return type for NodeDevice properties + """ + test_node_device_path =3D self.node_device_create() + obj =3D self.bus.get_object('org.libvirt', test_node_device_path) + props =3D obj.GetAll('org.libvirt.NodeDevice', dbus_interface=3Ddb= us.PROPERTIES_IFACE) + assert isinstance(props['Name'], dbus.String) + =20 if __name__ =3D=3D '__main__': libvirttest.run() --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082269254251.73174885045205; Fri, 15 Jun 2018 10:04:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9B9783001910; Fri, 15 Jun 2018 17:04:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6754C30A7613; Fri, 15 Jun 2018 17:04:27 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1C69D18037EF; Fri, 15 Jun 2018 17:04:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3vm6029840 for ; Fri, 15 Jun 2018 13:03:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 779D2202660C; Fri, 15 Jun 2018 17:03:57 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B7252026609 for ; Fri, 15 Jun 2018 17:03:56 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:44 +0200 Message-Id: <20180615170350.20851-9-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 08/14] Implement Parent property for NodeDevice Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 15 Jun 2018 17:04:28 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.NodeDevice.xml | 5 +++++ src/nodedev.c | 22 ++++++++++++++++++++++ tests/test_nodedev.py | 1 + 3 files changed, 28 insertions(+) diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.= xml index b4caac3..c4b4075 100644 --- a/data/org.libvirt.NodeDevice.xml +++ b/data/org.libvirt.NodeDevice.xml @@ -8,6 +8,11 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-nodedev.html= #virNodeDeviceGetName"/> + + + + diff --git a/src/nodedev.c b/src/nodedev.c index 9647fb6..c597411 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -45,6 +45,27 @@ virtDBusNodeDeviceGetName(const gchar *objectPath, *value =3D g_variant_new("s", name); } =20 +static void +virtDBusNodeDeviceGetParent(const gchar *objectPath, + gpointer userData, + GVariant **value, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + const gchar *parent; + + dev =3D virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error); + if (!dev) + return; + + parent =3D virNodeDeviceGetParent(dev); + if (!parent) + return virtDBusUtilSetLastVirtError(error); + + *value =3D g_variant_new("s", parent); +} + static void virtDBusNodeDeviceDestroy(GVariant *inArgs G_GNUC_UNUSED, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -91,6 +112,7 @@ virtDBusNodeDeviceDetach(GVariant *inArgs, =20 static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] =3D { { "Name", virtDBusNodeDeviceGetName, NULL }, + { "Parent", virtDBusNodeDeviceGetParent, NULL }, { 0 } }; =20 diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py index cc7199a..39343ae 100755 --- a/tests/test_nodedev.py +++ b/tests/test_nodedev.py @@ -33,6 +33,7 @@ class TestNodeDevice(libvirttest.BaseTestClass): obj =3D self.bus.get_object('org.libvirt', test_node_device_path) props =3D obj.GetAll('org.libvirt.NodeDevice', dbus_interface=3Ddb= us.PROPERTIES_IFACE) assert isinstance(props['Name'], dbus.String) + assert isinstance(props['Parent'], dbus.String) =20 =20 if __name__ =3D=3D '__main__': --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082263699117.41437523329273; Fri, 15 Jun 2018 10:04:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9532982C5; Fri, 15 Jun 2018 17:04:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65B9DBC58E; Fri, 15 Jun 2018 17:04:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D63CE4CA81; Fri, 15 Jun 2018 17:04:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3wZx029845 for ; Fri, 15 Jun 2018 13:03:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1A5EE202660C; Fri, 15 Jun 2018 17:03:58 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1D5E2026609 for ; Fri, 15 Jun 2018 17:03:57 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:45 +0200 Message-Id: <20180615170350.20851-10-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 09/14] Implement GetXMLDesc property for NodeDevice Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 15 Jun 2018 17:04:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.NodeDevice.xml | 6 ++++++ src/nodedev.c | 28 ++++++++++++++++++++++++++++ tests/test_nodedev.py | 6 ++++++ 3 files changed, 40 insertions(+) diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.= xml index c4b4075..1185bca 100644 --- a/data/org.libvirt.NodeDevice.xml +++ b/data/org.libvirt.NodeDevice.xml @@ -22,5 +22,11 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-nodedev.html= #virNodeDeviceDetachFlags"/> + + + + + diff --git a/src/nodedev.c b/src/nodedev.c index c597411..e61242d 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -110,6 +110,33 @@ virtDBusNodeDeviceDetach(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusNodeDeviceGetXMLDesc(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + g_autofree gchar *xml =3D NULL; + guint flags; + + g_variant_get(inArgs, "(u)", &flags); + + dev =3D virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error); + if (!dev) + return; + + xml =3D virNodeDeviceGetXMLDesc(dev, flags); + if (!xml) + return virtDBusUtilSetLastVirtError(error); + + *outArgs =3D g_variant_new("(s)", xml); +} + static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] =3D { { "Name", virtDBusNodeDeviceGetName, NULL }, { "Parent", virtDBusNodeDeviceGetParent, NULL }, @@ -119,6 +146,7 @@ static virtDBusGDBusPropertyTable virtDBusNodeDevicePro= pertyTable[] =3D { static virtDBusGDBusMethodTable virtDBusNodeDeviceMethodTable[] =3D { { "Destroy", virtDBusNodeDeviceDestroy }, { "Detach", virtDBusNodeDeviceDetach }, + { "GetXMLDesc", virtDBusNodeDeviceGetXMLDesc }, { 0 } }; =20 diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py index 39343ae..64c97b2 100755 --- a/tests/test_nodedev.py +++ b/tests/test_nodedev.py @@ -26,6 +26,12 @@ class TestNodeDevice(libvirttest.BaseTestClass): =20 self.main_loop() =20 + def test_node_device_get_xml_description(self): + test_node_device_path =3D self.node_device_create() + obj =3D self.bus.get_object('org.libvirt', test_node_device_path) + interface_obj =3D dbus.Interface(obj, 'org.libvirt.NodeDevice') + assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) + def test_node_device_properties_type(self): """ Ensure correct return type for NodeDevice properties """ --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152908226992212.07802067566422; Fri, 15 Jun 2018 10:04:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4687261D05; Fri, 15 Jun 2018 17:04:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13792125339; Fri, 15 Jun 2018 17:04:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 481324CA85; Fri, 15 Jun 2018 17:04:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3wHR029852 for ; Fri, 15 Jun 2018 13:03:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id AF8452026990; Fri, 15 Jun 2018 17:03:58 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 539652026DEF for ; Fri, 15 Jun 2018 17:03:58 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:46 +0200 Message-Id: <20180615170350.20851-11-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 10/14] Implement ListCaps method for NodeDevicesInterface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 15 Jun 2018 17:04:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.NodeDevice.xml | 5 +++++ src/nodedev.c | 37 +++++++++++++++++++++++++++++++++++++ tests/test_nodedev.py | 6 ++++++ 3 files changed, 48 insertions(+) diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.= xml index 1185bca..bf85958 100644 --- a/data/org.libvirt.NodeDevice.xml +++ b/data/org.libvirt.NodeDevice.xml @@ -28,5 +28,10 @@ + + + + diff --git a/src/nodedev.c b/src/nodedev.c index e61242d..01fcd35 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -137,6 +137,42 @@ virtDBusNodeDeviceGetXMLDesc(GVariant *inArgs, *outArgs =3D g_variant_new("(s)", xml); } =20 +static void +virtDBusNodeDeviceListCaps(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 =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + g_autoptr(virtDBusCharArray) caps =3D NULL; + gint ncaps; + GVariant *gret; + GVariantBuilder builder; + + dev =3D virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error); + if (!dev) + return; + + if ((ncaps =3D virNodeDeviceNumOfCaps(dev)) < 0) + return virtDBusUtilSetLastVirtError(error); + + caps =3D g_new0(char *, ncaps + 1); + + if ((ncaps =3D virNodeDeviceListCaps(dev, caps, ncaps)) < 0) + return virtDBusUtilSetLastVirtError(error); + + g_variant_builder_init(&builder, G_VARIANT_TYPE("as")); + for (gint i =3D 0; i < ncaps; i++) + g_variant_builder_add(&builder, "s", caps[i]); + gret =3D g_variant_builder_end(&builder); + + *outArgs =3D g_variant_new_tuple(&gret, 1); +} + static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] =3D { { "Name", virtDBusNodeDeviceGetName, NULL }, { "Parent", virtDBusNodeDeviceGetParent, NULL }, @@ -147,6 +183,7 @@ static virtDBusGDBusMethodTable virtDBusNodeDeviceMetho= dTable[] =3D { { "Destroy", virtDBusNodeDeviceDestroy }, { "Detach", virtDBusNodeDeviceDetach }, { "GetXMLDesc", virtDBusNodeDeviceGetXMLDesc }, + { "ListCaps", virtDBusNodeDeviceListCaps }, { 0 } }; =20 diff --git a/tests/test_nodedev.py b/tests/test_nodedev.py index 64c97b2..6aa6211 100755 --- a/tests/test_nodedev.py +++ b/tests/test_nodedev.py @@ -32,6 +32,12 @@ class TestNodeDevice(libvirttest.BaseTestClass): interface_obj =3D dbus.Interface(obj, 'org.libvirt.NodeDevice') assert isinstance(interface_obj.GetXMLDesc(0), dbus.String) =20 + def test_node_device_list_caps(self): + test_node_device_path =3D self.node_device_create() + obj =3D self.bus.get_object('org.libvirt', test_node_device_path) + interface_obj =3D dbus.Interface(obj, 'org.libvirt.NodeDevice') + assert isinstance(interface_obj.ListCaps(), dbus.Array) + def test_node_device_properties_type(self): """ Ensure correct return type for NodeDevice properties """ --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082289781706.0959036634591; Fri, 15 Jun 2018 10:04:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1CE848762D; Fri, 15 Jun 2018 17:04:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4C1887F6C; Fri, 15 Jun 2018 17:04:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 96AEB4A46E; Fri, 15 Jun 2018 17:04:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH3x9c029858 for ; Fri, 15 Jun 2018 13:03:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 51E43202660C; Fri, 15 Jun 2018 17:03:59 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA1172026609 for ; Fri, 15 Jun 2018 17:03:58 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:47 +0200 Message-Id: <20180615170350.20851-12-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 11/14] Implement NodeDeviceLookupByName method for Connect Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 15 Jun 2018 17:04:49 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 29 +++++++++++++++++++++++++++++ tests/test_connect.py | 13 +++++++++++++ 3 files changed, 48 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index d8b0d9e..a030d57 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -215,6 +215,12 @@ + + + + + diff --git a/src/connect.c b/src/connect.c index 5e146a6..6192f47 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1098,6 +1098,34 @@ virtDBusConnectNodeDeviceCreateXML(GVariant *inArgs, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusConnectNodeDeviceLookupByName(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath G_GNUC_UNUSE= D, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + g_autofree gchar *path =3D NULL; + const gchar *name; + + g_variant_get(inArgs, "(s)", &name); + + if (!virtDBusConnectOpen(connect, error)) + return; + + dev =3D virNodeDeviceLookupByName(connect->connection, name); + if (!dev) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirNodeDevice(dev, connect->devPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static void virtDBusConnectNWFilterDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1717,6 +1745,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NetworkLookupByName", virtDBusConnectNetworkLookupByName }, { "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID }, { "NodeDeviceCreateXML", virtDBusConnectNodeDeviceCreateXML }, + { "NodeDeviceLookupByName", virtDBusConnectNodeDeviceLookupByName }, { "NWFilterDefineXML", virtDBusConnectNWFilterDefineXML }, { "NWFilterLookupByName", virtDBusConnectNWFilterLookupByName }, { "NWFilterLookupByUUID", virtDBusConnectNWFilterLookupByUUID }, diff --git a/tests/test_connect.py b/tests/test_connect.py index e532016..7084397 100755 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -143,6 +143,19 @@ class TestConnect(libvirttest.BaseTestClass): =20 self.main_loop() =20 + @pytest.mark.usefixtures("node_device_create") + @pytest.mark.parametrize("lookup_method_name,lookup_item", [ + ("NodeDeviceLookupByName", 'Name'), + ]) + def test_connect_node_device_lookup_by_property(self, lookup_method_na= me, lookup_item): + """Parameterized test for all NodeDeviceLookupBy* API calls of Con= nect interface + """ + original_path =3D self.node_device_create() + obj =3D self.bus.get_object('org.libvirt', original_path) + prop =3D obj.Get('org.libvirt.NodeDevice', lookup_item, dbus_inter= face=3Ddbus.PROPERTIES_IFACE) + path =3D getattr(self.connect, lookup_method_name)(prop) + assert original_path =3D=3D path + @pytest.mark.parametrize("lookup_method_name,lookup_item", [ ("NetworkLookupByName", 'Name'), ("NetworkLookupByUUID", 'UUID'), --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 152908227446963.91190455873539; Fri, 15 Jun 2018 10:04:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3077CAA7D; Fri, 15 Jun 2018 17:04:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5D5410A33F3; Fri, 15 Jun 2018 17:04:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5DC044CA88; Fri, 15 Jun 2018 17:04:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH40p0029865 for ; Fri, 15 Jun 2018 13:04:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id E84E0202660C; Fri, 15 Jun 2018 17:03:59 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C0AA2026609 for ; Fri, 15 Jun 2018 17:03:59 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:48 +0200 Message-Id: <20180615170350.20851-13-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 12/14] Implement NodeDeviceLookupSCSIHostByWWN method for Connect Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 15 Jun 2018 17:04:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.Connect.xml | 8 ++++++++ src/connect.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index a030d57..7014a09 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -221,6 +221,14 @@ + + + + + + + diff --git a/src/connect.c b/src/connect.c index 6192f47..e1406dd 100644 --- a/src/connect.c +++ b/src/connect.c @@ -1126,6 +1126,37 @@ virtDBusConnectNodeDeviceLookupByName(GVariant *inAr= gs, *outArgs =3D g_variant_new("(o)", path); } =20 +static void +virtDBusConnectNodeDeviceLookupSCSIHostByWWN(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNU= SED, + const gchar *objectPath G_GNU= C_UNUSED, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_U= NUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + g_autofree gchar *path =3D NULL; + const gchar *wwnn; + const gchar *wwpn; + guint flags; + + g_variant_get(inArgs, "(&s&su)", &wwnn, &wwpn, &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + dev =3D virNodeDeviceLookupSCSIHostByWWN(connect->connection, wwnn, ww= pn, + flags); + if (!dev) + return virtDBusUtilSetLastVirtError(error); + + path =3D virtDBusUtilBusPathForVirNodeDevice(dev, connect->devPath); + + *outArgs =3D g_variant_new("(o)", path); +} + static void virtDBusConnectNWFilterDefineXML(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1746,6 +1777,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethod= Table[] =3D { { "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID }, { "NodeDeviceCreateXML", virtDBusConnectNodeDeviceCreateXML }, { "NodeDeviceLookupByName", virtDBusConnectNodeDeviceLookupByName }, + { "NodeDeviceLookupSCSIHostByWWN", virtDBusConnectNodeDeviceLookupSCSI= HostByWWN }, { "NWFilterDefineXML", virtDBusConnectNWFilterDefineXML }, { "NWFilterLookupByName", virtDBusConnectNWFilterLookupByName }, { "NWFilterLookupByUUID", virtDBusConnectNWFilterLookupByUUID }, --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082276746238.86154031098806; Fri, 15 Jun 2018 10:04:36 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A44D88765D; Fri, 15 Jun 2018 17:04:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6FFB1BC58C; Fri, 15 Jun 2018 17:04:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1AC504CA8B; Fri, 15 Jun 2018 17:04:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH40Gw029875 for ; Fri, 15 Jun 2018 13:04:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 89FF2202660C; Fri, 15 Jun 2018 17:04:00 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DEDC2026609 for ; Fri, 15 Jun 2018 17:04:00 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:49 +0200 Message-Id: <20180615170350.20851-14-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 13/14] Implement ReAttach method for NodeDevice Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 15 Jun 2018 17:04:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.NodeDevice.xml | 4 ++++ src/nodedev.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.= xml index bf85958..56deee3 100644 --- a/data/org.libvirt.NodeDevice.xml +++ b/data/org.libvirt.NodeDevice.xml @@ -33,5 +33,9 @@ value=3D"See https://libvirt.org/html/libvirt-libvirt-nodedev.html= #virNodeDeviceListCaps"/> + + + diff --git a/src/nodedev.c b/src/nodedev.c index 01fcd35..1d15d79 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -173,6 +173,26 @@ virtDBusNodeDeviceListCaps(GVariant *inArgs G_GNUC_UNU= SED, *outArgs =3D g_variant_new_tuple(&gret, 1); } =20 +static void +virtDBusNodeDeviceReAttach(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + + dev =3D virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error); + if (!dev) + return; + + if (virNodeDeviceReAttach(dev) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] =3D { { "Name", virtDBusNodeDeviceGetName, NULL }, { "Parent", virtDBusNodeDeviceGetParent, NULL }, @@ -184,6 +204,7 @@ static virtDBusGDBusMethodTable virtDBusNodeDeviceMetho= dTable[] =3D { { "Detach", virtDBusNodeDeviceDetach }, { "GetXMLDesc", virtDBusNodeDeviceGetXMLDesc }, { "ListCaps", virtDBusNodeDeviceListCaps }, + { "ReAttach", virtDBusNodeDeviceReAttach }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 11:46:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529082280325910.2056594247803; Fri, 15 Jun 2018 10:04:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A775B655; Fri, 15 Jun 2018 17:04:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DBC488B6D; Fri, 15 Jun 2018 17:04:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D01254CA8A; Fri, 15 Jun 2018 17:04:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5FH416e029885 for ; Fri, 15 Jun 2018 13:04:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2DCB12026990; Fri, 15 Jun 2018 17:04:01 +0000 (UTC) Received: from katerina.brq.redhat.com (unknown [10.43.2.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5D752026DEF for ; Fri, 15 Jun 2018 17:04:00 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Fri, 15 Jun 2018 19:03:50 +0200 Message-Id: <20180615170350.20851-15-kkoukiou@redhat.com> In-Reply-To: <20180615170350.20851-1-kkoukiou@redhat.com> References: <20180615170350.20851-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [dbus PATCH 14/14] Implement Reset method for NodeDevice Interface X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 15 Jun 2018 17:04:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Katerina Koukiou Reviewed-by: Pavel Hrdina --- data/org.libvirt.NodeDevice.xml | 4 ++++ src/nodedev.c | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/data/org.libvirt.NodeDevice.xml b/data/org.libvirt.NodeDevice.= xml index 56deee3..5464c9a 100644 --- a/data/org.libvirt.NodeDevice.xml +++ b/data/org.libvirt.NodeDevice.xml @@ -37,5 +37,9 @@ + + + diff --git a/src/nodedev.c b/src/nodedev.c index 1d15d79..7982fd1 100644 --- a/src/nodedev.c +++ b/src/nodedev.c @@ -193,6 +193,26 @@ virtDBusNodeDeviceReAttach(GVariant *inArgs G_GNUC_UNU= SED, virtDBusUtilSetLastVirtError(error); } =20 +static void +virtDBusNodeDeviceReset(GVariant *inArgs G_GNUC_UNUSED, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs G_GNUC_UNUSED, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect =3D userData; + g_autoptr(virNodeDevice) dev =3D NULL; + + dev =3D virtDBusNodeDeviceGetVirNodeDevice(connect, objectPath, error); + if (!dev) + return; + + if (virNodeDeviceReset(dev) < 0) + virtDBusUtilSetLastVirtError(error); +} + static virtDBusGDBusPropertyTable virtDBusNodeDevicePropertyTable[] =3D { { "Name", virtDBusNodeDeviceGetName, NULL }, { "Parent", virtDBusNodeDeviceGetParent, NULL }, @@ -205,6 +225,7 @@ static virtDBusGDBusMethodTable virtDBusNodeDeviceMetho= dTable[] =3D { { "GetXMLDesc", virtDBusNodeDeviceGetXMLDesc }, { "ListCaps", virtDBusNodeDeviceListCaps }, { "ReAttach", virtDBusNodeDeviceReAttach }, + { "Reset", virtDBusNodeDeviceReset }, { 0 } }; =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list