util/vircommand.c \
util/virconf.c \
util/virdbus.c \
+ util/virenum.c \
util/virerror.c \
util/virevent.c \
util/vireventpoll.c \
util/virbuffer.h \
util/vircommand.c \
util/vircommand.h \
+ util/virenum.c \
+ util/virenum.h \
util/virerror.c \
util/virerror.h \
util/virfile.c \
# include "internal.h"
# include "virutil.h"
+# include "virenum.h"
typedef enum {
/**
#include "virstring.h"
#include "virtypedparam.h"
#include "viruuid.h"
+#include "virenum.h"
#define VIR_FROM_THIS VIR_FROM_CAPABILITIES
# include "virbitmap.h"
# include "virarch.h"
# include "numa_conf.h"
+# include "virenum.h"
# define VIR_CPU_VENDOR_ID_LENGTH 12
# include "virbuffer.h"
# include "virpci.h"
# include "virnetdev.h"
+# include "virenum.h"
typedef enum {
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
# include "internal.h"
# include "domain_conf.h"
# include "virautoclean.h"
+# include "virenum.h"
typedef const char * (*virDomainCapsValToStr)(int value);
# include "virtypedparam.h"
# include "virsavecookie.h"
# include "virresctrl.h"
+# include "virenum.h"
/* Flags for the 'type' field in virDomainDeviceDef */
typedef enum {
# include "virutil.h"
# include "virthread.h"
# include "device_conf.h"
+# include "virenum.h"
/* There is currently 3 types of interfaces */
# include "networkcommon_conf.h"
# include "virobject.h"
# include "virmacmap.h"
+# include "virenum.h"
typedef enum {
VIR_NETWORK_FORWARD_NONE = 0,
# include "virvhba.h"
# include "device_conf.h"
# include "storage_adapter_conf.h"
+# include "virenum.h"
# include <libxml/tree.h>
# include "virutil.h"
# include "virbitmap.h"
# include "virbuffer.h"
+# include "virenum.h"
typedef struct _virDomainNuma virDomainNuma;
# include "virsocketaddr.h"
# include "virmacaddr.h"
# include "virdomainobjlist.h"
+# include "virenum.h"
/* XXX
* The config parser/structs should not be using platform specific
# include "internal.h"
# include "domain_conf.h"
# include "moment_conf.h"
+# include "virenum.h"
/* Items related to snapshot state */
# include "virpci.h"
# include "virxml.h"
+# include "virenum.h"
typedef enum {
# include "object_event.h"
# include "storage_adapter_conf.h"
# include "virautoclean.h"
+# include "virenum.h"
# include <libxml/tree.h>
ebtablesRemoveForwardAllowIn;
+# util/virenum.h
+virEnumFromString;
+virEnumToString;
+virTristateBoolFromBool;
+virTristateBoolTypeFromString;
+virTristateBoolTypeToString;
+virTristateSwitchFromBool;
+virTristateSwitchTypeFromString;
+virTristateSwitchTypeToString;
+
+
# util/virerror.h
virDispatchError;
virErrorCopyNew;
virDoesGroupExist;
virDoesUserExist;
virDoubleToStr;
-virEnumFromString;
-virEnumToString;
virFormatIntDecimal;
virFormatIntPretty;
virGetDeviceID;
virSetSockReuseAddr;
virSetUIDGID;
virSetUIDGIDWithCaps;
-virTristateBoolFromBool;
-virTristateBoolTypeFromString;
-virTristateBoolTypeToString;
-virTristateSwitchFromBool;
-virTristateSwitchTypeFromString;
-virTristateSwitchTypeToString;
virUpdateSelfLastChanged;
virValidateWWN;
virWaitForDevices;
#include "xen_common.h"
#include "xen_xl.h"
#include "virnetdevvportprofile.h"
+#include "virenum.h"
#define VIR_FROM_THIS VIR_FROM_LIBXL
# include "domain_conf.h"
# include "libxl_conf.h"
# include "virchrdev.h"
+# include "virenum.h"
# define JOB_MASK(job) (job == 0 ? 0 : 1 << (job - 1))
# define DEFAULT_JOB_MASK \
#include "viruuid.h"
#include "virstring.h"
#include "virgettext.h"
+#include "virenum.h"
#include "locking/lock_daemon_dispatch.h"
#include "locking/lock_protocol.h"
#include "viruuid.h"
#include "virstring.h"
#include "virgettext.h"
+#include "virenum.h"
#include "log_daemon_dispatch.h"
#include "log_protocol.h"
# include "vircgroup.h"
# include "lxc_conf.h"
# include "lxc_monitor.h"
+# include "virenum.h"
typedef enum {
# define LIBVIRT_LXC_NATIVE_H
# include "domain_conf.h"
+# include "virenum.h"
# define LXC_CONFIG_FORMAT "lxc-tools"
#include "viralloc.h"
#include "virjson.h"
#include "virlease.h"
+#include "virenum.h"
#include "configmake.h"
#include "virgettext.h"
#include "virobject.h"
#include "virstring.h"
#include "base64.h"
+#include "virenum.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
# include "domain_capabilities.h"
# include "virfirmware.h"
# include "virfilecache.h"
+# include "virenum.h"
/*
* Internal flags to keep track of qemu command line capabilities
# include "domain_addr.h"
# include "domain_conf.h"
# include "vircommand.h"
+# include "virenum.h"
# include "capabilities.h"
# include "qemu_block.h"
# include "qemu_conf.h"
# include "virobject.h"
# include "logging/log_manager.h"
# include "virdomainmomentobjlist.h"
+# include "virenum.h"
# define QEMU_DOMAIN_FORMAT_LIVE_FLAGS \
(VIR_DOMAIN_XML_SECURE)
#include "netdev_bandwidth_conf.h"
#include "virqemu.h"
#include "virdomainsnapshotobjlist.h"
+#include "virenum.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
#include "virlog.h"
#include "virstring.h"
#include "viralloc.h"
+#include "virenum.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
# include "qemu_conf.h"
# include "qemu_domain.h"
# include "qemu_migration_params.h"
+# include "virenum.h"
/*
* General function naming conventions:
# define LIBVIRT_QEMU_MIGRATION_COOKIE_H
# include "qemu_migration_params.h"
+# include "virenum.h"
typedef enum {
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS,
# include "qemu_monitor.h"
# include "qemu_conf.h"
# include "virautoclean.h"
+# include "virenum.h"
typedef enum {
QEMU_MIGRATION_CAP_XBZRLE,
# include "device_conf.h"
# include "cpu/cpu.h"
# include "util/virgic.h"
+# include "virenum.h"
typedef struct _qemuMonitor qemuMonitor;
typedef qemuMonitor *qemuMonitorPtr;
#include "virstring.h"
#include "cpu/cpu_x86.h"
#include "c-strcasestr.h"
+#include "virenum.h"
#ifdef WITH_DTRACE_PROBES
# include "libvirt_qemu_probes.h"
util/virebtables.c \
util/virebtables.h \
util/virendian.h \
+ util/virenum.h \
+ util/virenum.c \
util/virerror.c \
util/virerror.h \
util/virerrorpriv.h \
# include "virutil.h"
# include "virbitmap.h"
+# include "virenum.h"
struct _virCgroup;
typedef struct _virCgroup virCgroup;
# define LIBVIRT_VIRCONF_H
# include "virutil.h"
+# include "virenum.h"
/**
* virConfType:
--- /dev/null
+/*
+ * virenum.c: enum value conversion helpers
+ *
+ * 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/>.
+ */
+#include <config.h>
+
+#include "virenum.h"
+#include "virstring.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+VIR_ENUM_IMPL(virTristateBool, VIR_TRISTATE_BOOL_LAST,
+ "default",
+ "yes",
+ "no",
+);
+
+VIR_ENUM_IMPL(virTristateSwitch, VIR_TRISTATE_SWITCH_LAST,
+ "default",
+ "on",
+ "off",
+);
+
+
+virTristateBool
+virTristateBoolFromBool(bool val)
+{
+ if (val)
+ return VIR_TRISTATE_BOOL_YES;
+ else
+ return VIR_TRISTATE_BOOL_NO;
+}
+
+
+virTristateSwitch
+virTristateSwitchFromBool(bool val)
+{
+ if (val)
+ return VIR_TRISTATE_SWITCH_ON;
+ else
+ return VIR_TRISTATE_SWITCH_OFF;
+}
+
+
+int
+virEnumFromString(const char * const *types,
+ unsigned int ntypes,
+ const char *type)
+{
+ size_t i;
+ if (!type)
+ return -1;
+
+ for (i = 0; i < ntypes; i++)
+ if (STREQ(types[i], type))
+ return i;
+
+ return -1;
+}
+
+
+const char *
+virEnumToString(const char * const *types,
+ unsigned int ntypes,
+ int type)
+{
+ if (type < 0 || type >= ntypes)
+ return NULL;
+
+ return types[type];
+}
--- /dev/null
+/*
+ * virenum.h: enum value conversion helpers
+ *
+ * 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/>.
+ */
+
+#ifndef LIBVIRT_VIRENUM_H
+# define LIBVIRT_VIRENUM_H
+
+# include "internal.h"
+
+int
+virEnumFromString(const char * const *types,
+ unsigned int ntypes,
+ const char *type);
+
+const char *
+virEnumToString(const char * const *types,
+ unsigned int ntypes,
+ int type);
+
+# define VIR_ENUM_IMPL(name, lastVal, ...) \
+ static const char *const name ## TypeList[] = { __VA_ARGS__ }; \
+ const char *name ## TypeToString(int type) { \
+ return virEnumToString(name ## TypeList, \
+ ARRAY_CARDINALITY(name ## TypeList), \
+ type); \
+ } \
+ int name ## TypeFromString(const char *type) { \
+ return virEnumFromString(name ## TypeList, \
+ ARRAY_CARDINALITY(name ## TypeList), \
+ type); \
+ } \
+ verify(ARRAY_CARDINALITY(name ## TypeList) == lastVal)
+
+# define VIR_ENUM_DECL(name) \
+ const char *name ## TypeToString(int type); \
+ int name ## TypeFromString(const char*type)
+
+typedef enum {
+ VIR_TRISTATE_BOOL_ABSENT = 0,
+ VIR_TRISTATE_BOOL_YES,
+ VIR_TRISTATE_BOOL_NO,
+
+ VIR_TRISTATE_BOOL_LAST
+} virTristateBool;
+
+typedef enum {
+ VIR_TRISTATE_SWITCH_ABSENT = 0,
+ VIR_TRISTATE_SWITCH_ON,
+ VIR_TRISTATE_SWITCH_OFF,
+
+ VIR_TRISTATE_SWITCH_LAST
+} virTristateSwitch;
+
+VIR_ENUM_DECL(virTristateBool);
+VIR_ENUM_DECL(virTristateSwitch);
+
+virTristateBool virTristateBoolFromBool(bool val);
+virTristateSwitch virTristateSwitchFromBool(bool val);
+
+/* the two enums must be in sync to be able to use helpers interchangeably in
+ * some special cases */
+verify((int)VIR_TRISTATE_BOOL_YES == (int)VIR_TRISTATE_SWITCH_ON);
+verify((int)VIR_TRISTATE_BOOL_NO == (int)VIR_TRISTATE_SWITCH_OFF);
+verify((int)VIR_TRISTATE_BOOL_ABSENT == (int)VIR_TRISTATE_SWITCH_ABSENT);
+
+#endif /* LIBVIRT_VIRENUM_H */
#include "virutil.h"
#include "virlog.h"
#include "virdbus.h"
+#include "virenum.h"
#define VIR_FROM_THIS VIR_FROM_FIREWALLD
# define LIBVIRT_VIRGIC_H
# include "virutil.h"
+# include "virenum.h"
typedef enum {
VIR_GIC_VERSION_NONE = 0,
#include "virstring.h"
#include "virutil.h"
#include "virbuffer.h"
+#include "virenum.h"
#if WITH_YAJL
# include <yajl/yajl_gen.h>
# define LIBVIRT_VIRKEYCODE_H
# include "virutil.h"
+# include "virenum.h"
VIR_ENUM_DECL(virKeycodeSet);
int virKeycodeValueFromString(virKeycodeSet codeset, const char *keyname);
# include "virobject.h"
# include "virutil.h"
# include "virautoclean.h"
+# include "virenum.h"
typedef enum {
VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
# include "virpci.h"
# include "virnetdevvlan.h"
# include "virautoclean.h"
+# include "virenum.h"
# ifdef HAVE_STRUCT_IFREQ
typedef struct ifreq virIfreq;
# include "virnetdevbandwidth.h"
# include "virnetdevvportprofile.h"
# include "virnetdevvlan.h"
+# include "virenum.h"
/* the mode type for macvtap devices */
typedef enum {
# include <virutil.h>
# include "virautoclean.h"
+# include "virenum.h"
typedef enum {
VIR_NATIVE_VLAN_MODE_DEFAULT = 0,
# include "viruuid.h"
# include "virutil.h"
# include "virmacaddr.h"
+# include "virenum.h"
# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
# include "virobject.h"
# include "virutil.h"
# include "virautoclean.h"
+# include "virenum.h"
typedef struct _virPCIDevice virPCIDevice;
typedef virPCIDevice *virPCIDevicePtr;
# include "virutil.h"
# include "virautoclean.h"
+# include "virenum.h"
/* Some Intel processor families introduced some RDT (Resource Director
* Technology) features to monitor or control shared resource based on
# include "internal.h"
# include "virbitmap.h"
# include "virutil.h"
+# include "virenum.h"
typedef enum {
VIR_PROC_POLICY_NONE = 0,
# include "virbitmap.h"
# include "virutil.h"
-
+# include "virenum.h"
typedef enum {
VIR_CACHE_TYPE_BOTH,
# include "virutil.h"
# include "virxml.h"
+# include "virenum.h"
VIR_ENUM_DECL(virSecretUsage);
# include "virbuffer.h"
# include "virsecret.h"
# include "virutil.h"
+# include "virenum.h"
# include <libxml/tree.h>
# include "virutil.h"
# include "virsecret.h"
# include "virautoclean.h"
+# include "virenum.h"
/* Minimum header size required to probe all known formats with
* virStorageFileProbeFormat, or obtain metadata from a known format.
# include "internal.h"
# include "virutil.h"
# include "virbuffer.h"
+# include "virenum.h"
typedef enum {
VIR_SYSINFO_SMBIOS,
# include "internal.h"
# include "virutil.h"
+# include "virenum.h"
/**
* VIR_TYPED_PARAM_MULTIPLE:
VIR_LOG_INIT("util.util");
-VIR_ENUM_IMPL(virTristateBool, VIR_TRISTATE_BOOL_LAST,
- "default",
- "yes",
- "no",
-);
-
-VIR_ENUM_IMPL(virTristateSwitch, VIR_TRISTATE_SWITCH_LAST,
- "default",
- "on",
- "off",
-);
-
-
-virTristateBool
-virTristateBoolFromBool(bool val)
-{
- if (val)
- return VIR_TRISTATE_BOOL_YES;
- else
- return VIR_TRISTATE_BOOL_NO;
-}
-
-
-virTristateSwitch
-virTristateSwitchFromBool(bool val)
-{
- if (val)
- return VIR_TRISTATE_SWITCH_ON;
- else
- return VIR_TRISTATE_SWITCH_OFF;
-}
-
#ifndef WIN32
return 0;
}
-int virEnumFromString(const char *const*types,
- unsigned int ntypes,
- const char *type)
-{
- size_t i;
- if (!type)
- return -1;
-
- for (i = 0; i < ntypes; i++)
- if (STREQ(types[i], type))
- return i;
-
- return -1;
-}
-
-
/**
* Format @val as a base-10 decimal number, in the
* buffer @buf of size @buflen. To allocate a suitable
}
-const char *virEnumToString(const char *const*types,
- unsigned int ntypes,
- int type)
-{
- if (type < 0 || type >= ntypes)
- return NULL;
-
- return types[type];
-}
-
/* Translates a device name of the form (regex) /^[fhv]d[a-z]+[0-9]*$/
* into the corresponding index and partition number
* (e.g. sda0 => (0,0), hdz2 => (25,2), vdaa12 => (26,12))
int virDiskNameToIndex(const char* str);
char *virIndexToDiskName(int idx, const char *prefix);
-int virEnumFromString(const char *const*types,
- unsigned int ntypes,
- const char *type);
-
-const char *virEnumToString(const char *const*types,
- unsigned int ntypes,
- int type);
-
-# define VIR_ENUM_IMPL(name, lastVal, ...) \
- static const char *const name ## TypeList[] = { __VA_ARGS__ }; \
- const char *name ## TypeToString(int type) { \
- return virEnumToString(name ## TypeList, \
- ARRAY_CARDINALITY(name ## TypeList), \
- type); \
- } \
- int name ## TypeFromString(const char *type) { \
- return virEnumFromString(name ## TypeList, \
- ARRAY_CARDINALITY(name ## TypeList), \
- type); \
- } \
- verify(ARRAY_CARDINALITY(name ## TypeList) == lastVal)
-
-# define VIR_ENUM_DECL(name) \
- const char *name ## TypeToString(int type); \
- int name ## TypeFromString(const char*type)
-
/* No-op workarounds for functionality missing in mingw. */
# ifndef HAVE_GETUID
static inline int getuid(void)
time_t virGetSelfLastChanged(void);
void virUpdateSelfLastChanged(const char *path);
-typedef enum {
- VIR_TRISTATE_BOOL_ABSENT = 0,
- VIR_TRISTATE_BOOL_YES,
- VIR_TRISTATE_BOOL_NO,
-
- VIR_TRISTATE_BOOL_LAST
-} virTristateBool;
-
-typedef enum {
- VIR_TRISTATE_SWITCH_ABSENT = 0,
- VIR_TRISTATE_SWITCH_ON,
- VIR_TRISTATE_SWITCH_OFF,
-
- VIR_TRISTATE_SWITCH_LAST
-} virTristateSwitch;
-
-VIR_ENUM_DECL(virTristateBool);
-VIR_ENUM_DECL(virTristateSwitch);
-
-virTristateBool virTristateBoolFromBool(bool val);
-virTristateSwitch virTristateSwitchFromBool(bool val);
-
-/* the two enums must be in sync to be able to use helpers interchangeably in
- * some special cases */
-verify((int)VIR_TRISTATE_BOOL_YES == (int)VIR_TRISTATE_SWITCH_ON);
-verify((int)VIR_TRISTATE_BOOL_NO == (int)VIR_TRISTATE_SWITCH_OFF);
-verify((int)VIR_TRISTATE_BOOL_ABSENT == (int)VIR_TRISTATE_SWITCH_ABSENT);
-
unsigned int virGetListenFDs(void);
char *virGetUNIXSocketPath(int fd);
# include "internal.h"
# include "virdomainobjlist.h"
# include "virthread.h"
+# include "virenum.h"
# define VIR_FROM_THIS VIR_FROM_VMWARE
# define PROGRAM_SENTINEL ((char *)0x1)
#include "virxml.h"
#include "virstring.h"
#include "vsh-table.h"
+#include "virenum.h"
VIR_ENUM_DECL(virshDomainIOError);
VIR_ENUM_IMPL(virshDomainIOError,
#include "virsh-nodedev.h"
#include "viruri.h"
#include "vsh-table.h"
+#include "virenum.h"
/* Gnulib doesn't guarantee SA_SIGINFO support. */
#ifndef SA_SIGINFO
#include "virtypedparam.h"
#include "virstring.h"
#include "virfile.h"
+#include "virenum.h"
/*
* "capabilities" command
#include "virtime.h"
#include "conf/network_conf.h"
#include "vsh-table.h"
+#include "virenum.h"
#define VIRSH_COMMON_OPT_NETWORK(_helpstr, cflags) \
{.name = "network", \
#include "virstring.h"
#include "virtime.h"
#include "conf/node_device_conf.h"
+#include "virenum.h"
/*
* "nodedev-create" command
#include "virstring.h"
#include "virtime.h"
#include "vsh-table.h"
+#include "virenum.h"
#define VIRSH_COMMON_OPT_POOL_FULL(cflags) \
VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"), cflags)
#include "virstring.h"
#include "virtime.h"
#include "vsh-table.h"
+#include "virenum.h"
static virSecretPtr
virshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name)
#include "virxml.h"
#include "virstring.h"
#include "vsh-table.h"
+#include "virenum.h"
#define VIRSH_COMMON_OPT_POOL_FULL \
VIRSH_COMMON_OPT_POOL(N_("pool name or uuid"), \
#include "virtime.h"
#include "virt-admin-completer.h"
#include "vsh-table.h"
+#include "virenum.h"
/* Gnulib doesn't guarantee SA_SIGINFO support. */
#ifndef SA_SIGINFO
# include "internal.h"
# include "virutil.h"
# include "virbitmap.h"
+# include "virenum.h"
typedef enum {
VIR_HOST_VALIDATE_FAIL,