[libvirt] Small postpone of the 0.9.10 freeze
by Daniel Veillard
I'm finally back from vacation, and looking at the list
it seems there is many patches floating that should be pushed
for 0.9.10 . I suggest then to take a few more days to try
to push patches especially about APIs, and enter the freeze
on Monday instead. So we have a couple more working days
to try to push features to git before 0.9.10 freeze,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
12 years, 9 months
[libvirt] [PATCHv3 0/4] API for modification of domain metadata
by Peter Krempa
This third version incorporates fixes of Eric's review and a rebase on
the top of Jirka's new API.
Differences to v2:
xml: Add element <title> to allow short description of domains
- Move <title> before <description>
- fix tests to accomodate this
- remove forgotten length limits from docs
- fixed XML schema to work around libxml2 newline escape bug
API: Add api to set and get domain metadata
- added new remote procedures to remote_protocol-structs
( and installed tools to detect it in the future :( )
- Fixed function docs to accomodate new code semantics
- Changed error message to sync with other API functions
- Changed debug prints to print strings instead of pointers
- Removed conditions forbidding expansion/work with newer versins
- Changed RPC return type to nonnull_string
virsh: Add support for modifying domain description and titles
qemu: Add support for virDomainGetMetadata and virDomainSetMetadata
- no changes
docs/formatdomain.html.in | 8 +-
docs/schemas/domaincommon.rng | 15 +-
include/libvirt/libvirt.h.in | 24 ++
include/libvirt/virterror.h | 1 +
src/conf/domain_conf.c | 11 +
src/conf/domain_conf.h | 1 +
src/driver.h | 16 ++
src/libvirt.c | 178 ++++++++++++
src/libvirt_public.syms | 2 +
src/qemu/qemu_driver.c | 174 ++++++++++++
src/remote/remote_driver.c | 2 +
src/remote/remote_protocol.x | 24 ++-
src/remote_protocol-structs | 19 ++
src/util/virterror.c | 6 +
.../qemu-simple-description-title.xml | 27 ++
tests/qemuxml2argvdata/qemuxml2argv-minimal.xml | 5 +
tools/virsh.c | 283 ++++++++++++++++++--
tools/virsh.pod | 34 +++-
18 files changed, 806 insertions(+), 24 deletions(-)
create mode 100644 tests/domainschemadata/qemu-simple-description-title.xml
--
1.7.3.4
12 years, 9 months
[libvirt] oVirt Live Snapshots
by Federico Simoncelli
Hi,
oVirt, and more specifically VDSM, is currently implementing the live
snapshot feature using the API/commands provided by libvirt and qemu.
It would be great if you could review the design and the current open
issues at:
http://ovirt.org/wiki/Live_Snapshots
Thank you,
--
Federico
12 years, 9 months
[libvirt] [PATCH] virsh: Plug memory leak on cmdUndefine
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
Detected by valgrind. Leak is introduced in commit 3bb6bcf.
Free 'vol' memory before allocating memory, the codes will miss one time
free when 'vol_i = nvolumes' in for loop, so plug memory leak.
* tools/virsh.c: fix memory leak on cmdUndefine.
* How to reproduce?
% dd if=/dev/null of=/var/lib/libvirt/images/foo bs=1 count=1 seek=10M
% virsh define foo.xml (disk source file points to '/var/lib/libvirt/images/foo')
% virsh vol-clone foo foo-clone default (the original guest name is 'foo')
% virsh pool-refresh default
% virsh vol-list default (make sure 'foo-clone' volume exists)
% virsh define foo-clone.xml (disk source file points to '/var/lib/libvirt/images/foo-clone')
% valgrind -v --leak-check=full virsh undefine foo-clone --remove-all-storage
* Actual results:
1. virsh output
Domain foo-clone has been undefined
Volume '/var/lib/libvirt/images/foo-clone' removed.
error: Failed to disconnect from the hypervisor, 1 leaked reference(s)
2. valgrind result
==6515== 92 (40 direct, 52 indirect) bytes in 1 blocks are definitely lost in loss record 46 of 69
==6515== at 0x4A04A28: calloc (vg_replace_malloc.c:467)
==6515== by 0x4C89B71: virAlloc (memory.c:101)
==6515== by 0x4CFCACE: virGetStorageVol (datatypes.c:724)
==6515== by 0x4D4A8E0: remoteStorageVolLookupByPath (remote_driver.c:4664)
==6515== by 0x4D07153: virStorageVolLookupByPath (libvirt.c:12508)
==6515== by 0x4270E6: cmdUndefine (virsh.c:2828)
==6515== by 0x4151B6: vshCommandRun (virsh.c:17693)
==6515== by 0x4264D3: main (virsh.c:19270)
==6515==
==6515== LEAK SUMMARY:
==6515== definitely lost: 40 bytes in 1 blocks
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=786674
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
tools/virsh.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index c8fd448..73c2192 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2787,10 +2787,6 @@ out:
ctxt->node = vol_nodes[vol_i];
VIR_FREE(target);
VIR_FREE(source);
- if (vol) {
- virStorageVolFree(vol);
- vol = NULL;
- }
/* get volume source and target paths */
if (!(target = virXPathString("string(./target/@dev)", ctxt))) {
@@ -2852,6 +2848,10 @@ out:
vol_del_failed = true;
}
vshPrint(ctl, _("Volume '%s' removed.\n"), volume_tok?volume_tok:source);
+
+ /* cleanup */
+ virStorageVolFree(vol);
+ vol = NULL;
}
/* print volumes specified by user that were not found in domain definition */
--
1.7.1
12 years, 9 months
[libvirt] [PATCH] xen_xs: name xendConfigVersion magic numbers
by Philipp Hahn
libvirt supports 4 different versions of the user-land XenD daemon. When
queried the daemon just returns its generation number, which is hard to
match to the version of the Xen tools.
Replace the magic generation numbers by named macro definitions to
improve code readability.
Signed-off-by: Philipp Hahn <hahn(a)univention.de>
---
.../0013-improve-getting-xen-vcpu-counts.patch | 2 +-
.../0014-improve-setting-xen-vcpu-counts.patch | 6 +-
docs/api_extension/0015-remove-dead-xen-code.patch | 2 +-
src/xen/xen_driver.c | 14 ++--
src/xen/xend_internal.c | 70 ++++++++++----------
src/xenxs/xen_sxpr.c | 24 ++++----
src/xenxs/xen_sxpr.h | 5 ++
src/xenxs/xen_xm.c | 14 ++--
src/xenxs/xenxs_private.h | 7 +-
9 files changed, 75 insertions(+), 69 deletions(-)
diff --git a/docs/api_extension/0013-improve-getting-xen-vcpu-counts.patch b/docs/api_extension/0013-improve-getting-xen-vcpu-counts.patch
index 047bc7b..c1aad03 100644
--- a/docs/api_extension/0013-improve-getting-xen-vcpu-counts.patch
+++ b/docs/api_extension/0013-improve-getting-xen-vcpu-counts.patch
@@ -100,7 +100,7 @@ index dfc6415..3642296 100644
+ /* If xendConfigVersion is 2, then we can only report _LIVE (and
+ * xm_internal reports _CONFIG). If it is 3, then _LIVE and
+ * _CONFIG are always in sync for a running system. */
-+ if (domain->id < 0 && priv->xendConfigVersion < 3)
++ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
+ return -2;
+ if (domain->id < 0 && (flags & VIR_DOMAIN_VCPU_LIVE)) {
+ virXendError(VIR_ERR_OPERATION_INVALID, "%s",
diff --git a/docs/api_extension/0014-improve-setting-xen-vcpu-counts.patch b/docs/api_extension/0014-improve-setting-xen-vcpu-counts.patch
index 76dc948..3adbd75 100644
--- a/docs/api_extension/0014-improve-setting-xen-vcpu-counts.patch
+++ b/docs/api_extension/0014-improve-setting-xen-vcpu-counts.patch
@@ -110,7 +110,7 @@ index fe2ff86..66e8518 100644
+ * depends on xendConfigVersion. */
+ if (dom) {
+ priv = dom->conn->privateData;
-+ if (priv->xendConfigVersion >= 3)
++ if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
+ flags |= VIR_DOMAIN_VCPU_CONFIG;
+ }
+ return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, flags);
@@ -163,14 +163,14 @@ index 3642296..55c2cc4 100644
+
+ priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
+
-+ if ((domain->id < 0 && priv->xendConfigVersion < 3) ||
++ if ((domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ||
+ (flags & VIR_DOMAIN_VCPU_MAXIMUM))
+ return -2;
+
+ /* With xendConfigVersion 2, only _LIVE is supported. With
+ * xendConfigVersion 3, only _LIVE|_CONFIG is supported for
+ * running domains, or _CONFIG for inactive domains. */
-+ if (priv->xendConfigVersion < 3) {
++ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
+ if (flags & VIR_DOMAIN_VCPU_CONFIG) {
+ virXendError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("Xend version does not support modifying "
diff --git a/docs/api_extension/0015-remove-dead-xen-code.patch b/docs/api_extension/0015-remove-dead-xen-code.patch
index 56b99a3..64e0d98 100644
--- a/docs/api_extension/0015-remove-dead-xen-code.patch
+++ b/docs/api_extension/0015-remove-dead-xen-code.patch
@@ -122,7 +122,7 @@ index 55c2cc4..b90c331 100644
-
- priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
-
-- if (domain->id < 0 && priv->xendConfigVersion < 3)
+- if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
- return(-1);
-
- snprintf(buf, sizeof(buf), "%d", vcpus);
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 12d7eb0..94cafde 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -354,7 +354,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
/* XenD is active, so try the xm & xs drivers too, both requird to
* succeed if root, optional otherwise */
- if (priv->xendConfigVersion <= 2) {
+ if (priv->xendConfigVersion <= XEND_CONFIG_VERSION_3_0_3) {
VIR_DEBUG("Trying XM sub-driver");
if (xenXMOpen(conn, auth, flags) == VIR_DRV_OPEN_SUCCESS) {
VIR_DEBUG("Activated XM sub-driver");
@@ -1161,7 +1161,7 @@ xenUnifiedDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
* depends on xendConfigVersion. */
if (dom) {
priv = dom->conn->privateData;
- if (priv->xendConfigVersion >= 3)
+ if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
flags |= VIR_DOMAIN_VCPU_CONFIG;
}
return xenUnifiedDomainSetVcpusFlags(dom, nvcpus, flags);
@@ -1239,7 +1239,7 @@ xenUnifiedDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
{
GET_PRIVATE(dom->conn);
- if (dom->id == -1 && priv->xendConfigVersion < 3 ) {
+ if (dom->id == -1 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
return xenXMDomainGetXMLDesc(dom, flags);
} else {
@@ -1561,7 +1561,7 @@ xenUnifiedDomainAttachDevice (virDomainPtr dom, const char *xml)
* to make this API work
*/
if (priv->opened[XEN_UNIFIED_XEND_OFFSET] &&
- priv->xendConfigVersion >= 3)
+ priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
@@ -1600,7 +1600,7 @@ xenUnifiedDomainDetachDevice (virDomainPtr dom, const char *xml)
* to make this API work
*/
if (priv->opened[XEN_UNIFIED_XEND_OFFSET] &&
- priv->xendConfigVersion >= 3)
+ priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4)
flags |= VIR_DOMAIN_DEVICE_MODIFY_CONFIG;
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
@@ -1642,7 +1642,7 @@ xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
{
GET_PRIVATE(dom->conn);
- if (priv->xendConfigVersion < 3) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
return xenXMDomainGetAutostart(dom, autostart);
} else {
@@ -1659,7 +1659,7 @@ xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart)
{
GET_PRIVATE(dom->conn);
- if (priv->xendConfigVersion < 3) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (priv->opened[XEN_UNIFIED_XM_OFFSET])
return xenXMDomainSetAutostart(dom, autostart);
} else {
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index b754eca..5c3838f 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -954,7 +954,7 @@ xend_detect_config_version(virConnectPtr conn) {
} else {
/* Xen prior to 3.0.3 did not have the xend_config_format
field, and is implicitly version 1. */
- priv->xendConfigVersion = 1;
+ priv->xendConfigVersion = XEND_CONFIG_VERSION_3_0_2;
}
sexpr_free(root);
return (0);
@@ -1224,7 +1224,7 @@ sexpr_to_domain(virConnectPtr conn, const struct sexpr *root)
/* New 3.0.4 XenD will not report a domid for inactive domains,
* so only error out for old XenD
*/
- if (!tmp && priv->xendConfigVersion < 3)
+ if (!tmp && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
goto error;
if (tmp)
@@ -1512,7 +1512,7 @@ xenDaemonDomainGetOSType(virDomainPtr domain)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (domain->id < 0 && priv->xendConfigVersion < 3)
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(NULL);
/* can we ask for a subset ? worth it ? */
@@ -1652,7 +1652,7 @@ xenDaemonDomainGetMaxMemory(virDomainPtr domain)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (domain->id < 0 && priv->xendConfigVersion < 3)
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
/* can we ask for a subset ? worth it ? */
@@ -1691,7 +1691,7 @@ xenDaemonDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (domain->id < 0 && priv->xendConfigVersion < 3)
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
snprintf(buf, sizeof(buf), "%lu", VIR_DIV_UP(memory, 1024));
@@ -1728,7 +1728,7 @@ xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (domain->id < 0 && priv->xendConfigVersion < 3)
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
snprintf(buf, sizeof(buf), "%lu", VIR_DIV_UP(memory, 1024));
@@ -1808,7 +1808,7 @@ xenDaemonDomainGetXMLDesc(virDomainPtr domain, unsigned int flags,
}
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (domain->id < 0 && priv->xendConfigVersion < 3) {
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
/* fall-through to the next driver to handle */
return(NULL);
}
@@ -1852,7 +1852,7 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (domain->id < 0 && priv->xendConfigVersion < 3)
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
@@ -1887,7 +1887,7 @@ xenDaemonDomainGetState(virDomainPtr domain,
virCheckFlags(0, -1);
- if (domain->id < 0 && priv->xendConfigVersion < 3)
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return -1;
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
@@ -2186,14 +2186,14 @@ xenDaemonDomainSetVcpusFlags(virDomainPtr domain, unsigned int vcpus,
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if ((domain->id < 0 && priv->xendConfigVersion < 3) ||
+ if ((domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) ||
(flags & VIR_DOMAIN_VCPU_MAXIMUM))
return -2;
/* With xendConfigVersion 2, only _LIVE is supported. With
* xendConfigVersion 3, only _LIVE|_CONFIG is supported for
* running domains, or _CONFIG for inactive domains. */
- if (priv->xendConfigVersion < 3) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (flags & VIR_DOMAIN_VCPU_CONFIG) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
_("Xend version does not support modifying "
@@ -2267,7 +2267,7 @@ xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
}
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (priv->xendConfigVersion < 3) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
mapstr[0] = '[';
mapstr[1] = 0;
} else {
@@ -2280,7 +2280,7 @@ xenDaemonDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
snprintf(buf, sizeof(buf), "%d,", (8 * i) + j);
strcat(mapstr, buf);
}
- if (priv->xendConfigVersion < 3)
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
mapstr[strlen(mapstr) - 1] = ']';
else
mapstr[strlen(mapstr) - 1] = 0;
@@ -2343,7 +2343,7 @@ xenDaemonDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
/* If xendConfigVersion is 2, then we can only report _LIVE (and
* xm_internal reports _CONFIG). If it is 3, then _LIVE and
* _CONFIG are always in sync for a running system. */
- if (domain->id < 0 && priv->xendConfigVersion < 3)
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return -2;
if (domain->id < 0 && (flags & VIR_DOMAIN_VCPU_LIVE)) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -2477,7 +2477,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
/* Old approach for xen <= 3.0.3 */
- if (priv->xendConfigVersion < 3) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
char **names, **tmp;
unsigned char ident[VIR_UUID_BUFLEN];
names = xenDaemonListDomainsOld(conn);
@@ -2648,7 +2648,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
return -1;
}
/* If xendConfigVersion < 3 only live config can be changed */
- if (priv->xendConfigVersion < 3) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
_("Xend version does not support modifying "
"persistent config"));
@@ -2656,7 +2656,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
}
} else {
/* Only live config can be changed if xendConfigVersion < 3 */
- if (priv->xendConfigVersion < 3 &&
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4 &&
(flags != VIR_DOMAIN_DEVICE_MODIFY_CURRENT &&
flags != VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -2667,7 +2667,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const char *xml,
/* Xen only supports modifying both live and persistent config if
* xendConfigVersion >= 3
*/
- if (priv->xendConfigVersion >= 3 &&
+ if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4 &&
(flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
VIR_DOMAIN_DEVICE_MODIFY_CONFIG))) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -2816,7 +2816,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
return -1;
}
/* If xendConfigVersion < 3 only live config can be changed */
- if (priv->xendConfigVersion < 3) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
_("Xend version does not support modifying "
"persistent config"));
@@ -2824,7 +2824,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
}
} else {
/* Only live config can be changed if xendConfigVersion < 3 */
- if (priv->xendConfigVersion < 3 &&
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4 &&
(flags != VIR_DOMAIN_DEVICE_MODIFY_CURRENT &&
flags != VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -2835,7 +2835,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, const char *xml,
/* Xen only supports modifying both live and persistent config if
* xendConfigVersion >= 3
*/
- if (priv->xendConfigVersion >= 3 &&
+ if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4 &&
(flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
VIR_DOMAIN_DEVICE_MODIFY_CONFIG))) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -2929,7 +2929,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
return -1;
}
/* If xendConfigVersion < 3 only live config can be changed */
- if (priv->xendConfigVersion < 3) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
_("Xend version does not support modifying "
"persistent config"));
@@ -2937,7 +2937,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
}
} else {
/* Only live config can be changed if xendConfigVersion < 3 */
- if (priv->xendConfigVersion < 3 &&
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4 &&
(flags != VIR_DOMAIN_DEVICE_MODIFY_CURRENT &&
flags != VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -2948,7 +2948,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, const char *xml,
/* Xen only supports modifying both live and persistent config if
* xendConfigVersion >= 3
*/
- if (priv->xendConfigVersion >= 3 &&
+ if (priv->xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4 &&
(flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
VIR_DOMAIN_DEVICE_MODIFY_CONFIG))) {
virXendError(VIR_ERR_OPERATION_INVALID, "%s",
@@ -3016,7 +3016,7 @@ xenDaemonDomainGetAutostart(virDomainPtr domain,
* config files used by old Xen) will handle this.
*/
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (priv->xendConfigVersion < 3)
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
@@ -3056,7 +3056,7 @@ xenDaemonDomainSetAutostart(virDomainPtr domain,
* config files used by old Xen) will handle this.
*/
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (priv->xendConfigVersion < 3)
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
root = sexpr_get(domain->conn, "/xend/domain/%s?detail=1", domain->name);
@@ -3318,7 +3318,7 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
priv = (xenUnifiedPrivatePtr) conn->privateData;
- if (priv->xendConfigVersion < 3)
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(NULL);
if (!(def = virDomainDefParseString(priv->caps, xmlDesc,
@@ -3367,7 +3367,7 @@ int xenDaemonDomainCreate(virDomainPtr domain)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (priv->xendConfigVersion < 3)
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
ret = xend_op(domain->conn, domain->name, "op", "start", NULL);
@@ -3394,7 +3394,7 @@ int xenDaemonDomainUndefine(virDomainPtr domain)
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (priv->xendConfigVersion < 3)
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
return xend_op(domain->conn, domain->name, "op", "delete", NULL);
@@ -3419,7 +3419,7 @@ xenDaemonNumOfDefinedDomains(virConnectPtr conn)
/* xm_internal.c (the support for defined domains from /etc/xen
* config files used by old Xen) will handle this.
*/
- if (priv->xendConfigVersion < 3)
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
root = sexpr_get(conn, "/xend/domain?state=halted");
@@ -3447,7 +3447,7 @@ xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxnames
struct sexpr *_for_i, *node;
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
- if (priv->xendConfigVersion < 3)
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return(-1);
if ((names == NULL) || (maxnames < 0))
@@ -3513,7 +3513,7 @@ xenDaemonGetSchedulerType(virDomainPtr domain, int *nparams)
/* Support only xendConfigVersion >=4 */
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (priv->xendConfigVersion < 4) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
virXendError(VIR_ERR_OPERATION_INVALID,
"%s", _("unsupported in xendConfigVersion < 4"));
return NULL;
@@ -3586,7 +3586,7 @@ xenDaemonGetSchedulerParameters(virDomainPtr domain,
/* Support only xendConfigVersion >=4 */
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (priv->xendConfigVersion < 4) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
virXendError(VIR_ERR_OPERATION_INVALID,
"%s", _("unsupported in xendConfigVersion < 4"));
return (-1);
@@ -3694,7 +3694,7 @@ xenDaemonSetSchedulerParameters(virDomainPtr domain,
/* Support only xendConfigVersion >=4 and active domains */
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (priv->xendConfigVersion < 4) {
+ if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
virXendError(VIR_ERR_OPERATION_INVALID,
"%s", _("unsupported in xendConfigVersion < 4"));
return (-1);
@@ -3802,7 +3802,7 @@ xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path,
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
- if (domain->id < 0 && priv->xendConfigVersion < 3)
+ if (domain->id < 0 && priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
return -2; /* Decline, allow XM to handle it. */
/* Security check: The path must correspond to a block device. */
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 8c04596..756eb77 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -55,7 +55,7 @@ int xenGetDomIdFromSxpr(const struct sexpr *root, int xendConfigVersion)
{
int id = -1;
const char * tmp = sexpr_node(root, "domain/domid");
- if (tmp == NULL && xendConfigVersion < 3) { /* Old XenD, domid was mandatory */
+ if (tmp == NULL && xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { /* domid was mandatory */
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
"%s", _("domain information incomplete, missing id"));
} else {
@@ -468,7 +468,7 @@ xenParseSxprDisks(virDomainDefPtr def,
disk->device = VIR_DOMAIN_DISK_DEVICE_DISK;
/* New style disk config from Xen >= 3.0.3 */
- if (xendConfigVersion > 1) {
+ if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_3) {
offset = strrchr(dst, ':');
if (offset) {
if (STREQ (offset, ":cdrom")) {
@@ -814,7 +814,7 @@ xenParseSxprGraphicsOld(virDomainDefPtr def,
* present yet. Subsquent dumps of the XML will eventually
* find the port in XenStore once VNC server has started
*/
- if (port == -1 && xendConfigVersion < 2)
+ if (port == -1 && xendConfigVersion < XEND_CONFIG_VERSION_3_0_3)
port = 5900 + def->id;
if ((unused && STREQ(unused, "1")) || port == -1)
@@ -1132,7 +1132,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
tmp = sexpr_node(root, "domain/domid");
- if (tmp == NULL && xendConfigVersion < 3) { /* Old XenD, domid was mandatory */
+ if (tmp == NULL && xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { /* domid was mandatory */
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
"%s", _("domain information incomplete, missing id"));
goto error;
@@ -1318,7 +1318,7 @@ xenParseSxpr(const struct sexpr *root,
/* Old style cdrom config from Xen <= 3.0.2 */
if (hvm &&
- xendConfigVersion == 1) {
+ xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
tmp = sexpr_node(root, "domain/image/hvm/cdrom");
if ((tmp != NULL) && (tmp[0] != 0)) {
virDomainDiskDefPtr disk;
@@ -1617,7 +1617,7 @@ xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def,
virBufferAsprintf(buf, "(xauthority '%s')", def->data.sdl.xauth);
} else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
virBufferAddLit(buf, "(vnc 1)");
- if (xendConfigVersion >= 2) {
+ if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_3) {
if (def->data.vnc.autoport) {
virBufferAddLit(buf, "(vncunused 1)");
} else {
@@ -1762,7 +1762,7 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
/* Xend <= 3.0.2 doesn't include cdrom config here */
if (hvm &&
def->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
- xendConfigVersion == 1) {
+ xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
if (isAttach) {
XENXS_ERROR(VIR_ERR_INVALID_ARG,
_("Cannot directly attach CDROM %s"), def->src);
@@ -1787,7 +1787,7 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
if (hvm) {
/* Xend <= 3.0.2 wants a ioemu: prefix on devices for HVM */
- if (xendConfigVersion == 1) {
+ if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
virBufferEscapeSexpr(buf, "(dev 'ioemu:%s')", def->dst);
} else {
/* But newer does not */
@@ -2338,7 +2338,7 @@ xenFormatSxpr(virConnectPtr conn,
switch (def->disks[i]->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
/* Only xend <= 3.0.2 wants cdrom config here */
- if (xendConfigVersion != 1)
+ if (xendConfigVersion != XEND_CONFIG_VERSION_3_0_2)
break;
if (!STREQ(def->disks[i]->dst, "hdc") ||
def->disks[i]->src == NULL)
@@ -2437,7 +2437,7 @@ xenFormatSxpr(virConnectPtr conn,
}
/* get the device emulation model */
- if (def->emulator && (hvm || xendConfigVersion >= 3))
+ if (def->emulator && (hvm || xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4))
virBufferEscapeSexpr(&buf, "(device_model '%s')", def->emulator);
/* look for HPET in order to override the hypervisor/xend default */
@@ -2452,7 +2452,7 @@ xenFormatSxpr(virConnectPtr conn,
/* PV graphics for xen <= 3.0.4, or HVM graphics for xen <= 3.1.0 */
if ((!hvm && xendConfigVersion < XEND_CONFIG_MIN_VERS_PVFB_NEWCONF) ||
- (hvm && xendConfigVersion < 4)) {
+ (hvm && xendConfigVersion < XEND_CONFIG_VERSION_3_1_0)) {
if ((def->ngraphics == 1) &&
xenFormatSxprGraphicsOld(def->graphics[0],
&buf, xendConfigVersion) < 0)
@@ -2484,7 +2484,7 @@ xenFormatSxpr(virConnectPtr conn,
/* New style PV graphics config xen >= 3.0.4,
* or HVM graphics config xen >= 3.0.5 */
if ((xendConfigVersion >= XEND_CONFIG_MIN_VERS_PVFB_NEWCONF && !hvm) ||
- (xendConfigVersion >= 4 && hvm)) {
+ (xendConfigVersion >= XEND_CONFIG_VERSION_3_1_0 && hvm)) {
if ((def->ngraphics == 1) &&
xenFormatSxprGraphicsNew(def->graphics[0], &buf) < 0)
goto error;
diff --git a/src/xenxs/xen_sxpr.h b/src/xenxs/xen_sxpr.h
index a66c60a..4f96d2b 100644
--- a/src/xenxs/xen_sxpr.h
+++ b/src/xenxs/xen_sxpr.h
@@ -32,6 +32,11 @@
# include "domain_conf.h"
# include "sexpr.h"
+#define XEND_CONFIG_VERSION_3_0_2 1
+#define XEND_CONFIG_VERSION_3_0_3 2
+#define XEND_CONFIG_VERSION_3_0_4 3
+#define XEND_CONFIG_VERSION_3_1_0 4
+
/* helper functions to get the dom id from a sexpr */
int xenGetDomIdFromSxprString(const char *sexpr, int xendConfigVersion);
int xenGetDomIdFromSxpr(const struct sexpr *root, int xendConfigVersion);
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index a0d4806..e580a3e 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -570,7 +570,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
}
}
- if (hvm && xendConfigVersion == 1) {
+ if (hvm && xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
if (xenXMConfigGetString(conf, "cdrom", &str, NULL) < 0)
goto cleanup;
if (str) {
@@ -858,7 +858,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
}
/* HVM guests, or old PV guests use this config format */
- if (hvm || xendConfigVersion < 3) {
+ if (hvm || xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (xenXMConfigGetBool(conf, "vnc", &val, 0) < 0)
goto cleanup;
@@ -1169,7 +1169,7 @@ static int xenFormatXMDisk(virConfValuePtr list,
virBufferAdd(&buf, disk->src, -1);
}
virBufferAddLit(&buf, ",");
- if (hvm && xendConfigVersion == 1)
+ if (hvm && xendConfigVersion == XEND_CONFIG_VERSION_3_0_2)
virBufferAddLit(&buf, "ioemu:");
virBufferAdd(&buf, disk->dst, -1);
@@ -1545,7 +1545,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
(1 << VIR_DOMAIN_FEATURE_APIC)) ? 1 : 0) < 0)
goto no_memory;
- if (xendConfigVersion >= 3) {
+ if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) {
if (xenXMConfigSetInt(conf, "hap",
(def->features &
(1 << VIR_DOMAIN_FEATURE_HAP)) ? 1 : 0) < 0)
@@ -1584,7 +1584,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
break;
}
- if (xendConfigVersion == 1) {
+ if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
for (i = 0 ; i < def->ndisks ; i++) {
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
def->disks[i]->dst &&
@@ -1665,7 +1665,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
}
if (def->ngraphics == 1) {
- if (xendConfigVersion < (hvm ? 4 : XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) {
+ if (xendConfigVersion < (hvm ? XEND_CONFIG_VERSION_3_1_0 : XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) {
if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
if (xenXMConfigSetInt(conf, "sdl", 1) < 0)
goto no_memory;
@@ -1772,7 +1772,7 @@ virConfPtr xenFormatXM(virConnectPtr conn,
diskVal->list = NULL;
for (i = 0 ; i < def->ndisks ; i++) {
- if (xendConfigVersion == 1 &&
+ if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 &&
def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
def->disks[i]->dst &&
STREQ(def->disks[i]->dst, "hdc")) {
diff --git a/src/xenxs/xenxs_private.h b/src/xenxs/xenxs_private.h
index 60d27d2..bc903f5 100644
--- a/src/xenxs/xenxs_private.h
+++ b/src/xenxs/xenxs_private.h
@@ -29,6 +29,7 @@
# include <stdint.h>
# include <xen/xen.h>
+# include "xen_sxpr.h"
/* xen-unstable changeset 19788 removed MAX_VIRT_CPUS from public
* headers. Its semantic was retained with XEN_LEGACY_MAX_VCPUS.
@@ -40,10 +41,10 @@
# ifdef WITH_RHEL5_API
# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
-# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 2
+# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF XEND_CONFIG_VERSION_3_0_3
# else
-# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 3
-# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 3
+# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU XEND_CONFIG_VERSION_3_0_4
+# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF XEND_CONFIG_VERSION_3_0_4
# endif
# define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
--
1.7.1
12 years, 9 months
[libvirt] Linker error while compiling latest libvirt git source
by Deepak C Shetty
make all-am
make[3]: Entering directory `/home/dpkshetty/work/libvirt/libvirt/daemon'
GEN qemu_dispatch.h
GEN remote_dispatch.h
CC libvirtd-remote_protocol.o
CC libvirtd-qemu_protocol.o
CC libvirtd-remote.o
CC libvirtd-libvirtd.o
CC libvirtd-stream.o
In file included from remote.c:107:0:
remote_dispatch.h: In function 'remoteDispatchDomainGetDiskErrorsHelper':
remote.c:3611:9: warning: 'len' may be used uninitialized in this
function [-Wuninitialized]
At top level:
cc1: warning: unrecognized command line option
"-Wno-suggest-attribute=const"
cc1: warning: unrecognized command line option "-Wno-suggest-attribute=pure"
CCLD libvirtd
libtool: link: warning: library `/usr/lib/i386-linux-gnu/libgcrypt.la'
was moved.
libtool: link: warning: library `/usr/lib/i386-linux-gnu/libgcrypt.la'
was moved.
../src/.libs/libvirt_driver_qemu.a(libvirt_driver_qemu_la-qemu_process.o):
In function `qemuProcessStart':
/home/dpkshetty/work/libvirt/libvirt/src/qemu/qemu_process.c:3343:
undefined reference to `virCommandAllowCap'
../src/.libs/libvirt_driver_storage.a(libvirt_driver_storage_la-storage_backend_fs.o):
In function `virStorageBackendFileSystemVolResize':
/home/dpkshetty/work/libvirt/libvirt/src/storage/storage_backend_fs.c:1234:
undefined reference to `virStorageFileResize'
collect2: ld returned 1 exit status
make[3]: *** [libvirtd] Error 1
make[3]: Leaving directory `/home/dpkshetty/work/libvirt/libvirt/daemon'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/dpkshetty/work/libvirt/libvirt/daemon'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/dpkshetty/work/libvirt/libvirt'
make: *** [all] Error 2
12 years, 9 months
[libvirt] [PATCHv4] network: Avoid memory leaks on networkBuildDnsmasqArgv
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
Detected by valgrind. Leaks introduced in commit 973af236.
* src/network/bridge_driver.c: fix memory leaks on failure and successful path.
* How to reproduce?
% make -C tests check TESTS=networkxml2argvtest
% cd tests && valgrind -v --leak-check=full ./networkxml2argvtest
* Actual result:
==2226== 3 bytes in 1 blocks are definitely lost in loss record 1 of 24
==2226== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226== by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226== by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226== by 0x41E0B7: virAsprintf (util.c:1695)
==2226== by 0x41A2D9: networkBuildDhcpDaemonCommandLine (bridge_driver.c:545)
==2226== by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226== by 0x4156A1: virtTestRun (testutils.c:141)
==2226== by 0x414332: mymain (networkxml2argvtest.c:123)
==2226== by 0x414D97: virtTestMain (testutils.c:696)
==2226== by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== 3 bytes in 1 blocks are definitely lost in loss record 2 of 24
==2226== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226== by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226== by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226== by 0x41E0B7: virAsprintf (util.c:1695)
==2226== by 0x41A307: networkBuildDhcpDaemonCommandLine (bridge_driver.c:551)
==2226== by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226== by 0x4156A1: virtTestRun (testutils.c:141)
==2226== by 0x414332: mymain (networkxml2argvtest.c:123)
==2226== by 0x414D97: virtTestMain (testutils.c:696)
==2226== by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== 5 bytes in 1 blocks are definitely lost in loss record 4 of 24
==2226== at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==2226== by 0x39CF0FEDE7: __vasprintf_chk (in /lib64/libc-2.12.so)
==2226== by 0x41DFF7: virVasprintf (stdio2.h:199)
==2226== by 0x41E0B7: virAsprintf (util.c:1695)
==2226== by 0x41A2AB: networkBuildDhcpDaemonCommandLine (bridge_driver.c:539)
==2226== by 0x4145C8: testCompareXMLToArgvHelper (networkxml2argvtest.c:47)
==2226== by 0x4156A1: virtTestRun (testutils.c:141)
==2226== by 0x414332: mymain (networkxml2argvtest.c:123)
==2226== by 0x414D97: virtTestMain (testutils.c:696)
==2226== by 0x39CF01ECDC: (below main) (in /lib64/libc-2.12.so)
==2226==
==2226== LEAK SUMMARY:
==2226== definitely lost: 11 bytes in 3 blocks
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/network/bridge_driver.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 5d0d528..36bdf44 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -459,6 +459,10 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
int r, ret = -1;
int nbleases = 0;
int ii;
+ char *record = NULL;
+ char *recordPort = NULL;
+ char *recordWeight = NULL;
+ char *recordPriority = NULL;
virNetworkIpDefPtr tmpipdef;
/*
@@ -516,7 +520,6 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
int i;
for (i = 0; i < dns->ntxtrecords; i++) {
- char *record = NULL;
if (virAsprintf(&record, "%s,%s",
dns->txtrecords[i].name,
dns->txtrecords[i].value) < 0) {
@@ -529,11 +532,6 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
}
for (i = 0; i < dns->nsrvrecords; i++) {
- char *record = NULL;
- char *recordPort = NULL;
- char *recordPriority = NULL;
- char *recordWeight = NULL;
-
if (dns->srvrecords[i].service && dns->srvrecords[i].protocol) {
if (dns->srvrecords[i].port) {
if (virAsprintf(&recordPort, "%d", dns->srvrecords[i].port) < 0) {
@@ -568,6 +566,9 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
virCommandAddArgPair(cmd, "--srv-host", record);
VIR_FREE(record);
+ VIR_FREE(recordPort);
+ VIR_FREE(recordWeight);
+ VIR_FREE(recordPriority);
}
}
}
@@ -671,6 +672,10 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
ret = 0;
cleanup:
+ VIR_FREE(record);
+ VIR_FREE(recordPort);
+ VIR_FREE(recordWeight);
+ VIR_FREE(recordPriority);
return ret;
}
--
1.7.1
12 years, 9 months
[libvirt] [PATCH v2] tests: dynamically replace dnsmasq path
by Philipp Hahn
The path to the dnsmasq binary can be configured while in the test data
the path is hard-coded to /usr/bin/. This break the test suite if a the
binary is located in a different location, like /usr/local/sbin/.
Replace the hard coded path in the test data by a token, which is
dynamically replaced in networkxml2argvtest with the configured path
after the test data has been loaded.
(Another option would have been to modify configure.ac to generate the
test data during configure, but I do not know of an easy way do trick
configure into mass-generate those test files without listing every
single one, which I consider less flexible.)
v2:
- Use VIR_REALLOC_N() instead of realloc()
- Use memcpy() for replacement
- Skip shrinking buffer
- Add missing update of token_end
- simplify code after the changes above
- unit-test the unit-test:
#include <assert.h>
#define TEST(in,token,rep,out) { char *buf = strdup(in); assert(!replaceTokens(&buf, token, rep) && !strcmp(buf, out)); free(buf); }
TEST("", "AA", "B", "");
TEST("A", "AA", "B", "A");
TEST("AA", "AA", "B", "B");
TEST("AAA", "AA", "B", "BA");
TEST("AA", "AA", "BB", "BB");
TEST("AA", "AA", "BBB", "BBB");
TEST("<AA", "AA", "B", "<B");
TEST("<AA", "AA", "BB", "<BB");
TEST("<AA", "AA", "BBB", "<BBB");
TEST("AA>", "AA", "B", "B>");
TEST("AA>", "AA", "BB", "BB>");
TEST("AA>", "AA", "BBB", "BBB>");
TEST("<AA>", "AA", "B", "<B>");
TEST("<AA>", "AA", "BB", "<BB>");
TEST("<AA>", "AA", "BBB", "<BBB>");
TEST("<AA|AA>", "AA", "B", "<B|B>");
TEST("<AA|AA>", "AA", "BB", "<BB|BB>");
TEST("<AA|AA>", "AA", "BBB", "<BBB|BBB>");
TEST("<AAAA>", "AA", "B", "<BB>");
TEST("<AAAA>", "AA", "BB", "<BBBB>");
TEST("<AAAA>", "AA", "BBB", "<BBBBBB>");
TEST("AAAA>", "AA", "B", "BB>");
TEST("AAAA>", "AA", "BB", "BBBB>");
TEST("AAAA>", "AA", "BBB", "BBBBBB>");
TEST("<AAAA", "AA", "B", "<BB");
TEST("<AAAA", "AA", "BB", "<BBBB");
TEST("<AAAA", "AA", "BBB", "<BBBBBB");
alarm(1); /* no infinit loop */
TEST("A", "A", "A", "A");
TEST("AA", "A", "A", "AA");
alarm(0);
Signed-off-by: Philipp Hahn <hahn(a)univention.de>
---
tests/networkxml2argvdata/isolated-network.argv | 2 +-
.../networkxml2argvdata/nat-network-dns-hosts.argv | 2 +-
.../nat-network-dns-srv-record-minimal.argv | 2 +-
.../nat-network-dns-srv-record.argv | 2 +-
.../nat-network-dns-txt-record.argv | 2 +-
tests/networkxml2argvdata/nat-network.argv | 2 +-
tests/networkxml2argvdata/netboot-network.argv | 2 +-
.../networkxml2argvdata/netboot-proxy-network.argv | 2 +-
tests/networkxml2argvdata/routed-network.argv | 2 +-
tests/networkxml2argvtest.c | 33 ++++++++++++++++++++
10 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/tests/networkxml2argvdata/isolated-network.argv b/tests/networkxml2argvdata/isolated-network.argv
index 7ea2e94..a9beb05 100644
--- a/tests/networkxml2argvdata/isolated-network.argv
+++ b/tests/networkxml2argvdata/isolated-network.argv
@@ -1,4 +1,4 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= \
+@DNSMASQ@ --strict-order --bind-interfaces --conf-file= \
--except-interface lo --dhcp-option=3 --no-resolv \
--listen-address 192.168.152.1 \
--dhcp-range 192.168.152.2,192.168.152.254 \
diff --git a/tests/networkxml2argvdata/nat-network-dns-hosts.argv b/tests/networkxml2argvdata/nat-network-dns-hosts.argv
index 2158df8..c7e4967 100644
--- a/tests/networkxml2argvdata/nat-network-dns-hosts.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-hosts.argv
@@ -1,3 +1,3 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com \
+@DNSMASQ@ --strict-order --bind-interfaces --domain example.com \
--conf-file= --except-interface lo --listen-address 192.168.122.1 \
--expand-hosts --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts\
diff --git a/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv b/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
index 021e8f0..ea1da6d 100644
--- a/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-srv-record-minimal.argv
@@ -1,4 +1,4 @@
-/usr/sbin/dnsmasq \
+@DNSMASQ@ \
--strict-order \
--bind-interfaces \
--conf-file= \
diff --git a/tests/networkxml2argvdata/nat-network-dns-srv-record.argv b/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
index 85afbba..84c2d2f 100644
--- a/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-srv-record.argv
@@ -1,4 +1,4 @@
-/usr/sbin/dnsmasq \
+@DNSMASQ@ \
--strict-order \
--bind-interfaces \
--conf-file= \
diff --git a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
index be6ba4b..bed309f 100644
--- a/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
+++ b/tests/networkxml2argvdata/nat-network-dns-txt-record.argv
@@ -1,4 +1,4 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= \
+@DNSMASQ@ --strict-order --bind-interfaces --conf-file= \
--except-interface lo --txt-record=example,example value \
--listen-address 192.168.122.1 --listen-address 192.168.123.1 \
--listen-address 2001:db8:ac10:fe01::1 \
diff --git a/tests/networkxml2argvdata/nat-network.argv b/tests/networkxml2argvdata/nat-network.argv
index d7faee2..80878a8 100644
--- a/tests/networkxml2argvdata/nat-network.argv
+++ b/tests/networkxml2argvdata/nat-network.argv
@@ -1,4 +1,4 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= \
+@DNSMASQ@ --strict-order --bind-interfaces --conf-file= \
--except-interface lo --listen-address 192.168.122.1 \
--listen-address 192.168.123.1 --listen-address 2001:db8:ac10:fe01::1 \
--listen-address 2001:db8:ac10:fd01::1 --listen-address 10.24.10.1 \
diff --git a/tests/networkxml2argvdata/netboot-network.argv b/tests/networkxml2argvdata/netboot-network.argv
index 78e873c..7ae5b75 100644
--- a/tests/networkxml2argvdata/netboot-network.argv
+++ b/tests/networkxml2argvdata/netboot-network.argv
@@ -1,4 +1,4 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com \
+@DNSMASQ@ --strict-order --bind-interfaces --domain example.com \
--conf-file= --except-interface lo --listen-address 192.168.122.1 \
--dhcp-range 192.168.122.2,192.168.122.254 \
--dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases \
diff --git a/tests/networkxml2argvdata/netboot-proxy-network.argv b/tests/networkxml2argvdata/netboot-proxy-network.argv
index 5fe1b8e..2c5a0d5 100644
--- a/tests/networkxml2argvdata/netboot-proxy-network.argv
+++ b/tests/networkxml2argvdata/netboot-proxy-network.argv
@@ -1,4 +1,4 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --domain example.com \
+@DNSMASQ@ --strict-order --bind-interfaces --domain example.com \
--conf-file= --except-interface lo --listen-address 192.168.122.1 \
--dhcp-range 192.168.122.2,192.168.122.254 \
--dhcp-leasefile=/var/lib/libvirt/dnsmasq/netboot.leases \
diff --git a/tests/networkxml2argvdata/routed-network.argv b/tests/networkxml2argvdata/routed-network.argv
index d059630..75303e6 100644
--- a/tests/networkxml2argvdata/routed-network.argv
+++ b/tests/networkxml2argvdata/routed-network.argv
@@ -1,2 +1,2 @@
-/usr/sbin/dnsmasq --strict-order --bind-interfaces --conf-file= \
+@DNSMASQ@ --strict-order --bind-interfaces --conf-file= \
--except-interface lo --listen-address 192.168.122.1\
diff --git a/tests/networkxml2argvtest.c b/tests/networkxml2argvtest.c
index 2dd9b7f..f2e9086 100644
--- a/tests/networkxml2argvtest.c
+++ b/tests/networkxml2argvtest.c
@@ -15,6 +15,36 @@
#include "memory.h"
#include "network/bridge_driver.h"
+/* Replace all occurrences of @token in @buf by @replacement and adjust size of
+ * @buf accordingly. Returns 0 on success and -1 on out-of-memory errors. */
+static int replaceTokens(char **buf, const char *token, const char *replacement) {
+ char *token_start, *token_end;
+ size_t buf_len, rest_len;
+ const size_t token_len = strlen(token);
+ const size_t replacement_len = strlen(replacement);
+ const int diff = replacement_len - token_len;
+
+ buf_len = rest_len = strlen(*buf) + 1;
+ token_end = *buf;
+ for (;;) {
+ token_start = strstr(token_end, token);
+ if (token_start == NULL)
+ break;
+ rest_len -= token_start + token_len - token_end;
+ token_end = token_start + token_len;
+ buf_len += diff;
+ if (diff > 0)
+ if (VIR_REALLOC_N(*buf, buf_len) < 0)
+ return -1;
+ if (diff != 0)
+ memmove(token_end + diff, token_end, rest_len);
+ memcpy(token_start, replacement, replacement_len);
+ token_end += diff;
+ }
+ /* if diff < 0, we could shrinkt the buffer here... */
+ return 0;
+}
+
static int testCompareXMLToArgvFiles(const char *inxml, const char *outargv) {
char *inXmlData = NULL;
char *outArgvData = NULL;
@@ -32,6 +62,9 @@ static int testCompareXMLToArgvFiles(const char *inxml, const char *outargv) {
if (virtTestLoadFile(outargv, &outArgvData) < 0)
goto fail;
+ if (replaceTokens(&outArgvData, "@DNSMASQ@", DNSMASQ))
+ goto fail;
+
if (!(dev = virNetworkDefParseString(inXmlData)))
goto fail;
--
1.7.1
12 years, 9 months
[libvirt] [PATCH v2] tests: virnettlscontexttest needs gnutls-2.6.0
by Philipp Hahn
virnettlscontexttest uses gnutls_x509_crt_set_subject_alt_name() and
GNUTLS_FSAN_APPEND, which - according to
<http://www.gnu.org/software/gnutls/manual/gnutls.html> - are only
available since 2.6.0.
Since libvirt still works fine with gnutls-1.0.25 from RHEL5, only
enable the test when the version of GNUTLS is at least 2.6.0.
v2: greater-equal 2.6.0 instead of strictly greater.
Signed-off-by: Philipp Hahn <hahn(a)univention.de>
---
tests/virnettlscontexttest.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
index 51f75b4..508617a 100644
--- a/tests/virnettlscontexttest.c
+++ b/tests/virnettlscontexttest.c
@@ -36,7 +36,7 @@
#include "virsocketaddr.h"
#include "gnutls_1_0_compat.h"
-#if !defined WIN32 && HAVE_LIBTASN1_H && !defined GNUTLS_1_0_COMPAT
+#if !defined WIN32 && HAVE_LIBTASN1_H && !defined GNUTLS_1_0_COMPAT && LIBGNUTLS_VERSION_NUMBER >= 0x020600
# include <libtasn1.h>
# include "rpc/virnettlscontext.h"
--
1.7.1
12 years, 9 months
[libvirt] [PATCH 0/3] add virDomainBlockRebase
by Eric Blake
As discussed here:
https://www.redhat.com/archives/libvir-list/2012-January/msg01448.html
Qemu patch series here:
https://lists.gnu.org/archive/html/qemu-devel/2012-01/msg03488.html
This is the bare-minimum implementation for getting the API in
place prior to the 0.9.10 rc1 freeze; I can later do patches to
wire up the new optional argument to the qemu block_stream monitor
command to actually make use of the new base argument.
Eric Blake (3):
block rebase: add new API virDomainBlockRebase
block rebase: wire up remote protocol
block rebase: initial qemu implementation
docs/apibuild.py | 1 +
include/libvirt/libvirt.h.in | 9 +++-
src/driver.h | 5 ++
src/libvirt.c | 84 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 1 +
src/qemu/qemu_driver.c | 40 +++++++++++++-------
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 10 ++++-
src/remote_protocol-structs | 8 ++++
src/rpc/gendispatch.pl | 1 +
10 files changed, 143 insertions(+), 17 deletions(-)
--
1.7.7.6
12 years, 9 months