mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
util: Move enum convertors into virenum.(c|h)
virutil.(c|h) is a very gross collection of random code. Remove the enum handlers from there so we can limit the scope where virtutil.h is used. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c0abcca417
commit
285c5f28c4
@ -672,6 +672,7 @@ libvirt_setuid_rpc_client_la_SOURCES = \
|
||||
util/vircommand.c \
|
||||
util/virconf.c \
|
||||
util/virdbus.c \
|
||||
util/virenum.c \
|
||||
util/virerror.c \
|
||||
util/virevent.c \
|
||||
util/vireventpoll.c \
|
||||
@ -882,6 +883,8 @@ libvirt_nss_la_SOURCES = \
|
||||
util/virbuffer.h \
|
||||
util/vircommand.c \
|
||||
util/vircommand.h \
|
||||
util/virenum.c \
|
||||
util/virenum.h \
|
||||
util/virerror.c \
|
||||
util/virerror.h \
|
||||
util/virfile.c \
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
# include "internal.h"
|
||||
# include "virutil.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
/**
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "virstring.h"
|
||||
#include "virtypedparam.h"
|
||||
#include "viruuid.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_CAPABILITIES
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
# include "virbitmap.h"
|
||||
# include "virarch.h"
|
||||
# include "numa_conf.h"
|
||||
# include "virenum.h"
|
||||
|
||||
# define VIR_CPU_VENDOR_ID_LENGTH 12
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
# include "virbuffer.h"
|
||||
# include "virpci.h"
|
||||
# include "virnetdev.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
|
||||
|
@ -24,6 +24,7 @@
|
||||
# include "internal.h"
|
||||
# include "domain_conf.h"
|
||||
# include "virautoclean.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef const char * (*virDomainCapsValToStr)(int value);
|
||||
|
||||
|
@ -56,6 +56,7 @@
|
||||
# include "virtypedparam.h"
|
||||
# include "virsavecookie.h"
|
||||
# include "virresctrl.h"
|
||||
# include "virenum.h"
|
||||
|
||||
/* Flags for the 'type' field in virDomainDeviceDef */
|
||||
typedef enum {
|
||||
|
@ -29,6 +29,7 @@
|
||||
# include "virutil.h"
|
||||
# include "virthread.h"
|
||||
# include "device_conf.h"
|
||||
# include "virenum.h"
|
||||
|
||||
/* There is currently 3 types of interfaces */
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
# include "networkcommon_conf.h"
|
||||
# include "virobject.h"
|
||||
# include "virmacmap.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_NETWORK_FORWARD_NONE = 0,
|
||||
|
@ -31,6 +31,7 @@
|
||||
# include "virvhba.h"
|
||||
# include "device_conf.h"
|
||||
# include "storage_adapter_conf.h"
|
||||
# include "virenum.h"
|
||||
|
||||
# include <libxml/tree.h>
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
# include "virutil.h"
|
||||
# include "virbitmap.h"
|
||||
# include "virbuffer.h"
|
||||
# include "virenum.h"
|
||||
|
||||
|
||||
typedef struct _virDomainNuma virDomainNuma;
|
||||
|
@ -33,6 +33,7 @@
|
||||
# include "virsocketaddr.h"
|
||||
# include "virmacaddr.h"
|
||||
# include "virdomainobjlist.h"
|
||||
# include "virenum.h"
|
||||
|
||||
/* XXX
|
||||
* The config parser/structs should not be using platform specific
|
||||
|
@ -25,6 +25,7 @@
|
||||
# include "internal.h"
|
||||
# include "domain_conf.h"
|
||||
# include "moment_conf.h"
|
||||
# include "virenum.h"
|
||||
|
||||
/* Items related to snapshot state */
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
# include "virpci.h"
|
||||
# include "virxml.h"
|
||||
# include "virenum.h"
|
||||
|
||||
|
||||
typedef enum {
|
||||
|
@ -31,6 +31,7 @@
|
||||
# include "object_event.h"
|
||||
# include "storage_adapter_conf.h"
|
||||
# include "virautoclean.h"
|
||||
# include "virenum.h"
|
||||
|
||||
# include <libxml/tree.h>
|
||||
|
||||
|
@ -1784,6 +1784,17 @@ ebtablesContextNew;
|
||||
ebtablesRemoveForwardAllowIn;
|
||||
|
||||
|
||||
# util/virenum.h
|
||||
virEnumFromString;
|
||||
virEnumToString;
|
||||
virTristateBoolFromBool;
|
||||
virTristateBoolTypeFromString;
|
||||
virTristateBoolTypeToString;
|
||||
virTristateSwitchFromBool;
|
||||
virTristateSwitchTypeFromString;
|
||||
virTristateSwitchTypeToString;
|
||||
|
||||
|
||||
# util/virerror.h
|
||||
virDispatchError;
|
||||
virErrorCopyNew;
|
||||
@ -3187,8 +3198,6 @@ virUSBDeviceSetUsedBy;
|
||||
virDoesGroupExist;
|
||||
virDoesUserExist;
|
||||
virDoubleToStr;
|
||||
virEnumFromString;
|
||||
virEnumToString;
|
||||
virFormatIntDecimal;
|
||||
virFormatIntPretty;
|
||||
virGetDeviceID;
|
||||
@ -3234,12 +3243,6 @@ virSetNonBlock;
|
||||
virSetSockReuseAddr;
|
||||
virSetUIDGID;
|
||||
virSetUIDGIDWithCaps;
|
||||
virTristateBoolFromBool;
|
||||
virTristateBoolTypeFromString;
|
||||
virTristateBoolTypeToString;
|
||||
virTristateSwitchFromBool;
|
||||
virTristateSwitchTypeFromString;
|
||||
virTristateSwitchTypeToString;
|
||||
virUpdateSelfLastChanged;
|
||||
virValidateWWN;
|
||||
virWaitForDevices;
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "xen_common.h"
|
||||
#include "xen_xl.h"
|
||||
#include "virnetdevvportprofile.h"
|
||||
#include "virenum.h"
|
||||
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
||||
|
@ -26,6 +26,7 @@
|
||||
# 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 \
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "viruuid.h"
|
||||
#include "virstring.h"
|
||||
#include "virgettext.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#include "locking/lock_daemon_dispatch.h"
|
||||
#include "locking/lock_protocol.h"
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "viruuid.h"
|
||||
#include "virstring.h"
|
||||
#include "virgettext.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#include "log_daemon_dispatch.h"
|
||||
#include "log_protocol.h"
|
||||
|
@ -25,6 +25,7 @@
|
||||
# include "vircgroup.h"
|
||||
# include "lxc_conf.h"
|
||||
# include "lxc_monitor.h"
|
||||
# include "virenum.h"
|
||||
|
||||
|
||||
typedef enum {
|
||||
|
@ -22,6 +22,7 @@
|
||||
# define LIBVIRT_LXC_NATIVE_H
|
||||
|
||||
# include "domain_conf.h"
|
||||
# include "virenum.h"
|
||||
|
||||
# define LXC_CONFIG_FORMAT "lxc-tools"
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "viralloc.h"
|
||||
#include "virjson.h"
|
||||
#include "virlease.h"
|
||||
#include "virenum.h"
|
||||
#include "configmake.h"
|
||||
#include "virgettext.h"
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "virobject.h"
|
||||
#include "virstring.h"
|
||||
#include "base64.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
# include "domain_capabilities.h"
|
||||
# include "virfirmware.h"
|
||||
# include "virfilecache.h"
|
||||
# include "virenum.h"
|
||||
|
||||
/*
|
||||
* Internal flags to keep track of qemu command line capabilities
|
||||
|
@ -25,6 +25,7 @@
|
||||
# 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"
|
||||
|
@ -39,6 +39,7 @@
|
||||
# include "virobject.h"
|
||||
# include "logging/log_manager.h"
|
||||
# include "virdomainmomentobjlist.h"
|
||||
# include "virenum.h"
|
||||
|
||||
# define QEMU_DOMAIN_FORMAT_LIVE_FLAGS \
|
||||
(VIR_DOMAIN_XML_SECURE)
|
||||
|
@ -102,6 +102,7 @@
|
||||
#include "netdev_bandwidth_conf.h"
|
||||
#include "virqemu.h"
|
||||
#include "virdomainsnapshotobjlist.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "virlog.h"
|
||||
#include "virstring.h"
|
||||
#include "viralloc.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
# include "qemu_conf.h"
|
||||
# include "qemu_domain.h"
|
||||
# include "qemu_migration_params.h"
|
||||
# include "virenum.h"
|
||||
|
||||
/*
|
||||
* General function naming conventions:
|
||||
|
@ -20,6 +20,7 @@
|
||||
# define LIBVIRT_QEMU_MIGRATION_COOKIE_H
|
||||
|
||||
# include "qemu_migration_params.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS,
|
||||
|
@ -29,6 +29,7 @@
|
||||
# include "qemu_monitor.h"
|
||||
# include "qemu_conf.h"
|
||||
# include "virautoclean.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
QEMU_MIGRATION_CAP_XBZRLE,
|
||||
|
@ -32,6 +32,7 @@
|
||||
# include "device_conf.h"
|
||||
# include "cpu/cpu.h"
|
||||
# include "util/virgic.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef struct _qemuMonitor qemuMonitor;
|
||||
typedef qemuMonitor *qemuMonitorPtr;
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "virstring.h"
|
||||
#include "cpu/cpu_x86.h"
|
||||
#include "c-strcasestr.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#ifdef WITH_DTRACE_PROBES
|
||||
# include "libvirt_qemu_probes.h"
|
||||
|
@ -49,6 +49,8 @@ UTIL_SOURCES = \
|
||||
util/virebtables.c \
|
||||
util/virebtables.h \
|
||||
util/virendian.h \
|
||||
util/virenum.h \
|
||||
util/virenum.c \
|
||||
util/virerror.c \
|
||||
util/virerror.h \
|
||||
util/virerrorpriv.h \
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
# include "virutil.h"
|
||||
# include "virbitmap.h"
|
||||
# include "virenum.h"
|
||||
|
||||
struct _virCgroup;
|
||||
typedef struct _virCgroup virCgroup;
|
||||
|
@ -22,6 +22,7 @@
|
||||
# define LIBVIRT_VIRCONF_H
|
||||
|
||||
# include "virutil.h"
|
||||
# include "virenum.h"
|
||||
|
||||
/**
|
||||
* virConfType:
|
||||
|
84
src/util/virenum.c
Normal file
84
src/util/virenum.c
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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];
|
||||
}
|
80
src/util/virenum.h
Normal file
80
src/util/virenum.h
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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 */
|
@ -31,6 +31,7 @@
|
||||
#include "virutil.h"
|
||||
#include "virlog.h"
|
||||
#include "virdbus.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_FIREWALLD
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
# define LIBVIRT_VIRGIC_H
|
||||
|
||||
# include "virutil.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_GIC_VERSION_NONE = 0,
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "virstring.h"
|
||||
#include "virutil.h"
|
||||
#include "virbuffer.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#if WITH_YAJL
|
||||
# include <yajl/yajl_gen.h>
|
||||
|
@ -23,6 +23,7 @@
|
||||
# define LIBVIRT_VIRKEYCODE_H
|
||||
|
||||
# include "virutil.h"
|
||||
# include "virenum.h"
|
||||
|
||||
VIR_ENUM_DECL(virKeycodeSet);
|
||||
int virKeycodeValueFromString(virKeycodeSet codeset, const char *keyname);
|
||||
|
@ -23,6 +23,7 @@
|
||||
# include "virobject.h"
|
||||
# include "virutil.h"
|
||||
# include "virautoclean.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
|
||||
|
@ -27,6 +27,7 @@
|
||||
# include "virpci.h"
|
||||
# include "virnetdevvlan.h"
|
||||
# include "virautoclean.h"
|
||||
# include "virenum.h"
|
||||
|
||||
# ifdef HAVE_STRUCT_IFREQ
|
||||
typedef struct ifreq virIfreq;
|
||||
|
@ -26,6 +26,7 @@
|
||||
# include "virnetdevbandwidth.h"
|
||||
# include "virnetdevvportprofile.h"
|
||||
# include "virnetdevvlan.h"
|
||||
# include "virenum.h"
|
||||
|
||||
/* the mode type for macvtap devices */
|
||||
typedef enum {
|
||||
|
@ -22,6 +22,7 @@
|
||||
# include <virutil.h>
|
||||
|
||||
# include "virautoclean.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_NATIVE_VLAN_MODE_DEFAULT = 0,
|
||||
|
@ -23,6 +23,7 @@
|
||||
# include "viruuid.h"
|
||||
# include "virutil.h"
|
||||
# include "virmacaddr.h"
|
||||
# include "virenum.h"
|
||||
|
||||
# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
# include "virobject.h"
|
||||
# include "virutil.h"
|
||||
# include "virautoclean.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef struct _virPCIDevice virPCIDevice;
|
||||
typedef virPCIDevice *virPCIDevicePtr;
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
# 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
|
||||
|
@ -27,6 +27,7 @@
|
||||
# include "internal.h"
|
||||
# include "virbitmap.h"
|
||||
# include "virutil.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_PROC_POLICY_NONE = 0,
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
# include "virbitmap.h"
|
||||
# include "virutil.h"
|
||||
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_CACHE_TYPE_BOTH,
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
# include "virutil.h"
|
||||
# include "virxml.h"
|
||||
# include "virenum.h"
|
||||
|
||||
VIR_ENUM_DECL(virSecretUsage);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
# include "virbuffer.h"
|
||||
# include "virsecret.h"
|
||||
# include "virutil.h"
|
||||
# include "virenum.h"
|
||||
|
||||
# include <libxml/tree.h>
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
# 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.
|
||||
|
@ -25,6 +25,7 @@
|
||||
# include "internal.h"
|
||||
# include "virutil.h"
|
||||
# include "virbuffer.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_SYSINFO_SMBIOS,
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
# include "internal.h"
|
||||
# include "virutil.h"
|
||||
# include "virenum.h"
|
||||
|
||||
/**
|
||||
* VIR_TYPED_PARAM_MULTIPLE:
|
||||
|
@ -84,38 +84,6 @@ verify(sizeof(gid_t) <= sizeof(unsigned int) &&
|
||||
|
||||
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
|
||||
|
||||
@ -324,22 +292,6 @@ virParseVersionString(const char *str, unsigned long *version,
|
||||
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
|
||||
@ -419,16 +371,6 @@ virFormatIntPretty(unsigned long long val,
|
||||
}
|
||||
|
||||
|
||||
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))
|
||||
|
@ -68,32 +68,6 @@ int virDiskNameParse(const char *name, int *disk, int *partition);
|
||||
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)
|
||||
@ -176,34 +150,6 @@ bool virIsSUID(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);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
# include "internal.h"
|
||||
# include "virdomainobjlist.h"
|
||||
# include "virthread.h"
|
||||
# include "virenum.h"
|
||||
|
||||
# define VIR_FROM_THIS VIR_FROM_VMWARE
|
||||
# define PROGRAM_SENTINEL ((char *)0x1)
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "virxml.h"
|
||||
#include "virstring.h"
|
||||
#include "vsh-table.h"
|
||||
#include "virenum.h"
|
||||
|
||||
VIR_ENUM_DECL(virshDomainIOError);
|
||||
VIR_ENUM_IMPL(virshDomainIOError,
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "virsh-nodedev.h"
|
||||
#include "viruri.h"
|
||||
#include "vsh-table.h"
|
||||
#include "virenum.h"
|
||||
|
||||
/* Gnulib doesn't guarantee SA_SIGINFO support. */
|
||||
#ifndef SA_SIGINFO
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "virtypedparam.h"
|
||||
#include "virstring.h"
|
||||
#include "virfile.h"
|
||||
#include "virenum.h"
|
||||
|
||||
/*
|
||||
* "capabilities" command
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "virtime.h"
|
||||
#include "conf/network_conf.h"
|
||||
#include "vsh-table.h"
|
||||
#include "virenum.h"
|
||||
|
||||
#define VIRSH_COMMON_OPT_NETWORK(_helpstr, cflags) \
|
||||
{.name = "network", \
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "virstring.h"
|
||||
#include "virtime.h"
|
||||
#include "conf/node_device_conf.h"
|
||||
#include "virenum.h"
|
||||
|
||||
/*
|
||||
* "nodedev-create" command
|
||||
|
@ -29,6 +29,7 @@
|
||||
#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)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "virstring.h"
|
||||
#include "virtime.h"
|
||||
#include "vsh-table.h"
|
||||
#include "virenum.h"
|
||||
|
||||
static virSecretPtr
|
||||
virshCommandOptSecret(vshControl *ctl, const vshCmd *cmd, const char **name)
|
||||
|
@ -38,6 +38,7 @@
|
||||
#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"), \
|
||||
|
@ -38,6 +38,7 @@
|
||||
#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
|
||||
|
@ -25,6 +25,7 @@
|
||||
# include "internal.h"
|
||||
# include "virutil.h"
|
||||
# include "virbitmap.h"
|
||||
# include "virenum.h"
|
||||
|
||||
typedef enum {
|
||||
VIR_HOST_VALIDATE_FAIL,
|
||||
|
Loading…
Reference in New Issue
Block a user