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

[libvirt] [PATCH 2/6] virDomain{Get, Set}PerfEvents: Add @flags argument



I've noticed that these APIs are missing @flags argument. Even
though we don't have a use for them, it's our policy that every
new API must have @flags.

Signed-off-by: Michal Privoznik <mprivozn redhat com>
---
 daemon/remote.c                  |  2 +-
 include/libvirt/libvirt-domain.h |  6 ++++--
 src/driver-hypervisor.h          |  6 ++++--
 src/libvirt-domain.c             | 22 ++++++++++++++--------
 src/qemu/qemu_driver.c           | 11 ++++++++---
 src/remote/remote_driver.c       |  4 +++-
 src/remote/remote_protocol.x     |  2 ++
 tools/virsh-domain.c             |  5 +++--
 8 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index bbe22b0..9db93ff 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2694,7 +2694,7 @@ remoteDispatchDomainGetPerfEvents(virNetServerPtr server ATTRIBUTE_UNUSED,
     if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
         goto cleanup;
 
-    if (virDomainGetPerfEvents(dom, &params, &nparams) < 0)
+    if (virDomainGetPerfEvents(dom, &params, &nparams, args->flags) < 0)
         goto cleanup;
 
     if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 552a40b..728b6eb 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1848,10 +1848,12 @@ void virDomainStatsRecordListFree(virDomainStatsRecordPtr *stats);
 
 int virDomainGetPerfEvents(virDomainPtr dom,
                            virTypedParameterPtr *params,
-                           int *nparams);
+                           int *nparams,
+                           unsigned int flags);
 int virDomainSetPerfEvents(virDomainPtr dom,
                            virTypedParameterPtr params,
-                           int nparams);
+                           int nparams,
+                           unsigned int flags);
 
 /*
  * BlockJob API
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index d0e7298..d11ff7f 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -964,12 +964,14 @@ typedef int
 typedef int
 (*virDrvDomainGetPerfEvents)(virDomainPtr dom,
                              virTypedParameterPtr *params,
-                             int *nparams);
+                             int *nparams,
+                             unsigned int flags);
 
 typedef int
 (*virDrvDomainSetPerfEvents)(virDomainPtr dom,
                              virTypedParameterPtr params,
-                             int nparams);
+                             int nparams,
+                             unsigned int flags);
 
 typedef int
 (*virDrvDomainBlockJobAbort)(virDomainPtr dom,
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 42031bc..3e144b6 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -9695,6 +9695,7 @@ virDomainOpenChannel(virDomainPtr dom,
  * @domain: a domain object
  * @params: where to store perf events setting
  * @nparams: number of items in @params
+ * @flags: extra flags; not used yet, so callers should always pass 0
  *
  * Get all perf events setting. Possible fields returned in @params are
  * defined by VIR_DOMAIN_PERF_* macros and new fields will likely be
@@ -9704,12 +9705,13 @@ virDomainOpenChannel(virDomainPtr dom,
  */
 int virDomainGetPerfEvents(virDomainPtr domain,
                            virTypedParameterPtr *params,
-                           int *nparams)
+                           int *nparams,
+                           unsigned int flags)
 {
     virConnectPtr conn;
 
-    VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%p",
-                     params, nparams);
+    VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%p flags=%x",
+                     params, nparams, flags);
 
     virResetLastError();
 
@@ -9721,7 +9723,8 @@ int virDomainGetPerfEvents(virDomainPtr domain,
 
     if (conn->driver->domainGetPerfEvents) {
         int ret;
-        ret = conn->driver->domainGetPerfEvents(domain, params, nparams);
+        ret = conn->driver->domainGetPerfEvents(domain, params,
+                                                nparams, flags);
         if (ret < 0)
             goto error;
         return ret;
@@ -9740,6 +9743,7 @@ int virDomainGetPerfEvents(virDomainPtr domain,
  * @params: pointer to perf events parameter object
  * @nparams: number of perf event parameters (this value can be the same
  *           less than the number of parameters supported)
+ * @flags: extra flags; not used yet, so callers should always pass 0
  *
  * Enable or disable the particular list of perf events you care about.
  *
@@ -9747,12 +9751,13 @@ int virDomainGetPerfEvents(virDomainPtr domain,
  */
 int virDomainSetPerfEvents(virDomainPtr domain,
                            virTypedParameterPtr params,
-                           int nparams)
+                           int nparams,
+                           unsigned int flags)
 {
     virConnectPtr conn;
 
-    VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d",
-                     params, nparams);
+    VIR_DOMAIN_DEBUG(domain, "params=%p, nparams=%d flags=%x",
+                     params, nparams, flags);
     VIR_TYPED_PARAMS_DEBUG(params, nparams);
 
     virResetLastError();
@@ -9769,7 +9774,8 @@ int virDomainSetPerfEvents(virDomainPtr domain,
 
     if (conn->driver->domainSetPerfEvents) {
         int ret;
-        ret = conn->driver->domainSetPerfEvents(domain, params, nparams);
+        ret = conn->driver->domainSetPerfEvents(domain, params,
+                                                nparams, flags);
         if (ret < 0)
             goto error;
         return ret;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a0a33a4..cbd520b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10040,7 +10040,8 @@ qemuSetGlobalBWLive(virCgroupPtr cgroup, unsigned long long period,
 static int
 qemuDomainSetPerfEvents(virDomainPtr dom,
                         virTypedParameterPtr params,
-                        int nparams)
+                        int nparams,
+                        unsigned int flags)
 {
     virQEMUDriverPtr driver = dom->conn->privateData;
     size_t i;
@@ -10049,11 +10050,12 @@ qemuDomainSetPerfEvents(virDomainPtr dom,
     qemuDomainObjPrivatePtr priv;
     virDomainDefPtr def;
     virDomainDefPtr persistentDef;
-    unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
     int ret = -1;
     virPerfEventType type;
     bool enabled;
 
+    virCheckFlags(0, -1);
+
     if (virTypedParamsValidate(params, nparams, VIR_PERF_PARAMETERS) < 0)
         return -1;
 
@@ -10107,7 +10109,8 @@ qemuDomainSetPerfEvents(virDomainPtr dom,
 static int
 qemuDomainGetPerfEvents(virDomainPtr dom,
                         virTypedParameterPtr *params,
-                        int *nparams)
+                        int *nparams,
+                        unsigned int flags)
 {
     size_t i;
     virDomainObjPtr vm = NULL;
@@ -10117,6 +10120,8 @@ qemuDomainGetPerfEvents(virDomainPtr dom,
     int maxpar = 0;
     int npar = 0;
 
+    virCheckFlags(0, -1);
+
     if (!(vm = qemuDomObjFromDomain(dom)))
         goto cleanup;
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 254e0e9..b03c9ca 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1819,7 +1819,8 @@ remoteDomainGetNumaParameters(virDomainPtr domain,
 static int
 remoteDomainGetPerfEvents(virDomainPtr domain,
                           virTypedParameterPtr *params,
-                          int *nparams)
+                          int *nparams,
+                          unsigned int flags)
 {
     int rv = -1;
     remote_domain_get_perf_events_args args;
@@ -1829,6 +1830,7 @@ remoteDomainGetPerfEvents(virDomainPtr domain,
     remoteDriverLock(priv);
 
     make_nonnull_domain(&args.dom, domain);
+    args.flags = flags;
 
     memset(&ret, 0, sizeof(ret));
     if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_PERF_EVENTS,
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index cb19bc0..8bda792 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -634,10 +634,12 @@ struct remote_domain_get_numa_parameters_ret {
 struct remote_domain_set_perf_events_args {
     remote_nonnull_domain dom;
     remote_typed_param params<REMOTE_DOMAIN_PERF_EVENTS_MAX>;
+    unsigned int flags;
 };
 
 struct remote_domain_get_perf_events_args {
     remote_nonnull_domain dom;
+    unsigned int flags;
 };
 
 struct remote_domain_get_perf_events_ret {
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index cda442d..a105268 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8610,6 +8610,7 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
     virTypedParameterPtr params = NULL;
     bool ret = false;
     const char *enable = NULL, *disable = NULL;
+    unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
 
     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
@@ -8627,7 +8628,7 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
 
     if (nparams == 0) {
-        if (virDomainGetPerfEvents(dom, &params, &nparams) != 0) {
+        if (virDomainGetPerfEvents(dom, &params, &nparams, flags) != 0) {
             vshError(ctl, "%s", _("Unable to get perf events"));
             goto cleanup;
         }
@@ -8640,7 +8641,7 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd)
             }
         }
     } else {
-        if (virDomainSetPerfEvents(dom, params, nparams) != 0)
+        if (virDomainSetPerfEvents(dom, params, nparams, flags) != 0)
             goto error;
     }
 
-- 
2.7.3


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