
On Fri, Jun 03, 2011 at 10:15:29AM +0800, Hu Tao wrote:
This patch unify the PARAM_CURRENT/PARAM_LIVE/PARAM_CONFIG flags as Daniel Veillard suggested. --- include/libvirt/libvirt.h.in | 58 ++++--------- src/esx/esx_driver.c | 10 +- src/libvirt.c | 4 +- src/openvz/openvz_driver.c | 10 +- src/qemu/qemu_driver.c | 194 +++++++++++++++++++++--------------------- src/test/test_driver.c | 42 +++++----- src/uml/uml_driver.c | 4 +- src/vbox/vbox_tmpl.c | 22 +++--- tools/virsh.c | 74 ++++++++-------- 9 files changed, 196 insertions(+), 222 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 8058229..8ef07b0 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -142,6 +142,22 @@ typedef enum { } virDomainCrashedReason;
/** + * virDomainParamFlags: + * + * common flags for commands that support --current, --live, --config + * and --force parameters + */ + +typedef enum { + VIR_DOMAIN_PARAM_CURRENT = 0, /* affect current domain state */ + VIR_DOMAIN_PARAM_LIVE = (1 << 0), /* affect active domain */ + VIR_DOMAIN_PARAM_CONFIG = (1 << 1), /* affect next boot */ + VIR_DOMAIN_PARAM_FORCE = (1 << 2), /* Forcibly modify device + (ex. force eject a cdrom) */ + VIR_DOMAIN_PARAM_MAXIMUM = (1 << 3), /* affect Max rather than current */ +} virDomainParamFlags; + +/** * virDomainInfoPtr: * * a virDomainInfo is a structure filled by virDomainGetInfo() and extracting @@ -338,12 +354,6 @@ typedef virTypedParameter *virTypedParameterPtr;
/* Management of scheduler parameters */
-typedef enum { - VIR_DOMAIN_SCHEDPARAM_CURRENT = 0, /* affect current domain state */ - VIR_DOMAIN_SCHEDPARAM_LIVE = (1 << 0), /* Affect active domain */ - VIR_DOMAIN_SCHEDPARAM_CONFIG = (1 << 1), /* Affect next boot */ -} virDomainSchedParameterFlags; - /* * Fetch scheduler parameters, caller allocates 'params' field of size 'nparams' */ @@ -799,13 +809,6 @@ int virDomainGetBlkioParameters(virDomainPtr domain,
/* Manage memory parameters. */
-/* flags for setting memory parameters */ -typedef enum { - VIR_DOMAIN_MEMORY_PARAM_CURRENT = 0, /* affect current domain state */ - VIR_DOMAIN_MEMORY_PARAM_LIVE = (1 << 0), /* affect active domain */ - VIR_DOMAIN_MEMORY_PARAM_CONFIG = (1 << 1) /* affect next boot */ -} virMemoryParamFlags; - /** * VIR_DOMAIN_MEMORY_PARAM_UNLIMITED: * @@ -859,15 +862,6 @@ int virDomainGetMemoryParameters(virDomainPtr domain, virTypedParameterPtr params, int *nparams, unsigned int flags);
-/* Memory size modification flags. */ -typedef enum { - VIR_DOMAIN_MEM_CURRENT = 0, /* affect current domain state */ - VIR_DOMAIN_MEM_LIVE = (1 << 0), /* affect active domain */ - VIR_DOMAIN_MEM_CONFIG = (1 << 1), /* affect next boot */ - VIR_DOMAIN_MEM_MAXIMUM = (1 << 2), /* affect Max rather than current */ -} virDomainMemoryModFlags; - - /* * Dynamic control of domains */ @@ -1023,16 +1017,6 @@ struct _virVcpuInfo { }; typedef virVcpuInfo *virVcpuInfoPtr;
-/* Flags for controlling virtual CPU hot-plugging. */ -typedef enum { - /* Must choose at least one of these two bits; SetVcpus can choose both */ - VIR_DOMAIN_VCPU_LIVE = (1 << 0), /* Affect active domain */ - VIR_DOMAIN_VCPU_CONFIG = (1 << 1), /* Affect next boot */ - - /* Additional flags to be bit-wise OR'd in */ - VIR_DOMAIN_VCPU_MAXIMUM = (1 << 2), /* Max rather than current count */ -} virDomainVcpuFlags; - int virDomainSetVcpus (virDomainPtr domain, unsigned int nvcpus); int virDomainSetVcpusFlags (virDomainPtr domain, @@ -1131,16 +1115,6 @@ int virDomainGetVcpus (virDomainPtr domain, */ #define VIR_GET_CPUMAP(cpumaps,maplen,vcpu) &(cpumaps[(vcpu)*(maplen)])
- -typedef enum { - - VIR_DOMAIN_DEVICE_MODIFY_CURRENT = 0, /* Modify device allocation based on current domain state */ - VIR_DOMAIN_DEVICE_MODIFY_LIVE = (1 << 0), /* Modify live device allocation */ - VIR_DOMAIN_DEVICE_MODIFY_CONFIG = (1 << 1), /* Modify persisted device allocation */ - VIR_DOMAIN_DEVICE_MODIFY_FORCE = (1 << 2), /* Forcibly modify device - (ex. force eject a cdrom) */ -} virDomainDeviceModifyFlags; - int virDomainAttachDevice(virDomainPtr domain, const char *xml); int virDomainDetachDevice(virDomainPtr domain, const char *xml);
NACK, you can't just go deleting things from the libvirt.h header file. Everything in there is public API which must be maintained for application compatibility *forever* Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|