提交 269ce467 编写于 作者: E Eric Blake

domiftune: clean up previous patches

Most severe here is a latent (but currently untriggered) memory leak
if any hypervisor ever adds a string interface property; the
remainder are mainly cosmetic.

* include/libvirt/libvirt.h.in (VIR_DOMAIN_BANDWIDTH_*): Move
macros closer to interface that uses them, and document type.
* src/libvirt.c (virDomainSetInterfaceParameters)
(virDomainGetInterfaceParameters): Formatting tweaks.
* daemon/remote.c (remoteDispatchDomainGetInterfaceParameters):
Avoid memory leak.
* src/libvirt_public.syms (LIBVIRT_0.9.9): Sort lines.
* src/libvirt_private.syms (domain_conf.h): Likewise.
* src/qemu/qemu_driver.c (qemuDomainSetInterfaceParameters): Fix
comments, break long lines.
上级 d82c6bcf
/* /*
* remote.c: handlers for RPC method calls * remote.c: handlers for RPC method calls
* *
* Copyright (C) 2007-2011 Red Hat, Inc. * Copyright (C) 2007-2012 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -3495,9 +3495,10 @@ success: ...@@ -3495,9 +3495,10 @@ success:
cleanup: cleanup:
if (rv < 0) if (rv < 0)
virNetMessageSaveError(rerr); virNetMessageSaveError(rerr);
virTypedParameterArrayClear(params, nparams);
VIR_FREE(params);
if (dom) if (dom)
virDomainFree(dom); virDomainFree(dom);
VIR_FREE(params);
return rv; return rv;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Description: Provides the interfaces of the libvirt library to handle * Description: Provides the interfaces of the libvirt library to handle
* virtualized domains * virtualized domains
* *
* Copy: Copyright (C) 2005-2006, 2010-2011 Red Hat, Inc. * Copy: Copyright (C) 2005-2006, 2010-2012 Red Hat, Inc.
* *
* See COPYING.LIB for the License of this software * See COPYING.LIB for the License of this software
* *
...@@ -645,48 +645,6 @@ typedef virTypedParameter *virTypedParameterPtr; ...@@ -645,48 +645,6 @@ typedef virTypedParameter *virTypedParameterPtr;
*/ */
#define VIR_DOMAIN_SCHEDULER_SHARES "shares" #define VIR_DOMAIN_SCHEDULER_SHARES "shares"
/**
* VIR_DOMAIN_BANDWIDTH_IN_AVERAGE:
*
* Macro represents the inbound average of NIC bandwidth.
*/
#define VIR_DOMAIN_BANDWIDTH_IN_AVERAGE "inbound.average"
/**
* VIR_DOMAIN_BANDWIDTH_IN_PEAK:
*
* Macro represents the inbound peak of NIC bandwidth.
*/
#define VIR_DOMAIN_BANDWIDTH_IN_PEAK "inbound.peak"
/**
* VIR_DOMAIN_BANDWIDTH_IN_BURST:
*
* Macro represents the inbound burst of NIC bandwidth.
*/
#define VIR_DOMAIN_BANDWIDTH_IN_BURST "inbound.burst"
/**
* VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE:
*
* Macro represents the outbound average of NIC bandwidth.
*/
#define VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE "outbound.average"
/**
* VIR_DOMAIN_BANDWIDTH_OUT_PEAK:
*
* Macro represents the outbound peak of NIC bandwidth.
*/
#define VIR_DOMAIN_BANDWIDTH_OUT_PEAK "outbound.peak"
/**
* VIR_DOMAIN_BANDWIDTH_OUT_BURST:
*
* Macro represents the outbound burst of NIC bandwidth.
*/
#define VIR_DOMAIN_BANDWIDTH_OUT_BURST "outbound.burst"
/* /*
* Fetch scheduler parameters, caller allocates 'params' field of size 'nparams' * Fetch scheduler parameters, caller allocates 'params' field of size 'nparams'
*/ */
...@@ -1488,6 +1446,51 @@ int virDomainInterfaceStats (virDomainPtr dom, ...@@ -1488,6 +1446,51 @@ int virDomainInterfaceStats (virDomainPtr dom,
const char *path, const char *path,
virDomainInterfaceStatsPtr stats, virDomainInterfaceStatsPtr stats,
size_t size); size_t size);
/* Management of interface parameters */
/**
* VIR_DOMAIN_BANDWIDTH_IN_AVERAGE:
*
* Macro represents the inbound average of NIC bandwidth, as a uint.
*/
#define VIR_DOMAIN_BANDWIDTH_IN_AVERAGE "inbound.average"
/**
* VIR_DOMAIN_BANDWIDTH_IN_PEAK:
*
* Macro represents the inbound peak of NIC bandwidth, as a uint.
*/
#define VIR_DOMAIN_BANDWIDTH_IN_PEAK "inbound.peak"
/**
* VIR_DOMAIN_BANDWIDTH_IN_BURST:
*
* Macro represents the inbound burst of NIC bandwidth, as a uint.
*/
#define VIR_DOMAIN_BANDWIDTH_IN_BURST "inbound.burst"
/**
* VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE:
*
* Macro represents the outbound average of NIC bandwidth, as a uint.
*/
#define VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE "outbound.average"
/**
* VIR_DOMAIN_BANDWIDTH_OUT_PEAK:
*
* Macro represents the outbound peak of NIC bandwidth, as a uint.
*/
#define VIR_DOMAIN_BANDWIDTH_OUT_PEAK "outbound.peak"
/**
* VIR_DOMAIN_BANDWIDTH_OUT_BURST:
*
* Macro represents the outbound burst of NIC bandwidth, as a uint.
*/
#define VIR_DOMAIN_BANDWIDTH_OUT_BURST "outbound.burst"
int virDomainSetInterfaceParameters (virDomainPtr dom, int virDomainSetInterfaceParameters (virDomainPtr dom,
const char *device, const char *device,
virTypedParameterPtr params, virTypedParameterPtr params,
...@@ -1496,10 +1499,9 @@ int virDomainGetInterfaceParameters (virDomainPtr dom, ...@@ -1496,10 +1499,9 @@ int virDomainGetInterfaceParameters (virDomainPtr dom,
const char *device, const char *device,
virTypedParameterPtr params, virTypedParameterPtr params,
int *nparams, unsigned int flags); int *nparams, unsigned int flags);
int virDomainMemoryStats (virDomainPtr dom,
virDomainMemoryStatPtr stats, /* Management of domain block devices */
unsigned int nr_stats,
unsigned int flags);
int virDomainBlockPeek (virDomainPtr dom, int virDomainBlockPeek (virDomainPtr dom,
const char *disk, const char *disk,
unsigned long long offset, unsigned long long offset,
...@@ -1546,7 +1548,15 @@ int virDomainGetBlockInfo(virDomainPtr dom, ...@@ -1546,7 +1548,15 @@ int virDomainGetBlockInfo(virDomainPtr dom,
virDomainBlockInfoPtr info, virDomainBlockInfoPtr info,
unsigned int flags); unsigned int flags);
/* Management of domain memory */
int virDomainMemoryStats (virDomainPtr dom,
virDomainMemoryStatPtr stats,
unsigned int nr_stats,
unsigned int flags);
/* Memory peeking flags. */ /* Memory peeking flags. */
typedef enum { typedef enum {
VIR_MEMORY_VIRTUAL = 1, /* addresses are virtual addresses */ VIR_MEMORY_VIRTUAL = 1, /* addresses are virtual addresses */
VIR_MEMORY_PHYSICAL = 2, /* addresses are physical addresses */ VIR_MEMORY_PHYSICAL = 2, /* addresses are physical addresses */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvirt.c: Main interfaces for the libvirt library to handle virtualization * libvirt.c: Main interfaces for the libvirt library to handle virtualization
* domains from a process running in domain 0 * domains from a process running in domain 0
* *
* Copyright (C) 2005-2006, 2008-2011 Red Hat, Inc. * Copyright (C) 2005-2006, 2008-2012 Red Hat, Inc.
* *
* See COPYING.LIB for the License of this software * See COPYING.LIB for the License of this software
* *
...@@ -7084,7 +7084,12 @@ error: ...@@ -7084,7 +7084,12 @@ error:
* less than the number of parameters supported) * less than the number of parameters supported)
* @flags: bitwise-OR of virDomainModificationImpact * @flags: bitwise-OR of virDomainModificationImpact
* *
* Currently this function sets bandwidth parameters of interface. * Change a subset or all parameters of interface; currently this
* includes bandwidth parameters. The value of @flags should be
* either VIR_DOMAIN_AFFECT_CURRENT, or a bitwise-or of values from
* VIR_DOMAIN_AFFECT_LIVE and VIR_DOMAIN_AFFECT_CURRENT, although
* hypervisors vary in which flags are supported.
*
* This function may require privileged access to the hypervisor. * This function may require privileged access to the hypervisor.
* *
* Returns -1 in case of error, 0 in case of success. * Returns -1 in case of error, 0 in case of success.
...@@ -7122,7 +7127,9 @@ virDomainSetInterfaceParameters(virDomainPtr domain, ...@@ -7122,7 +7127,9 @@ virDomainSetInterfaceParameters(virDomainPtr domain,
if (conn->driver->domainSetInterfaceParameters) { if (conn->driver->domainSetInterfaceParameters) {
int ret; int ret;
ret = conn->driver->domainSetInterfaceParameters(domain, device, params, nparams, flags); ret = conn->driver->domainSetInterfaceParameters(domain, device,
params, nparams,
flags);
if (ret < 0) if (ret < 0)
goto error; goto error;
return ret; return ret;
...@@ -7141,8 +7148,8 @@ error: ...@@ -7141,8 +7148,8 @@ error:
* @device: the interface name or mac address * @device: the interface name or mac address
* @params: pointer to interface parameter objects * @params: pointer to interface parameter objects
* (return value, allocated by the caller) * (return value, allocated by the caller)
* @nparams: pointer to number of interface parameter * @nparams: pointer to number of interface parameter; input and output
* @flags: one of virDomainModificationImpact * @flags: bitwise-OR of virDomainModificationImpact and virTypedParameterFlags
* *
* Get all interface parameters. On input, @nparams gives the size of * Get all interface parameters. On input, @nparams gives the size of
* the @params array; on output, @nparams gives how many slots were * the @params array; on output, @nparams gives how many slots were
...@@ -7193,7 +7200,9 @@ virDomainGetInterfaceParameters(virDomainPtr domain, ...@@ -7193,7 +7200,9 @@ virDomainGetInterfaceParameters(virDomainPtr domain,
if (conn->driver->domainGetInterfaceParameters) { if (conn->driver->domainGetInterfaceParameters) {
int ret; int ret;
ret = conn->driver->domainGetInterfaceParameters (domain, device, params, nparams, flags); ret = conn->driver->domainGetInterfaceParameters(domain, device,
params, nparams,
flags);
if (ret < 0) if (ret < 0)
goto error; goto error;
return ret; return ret;
......
...@@ -260,10 +260,10 @@ virDomainConfigFile; ...@@ -260,10 +260,10 @@ virDomainConfigFile;
virDomainControllerDefFree; virDomainControllerDefFree;
virDomainControllerInsert; virDomainControllerInsert;
virDomainControllerInsertPreAlloced; virDomainControllerInsertPreAlloced;
virDomainControllerModelUSBTypeFromString;
virDomainControllerModelUSBTypeToString;
virDomainControllerModelSCSITypeFromString; virDomainControllerModelSCSITypeFromString;
virDomainControllerModelSCSITypeToString; virDomainControllerModelSCSITypeToString;
virDomainControllerModelUSBTypeFromString;
virDomainControllerModelUSBTypeToString;
virDomainControllerTypeToString; virDomainControllerTypeToString;
virDomainCpuSetFormat; virDomainCpuSetFormat;
virDomainCpuSetParse; virDomainCpuSetParse;
...@@ -308,7 +308,6 @@ virDomainDiskSnapshotTypeFromString; ...@@ -308,7 +308,6 @@ virDomainDiskSnapshotTypeFromString;
virDomainDiskSnapshotTypeToString; virDomainDiskSnapshotTypeToString;
virDomainDiskTypeFromString; virDomainDiskTypeFromString;
virDomainDiskTypeToString; virDomainDiskTypeToString;
virDomainNetFind;
virDomainFSDefFree; virDomainFSDefFree;
virDomainFSTypeFromString; virDomainFSTypeFromString;
virDomainFSTypeToString; virDomainFSTypeToString;
...@@ -366,12 +365,13 @@ virDomainLoadAllConfigs; ...@@ -366,12 +365,13 @@ virDomainLoadAllConfigs;
virDomainMemballoonModelTypeFromString; virDomainMemballoonModelTypeFromString;
virDomainMemballoonModelTypeToString; virDomainMemballoonModelTypeToString;
virDomainNetDefFree; virDomainNetDefFree;
virDomainNetFind;
virDomainNetGetActualBandwidth; virDomainNetGetActualBandwidth;
virDomainNetGetActualBridgeName; virDomainNetGetActualBridgeName;
virDomainNetGetActualDirectDev; virDomainNetGetActualDirectDev;
virDomainNetGetActualDirectMode; virDomainNetGetActualDirectMode;
virDomainNetGetActualType;
virDomainNetGetActualDirectVirtPortProfile; virDomainNetGetActualDirectVirtPortProfile;
virDomainNetGetActualType;
virDomainNetIndexByMac; virDomainNetIndexByMac;
virDomainNetInsert; virDomainNetInsert;
virDomainNetRemoveByMac; virDomainNetRemoveByMac;
...@@ -462,9 +462,9 @@ virDomainVideoDefaultRAM; ...@@ -462,9 +462,9 @@ virDomainVideoDefaultRAM;
virDomainVideoDefaultType; virDomainVideoDefaultType;
virDomainVideoTypeFromString; virDomainVideoTypeFromString;
virDomainVideoTypeToString; virDomainVideoTypeToString;
virDomainVirtTypeToString;
virDomainVirtioEventIdxTypeFromString; virDomainVirtioEventIdxTypeFromString;
virDomainVirtioEventIdxTypeToString; virDomainVirtioEventIdxTypeToString;
virDomainVirtTypeToString;
virDomainWatchdogActionTypeFromString; virDomainWatchdogActionTypeFromString;
virDomainWatchdogActionTypeToString; virDomainWatchdogActionTypeToString;
virDomainWatchdogModelTypeFromString; virDomainWatchdogModelTypeFromString;
......
...@@ -510,10 +510,10 @@ LIBVIRT_0.9.8 { ...@@ -510,10 +510,10 @@ LIBVIRT_0.9.8 {
LIBVIRT_0.9.9 { LIBVIRT_0.9.9 {
global: global:
virDomainGetNumaParameters;
virDomainSetNumaParameters;
virDomainGetInterfaceParameters; virDomainGetInterfaceParameters;
virDomainGetNumaParameters;
virDomainSetInterfaceParameters; virDomainSetInterfaceParameters;
virDomainSetNumaParameters;
} LIBVIRT_0.9.8; } LIBVIRT_0.9.8;
# .... define new API here using predicted next version number .... # .... define new API here using predicted next version number ....
/* /*
* qemu_driver.c: core driver methods for managing qemu guests * qemu_driver.c: core driver methods for managing qemu guests
* *
* Copyright (C) 2006-2011 Red Hat, Inc. * Copyright (C) 2006-2012 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange * Copyright (C) 2006 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -7920,7 +7920,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7920,7 +7920,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_AVERAGE)) { if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_AVERAGE)) {
if (param->type != VIR_TYPED_PARAM_UINT) { if (param->type != VIR_TYPED_PARAM_UINT) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s", qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for bandwidth average tunable, expected a 'unsigned int'")); _("invalid type for bandwidth average tunable, "
"expected an 'unsigned int'"));
goto cleanup; goto cleanup;
} }
...@@ -7928,7 +7929,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7928,7 +7929,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
} else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_PEAK)) { } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_PEAK)) {
if (param->type != VIR_TYPED_PARAM_UINT) { if (param->type != VIR_TYPED_PARAM_UINT) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s", qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for bandwidth peak tunable, expected a 'unsigned int'")); _("invalid type for bandwidth peak tunable, "
"expected an 'unsigned int'"));
goto cleanup; goto cleanup;
} }
...@@ -7936,7 +7938,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7936,7 +7938,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
} else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_BURST)) { } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_IN_BURST)) {
if (param->type != VIR_TYPED_PARAM_UINT) { if (param->type != VIR_TYPED_PARAM_UINT) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s", qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for bandwidth burst tunable, expected a 'unsigned int'")); _("invalid type for bandwidth burst tunable, "
"expected an 'unsigned int'"));
goto cleanup; goto cleanup;
} }
...@@ -7944,7 +7947,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7944,7 +7947,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
} else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE)) { } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE)) {
if (param->type != VIR_TYPED_PARAM_UINT) { if (param->type != VIR_TYPED_PARAM_UINT) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s", qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for bandwidth average tunable, expected a 'unsigned int'")); _("invalid type for bandwidth average tunable, "
"expected an 'unsigned int'"));
goto cleanup; goto cleanup;
} }
...@@ -7952,7 +7956,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7952,7 +7956,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
} else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_PEAK)) { } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_PEAK)) {
if (param->type != VIR_TYPED_PARAM_UINT) { if (param->type != VIR_TYPED_PARAM_UINT) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s", qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for bandwidth peak tunable, expected a 'unsigned int'")); _("invalid type for bandwidth peak tunable, "
"expected an 'unsigned int'"));
goto cleanup; goto cleanup;
} }
...@@ -7960,7 +7965,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7960,7 +7965,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
} else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_BURST)) { } else if (STREQ(param->field, VIR_DOMAIN_BANDWIDTH_OUT_BURST)) {
if (param->type != VIR_TYPED_PARAM_UINT) { if (param->type != VIR_TYPED_PARAM_UINT) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s", qemuReportError(VIR_ERR_INVALID_ARG, "%s",
_("invalid type for bandwidth burst tunable, expected a 'unsigned int'")); _("invalid type for bandwidth burst tunable, "
"expected an 'unsigned int'"));
goto cleanup; goto cleanup;
} }
...@@ -7973,9 +7979,9 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, ...@@ -7973,9 +7979,9 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
} }
} }
/* average is mandatory, peak and burst is optional. So if no /* average is mandatory, peak and burst are optional. So if no
* average is given, we free inbound/outbound here which causes * average is given, we free inbound/outbound here which causes
* inbound/outbound won't be set. */ * inbound/outbound to not be set. */
if (!bandwidth->in->average) { if (!bandwidth->in->average) {
VIR_FREE(bandwidth->in); VIR_FREE(bandwidth->in);
bandwidth->in = NULL; bandwidth->in = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册