Let's move those to their own newly created files
(src/util/virblkio.{c,h}) as this will help us to easily start sharing
the cgroup code that's duplicated between QEMU and LXC.

Signed-off-by: Fabiano Fidêncio <fiden...@redhat.com>
---
 src/conf/domain_conf.c   | 11 +--------
 src/conf/domain_conf.h   | 27 ++-------------------
 src/libvirt_private.syms |  5 +++-
 src/util/Makefile.inc.am |  2 ++
 src/util/virblkio.c      | 37 ++++++++++++++++++++++++++++
 src/util/virblkio.h      | 52 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 98 insertions(+), 36 deletions(-)
 create mode 100644 src/util/virblkio.c
 create mode 100644 src/util/virblkio.h

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 409a2291ff..3384a36d76 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -59,6 +59,7 @@
 #include "virnetdevmacvlan.h"
 #include "virhostdev.h"
 #include "virmdev.h"
+#include "virblkio.h"
 
 #define VIR_FROM_THIS VIR_FROM_DOMAIN
 
@@ -1205,16 +1206,6 @@ virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr 
xmlopt)
 }
 
 
-void
-virBlkioDeviceArrayClear(virBlkioDevicePtr devices,
-                         int ndevices)
-{
-    size_t i;
-
-    for (i = 0; i < ndevices; i++)
-        VIR_FREE(devices[i].path);
-}
-
 /**
  * virDomainBlkioDeviceParseXML
  *
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index e30a4b2fe7..e9e6b6d6c4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -57,6 +57,7 @@
 # include "virtypedparam.h"
 # include "virsavecookie.h"
 # include "virresctrl.h"
+# include "virblkio.h"
 
 /* forward declarations of all device types, required by
  * virDomainDeviceDef
@@ -2084,17 +2085,6 @@ struct _virDomainClockDef {
 };
 
 
-typedef struct _virBlkioDevice virBlkioDevice;
-typedef virBlkioDevice *virBlkioDevicePtr;
-struct _virBlkioDevice {
-    char *path;
-    unsigned int weight;
-    unsigned int riops;
-    unsigned int wiops;
-    unsigned long long rbps;
-    unsigned long long wbps;
-};
-
 typedef enum {
     VIR_DOMAIN_RNG_MODEL_VIRTIO,
 
@@ -2184,9 +2174,6 @@ struct _virDomainPanicDef {
 };
 
 
-void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
-                              int ndevices);
-
 typedef struct _virDomainResourceDef virDomainResourceDef;
 typedef virDomainResourceDef *virDomainResourceDefPtr;
 struct _virDomainResourceDef {
@@ -2260,16 +2247,6 @@ struct _virDomainVcpuDef {
     virObjectPtr privateData;
 };
 
-typedef struct _virDomainBlkiotune virDomainBlkiotune;
-typedef virDomainBlkiotune *virDomainBlkiotunePtr;
-
-struct _virDomainBlkiotune {
-    unsigned int weight;
-
-    size_t ndevices;
-    virBlkioDevicePtr devices;
-};
-
 typedef struct _virDomainMemtune virDomainMemtune;
 typedef virDomainMemtune *virDomainMemtunePtr;
 
@@ -2402,7 +2379,7 @@ struct _virDomainDef {
     char *title;
     char *description;
 
-    virDomainBlkiotune blkio;
+    virBlkioTune blkio;
     virDomainMemtune mem;
 
     virDomainVcpuDefPtr *vcpus;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a0d229a79f..bf1536ea57 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -190,7 +190,6 @@ virSEVCapabilitiesFree;
 
 
 # conf/domain_conf.h
-virBlkioDeviceArrayClear;
 virDiskNameParse;
 virDiskNameToBusDeviceIndex;
 virDiskNameToIndex;
@@ -1471,6 +1470,10 @@ virBitmapToDataBuf;
 virBitmapToString;
 
 
+# util/virblkio.h
+virBlkioDeviceArrayClear;
+
+
 # util/virbuffer.h
 virBufferAdd;
 virBufferAddBuffer;
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index a22265606c..13f415b23c 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -17,6 +17,8 @@ UTIL_SOURCES = \
        util/virauthconfig.h \
        util/virbitmap.c \
        util/virbitmap.h \
+       util/virblkio.c \
+       util/virblkio.h \
        util/virbuffer.c \
        util/virbuffer.h \
        util/virperf.c \
diff --git a/src/util/virblkio.c b/src/util/virblkio.c
new file mode 100644
index 0000000000..9711077ee8
--- /dev/null
+++ b/src/util/virblkio.c
@@ -0,0 +1,37 @@
+/*
+ * virblkio.c: Block IO helpers
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ *  Fabiano Fidêncio <fiden...@redhat.com>
+ */
+
+#include <config.h>
+
+#include "viralloc.h"
+#include "virblkio.h"
+
+void
+virBlkioDeviceArrayClear(virBlkioDevicePtr devices,
+                         int ndevices)
+{
+    size_t i;
+
+    for (i = 0; i < ndevices; i++)
+        VIR_FREE(devices[i].path);
+}
diff --git a/src/util/virblkio.h b/src/util/virblkio.h
new file mode 100644
index 0000000000..aa9788636d
--- /dev/null
+++ b/src/util/virblkio.h
@@ -0,0 +1,52 @@
+/*
+ * virblkio.h: Block IO definitions and helpers
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Author: Fabiano Fidêncio <fiden...@redhat.com>
+ */
+
+#ifndef __VIR_BLKIO_H__
+# define __VIR_BLKIO_H__
+
+# include "virutil.h"
+
+typedef struct _virBlkioDevice virBlkioDevice;
+typedef virBlkioDevice *virBlkioDevicePtr;
+struct _virBlkioDevice {
+    char *path;
+    unsigned int weight;
+    unsigned int riops;
+    unsigned int wiops;
+    unsigned long long rbps;
+    unsigned long long wbps;
+};
+
+
+typedef struct _virBlkioTune virBlkioTune;
+typedef virBlkioTune *virBlkioTunePtr;
+struct _virBlkioTune {
+    unsigned int weight;
+
+    size_t ndevices;
+    virBlkioDevicePtr devices;
+};
+
+void virBlkioDeviceArrayClear(virBlkioDevicePtr deviceWeights,
+                              int ndevices);
+
+#endif /* __VIR_BLKIO_H__ */
-- 
2.17.1

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

Reply via email to