[Libvir] Re: libvirt adding new methods to the xenUnifiedDriver
by Richard W.M. Jones
Roman Divacky wrote:
> hi
>
> I am messing with libvirt and I need to add some methods to the
> xenUnifiedDriver structure. I do it this way:
> (currently #ifdef-ed out)
>
> struct xenUnifiedDriver {
> virDrvOpen open;
> virDrvClose close;
> virDrvGetVersion version;
> virDrvGetHostname getHostname;
> virDrvGetURI getURI;
> virDrvNodeGetInfo nodeGetInfo;
> virDrvGetCapabilities getCapabilities;
> virDrvListDomains listDomains;
> #if 0
> virDrvListDatastores listDatastores;
> virDrvListSyspreps listSyspreps;
> #endif
> ....
>
> with the #if switched to off I am seeing some problems in
> xenUnifiedDomainGetInfo(). it basically iterates through
> array of driver structures to find out suitable domainGetInfo()
> method. When I flip the #if to 1 the driver structures get redefined
> causing xenUnifiedDomainGetInfo() to not find any suitable driver.
Don't add things to xenUnifiedDriver structure -- this structure should
go away eventually. (See the comment in src/xen_unified.h).
Instead, just do whatever you need directly from src/xen_unified.c, be
that direct code or calling something lower level.
> code stuffed with debugging printfs:
>
> #if 0 case:
>
> priv->opened[i]: 0
> drivers[i]->domainGetInfo: 0x2aaaaaae0c10
> priv->opened[i]: 1
> drivers[i]->domainGetInfo: 0x2aaaaaaec2c0
> Domains 0: 2 CPUs
>
> #if 1 case:
>
> priv->opened[i]: 0
> drivers[i]->domainGetInfo: (nil)
> priv->opened[i]: 1
> drivers[i]->domainGetInfo: (nil)
> priv->opened[i]: 0
> drivers[i]->domainGetInfo: 0x2aaaaaae7400
> priv->opened[i]: 0
> drivers[i]->domainGetInfo: (nil)
> priv->opened[i]: 1
> drivers[i]->domainGetInfo: (nil)
> Failed to get informations for Domain 0
>
> as you can see the "drivers" (xenHypervisorDriver etc.) got
> redefined...
>
> any idea why? or whats going on?
>
> thnx for any possible help, if you cannot help me could you please
> forward this mail to the appropriete place?
You should send any questions to libvirt-list:
http://www.redhat.com/mailman/listinfo/libvir-list
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
16 years, 9 months
[Libvir] libvirt & vde_switch
by Loic Dachary
In reply to
http://www.redhat.com/archives/libvir-list/2007-April/msg00177.html
an area where vde_switch support is usefull is an unprivileged user
running tests. A test suite involving the creation of qemu instances
thru libvirt should not be forced to create a bridge or alter the
iptables configuration. With vde_switch and slirpvde multiple qemu
instances can be run without altering the network configuration of the host.
I hope it helps.
Cheers
16 years, 9 months
[Libvir] mark some diagnostics for translation
by Jim Meyering
This makes it so some diagnostics emitted via the error function
are checked for use of "_(...)" when you run "make syntax-check",
and fixes the ones that lacked that:
Enable the sc_unmarked_diagnostics test and correct all violations
involving the "error" function.
* Makefile.cfg (local-checks-to-skip): Remove from skip list.
Then, at the end, a second patch:
Mark a string for translation.
* src/virsh.c: Add a "%s" and wrap with _(...).
Note that technically, it doesn't make sense to translate
a diagnostic like this (there are several like this):
error (conn, VIR_ERR_RPC, _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
However, if it's worth emitting the diagnostic, then I think it's worth
making it a little more useful to someone not reading the code, e.g.,
too many domains (maximum is %d)
If no one objects, I'll convert the ones below.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.cfg | 3 +-
src/remote_internal.c | 81 +++++++++++++++++++++++++++----------------------
2 files changed, 46 insertions(+), 38 deletions(-)
diff --git a/Makefile.cfg b/Makefile.cfg
index 9e75fda..dca7c5b 100644
--- a/Makefile.cfg
+++ b/Makefile.cfg
@@ -1,5 +1,5 @@
# Customize Makefile.maint. -*- makefile -*-
-# Copyright (C) 2003-2007 Free Software Foundation, Inc.
+# Copyright (C) 2003-2008 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -29,7 +29,6 @@ local-checks-to-skip = \
makefile_path_separator_check \
makefile-check \
sc_no_have_config_h \
- sc_unmarked_diagnostics \
sc_tight_scope \
sc_trailing_blank \
sc_GPL_version \
diff --git a/src/remote_internal.c b/src/remote_internal.c
index aa6bb5c..e9c7781 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -104,7 +104,7 @@ struct private_data {
struct private_data *priv = (struct private_data *) (conn)->privateData; \
if (!priv || priv->magic != MAGIC) { \
error (conn, VIR_ERR_INVALID_ARG, \
- "tried to use a closed or uninitialised handle"); \
+ _("tried to use a closed or uninitialised handle")); \
return (retcode); \
}
@@ -112,7 +112,7 @@ struct private_data {
struct private_data *priv = (struct private_data *) (conn)->networkPrivateData; \
if (!priv || priv->magic != MAGIC) { \
error (conn, VIR_ERR_INVALID_ARG, \
- "tried to use a closed or uninitialised handle"); \
+ _("tried to use a closed or uninitialised handle")); \
return (retcode); \
}
@@ -206,7 +206,7 @@ remoteForkDaemon(virConnectPtr conn)
int ret, pid, status;
if (!daemonPath) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "failed to find libvirtd binary");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("failed to find libvirtd binary"));
return(-1);
}
@@ -313,8 +313,8 @@ doRemoteOpen (virConnectPtr conn,
transport = trans_tcp;
else {
error (conn, VIR_ERR_INVALID_ARG,
- "remote_open: transport in URL not recognised "
- "(should be tls|unix|ssh|ext|tcp)");
+ _("remote_open: transport in URL not recognised "
+ "(should be tls|unix|ssh|ext|tcp)"));
return VIR_DRV_OPEN_ERROR;
}
@@ -354,7 +354,7 @@ doRemoteOpen (virConnectPtr conn,
priv->hostname = strdup (uri->server ? uri->server : "localhost");
if (!priv->hostname) {
- error (NULL, VIR_ERR_NO_MEMORY, "allocating priv->hostname");
+ error (NULL, VIR_ERR_NO_MEMORY, _("allocating priv->hostname"));
goto failed;
}
if (uri->user) {
@@ -436,7 +436,8 @@ doRemoteOpen (virConnectPtr conn,
/* For ext transport, command is required. */
if (transport == trans_ext && !command) {
- error (conn, VIR_ERR_INVALID_ARG, "remote_open: for 'ext' transport, command is required");
+ error (conn, VIR_ERR_INVALID_ARG,
+ _("remote_open: for 'ext' transport, command is required"));
goto failed;
}
@@ -754,7 +755,7 @@ doRemoteOpen (virConnectPtr conn,
return retcode;
out_of_memory:
- error (NULL, VIR_ERR_NO_MEMORY, "uri params");
+ error (NULL, VIR_ERR_NO_MEMORY, _("uri params"));
failed:
/* Close the socket if we failed. */
@@ -798,7 +799,7 @@ remoteOpen (virConnectPtr conn,
priv = malloc (sizeof(*priv));
if (!priv) {
- error (conn, VIR_ERR_NO_MEMORY, "struct private_data");
+ error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
return VIR_DRV_OPEN_ERROR;
}
@@ -1050,12 +1051,12 @@ verify_certificate (virConnectPtr conn ATTRIBUTE_UNUSED,
}
if (gnutls_certificate_type_get(session) != GNUTLS_CRT_X509) {
- error (conn, VIR_ERR_RPC, "Certificate type is not X.509");
+ error (conn, VIR_ERR_RPC, _("Certificate type is not X.509"));
return -1;
}
if (!(certs = gnutls_certificate_get_peers(session, &nCerts))) {
- error (conn, VIR_ERR_RPC, "gnutls_certificate_get_peers failed");
+ error (conn, VIR_ERR_RPC, _("gnutls_certificate_get_peers failed"));
return -1;
}
@@ -1076,13 +1077,13 @@ verify_certificate (virConnectPtr conn ATTRIBUTE_UNUSED,
}
if (gnutls_x509_crt_get_expiration_time (cert) < now) {
- error (conn, VIR_ERR_RPC, "The certificate has expired");
+ error (conn, VIR_ERR_RPC, _("The certificate has expired"));
gnutls_x509_crt_deinit (cert);
return -1;
}
if (gnutls_x509_crt_get_activation_time (cert) > now) {
- error (conn, VIR_ERR_RPC, "The certificate is not yet activated");
+ error (conn, VIR_ERR_RPC, _("The certificate is not yet activated"));
gnutls_x509_crt_deinit (cert);
return -1;
}
@@ -1309,7 +1310,7 @@ remoteListDomains (virConnectPtr conn, int *ids, int maxids)
GET_PRIVATE (conn, -1);
if (maxids > REMOTE_DOMAIN_ID_LIST_MAX) {
- error (conn, VIR_ERR_RPC, "maxids > REMOTE_DOMAIN_ID_LIST_MAX");
+ error (conn, VIR_ERR_RPC, _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
return -1;
}
args.maxids = maxids;
@@ -1321,7 +1322,7 @@ remoteListDomains (virConnectPtr conn, int *ids, int maxids)
return -1;
if (ret.ids.ids_len > maxids) {
- error (conn, VIR_ERR_RPC, "ret.ids.ids_len > maxids");
+ error (conn, VIR_ERR_RPC, _("ret.ids.ids_len > maxids"));
xdr_free ((xdrproc_t) xdr_remote_list_domains_ret, (char *) &ret);
return -1;
}
@@ -1693,7 +1694,7 @@ remoteDomainPinVcpu (virDomainPtr domain,
GET_PRIVATE (domain->conn, -1);
if (maplen > REMOTE_CPUMAP_MAX) {
- error (domain->conn, VIR_ERR_RPC, "maplen > REMOTE_CPUMAP_MAX");
+ error (domain->conn, VIR_ERR_RPC, _("maplen > REMOTE_CPUMAP_MAX"));
return -1;
}
@@ -1723,11 +1724,12 @@ remoteDomainGetVcpus (virDomainPtr domain,
GET_PRIVATE (domain->conn, -1);
if (maxinfo > REMOTE_VCPUINFO_MAX) {
- error (domain->conn, VIR_ERR_RPC, "maxinfo > REMOTE_VCPUINFO_MAX");
+ error (domain->conn, VIR_ERR_RPC, _("maxinfo > REMOTE_VCPUINFO_MAX"));
return -1;
}
if (maxinfo * maplen > REMOTE_CPUMAPS_MAX) {
- error (domain->conn, VIR_ERR_RPC, "maxinfo * maplen > REMOTE_CPUMAPS_MAX");
+ error (domain->conn, VIR_ERR_RPC,
+ _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
return -1;
}
@@ -1742,12 +1744,13 @@ remoteDomainGetVcpus (virDomainPtr domain,
return -1;
if (ret.info.info_len > maxinfo) {
- error (domain->conn, VIR_ERR_RPC, "ret.info.info_len > maxinfo");
+ error (domain->conn, VIR_ERR_RPC, _("ret.info.info_len > maxinfo"));
xdr_free ((xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret);
return -1;
}
if (ret.cpumaps.cpumaps_len > maxinfo * maplen) {
- error (domain->conn, VIR_ERR_RPC, "ret.cpumaps.cpumaps_len > maxinfo * maplen");
+ error (domain->conn, VIR_ERR_RPC,
+ _("ret.cpumaps.cpumaps_len > maxinfo * maplen"));
xdr_free ((xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret);
return -1;
}
@@ -1907,7 +1910,7 @@ remoteListDefinedDomains (virConnectPtr conn, char **const names, int maxnames)
GET_PRIVATE (conn, -1);
if (maxnames > REMOTE_DOMAIN_NAME_LIST_MAX) {
- error (conn, VIR_ERR_RPC, "maxnames > REMOTE_DOMAIN_NAME_LIST_MAX");
+ error (conn, VIR_ERR_RPC, _("maxnames > REMOTE_DOMAIN_NAME_LIST_MAX"));
return -1;
}
args.maxnames = maxnames;
@@ -1919,7 +1922,7 @@ remoteListDefinedDomains (virConnectPtr conn, char **const names, int maxnames)
return -1;
if (ret.names.names_len > maxnames) {
- error (conn, VIR_ERR_RPC, "ret.names.names_len > maxnames");
+ error (conn, VIR_ERR_RPC, _("ret.names.names_len > maxnames"));
xdr_free ((xdrproc_t) xdr_remote_list_defined_domains_ret, (char *) &ret);
return -1;
}
@@ -2119,7 +2122,9 @@ remoteDomainGetSchedulerParameters (virDomainPtr domain,
if (ret.params.params_len > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX ||
ret.params.params_len > *nparams) {
xdr_free ((xdrproc_t) xdr_remote_domain_get_scheduler_parameters_ret, (char *) &ret);
- error (domain->conn, VIR_ERR_RPC, "remoteDomainGetSchedulerParameters: returned number of parameters exceeds limit");
+ error (domain->conn, VIR_ERR_RPC,
+ _("remoteDomainGetSchedulerParameters: "
+ "returned number of parameters exceeds limit"));
return -1;
}
*nparams = ret.params.params_len;
@@ -2145,7 +2150,9 @@ remoteDomainGetSchedulerParameters (virDomainPtr domain,
params[i].value.b = ret.params.params_val[i].value.remote_sched_param_value_u.b; break;
default:
xdr_free ((xdrproc_t) xdr_remote_domain_get_scheduler_parameters_ret, (char *) &ret);
- error (domain->conn, VIR_ERR_RPC, "remoteDomainGetSchedulerParameters: unknown parameter type");
+ error (domain->conn, VIR_ERR_RPC,
+ _("remoteDomainGetSchedulerParameters: "
+ "unknown parameter type"));
return -1;
}
}
@@ -2169,7 +2176,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
args.params.params_val = malloc (sizeof (*args.params.params_val)
* nparams);
if (args.params.params_val == NULL) {
- error (domain->conn, VIR_ERR_RPC, "out of memory allocating array");
+ error (domain->conn, VIR_ERR_RPC, _("out of memory allocating array"));
return -1;
}
@@ -2178,7 +2185,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
// call() will free this:
args.params.params_val[i].field = strdup (params[i].field);
if (args.params.params_val[i].field == NULL) {
- error (domain->conn, VIR_ERR_NO_MEMORY, "out of memory");
+ error (domain->conn, VIR_ERR_NO_MEMORY, _("out of memory"));
do_error = 1;
}
args.params.params_val[i].value.type = params[i].type;
@@ -2196,7 +2203,7 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
args.params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
default:
- error (domain->conn, VIR_ERR_RPC, "unknown parameter type");
+ error (domain->conn, VIR_ERR_RPC, _("unknown parameter type"));
do_error = 1;
}
}
@@ -2301,7 +2308,7 @@ remoteNetworkOpen (virConnectPtr conn,
struct private_data *priv = malloc (sizeof(*priv));
int ret, rflags = 0;
if (!priv) {
- error (conn, VIR_ERR_NO_MEMORY, "struct private_data");
+ error (conn, VIR_ERR_NO_MEMORY, _("struct private_data"));
return VIR_DRV_OPEN_ERROR;
}
if (flags & VIR_CONNECT_RO)
@@ -2361,7 +2368,7 @@ remoteListNetworks (virConnectPtr conn, char **const names, int maxnames)
GET_NETWORK_PRIVATE (conn, -1);
if (maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- error (conn, VIR_ERR_RPC, "maxnames > REMOTE_NETWORK_NAME_LIST_MAX");
+ error (conn, VIR_ERR_RPC, _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
return -1;
}
args.maxnames = maxnames;
@@ -2373,7 +2380,7 @@ remoteListNetworks (virConnectPtr conn, char **const names, int maxnames)
return -1;
if (ret.names.names_len > maxnames) {
- error (conn, VIR_ERR_RPC, "ret.names.names_len > maxnames");
+ error (conn, VIR_ERR_RPC, _("ret.names.names_len > maxnames"));
xdr_free ((xdrproc_t) xdr_remote_list_networks_ret, (char *) &ret);
return -1;
}
@@ -2416,7 +2423,7 @@ remoteListDefinedNetworks (virConnectPtr conn,
GET_NETWORK_PRIVATE (conn, -1);
if (maxnames > REMOTE_NETWORK_NAME_LIST_MAX) {
- error (conn, VIR_ERR_RPC, "maxnames > REMOTE_NETWORK_NAME_LIST_MAX");
+ error (conn, VIR_ERR_RPC, _("maxnames > REMOTE_NETWORK_NAME_LIST_MAX"));
return -1;
}
args.maxnames = maxnames;
@@ -2428,7 +2435,7 @@ remoteListDefinedNetworks (virConnectPtr conn,
return -1;
if (ret.names.names_len > maxnames) {
- error (conn, VIR_ERR_RPC, "ret.names.names_len > maxnames");
+ error (conn, VIR_ERR_RPC, _("ret.names.names_len > maxnames"));
xdr_free ((xdrproc_t) xdr_remote_list_defined_networks_ret, (char *) &ret);
return -1;
}
@@ -3413,7 +3420,8 @@ call (virConnectPtr conn, struct private_data *priv,
}
if (!(*args_filter) (&xdr, args)) {
- error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC, "marshalling args");
+ error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC,
+ _("marshalling args"));
return -1;
}
@@ -3429,7 +3437,7 @@ call (virConnectPtr conn, struct private_data *priv,
/* Encode the length word. */
xdrmem_create (&xdr, buffer2, sizeof buffer2, XDR_ENCODE);
if (!xdr_int (&xdr, &len)) {
- error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC, "xdr_int (length word)");
+ error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC, _("xdr_int (length word)"));
return -1;
}
xdr_destroy (&xdr);
@@ -3521,7 +3529,8 @@ call (virConnectPtr conn, struct private_data *priv,
switch (hdr.status) {
case REMOTE_OK:
if (!(*ret_filter) (&xdr, ret)) {
- error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC, "unmarshalling ret");
+ error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, VIR_ERR_RPC,
+ _("unmarshalling ret"));
return -1;
}
xdr_destroy (&xdr);
@@ -3531,7 +3540,7 @@ call (virConnectPtr conn, struct private_data *priv,
memset (&rerror, 0, sizeof rerror);
if (!xdr_remote_error (&xdr, &rerror)) {
error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
- VIR_ERR_RPC, "unmarshalling remote_error");
+ VIR_ERR_RPC, _("unmarshalling remote_error"));
return -1;
}
xdr_destroy (&xdr);
--
1.5.4.8.g2b39
Mark a string for translation.
* src/virsh.c: Add a "%s" and wrap with _(...).
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
src/virsh.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/virsh.c b/src/virsh.c
index 487f256..8d3bdc2 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -1,7 +1,7 @@
/*
* virsh.c: a Xen shell used to exercise the libvirt API
*
- * Copyright (C) 2005, 2007 Red Hat, Inc.
+ * Copyright (C) 2005, 2007-2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -4770,7 +4770,7 @@ vshReadline (vshControl *ctl, const char *prompt)
#endif /* !USE_READLINE */
/*
- * Deinitliaze virsh
+ * Deinitialize virsh
*/
static int
vshDeinit(vshControl * ctl)
@@ -4780,8 +4780,8 @@ vshDeinit(vshControl * ctl)
if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) {
ctl->conn = NULL; /* prevent recursive call from vshError() */
- vshError(ctl, TRUE,
- "failed to disconnect from the hypervisor");
+ vshError(ctl, TRUE, "%s",
+ _("failed to disconnect from the hypervisor"));
}
}
virResetLastError();
--
1.5.4.8.g2b39
16 years, 9 months
[Libvir] mark more translatable messages
by Jim Meyering
This change marks for translation some more messages.
It adds a few new ones, too, e.g., replacing "domain" with
_("failed to parse domain description") in two places.
Likewise, there are some like this:
- virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+ virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
The two new grep invocations in Makefile.maint handle two situations:
First, when the entire statement is on a single line (ends in ";").
The second grep (with -A1) is to get the diagnostics that appear
on the line following the function name. Hence where the first line
ends in ",". With checks like this, it's nice if you can assume no
trailing blanks in the code base. IMHO, that would be a nice change
to make soon, but it's more invasive.
Enable more checks for unmarked messages; fix violators.
* Makefile.maint (sc_unmarked_diagnostics): Check for more functions.
* src/conf.c (virConfParseValue): Remove trailing space in diagnostic.
* src/libvirt.c (do_open, virDomainMigrate): Mark diagnostics.
* src/xend_internal.c (do_connect, xenDaemonDomainDumpXMLByID): Likewise.
(xenDaemonDomainDumpXMLByName, xenDaemonCreateLinux): Likewise.
(xenDaemonDomainMigratePerform, xenDaemonDomainDefineXML): Likewise.
* src/xml.c (virXPathString, virXPathNumber, virXPathLong): Likewise.
(virXPathBoolean, virXPathNode, virXPathNodeSet): Likewise.
(virDomainParseXMLOSDescHVM): Likewise.
* src/xmlrpc.c (xmlRpcValueNew): Likewise.
(xmlRpcValueUnmarshalDictElement): Likewise.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 10 +++++++++-
src/conf.c | 4 ++--
src/libvirt.c | 6 +++---
src/xend_internal.c | 40 ++++++++++++++++++++++++----------------
src/xml.c | 24 +++++++++++++-----------
src/xmlrpc.c | 4 ++--
6 files changed, 53 insertions(+), 35 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 0336f13..356ca73 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -287,14 +287,22 @@ sc_two_space_separator_in_usage:
echo "$(ME): an option and its description"; \
1>&2; exit 1; } || :
+err_func_re = \
+(DISABLE_fprintf|(xmlRpc|vir(Xend|XML|Hash|Conf|Test|LibConn))Error)
+
# Look for diagnostics that aren't marked for translation.
# This won't find any for which error's format string is on a separate line.
sc_unmarked_diagnostics:
@grep -nE \
- '\<error \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT)) \
+ '\<(vshError|error) \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT)) \
| grep -v '_''(' && \
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
+ @{ grep -nE '\<$(err_func_re) *\(.*;$$' $$($(CVS_LIST_EXCEPT)); \
+ grep -A1 -nE '\<$(err_func_re) *\(.*,$$' $$($(CVS_LIST_EXCEPT)); } \
+ | grep '[ ]"' && \
+ { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
+ exit 1; } || :
# Avoid useless parentheses like those in this example:
# #if defined (SYMBOL) || defined (SYM2)
diff --git a/src/conf.c b/src/conf.c
index 8b3aae5..d4e5227 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -1,7 +1,7 @@
/**
* conf.c: parser for a subset of the Python encoded Xen configuration files
*
- * Copyright (C) 2006, 2007 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -473,7 +473,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
NEXT;
} else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX,
- _("list is not closed with ] "), ctxt->line);
+ _("list is not closed with ]"), ctxt->line);
virConfFreeList(lst);
return(NULL);
}
diff --git a/src/libvirt.c b/src/libvirt.c
index c19565f..8ab4cbd 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2,7 +2,7 @@
* libvirt.c: Main interfaces for the libvirt library to handle virtualization
* domains from a process running in domain 0
*
- * Copyright (C) 2005,2006 Red Hat, Inc.
+ * Copyright (C) 2005,2006,2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -562,7 +562,7 @@ do_open (const char *name,
ret->name = strdup (name);
if (!ret->name) {
- virLibConnError (ret, VIR_ERR_NO_MEMORY, "allocating conn->name");
+ virLibConnError (ret, VIR_ERR_NO_MEMORY, _("allocating conn->name"));
goto failed;
}
@@ -1946,7 +1946,7 @@ virDomainMigrate (virDomainPtr domain,
if (ret == -1) goto done;
if (uri == NULL && uri_out == NULL) {
virLibConnError (conn, VIR_ERR_INTERNAL_ERROR,
- "domainMigratePrepare did not set uri");
+ _("domainMigratePrepare did not set uri"));
goto done;
}
if (uri_out) uri = uri_out; /* Did domainMigratePrepare change URI? */
diff --git a/src/xend_internal.c b/src/xend_internal.c
index bbe5013..78691c9 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -217,7 +217,7 @@ do_connect(virConnectPtr xend)
s = socket(priv->type, SOCK_STREAM, 0);
if (s == -1) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR,
- "failed to create a socket");
+ _("failed to create a socket"));
return -1;
}
@@ -240,7 +240,7 @@ do_connect(virConnectPtr xend)
*/
if ((getuid() == 0) || (xend->flags & VIR_CONNECT_RO)) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR,
- "failed to connect to xend");
+ _("failed to connect to xend"));
}
}
@@ -2512,7 +2512,8 @@ xenDaemonDomainDumpXMLByID(virConnectPtr conn, int domid, int flags,
root = sexpr_get(conn, "/xend/domain/%d?detail=1", domid);
if (root == NULL) {
virXendError (conn, VIR_ERR_XEN_CALL,
- "xenDaemonDomainDumpXMLByID failed to find this domain");
+ _("xenDaemonDomainDumpXMLByID failed to"
+ " find this domain"));
return (NULL);
}
@@ -2536,7 +2537,8 @@ xenDaemonDomainDumpXMLByName(virConnectPtr conn, const char *name, int flags,
root = sexpr_get(conn, "/xend/domain/%s?detail=1", name);
if (root == NULL) {
virXendError (conn, VIR_ERR_XEN_CALL,
- "xenDaemonDomainDumpXMLByName failed to find this domain");
+ _("xenDaemonDomainDumpXMLByName failed to"
+ " find this domain"));
return (NULL);
}
@@ -3144,7 +3146,8 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
if ((sexpr == NULL) || (name == NULL)) {
- virXendError(conn, VIR_ERR_XML_ERROR, "domain");
+ virXendError(conn, VIR_ERR_XML_ERROR,
+ _("failed to parse domain description"));
free(sexpr);
free(name);
@@ -3323,7 +3326,8 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
/* Xen doesn't support renaming domains during migration. */
if (dname) {
virXendError (conn, VIR_ERR_NO_SUPPORT,
- "xenDaemonDomainMigrate: Xen does not support renaming domains during migration");
+ _("xenDaemonDomainMigrate: Xen does not support"
+ " renaming domains during migration"));
return -1;
}
@@ -3332,7 +3336,8 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
*/
if (bandwidth) {
virXendError (conn, VIR_ERR_NO_SUPPORT,
- "xenDaemonDomainMigrate: Xen does not support bandwidth limits during migration");
+ _("xenDaemonDomainMigrate: Xen does not support"
+ " bandwidth limits during migration"));
return -1;
}
@@ -3343,7 +3348,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
}
if (flags != 0) {
virXendError (conn, VIR_ERR_NO_SUPPORT,
- "xenDaemonDomainMigrate: unsupported flag");
+ _("xenDaemonDomainMigrate: unsupported flag"));
return -1;
}
@@ -3356,24 +3361,26 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
xmlURIPtr uriptr = xmlParseURI (uri);
if (!uriptr) {
virXendError (conn, VIR_ERR_INVALID_ARG,
- "xenDaemonDomainMigrate: invalid URI");
+ _("xenDaemonDomainMigrate: invalid URI"));
return -1;
}
if (uriptr->scheme && STRCASENEQ (uriptr->scheme, "xenmigr")) {
virXendError (conn, VIR_ERR_INVALID_ARG,
- "xenDaemonDomainMigrate: only xenmigr:// migrations are supported by Xen");
+ _("xenDaemonDomainMigrate: only xenmigr://"
+ " migrations are supported by Xen"));
xmlFreeURI (uriptr);
return -1;
}
if (!uriptr->server) {
virXendError (conn, VIR_ERR_INVALID_ARG,
- "xenDaemonDomainMigrate: a hostname must be specified in the URI");
+ _("xenDaemonDomainMigrate: a hostname must be"
+ " specified in the URI"));
xmlFreeURI (uriptr);
return -1;
}
hostname = strdup (uriptr->server);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+ virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
xmlFreeURI (uriptr);
return -1;
}
@@ -3386,7 +3393,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
if (sscanf (p+1, "%d", &port_nr) != 1) {
virXendError (conn, VIR_ERR_INVALID_ARG,
- "xenDaemonDomainMigrate: invalid port number");
+ _("xenDaemonDomainMigrate: invalid port number"));
return -1;
}
snprintf (port, sizeof port, "%d", port_nr);
@@ -3395,7 +3402,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
n = p - uri; /* n = Length of hostname in bytes. */
hostname = strdup (uri);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+ virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
return -1;
}
hostname[n] = '\0';
@@ -3403,7 +3410,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
else { /* "hostname" (or IP address) */
hostname = strdup (uri);
if (!hostname) {
- virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+ virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
return -1;
}
}
@@ -3448,7 +3455,8 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
if ((sexpr == NULL) || (name == NULL)) {
- virXendError(conn, VIR_ERR_XML_ERROR, "domain");
+ virXendError(conn, VIR_ERR_XML_ERROR,
+ _("failed to parse domain description"));
free(sexpr);
free(name);
diff --git a/src/xml.c b/src/xml.c
index bf1c2eb..b7ffe2a 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1,7 +1,7 @@
/*
* xml.c: XML based interfaces for the libvir library
*
- * Copyright (C) 2005, 2007 Red Hat, Inc.
+ * Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -473,7 +473,7 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt)
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathString()", 0);
+ _("Invalid parameter to virXPathString()"), 0);
return (NULL);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -486,7 +486,7 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt)
ret = strdup((char *) obj->stringval);
xmlXPathFreeObject(obj);
if (ret == NULL) {
- virXMLError(NULL, VIR_ERR_NO_MEMORY, "strdup", 0);
+ virXMLError(NULL, VIR_ERR_NO_MEMORY, _("strdup failed"), 0);
}
return (ret);
}
@@ -509,7 +509,7 @@ virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value)
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathNumber()", 0);
+ _("Invalid parameter to virXPathNumber()"), 0);
return (-1);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -544,7 +544,7 @@ virXPathLong(const char *xpath, xmlXPathContextPtr ctxt, long *value)
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathNumber()", 0);
+ _("Invalid parameter to virXPathNumber()"), 0);
return (-1);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -590,7 +590,7 @@ virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt)
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathBoolean()", 0);
+ _("Invalid parameter to virXPathBoolean()"), 0);
return (-1);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -623,7 +623,7 @@ virXPathNode(const char *xpath, xmlXPathContextPtr ctxt)
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathNode()", 0);
+ _("Invalid parameter to virXPathNode()"), 0);
return (NULL);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -659,7 +659,7 @@ virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt,
if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
- "Invalid parameter to virXPathNodeSet()", 0);
+ _("Invalid parameter to virXPathNodeSet()"), 0);
return (-1);
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -882,7 +882,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
if (nbootorder ==
((sizeof(bootorder) / sizeof(bootorder[0])) - 1)) {
virXMLError(conn, VIR_ERR_XML_ERROR,
- "too many boot devices", 0);
+ _("too many boot devices"), 0);
return (-1);
}
if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
@@ -1004,7 +1004,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
isMouse = 0;
else if (strcmp((const char *) itype, "mouse")) {
xmlFree(itype);
- virXMLError(conn, VIR_ERR_XML_ERROR, "input", 0);
+ virXMLError(conn, VIR_ERR_XML_ERROR,
+ _("invalid input device"), 0);
goto error;
}
xmlFree(itype);
@@ -1020,7 +1021,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
if (!strcmp((const char *) bus, "ps2")) {
if (!isMouse) {
xmlFree(bus);
- virXMLError(conn, VIR_ERR_XML_ERROR, "input", 0);
+ virXMLError(conn, VIR_ERR_XML_ERROR,
+ _("invalid input device"), 0);
goto error;
}
/* Nothing - implicit ps2 */
diff --git a/src/xmlrpc.c b/src/xmlrpc.c
index ac4ea6e..5baa353 100644
--- a/src/xmlrpc.c
+++ b/src/xmlrpc.c
@@ -50,7 +50,7 @@ static xmlRpcValuePtr xmlRpcValueNew(xmlRpcValueType type)
xmlRpcValuePtr ret = malloc(sizeof(*ret));
if (!ret)
- xmlRpcError(VIR_ERR_NO_MEMORY, "allocate value", sizeof(*ret));
+ xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value"), sizeof(*ret));
else
ret->kind = type;
return ret;
@@ -183,7 +183,7 @@ static xmlRpcValueDictElementPtr xmlRpcValueUnmarshalDictElement(xmlNodePtr node
xmlNodePtr cur;
if (!ret) {
- xmlRpcError(VIR_ERR_NO_MEMORY, "allocate dict", sizeof(*ret));
+ xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate dict"), sizeof(*ret));
return NULL;
}
memset(ret, 0, sizeof(*ret));
--
1.5.4.19.gd3dfd
16 years, 9 months
[Libvir] Re: libvirt on mingw
by Richard W.M. Jones
Brecht Sanders wrote:
> Did you have a win32 Python version of gconf?
Nope.
Please CC questions to libvir-list so that everyone can see questions &
answers.
Rich.
--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in
England and Wales under Company Registration No. 03798903
16 years, 9 months
[Libvir] virsh vncdisplay fix
by John Levon
I have an old HVM guest defined in 3.0.4, and now I'm running 3.1.2 and
libvirt 0.4.0. The config looks like this:
(domain
(image
(hvm
(vnc 1)
(vncdisplay 0)
(device
(vfb
(location localhost:5900)
(vncdisplay 0)
(uuid ...)
The libvirt code looks like this:
1757 /* Graphics device (HVM <= 3.0.4, or PV <= 3.0.3) vnc config */
1758 if ((hvm && xendConfigVersion < 4) ||
1759 (!hvm && xendConfigVersion < 3)) {
1760 tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux");
So we don't see the 'vnc 1' at the top. But the code to parse device/vfb doesn't
expect this config either:
1685 tmp = sexpr_node(node, "device/vfb/type");
The patch below replaces the later version check with something that
copes correctly with the "upgrade" case.
regards
john
2008-01-15 John Levon <levon(a)movementarian.org>
* src/xend_internal.c: fix VNC parsing of old Xen domains on
newer Xen versions.
diff -prauN libvirt-0.4.0/src/xend_internal.c libvirt-new/src/xend_internal.c
--- libvirt-0.4.0/src/xend_internal.c 2007-12-17 15:05:27.000000000 -0800
+++ libvirt-new/src/xend_internal.c 2008-01-14 18:42:08.895060570 -0800
@@ -1371,6 +1371,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
unsigned char uuid[VIR_UUID_BUFLEN];
char uuidstr[VIR_UUID_STRING_BUFLEN];
int vif_index = 0;
+ int found_graphics = 0;
if (root == NULL) {
/* ERROR */
@@ -1683,6 +1684,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
if (tmp && !strcmp(tmp, "sdl")) {
virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2": "xen");
virBufferAdd(&buf, " <graphics type='sdl'/>\n", 27);
+ found_graphics = 1;
} else if (tmp && !strcmp(tmp, "vnc")) {
int port = xenStoreDomainGetVNCPort(conn, domid);
const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten");
@@ -1700,6 +1702,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
virBufferAdd(&buf, "/>\n", 3);
+ found_graphics = 1;
}
}
}
@@ -1751,8 +1754,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
}
/* Graphics device (HVM <= 3.0.4, or PV <= 3.0.3) vnc config */
- if ((hvm && xendConfigVersion < 4) ||
- (!hvm && xendConfigVersion < 3)) {
+ if (!found_graphics) {
tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux");
if (tmp != NULL) {
if (tmp[0] == '1') {
@@ -1780,6 +1782,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
if (keymap)
virBufferVSprintf(&buf, " keymap='%s'", keymap);
virBufferAdd(&buf, "/>\n", 3);
+ found_graphics = 1;
}
}
@@ -1789,6 +1792,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
if (tmp[0] == '1') {
virBufferVSprintf(&buf, " <input type='mouse' bus='%s'/>\n", hvm ? "ps2" : "xen");
virBufferAdd(&buf, " <graphics type='sdl'/>\n", 27 );
+ found_graphics = 1;
}
}
}
16 years, 9 months
[Libvir] [PATCH] Pull vc-list-files from gnulib, and update.
by Jim Meyering
Now that I've added the vc-list-files script to gnulib,
this patch makes libvirt's bootstrap pull it from there.
Changes from the previous version of the script:
I reintroduced support for mercurial (only lightly tested),
and rearranged the directory-existence tests so git is first.
Here's the full patch, including a renaming in vasnprintf.c:
----------------
Pull vc-list-files from gnulib, and update.
* bootstrap (gnulib_tool): Add the vc-list-files module.
---
bootstrap | 3 ++-
build-aux/vc-list-files | 19 +++++++++++++------
gnulib/lib/Makefile.am | 9 ++++++++-
gnulib/lib/vasnprintf.c | 18 ++++++++++--------
gnulib/m4/gnulib-cache.m4 | 4 ++--
gnulib/m4/gnulib-comp.m4 | 1 +
6 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/bootstrap b/bootstrap
index 751b244..1627086 100755
--- a/bootstrap
+++ b/bootstrap
@@ -77,7 +77,8 @@ $gnulib_tool \
--tests-base=gnulib/tests \
--import physmem getaddrinfo \
sys_stat vasprintf strndup \
- strsep poll gettext getpass
+ strsep poll gettext getpass \
+ vc-list-files
rm -f \
.gitignore \
diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files
index 72a6f54..1e158bb 100755
--- a/build-aux/vc-list-files
+++ b/build-aux/vc-list-files
@@ -1,7 +1,7 @@
#!/bin/sh
-# List the specified version-controlled files.
+# List version-controlled file names.
-# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2006-2008 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,7 +18,8 @@
# List the specified version-controlled files.
-# With no argument, list them all.
+# With no argument, list them all. With a single DIRECTORY argument,
+# list the version-controlled files in that directory.
# This script must be run solely from the top of a $srcdir build directory.
# If there's an argument, it must be a single, "."-relative directory name.
@@ -28,12 +29,17 @@ dir=
case $# in
0) ;;
1) dir=$1 ;;
- *) echo "$0: too many arguments" 1>&2; exit 1 ;;
+ *) echo "$0: too many arguments" 1>&2
+ echo "Usage: $0 [DIR]" 1>&2; exit 1;;
esac
test "x$dir" = x && dir=.
-if test -d CVS; then
+if test -d .git; then
+ exec git ls-files "$dir"
+elif test -d .hg; then
+ exec hg locate "$dir/*"
+elif test -d CVS; then
if test -x build-aux/cvsu; then
build-aux/cvsu --find --types=AFGM "$dir"
else
@@ -46,5 +52,6 @@ if test -d CVS; then
$(find ${*-*} -name Entries -print) /dev/null;
fi
else
- git-ls-files "$dir"
+ echo "$0: Failed to determine type of version control used in "`pwd` 1>&2
+ exit 1
fi
diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am
index 64fc398..8f545ca 100644
--- a/gnulib/lib/Makefile.am
+++ b/gnulib/lib/Makefile.am
@@ -9,7 +9,7 @@
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf vc-list-files
AUTOMAKE_OPTIONS = 1.5 gnits
@@ -719,6 +719,13 @@ EXTRA_libgnu_la_SOURCES += asprintf.c vasprintf.c
## end gnulib module vasprintf
+## begin gnulib module vc-list-files
+
+
+EXTRA_DIST += $(top_srcdir)/build-aux/vc-list-files
+
+## end gnulib module vc-list-files
+
## begin gnulib module wchar
BUILT_SOURCES += $(WCHAR_H)
diff --git a/gnulib/lib/vasnprintf.c b/gnulib/lib/vasnprintf.c
index 6c8d5dc..205a9bf 100644
--- a/gnulib/lib/vasnprintf.c
+++ b/gnulib/lib/vasnprintf.c
@@ -1,5 +1,5 @@
/* vsprintf with automatic memory allocation.
- Copyright (C) 1999, 2002-2007 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -95,7 +95,7 @@
#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
# include <math.h>
-# include "isnan.h"
+# include "isnand.h"
#endif
#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL
@@ -106,7 +106,7 @@
#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
# include <math.h>
-# include "isnan.h"
+# include "isnand.h"
# include "printf-frexp.h"
#endif
@@ -236,7 +236,7 @@ decimal_point_char ()
static int
is_infinite_or_zero (double x)
{
- return isnan (x) || x + x == x;
+ return isnand (x) || x + x == x;
}
#endif
@@ -2327,7 +2327,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
# if NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE
double arg = a.arg[dp->arg_index].a.a_double;
- if (isnan (arg))
+ if (isnand (arg))
{
if (dp->conversion == 'A')
{
@@ -2676,7 +2676,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (dp->conversion == 'f' || dp->conversion == 'F')
{
double arg = a.arg[dp->arg_index].a.a_double;
- if (!(isnan (arg) || arg + arg == arg))
+ if (!(isnand (arg) || arg + arg == arg))
{
/* arg is finite and nonzero. */
int exponent = floorlog10 (arg < 0 ? -arg : arg);
@@ -3080,7 +3080,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
{
double arg = a.arg[dp->arg_index].a.a_double;
- if (isnan (arg))
+ if (isnand (arg))
{
if (dp->conversion >= 'A' && dp->conversion <= 'Z')
{
@@ -4327,7 +4327,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (prec_ourselves)
{
/* Handle the precision. */
- TCHAR_T *prec_ptr =
+ TCHAR_T *prec_ptr =
# if USE_SNPRINTF
(TCHAR_T *) (result + length);
# else
@@ -4654,6 +4654,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
not have this limitation. */
return result;
+#if USE_SNPRINTF
overflow:
if (!(result == resultbuf || result == NULL))
free (result);
@@ -4662,6 +4663,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
CLEANUP ();
errno = EOVERFLOW;
return NULL;
+#endif
out_of_memory:
if (!(result == resultbuf || result == NULL))
diff --git a/gnulib/m4/gnulib-cache.m4 b/gnulib/m4/gnulib-cache.m4
index d55e07a..357f170 100644
--- a/gnulib/m4/gnulib-cache.m4
+++ b/gnulib/m4/gnulib-cache.m4
@@ -15,11 +15,11 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf
+# gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf vc-list-files
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([])
-gl_MODULES([getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf])
+gl_MODULES([getaddrinfo getpass gettext physmem poll strndup strsep sys_stat vasprintf vc-list-files])
gl_AVOID([])
gl_SOURCE_BASE([gnulib/lib])
gl_M4_BASE([gnulib/m4])
diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4
index 1b91a1e..8896a38 100644
--- a/gnulib/m4/gnulib-comp.m4
+++ b/gnulib/m4/gnulib-comp.m4
@@ -225,6 +225,7 @@ AC_DEFUN([gltests_LIBSOURCES], [
AC_DEFUN([gl_FILE_LIST], [
build-aux/config.rpath
build-aux/link-warning.h
+ build-aux/vc-list-files
lib/alloca.in.h
lib/asnprintf.c
lib/asprintf.c
--
1.5.4.rc5.1.g0fa73
16 years, 9 months
[Libvir] avoid used-uninitialized errors in test driver
by Jim Meyering
Here's another distracting and easily avoided error:
$ valgrind --leak-check=full ./virsh --connect test://$PWD/../docs/testnode.xml list
==13150== Conditional jump or move depends on uninitialised value(s)
==13150== at 0x4177DE: testLoadDomain (test.c:324)
==13150== by 0x417BA4: testLoadDomainFromFile (test.c:401)
==13150== by 0x418E52: testOpenFromFile (test.c:797)
==13150== by 0x4192C9: testOpen (test.c:913)
==13150== by 0x40FA20: do_open (libvirt.c:572)
==13150== by 0x40FDE4: virConnectOpenAuth (libvirt.c:681)
==13150== by 0x40D5B1: vshInit (virsh.c:4464)
==13150== by 0x40E67C: main (virsh.c:4985)
==13150==
==13150== Conditional jump or move depends on uninitialised value(s)
==13150== at 0x417F0D: testLoadNetwork (test.c:486)
==13150== by 0x4183AA: testLoadNetworkFromFile (test.c:577)
==13150== by 0x418F81: testOpenFromFile (test.c:822)
==13150== by 0x4192C9: testOpen (test.c:913)
==13150== by 0x40FA20: do_open (libvirt.c:572)
==13150== by 0x40FDE4: virConnectOpenAuth (libvirt.c:681)
==13150== by 0x40D5B1: vshInit (virsh.c:4464)
==13150== by 0x40E67C: main (virsh.c:4985)
==13150==
==13150== Conditional jump or move depends on uninitialised value(s)
==13150== at 0x41955B: testNumOfDomains (test.c:1020)
==13150== by 0x4104B9: virConnectNumOfDomains (libvirt.c:940)
==13150== by 0x405363: cmdList (virsh.c:557)
==13150== by 0x40C5F9: vshCommandRun (virsh.c:4032)
==13150== by 0x40E6AF: main (virsh.c:4991)
Id Name State
----------------------------------
1 fv0 running
2 fc4 running
This patch fixes it:
* src/test.c (testOpenFromFile): avoid used-uninitialized errors in test driver
---
src/test.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/test.c b/src/test.c
index 85170d9..fe5da41 100644
--- a/src/test.c
+++ b/src/test.c
@@ -672,7 +672,7 @@ static int testOpenFromFile(virConnectPtr conn,
xmlNodePtr *domains, *networks = NULL;
xmlXPathContextPtr ctxt = NULL;
virNodeInfoPtr nodeInfo;
- testConnPtr privconn = malloc(sizeof(*privconn));
+ testConnPtr privconn = calloc(1, sizeof(*privconn));
if (!privconn) {
testError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "testConn");
return VIR_DRV_OPEN_ERROR;
--
1.5.4.rc5.1.g0fa73
16 years, 9 months
[Libvir] libvirt.c: avoid a double-free upon do_open failure
by Jim Meyering
With a contrived example using more than 20 (the max permitted by
the testing framework) domains, I got a double-free error:
==4821== Invalid free() / delete / delete[]
==4821== at 0x4A0560B: free (vg_replace_malloc.c:233)
==4821== by 0x4167F1: virReleaseConnect (hash.c:717)
==4821== by 0x4168E7: virUnrefConnect (hash.c:746)
==4821== by 0x40FCEB: do_open (libvirt.c:621)
==4821== by 0x40FDF1: virConnectOpenAuth (libvirt.c:682)
==4821== by 0x40D5B1: vshInit (virsh.c:4464)
==4821== by 0x40E67C: main (virsh.c:4985)
==4821== Address 0x4C3BA68 is 0 bytes inside a block of size 60 free'd
==4821== at 0x4A0560B: free (vg_replace_malloc.c:233)
==4821== by 0x40FCB3: do_open (libvirt.c:618)
==4821== by 0x40FDF1: virConnectOpenAuth (libvirt.c:682)
==4821== by 0x40D5B1: vshInit (virsh.c:4464)
==4821== by 0x40E67C: main (virsh.c:4985)
error: failed to connect to the hypervisor
...
here's one way to fix it:
diff --git a/src/libvirt.c b/src/libvirt.c
index defadc1..c19565f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -615,7 +615,6 @@ do_open (const char *name,
return ret;
failed:
- free (ret->name);
if (ret->driver) ret->driver->close (ret);
if (uri) xmlFreeURI(uri);
virUnrefConnect(ret);
At first, rather than removing the offending
free, I inserted this line just after it:
ret->name = NULL;
which avoids leaking ->name even if some driver-specific close function
fails to clean up properly. But IMHO if such a function doesn't clean
up properly then *it* should be fixed, not all callers.
16 years, 9 months
[Libvir] [PATCH] test.c: Avoid segfault upon malloc failure, and plug a leak.
by Jim Meyering
Testing exposed a tiny leak:
$ valgrind --leak-check=full ./virsh --connect \
test://$PWD/../docs/testnode.xml save fc4 /dev/null
...
==11077== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
==11077== malloc/free: in use at exit: 24,677 bytes in 367 blocks.
==11077== malloc/free: 23,521 allocs, 23,154 frees, 3,424,316 bytes allocated.
==11077== For counts of detected errors, rerun with: -v
==11077== searching for pointers to 367 not-freed blocks.
==11077== checked 538,400 bytes.
==11077==
==11077== 4,000 bytes in 1 blocks are definitely lost in loss record 26 of 27
==11077== at 0x4A059F6: malloc (vg_replace_malloc.c:149)
==11077== by 0x41C53A: virBufferNew (buf.c:132)
==11077== by 0x41AB22: testDomainDumpXML (test.c:1473)
==11077== by 0x41A1B5: testDomainSave (test.c:1284)
==11077== by 0x41120B: virDomainSave (libvirt.c:1342)
==11077== by 0x406169: cmdSave (virsh.c:1057)
==11077== by 0x40C5F9: vshCommandRun (virsh.c:4032)
==11077== by 0x40E6AF: main (virsh.c:4991)
==11077==
==11077== LEAK SUMMARY:
==11077== definitely lost: 4,000 bytes in 1 blocks.
==11077== possibly lost: 0 bytes in 0 blocks.
==11077== still reachable: 20,677 bytes in 366 blocks.
==11077== suppressed: 0 bytes in 0 blocks.
Here's the fix:
test.c: Avoid segfault upon malloc failure, and plug a leak.
* src/test.c (testDomainSave):
Time permitting, I will add tests to exercise as many of the
commands as possible.
---
src/test.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/test.c b/src/test.c
index 35e41a3..85170d9 100644
--- a/src/test.c
+++ b/src/test.c
@@ -1,7 +1,7 @@
/*
* test.c: A "mock" hypervisor for use by application unit tests
*
- * Copyright (C) 2006-2007 Red Hat, Inc.
+ * Copyright (C) 2006-2008 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -1281,6 +1281,11 @@ static int testDomainSave(virDomainPtr domain,
GET_DOMAIN(domain, -1);
xml = testDomainDumpXML(domain, 0);
+ if (xml == NULL) {
+ testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
+ "cannot allocate space for metadata");
+ return (-1);
+ }
if ((fd = open(path, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
@@ -1303,9 +1308,11 @@ static int testDomainSave(virDomainPtr domain,
if (write(fd, xml, len) != len) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write metadata");
+ free(xml);
close(fd);
return (-1);
}
+ free(xml);
if (close(fd) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot save domain data");
--
1.5.4.rc5.1.g0fa73
16 years, 9 months