提交 7b1fe89a 编写于 作者: D Daniel P. Berrange

Misc win32 build fixes

* daemon/Makefile.am: Fix missing sasl rule
* src/datatypes.c: Add unistd.h to avoid gnulib bug
* src/util/cgroup.c: Disable mntent if not available
上级 e1f5f851
...@@ -243,6 +243,9 @@ install-data-sasl: ...@@ -243,6 +243,9 @@ install-data-sasl:
uninstall-data-sasl: uninstall-data-sasl:
rm -f $(DESTDIR)$(sysconfdir)/sasl2/libvirt.conf rm -f $(DESTDIR)$(sysconfdir)/sasl2/libvirt.conf
rmdir $(DESTDIR)$(sysconfdir)/sasl2/ rmdir $(DESTDIR)$(sysconfdir)/sasl2/
else
install-data-sasl:
uninstall-data-sasl:
endif endif
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
*/ */
#include <config.h> #include <config.h>
#include <unistd.h>
#include "datatypes.h" #include "datatypes.h"
#include "virterror_internal.h" #include "virterror_internal.h"
......
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <inttypes.h> #include <inttypes.h>
#ifdef HAVE_MNTENT_H
#include <mntent.h> #include <mntent.h>
#endif
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
...@@ -68,7 +70,7 @@ void virCgroupFree(virCgroupPtr *group) ...@@ -68,7 +70,7 @@ void virCgroupFree(virCgroupPtr *group)
VIR_FREE(*group); VIR_FREE(*group);
} }
#ifdef HAVE_MNTENT_H
/* /*
* Process /proc/mounts figuring out what controllers are * Process /proc/mounts figuring out what controllers are
* mounted and where * mounted and where
...@@ -233,6 +235,7 @@ static int virCgroupDetect(virCgroupPtr group) ...@@ -233,6 +235,7 @@ static int virCgroupDetect(virCgroupPtr group)
return rc; return rc;
} }
#endif
static int virCgroupPathOfController(virCgroupPtr group, static int virCgroupPathOfController(virCgroupPtr group,
...@@ -317,12 +320,12 @@ static int virCgroupGetValueStr(virCgroupPtr group, ...@@ -317,12 +320,12 @@ static int virCgroupGetValueStr(virCgroupPtr group,
static int virCgroupSetValueU64(virCgroupPtr group, static int virCgroupSetValueU64(virCgroupPtr group,
int controller, int controller,
const char *key, const char *key,
uint64_t value) unsigned long long int value)
{ {
char *strval = NULL; char *strval = NULL;
int rc; int rc;
if (virAsprintf(&strval, "%" PRIu64, value) == -1) if (virAsprintf(&strval, "%llu", value) == -1)
return -ENOMEM; return -ENOMEM;
rc = virCgroupSetValueStr(group, controller, key, strval); rc = virCgroupSetValueStr(group, controller, key, strval);
...@@ -339,12 +342,12 @@ static int virCgroupSetValueU64(virCgroupPtr group, ...@@ -339,12 +342,12 @@ static int virCgroupSetValueU64(virCgroupPtr group,
static int virCgroupSetValueI64(virCgroupPtr group, static int virCgroupSetValueI64(virCgroupPtr group,
int controller, int controller,
const char *key, const char *key,
int64_t value) long long int value)
{ {
char *strval = NULL; char *strval = NULL;
int rc; int rc;
if (virAsprintf(&strval, "%" PRIi64, value) == -1) if (virAsprintf(&strval, "%lld", value) == -1)
return -ENOMEM; return -ENOMEM;
rc = virCgroupSetValueStr(group, controller, key, strval); rc = virCgroupSetValueStr(group, controller, key, strval);
...@@ -357,7 +360,7 @@ static int virCgroupSetValueI64(virCgroupPtr group, ...@@ -357,7 +360,7 @@ static int virCgroupSetValueI64(virCgroupPtr group,
static int virCgroupGetValueI64(virCgroupPtr group, static int virCgroupGetValueI64(virCgroupPtr group,
int controller, int controller,
const char *key, const char *key,
int64_t *value) long long int *value)
{ {
char *strval = NULL; char *strval = NULL;
int rc = 0; int rc = 0;
...@@ -378,7 +381,7 @@ out: ...@@ -378,7 +381,7 @@ out:
static int virCgroupGetValueU64(virCgroupPtr group, static int virCgroupGetValueU64(virCgroupPtr group,
int controller, int controller,
const char *key, const char *key,
uint64_t *value) unsigned long long int *value)
{ {
char *strval = NULL; char *strval = NULL;
int rc = 0; int rc = 0;
...@@ -387,7 +390,7 @@ static int virCgroupGetValueU64(virCgroupPtr group, ...@@ -387,7 +390,7 @@ static int virCgroupGetValueU64(virCgroupPtr group,
if (rc != 0) if (rc != 0)
goto out; goto out;
if (sscanf(strval, "%" SCNu64, value) != 1) if (virStrToLong_ull(strval, NULL, 10, value) < 0)
rc = -EINVAL; rc = -EINVAL;
out: out:
VIR_FREE(strval); VIR_FREE(strval);
...@@ -396,6 +399,7 @@ out: ...@@ -396,6 +399,7 @@ out:
} }
#ifdef HAVE_MNTENT_H
static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group) static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group)
{ {
int i; int i;
...@@ -546,7 +550,7 @@ cleanup: ...@@ -546,7 +550,7 @@ cleanup:
virCgroupFree(&rootgrp); virCgroupFree(&rootgrp);
return rc; return rc;
} }
#endif
/** /**
* virCgroupRemove: * virCgroupRemove:
...@@ -617,6 +621,7 @@ int virCgroupAddTask(virCgroupPtr group, pid_t pid) ...@@ -617,6 +621,7 @@ int virCgroupAddTask(virCgroupPtr group, pid_t pid)
* *
* Returns 0 on success * Returns 0 on success
*/ */
#ifdef HAVE_MNTENT_H
int virCgroupForDriver(const char *name, int virCgroupForDriver(const char *name,
virCgroupPtr *group, virCgroupPtr *group,
int privileged, int privileged,
...@@ -650,6 +655,16 @@ out: ...@@ -650,6 +655,16 @@ out:
return rc; return rc;
} }
#else
int virCgroupForDriver(const char *name ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED,
int privileged ATTRIBUTE_UNUSED,
int create ATTRIBUTE_UNUSED)
{
/* Claim no support */
return -ENXIO;
}
#endif
/** /**
...@@ -661,6 +676,7 @@ out: ...@@ -661,6 +676,7 @@ out:
* *
* Returns 0 on success * Returns 0 on success
*/ */
#ifdef HAVE_MNTENT_H
int virCgroupForDomain(virCgroupPtr driver, int virCgroupForDomain(virCgroupPtr driver,
const char *name, const char *name,
virCgroupPtr *group, virCgroupPtr *group,
...@@ -684,6 +700,15 @@ int virCgroupForDomain(virCgroupPtr driver, ...@@ -684,6 +700,15 @@ int virCgroupForDomain(virCgroupPtr driver,
return rc; return rc;
} }
#else
int virCgroupForDomain(virCgroupPtr driver ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
virCgroupPtr *group ATTRIBUTE_UNUSED,
int create ATTRIBUTE_UNUSED)
{
return -ENXIO;
}
#endif
/** /**
* virCgroupSetMemory: * virCgroupSetMemory:
...@@ -806,6 +831,7 @@ int virCgroupAllowDeviceMajor(virCgroupPtr group, char type, int major) ...@@ -806,6 +831,7 @@ int virCgroupAllowDeviceMajor(virCgroupPtr group, char type, int major)
* *
* Returns: 0 on success * Returns: 0 on success
*/ */
#if defined(major) && defined(minor)
int virCgroupAllowDevicePath(virCgroupPtr group, const char *path) int virCgroupAllowDevicePath(virCgroupPtr group, const char *path)
{ {
struct stat sb; struct stat sb;
...@@ -821,6 +847,14 @@ int virCgroupAllowDevicePath(virCgroupPtr group, const char *path) ...@@ -821,6 +847,14 @@ int virCgroupAllowDevicePath(virCgroupPtr group, const char *path)
major(sb.st_rdev), major(sb.st_rdev),
minor(sb.st_rdev)); minor(sb.st_rdev));
} }
#else
int virCgroupAllowDevicePath(virCgroupPtr group ATTRIBUTE_UNUSED,
const char *path ATTRIBUTE_UNUSED)
{
return -ENOSYS;
}
#endif
/** /**
* virCgroupDenyDevice: * virCgroupDenyDevice:
...@@ -881,6 +915,7 @@ int virCgroupDenyDeviceMajor(virCgroupPtr group, char type, int major) ...@@ -881,6 +915,7 @@ int virCgroupDenyDeviceMajor(virCgroupPtr group, char type, int major)
return rc; return rc;
} }
#if defined(major) && defined(minor)
int virCgroupDenyDevicePath(virCgroupPtr group, const char *path) int virCgroupDenyDevicePath(virCgroupPtr group, const char *path)
{ {
struct stat sb; struct stat sb;
...@@ -896,26 +931,33 @@ int virCgroupDenyDevicePath(virCgroupPtr group, const char *path) ...@@ -896,26 +931,33 @@ int virCgroupDenyDevicePath(virCgroupPtr group, const char *path)
major(sb.st_rdev), major(sb.st_rdev),
minor(sb.st_rdev)); minor(sb.st_rdev));
} }
#else
int virCgroupDenyDevicePath(virCgroupPtr group ATTRIBUTE_UNUSED,
const char *path ATTRIBUTE_UNUSED)
{
return -ENOSYS;
}
#endif
int virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares) int virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares)
{ {
return virCgroupSetValueU64(group, return virCgroupSetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU, VIR_CGROUP_CONTROLLER_CPU,
"cpu.shares", (uint64_t)shares); "cpu.shares", shares);
} }
int virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares) int virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares)
{ {
return virCgroupGetValueU64(group, return virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPU, VIR_CGROUP_CONTROLLER_CPU,
"cpu.shares", (uint64_t *)shares); "cpu.shares", shares);
} }
int virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage) int virCgroupGetCpuacctUsage(virCgroupPtr group, unsigned long long *usage)
{ {
return virCgroupGetValueU64(group, return virCgroupGetValueU64(group,
VIR_CGROUP_CONTROLLER_CPUACCT, VIR_CGROUP_CONTROLLER_CPUACCT,
"cpuacct.usage", (uint64_t *)usage); "cpuacct.usage", usage);
} }
int virCgroupSetFreezerState(virCgroupPtr group, const char *state) int virCgroupSetFreezerState(virCgroupPtr group, const char *state)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册