[PATCH 2/5] vz: add net group to all domain stats

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

 



---
 src/vz/vz_driver.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 6d173ef..c282858 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -3586,6 +3586,47 @@ vzDomainGetBlockStats(virDomainObjPtr dom,
     return 0;
 }
 
+static int
+vzDomainGetNetStats(virDomainObjPtr dom,
+                    virDomainStatsRecordPtr record,
+                    int *maxparams)
+{
+    vzDomObjPtr privdom = dom->privateData;
+    size_t i;
+    char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
+
+    if (virTypedParamsAddUInt(&record->params,
+                              &record->nparams,
+                              maxparams,
+                              "net.count",
+                              dom->def->nnets) < 0)
+        return -1;
+
+    for (i = 0; i < dom->def->nnets; i++) {
+        virDomainInterfaceStatsStruct stat;
+        virDomainNetDefPtr net = dom->def->nets[i];
+
+        if (prlsdkGetNetStats(privdom->stats, privdom->sdkdom, net->ifname,
+                              &stat) < 0)
+            return -1;
+
+        snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "net.%zu.name", i);
+        if (virTypedParamsAddString(&record->params,
+                                    &record->nparams,
+                                    maxparams,
+                                    param_name,
+                                    net->ifname) < 0)
+            return -1;
+
+        VZ_ADD_STAT_PARAM_UUL("net", rx_bytes, "rx.bytes");
+        VZ_ADD_STAT_PARAM_UUL("net", rx_packets, "rx.pkts");
+        VZ_ADD_STAT_PARAM_UUL("net", tx_bytes, "tx.bytes");
+        VZ_ADD_STAT_PARAM_UUL("net", tx_packets, "tx.pkts");
+    }
+
+    return 0;
+}
+
 static virDomainStatsRecordPtr
 vzDomainGetAllStats(virConnectPtr conn,
                     virDomainObjPtr dom)
@@ -3599,6 +3640,9 @@ vzDomainGetAllStats(virConnectPtr conn,
     if (vzDomainGetBlockStats(dom, stat, &maxparams) < 0)
         goto error;
 
+    if (vzDomainGetNetStats(dom, stat, &maxparams) < 0)
+        goto error;
+
     if (!(stat->dom = virGetDomain(conn, dom->def->name, dom->def->uuid)))
         goto error;
 
-- 
1.8.3.1

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux