[RFC REPOST 4/7] src: introduce virDomainSetFibreChannelAppid API

Pavel Hrdina posted 7 patches 4 years, 5 months ago
[RFC REPOST 4/7] src: introduce virDomainSetFibreChannelAppid API
Posted by Pavel Hrdina 4 years, 5 months ago
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 include/libvirt/libvirt-domain.h |  4 +++
 src/driver-hypervisor.h          |  6 +++++
 src/libvirt-domain.c             | 44 ++++++++++++++++++++++++++++++++
 src/libvirt_public.syms          |  1 +
 4 files changed, 55 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 7ef8ac51e5..4f7b88ef61 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -5153,4 +5153,8 @@ int virDomainStartDirtyRateCalc(virDomainPtr domain,
                                 int seconds,
                                 unsigned int flags);
 
+int virDomainSetFibreChannelAppid(virDomainPtr domain,
+                                  const char *appid,
+                                  unsigned int flags);
+
 #endif /* LIBVIRT_DOMAIN_H */
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index d642af8a37..e6b1ceb3ce 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1412,6 +1412,11 @@ typedef int
 
 typedef struct _virHypervisorDriver virHypervisorDriver;
 
+typedef int
+(*virDrvDomainSetFibreChannelAppid)(virDomainPtr domain,
+                                    const char *appid,
+                                    unsigned int flags);
+
 /**
  * _virHypervisorDriver:
  *
@@ -1676,4 +1681,5 @@ struct _virHypervisorDriver {
     virDrvDomainAuthorizedSSHKeysSet domainAuthorizedSSHKeysSet;
     virDrvDomainGetMessages domainGetMessages;
     virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc;
+    virDrvDomainSetFibreChannelAppid domainSetFibreChannelAppid;
 };
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index a8a386e839..f3e6854a39 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -13229,3 +13229,47 @@ virDomainStartDirtyRateCalc(virDomainPtr domain,
     virDispatchError(conn);
     return -1;
 }
+
+
+/**
+ * virDomainSetFibreChannelAppid:
+ * @domain: a domain object
+ * @appid: user provided appid string
+ * @flags: extra flags
+ *
+ * Set the Fibre Channel APPID. Accepts only printable characters
+ * and maximal length is 128 characters. To remove the APPID use
+ * NULL as @appid value.
+ *
+ * Returns 0 in case of success, -1 otherwise.
+ */
+int
+virDomainSetFibreChannelAppid(virDomainPtr domain,
+                              const char *appid,
+                              unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "appid=%s, flags=0x%x", appid, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    conn = domain->conn;
+
+    virCheckReadOnlyGoto(conn->flags, error);
+
+    if (conn->driver->domainSetFibreChannelAppid) {
+        int ret;
+        ret = conn->driver->domainSetFibreChannelAppid(domain, appid, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(conn);
+    return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 3a5fa7cb09..912b421632 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -900,6 +900,7 @@ LIBVIRT_7.7.0 {
     global:
         virNWFilterDefineXMLFlags;
         virNetworkDefineXMLFlags;
+        virDomainSetFibreChannelAppid;
 } LIBVIRT_7.3.0;
 
 # .... define new API here using predicted next version number ....
-- 
2.31.1

Re: [RFC REPOST 4/7] src: introduce virDomainSetFibreChannelAppid API
Posted by Michal Prívozník 4 years, 5 months ago
On 9/9/21 6:13 PM, Pavel Hrdina wrote:
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  include/libvirt/libvirt-domain.h |  4 +++
>  src/driver-hypervisor.h          |  6 +++++
>  src/libvirt-domain.c             | 44 ++++++++++++++++++++++++++++++++
>  src/libvirt_public.syms          |  1 +
>  4 files changed, 55 insertions(+)
> 


> diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> index a8a386e839..f3e6854a39 100644
> --- a/src/libvirt-domain.c
> +++ b/src/libvirt-domain.c
> @@ -13229,3 +13229,47 @@ virDomainStartDirtyRateCalc(virDomainPtr domain,
>      virDispatchError(conn);
>      return -1;
>  }
> +
> +
> +/**
> + * virDomainSetFibreChannelAppid:
> + * @domain: a domain object
> + * @appid: user provided appid string
> + * @flags: extra flags

I like the following more:

 * @flags: extra flags; not used yet, so callers should always pass 0

> + *
> + * Set the Fibre Channel APPID. Accepts only printable characters
> + * and maximal length is 128 characters. To remove the APPID use
> + * NULL as @appid value.
> + *
> + * Returns 0 in case of success, -1 otherwise.
> + */

Michal

Re: [RFC REPOST 4/7] src: introduce virDomainSetFibreChannelAppid API
Posted by Pavel Hrdina 4 years, 5 months ago
On Fri, Sep 10, 2021 at 01:49:20PM +0200, Michal Prívozník wrote:
> On 9/9/21 6:13 PM, Pavel Hrdina wrote:
> > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > ---
> >  include/libvirt/libvirt-domain.h |  4 +++
> >  src/driver-hypervisor.h          |  6 +++++
> >  src/libvirt-domain.c             | 44 ++++++++++++++++++++++++++++++++
> >  src/libvirt_public.syms          |  1 +
> >  4 files changed, 55 insertions(+)
> > 
> 
> 
> > diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> > index a8a386e839..f3e6854a39 100644
> > --- a/src/libvirt-domain.c
> > +++ b/src/libvirt-domain.c
> > @@ -13229,3 +13229,47 @@ virDomainStartDirtyRateCalc(virDomainPtr domain,
> >      virDispatchError(conn);
> >      return -1;
> >  }
> > +
> > +
> > +/**
> > + * virDomainSetFibreChannelAppid:
> > + * @domain: a domain object
> > + * @appid: user provided appid string
> > + * @flags: extra flags
> 
> I like the following more:
> 
>  * @flags: extra flags; not used yet, so callers should always pass 0

Not true, @flags are used to control if we are modifying live or config
XML.

Pavel

> > + *
> > + * Set the Fibre Channel APPID. Accepts only printable characters
> > + * and maximal length is 128 characters. To remove the APPID use
> > + * NULL as @appid value.
> > + *
> > + * Returns 0 in case of success, -1 otherwise.
> > + */
> 
> Michal
>