OPENVZ_DRIVER_SOURCES = \
openvz/openvz_conf.c openvz/openvz_conf.h \
- openvz/openvz_driver.c openvz/openvz_driver.h
+ openvz/openvz_driver.c openvz/openvz_driver.h \
+ openvz/openvz_util.c openvz/openvz_util.h
VMWARE_DRIVER_SOURCES = \
vmware/vmware_driver.c vmware/vmware_driver.h \
#include "virterror_internal.h"
#include "openvz_conf.h"
+#include "openvz_util.h"
#include "uuid.h"
#include "buf.h"
#include "memory.h"
char *temp = NULL;
unsigned long long barrier, limit;
const char *param;
- unsigned long kb_per_pages;
+ long kb_per_pages;
- kb_per_pages = sysconf(_SC_PAGESIZE);
- if (kb_per_pages > 0) {
- kb_per_pages /= 1024;
- } else {
- openvzError(VIR_ERR_INTERNAL_ERROR,
- _("Can't determine page size"));
+ kb_per_pages = openvzKBPerPages();
+ if (kb_per_pages < 0)
goto error;
- }
/* Memory allocation guarantee */
param = "VMGUARPAGES";
#include "virterror_internal.h"
#include "datatypes.h"
#include "openvz_driver.h"
+#include "openvz_util.h"
#include "buf.h"
#include "util.h"
#include "openvz_conf.h"
virCheckFlags(0, -1);
- kb_per_pages = sysconf(_SC_PAGESIZE);
- if (kb_per_pages > 0) {
- kb_per_pages /= 1024;
- } else {
- openvzError(VIR_ERR_INTERNAL_ERROR,
- _("Can't determine page size"));
+ kb_per_pages = openvzKBPerPages();
+ if (kb_per_pages < 0)
goto cleanup;
- }
if (*nparams == 0) {
*nparams = OPENVZ_NB_MEM_PARAM;
int i, result = -1;
long kb_per_pages;
- kb_per_pages = sysconf(_SC_PAGESIZE);
- if (kb_per_pages > 0) {
- kb_per_pages /= 1024;
- } else {
- openvzError(VIR_ERR_INTERNAL_ERROR,
- _("Can't determine page size"));
+ kb_per_pages = openvzKBPerPages();
+ if (kb_per_pages < 0)
goto cleanup;
- }
virCheckFlags(0, -1);
if (virTypedParameterArrayValidate(params, nparams,
--- /dev/null
+/*
+ * openvz_driver.c: core driver methods for managing OpenVZ VEs
+ *
+ * Copyright (C) 2012 Guido Günther
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include "internal.h"
+
+#include "virterror_internal.h"
+
+#include "openvz_conf.h"
+#include "openvz_util.h"
+
+
+long
+openvzKBPerPages(void)
+{
+ static long kb_per_pages = 0;
+
+ if (kb_per_pages == 0) {
+ kb_per_pages = sysconf(_SC_PAGESIZE);
+ if (kb_per_pages > 0) {
+ kb_per_pages /= 1024;
+ } else {
+ openvzError(VIR_ERR_INTERNAL_ERROR,
+ _("Can't determine page size"));
+ kb_per_pages = 0;
+ return -1;
+ }
+ }
+ return kb_per_pages;
+}
--- /dev/null
+/*
+ * openvz_driver.h: common util functions for managing openvz VPEs
+ *
+ * Copyright (C) 2012 Guido Günther
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+
+#ifndef OPENVZ_UTIL_H
+# define OPENVZ_UTIL_H
+
+long openvzKBPerPages(void);
+
+#endif