Added support for i18n translation with gettext

This commit is contained in:
Daniel P. Berrange 2006-09-21 15:24:37 +00:00
parent 870bf1cdbd
commit e8e5844089
32 changed files with 3417 additions and 440 deletions

View File

@ -1,3 +1,13 @@
Thu Sep 21 10:19:02 EDT 2006 Daniel Berrange <berrange@redhat.com>
* Makefile.am: Added po directory
* autogen.sh: Call autopoint to install the gettext infrastructure
* src/*.c, proxy/*.c: Pass all strings through gettext for translation.
Set up the text domains in libvirt, proxy & virsh at startup.
* libvirt.spec.in: Include compiled .po files in distro
* tests/virshdata/*.txt: Tweak expected data to take account of
some text changes.
Thu Sep 21 10:19:02 EDT 2006 Daniel Berrange <berrange@redhat.com> Thu Sep 21 10:19:02 EDT 2006 Daniel Berrange <berrange@redhat.com>
* docs/*.html: re-generated documentation to pull in latest * docs/*.html: re-generated documentation to pull in latest

View File

@ -1,6 +1,8 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
SUBDIRS = src include docs @PYTHON_SUBDIR@ tests proxy SUBDIRS = src include docs @PYTHON_SUBDIR@ tests proxy po
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = libvirt.spec.in libvirt.spec COPYING.LIB \ EXTRA_DIST = libvirt.spec.in libvirt.spec COPYING.LIB \
libvirt.pc.in libvirt.pc TODO AUTHORS ChangeLog \ libvirt.pc.in libvirt.pc TODO AUTHORS ChangeLog \

View File

@ -8,6 +8,14 @@ THEDIR=`pwd`
cd $srcdir cd $srcdir
DIE=0 DIE=0
(autopoint --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autopoint installed to compile libvirt."
echo "Download the appropriate package for your distribution,"
echo "or see http://www.gnu.org/software/gettext"
DIE=1
}
(autoconf --version) < /dev/null > /dev/null 2>&1 || { (autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo echo
echo "You must have autoconf installed to compile libvirt." echo "You must have autoconf installed to compile libvirt."
@ -46,6 +54,8 @@ if test -z "$*"; then
echo "to pass any to it, please specify them on the $0 command line." echo "to pass any to it, please specify them on the $0 command line."
fi fi
autopoint --force
#rm -rf m4
libtoolize --copy --force libtoolize --copy --force
aclocal $ACLOCAL_FLAGS aclocal $ACLOCAL_FLAGS
automake --add-missing automake --add-missing

View File

@ -1,8 +1,30 @@
/* config.h.in. Generated from configure.in by autoheader. */ /* config.h.in. Generated from configure.in by autoheader. */
/* Define to 1 if translation of program messages to the user's native
language is requested. */
#undef ENABLE_NLS
/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
CoreFoundation framework. */
#undef HAVE_CFLOCALECOPYCURRENT
/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
the CoreFoundation framework. */
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
/* Define if the GNU dcgettext() function is already present or preinstalled.
*/
#undef HAVE_DCGETTEXT
/* Define to 1 if you have the <dlfcn.h> header file. */ /* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H #undef HAVE_DLFCN_H
/* Define if the GNU gettext() function is already present or preinstalled. */
#undef HAVE_GETTEXT
/* Define if you have the iconv() function. */
#undef HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #undef HAVE_INTTYPES_H

View File

@ -246,6 +246,10 @@ AC_SUBST(PYTHON_VERSION)
AC_SUBST(PYTHON_INCLUDES) AC_SUBST(PYTHON_INCLUDES)
AC_SUBST(PYTHON_SITE_PACKAGES) AC_SUBST(PYTHON_SITE_PACKAGES)
AM_GNU_GETTEXT_VERSION([0.14.1])
AM_GNU_GETTEXT([external])
ALL_LINGUAS=en_GB
# very annoying # very annoying
rm -f COPYING rm -f COPYING
cp COPYING.LIB COPYING cp COPYING.LIB COPYING
@ -254,6 +258,7 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
docs/examples/Makefile docs/devhelp/Makefile \ docs/examples/Makefile docs/devhelp/Makefile \
docs/examples/python/Makefile \ docs/examples/python/Makefile \
libvirt.pc libvirt.spec \ libvirt.pc libvirt.spec \
po/Makefile.in \
include/libvirt/Makefile include/libvirt/libvirt.h \ include/libvirt/Makefile include/libvirt/libvirt.h \
python/Makefile python/tests/Makefile \ python/Makefile python/tests/Makefile \
tests/Makefile proxy/Makefile \ tests/Makefile proxy/Makefile \

View File

@ -1,3 +1,5 @@
# -*- rpm-spec -*-
Summary: Library providing an API to use the Xen virtualization Summary: Library providing an API to use the Xen virtualization
Name: libvirt Name: libvirt
Version: @VERSION@ Version: @VERSION@
@ -6,7 +8,7 @@ License: LGPL
Group: Development/Libraries Group: Development/Libraries
Source: libvirt-%{version}.tar.gz Source: libvirt-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-root BuildRoot: %{_tmppath}/%{name}-%{version}-root
URL: http://libvir.org/ URL: http://libvirt.org/
BuildRequires: python python-devel BuildRequires: python python-devel
Requires: xen Requires: xen
Requires: libxml2 Requires: libxml2
@ -16,6 +18,7 @@ BuildRequires: xen-devel
BuildRequires: libxml2-devel BuildRequires: libxml2-devel
BuildRequires: readline-devel BuildRequires: readline-devel
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
BuildRequires: gettext
Obsoletes: libvir Obsoletes: libvir
ExclusiveArch: i386 x86_64 ia64 ExclusiveArch: i386 x86_64 ia64
@ -61,6 +64,7 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a rm -f $RPM_BUILD_ROOT%{_libdir}/*.a
rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.la rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.a rm -f $RPM_BUILD_ROOT%{_libdir}/python*/site-packages/*.a
%find_lang %{name}
%clean %clean
rm -fr %{buildroot} rm -fr %{buildroot}
@ -71,7 +75,7 @@ rm -fr %{buildroot}
%postun %postun
/sbin/ldconfig /sbin/ldconfig
%files %files -f %{name}.lang
%defattr(-, root, root) %defattr(-, root, root)
%doc AUTHORS ChangeLog NEWS README COPYING.LIB TODO %doc AUTHORS ChangeLog NEWS README COPYING.LIB TODO

41
po/Makevars Normal file
View File

@ -0,0 +1,41 @@
# Makefile variables for PO directory in any package using GNU gettext.
# Usually the message domain is the same as the package name.
DOMAIN = $(PACKAGE)
# These two variables depend on the location of this directory.
subdir = po
top_builddir = ..
# These options get passed to xgettext.
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
# package. (Note that the msgstr strings, extracted from the package's
# sources, belong to the copyright holder of the package.) Translators are
# expected to transfer the copyright for their translations to this person
# or entity, or to disclaim their copyright. The empty string stands for
# the public domain; in this case the translators are expected to disclaim
# their copyright.
COPYRIGHT_HOLDER = Free Software Foundation, Inc.
# This is the email address or URL to which the translators shall report
# bugs in the untranslated strings:
# - Strings which are not entire sentences, see the maintainer guidelines
# in the GNU gettext documentation, section 'Preparing Strings'.
# - Strings which use unclear terms or require additional context to be
# understood.
# - Strings which make invalid assumptions about notation of date, time or
# money.
# - Pluralisation problems.
# - Incorrect English spelling.
# - Incorrect formatting.
# It can be your email address, or a mailing list address where translators
# can write to without being subscribed, or the URL of a web page through
# which the translators can contact you.
MSGID_BUGS_ADDRESS =
# This is the list of locale categories, beyond LC_MESSAGES, for which the
# message catalogs shall be used. It is usually empty.
EXTRA_LOCALE_CATEGORIES =

13
po/POTFILES.in Normal file
View File

@ -0,0 +1,13 @@
src/libvirt.c
src/virterror.c
src/xmlrpc.c
src/hash.c
src/test.c
src/xml.c
src/sexpr.c
src/xend_internal.c
src/virsh.c
src/conf.c
src/xs_internal.c
src/proxy_internal.c
src/xen_internal.c

1413
po/en_GB.po Normal file

File diff suppressed because it is too large Load Diff

1413
po/libvirt.pot Normal file

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,8 @@
INCLUDES = -I$(top_builddir)/include -I@top_srcdir@/include \ INCLUDES = -I$(top_builddir)/include -I@top_srcdir@/include \
-I@top_srcdir@/proxy -I@top_srcdir@/src @LIBXML_CFLAGS@ \ -I@top_srcdir@/proxy -I@top_srcdir@/src @LIBXML_CFLAGS@ \
-DPROXY -DPROXY -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
-DGETTEXT_PACKAGE=\"$(PACKAGE)\"
libexec_PROGRAMS = libvirt_proxy libexec_PROGRAMS = libvirt_proxy

View File

@ -715,6 +715,19 @@ usage(const char *progname) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
int i; int i;
if (!setlocale(LC_ALL, "")) {
perror("setlocale");
return -1;
}
if (!bindtextdomain(GETTEXT_PACKAGE, LOCALEBASEDIR)) {
perror("bindtextdomain");
return -1;
}
if (!textdomain(GETTEXT_PACKAGE)) {
perror("textdomain");
return -1;
}
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-v")) { if (!strcmp(argv[i], "-v")) {
debug++; debug++;
@ -725,7 +738,8 @@ int main(int argc, char **argv) {
exit(1); exit(1);
} }
} }
if (geteuid() != 0) { if (geteuid() != 0) {
fprintf(stderr, "%s must be run as root or suid\n", argv[0]); fprintf(stderr, "%s must be run as root or suid\n", argv[0]);
/* exit(1); */ /* exit(1); */

View File

@ -1,7 +1,8 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
INCLUDES = -I$(top_builddir)/include -I@top_srcdir@/include @LIBXML_CFLAGS@ \ INCLUDES = -I$(top_builddir)/include -I@top_srcdir@/include @LIBXML_CFLAGS@ \
-DBINDIR=\""$(libexecdir)"\" -DBINDIR=\""$(libexecdir)"\" -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
-DGETTEXT_PACKAGE=\"$(PACKAGE)\"
DEPS = libvirt.la DEPS = libvirt.la
LDADDS = @STATIC_BINARIES@ libvirt.la LDADDS = @STATIC_BINARIES@ libvirt.la
VIRSH_LIBS = @VIRSH_LIBS@ VIRSH_LIBS = @VIRSH_LIBS@

View File

@ -159,7 +159,7 @@ virConfCreate(const char *filename)
ret = (virConfPtr) malloc(sizeof(virConf)); ret = (virConfPtr) malloc(sizeof(virConf));
if (ret == NULL) { if (ret == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, "Allocating configuration", 0); virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"), 0);
return(NULL); return(NULL);
} }
memset(ret, 0, sizeof(virConf)); memset(ret, 0, sizeof(virConf));
@ -193,7 +193,7 @@ virConfAddEntry(virConfPtr conf, char *name, virConfValuePtr value, char *comm)
ret = (virConfEntryPtr) malloc(sizeof(virConfEntry)); ret = (virConfEntryPtr) malloc(sizeof(virConfEntry));
if (ret == NULL) { if (ret == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, "Allocating configuration", 0); virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"), 0);
return(NULL); return(NULL);
} }
memset(ret, 0, sizeof(virConfEntry)); memset(ret, 0, sizeof(virConfEntry));
@ -328,7 +328,7 @@ virConfParseLong(virConfParserCtxtPtr ctxt, long *val)
NEXT; NEXT;
} }
if ((ctxt->cur >= ctxt->end) || (!IS_DIGIT(CUR))) { if ((ctxt->cur >= ctxt->end) || (!IS_DIGIT(CUR))) {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, "unterminated number", virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated number"),
ctxt->line); ctxt->line);
return(-1); return(-1);
} }
@ -360,7 +360,7 @@ virConfParseString(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (CUR != '\'') && (!IS_EOL(CUR))) while ((ctxt->cur < ctxt->end) && (CUR != '\'') && (!IS_EOL(CUR)))
NEXT; NEXT;
if (CUR != '\'') { if (CUR != '\'') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, "unterminated string", virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated string"),
ctxt->line); ctxt->line);
return(NULL); return(NULL);
} }
@ -377,7 +377,7 @@ virConfParseString(virConfParserCtxtPtr ctxt)
} }
if ((ctxt->cur[0] != '"') || (ctxt->cur[1] != '"') || if ((ctxt->cur[0] != '"') || (ctxt->cur[1] != '"') ||
(ctxt->cur[2] != '"')) { (ctxt->cur[2] != '"')) {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, "unterminated string", virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated string"),
ctxt->line); ctxt->line);
return(NULL); return(NULL);
} }
@ -389,7 +389,7 @@ virConfParseString(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (CUR != '"') && (!IS_EOL(CUR))) while ((ctxt->cur < ctxt->end) && (CUR != '"') && (!IS_EOL(CUR)))
NEXT; NEXT;
if (CUR != '"') { if (CUR != '"') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, "unterminated string", virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("unterminated string"),
ctxt->line); ctxt->line);
return(NULL); return(NULL);
} }
@ -417,7 +417,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
SKIP_SPACES; SKIP_SPACES;
if (ctxt->cur >= ctxt->end) { if (ctxt->cur >= ctxt->end) {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, "expecting a value", virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting a value"),
ctxt->line); ctxt->line);
return(NULL); return(NULL);
} }
@ -437,7 +437,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (CUR != ']')) { while ((ctxt->cur < ctxt->end) && (CUR != ']')) {
if (CUR != ',') { if (CUR != ',') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, virConfError(NULL, VIR_ERR_CONF_SYNTAX,
"expecting a separator in list", ctxt->line); _("expecting a separator in list"), ctxt->line);
virConfFreeList(lst); virConfFreeList(lst);
return(NULL); return(NULL);
} }
@ -460,7 +460,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
NEXT; NEXT;
} else { } else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, virConfError(NULL, VIR_ERR_CONF_SYNTAX,
"list is not closed with ] ", ctxt->line); _("list is not closed with ] "), ctxt->line);
virConfFreeList(lst); virConfFreeList(lst);
return(NULL); return(NULL);
} }
@ -470,13 +470,13 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
} }
type = VIR_CONF_LONG; type = VIR_CONF_LONG;
} else { } else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, "expecting a value", virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting a value"),
ctxt->line); ctxt->line);
return(NULL); return(NULL);
} }
ret = (virConfValuePtr) malloc(sizeof(virConfValue)); ret = (virConfValuePtr) malloc(sizeof(virConfValue));
if (ret == NULL) { if (ret == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, "Allocating configuration", 0); virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"), 0);
if (str != NULL) if (str != NULL)
free(str); free(str);
return(NULL); return(NULL);
@ -508,14 +508,14 @@ virConfParseName(virConfParserCtxtPtr ctxt)
base = ctxt->cur; base = ctxt->cur;
/* TODO: probably need encoding support and UTF-8 parsing ! */ /* TODO: probably need encoding support and UTF-8 parsing ! */
if (!IS_CHAR(CUR)) { if (!IS_CHAR(CUR)) {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, "expecting a name", ctxt->line); virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting a name"), ctxt->line);
return(NULL); return(NULL);
} }
while ((ctxt->cur < ctxt->end) && ((IS_CHAR(CUR)) || (IS_DIGIT(CUR)) || (CUR == '_'))) while ((ctxt->cur < ctxt->end) && ((IS_CHAR(CUR)) || (IS_DIGIT(CUR)) || (CUR == '_')))
NEXT; NEXT;
ret = strndup(base, ctxt->cur - base); ret = strndup(base, ctxt->cur - base);
if (ret == NULL) { if (ret == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, "Allocating configuration", virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"),
ctxt->line); ctxt->line);
return(NULL); return(NULL);
} }
@ -543,7 +543,7 @@ virConfParseComment(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT; while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base); comm = strndup(base, ctxt->cur - base);
if (comm == NULL) { if (comm == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, "Allocating configuration", virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"),
ctxt->line); ctxt->line);
return(-1); return(-1);
} }
@ -571,7 +571,7 @@ virConfParseSeparator(virConfParserCtxtPtr ctxt)
NEXT; NEXT;
SKIP_BLANKS; SKIP_BLANKS;
} else { } else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, "expecting a separator", virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting a separator"),
ctxt->line); ctxt->line);
return(-1); return(-1);
} }
@ -603,7 +603,7 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
return(-1); return(-1);
SKIP_SPACES; SKIP_SPACES;
if (CUR != '=') { if (CUR != '=') {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, "expecting an assignment", virConfError(NULL, VIR_ERR_CONF_SYNTAX, _("expecting an assignment"),
ctxt->line); ctxt->line);
return(-1); return(-1);
} }
@ -621,7 +621,7 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT; while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
comm = strndup(base, ctxt->cur - base); comm = strndup(base, ctxt->cur - base);
if (comm == NULL) { if (comm == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, "Allocating configuration", virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"),
ctxt->line); ctxt->line);
free(name); free(name);
virConfFreeValue(value); virConfFreeValue(value);
@ -816,7 +816,7 @@ virConfWriteFile(const char *filename, virConfPtr conf)
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR ); fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR );
if (fd < 0) { if (fd < 0) {
virConfError(NULL, VIR_ERR_WRITE_FAILED, "failed to open file", 0); virConfError(NULL, VIR_ERR_WRITE_FAILED, _("failed to open file"), 0);
ret = -1; ret = -1;
goto error; goto error;
} }
@ -824,7 +824,7 @@ virConfWriteFile(const char *filename, virConfPtr conf)
ret = write(fd, buf->content, buf->use); ret = write(fd, buf->content, buf->use);
close(fd); close(fd);
if (ret != (int) buf->use) { if (ret != (int) buf->use) {
virConfError(NULL, VIR_ERR_WRITE_FAILED, "failed to save content", 0); virConfError(NULL, VIR_ERR_WRITE_FAILED, _("failed to save content"), 0);
ret = -1; ret = -1;
goto error; goto error;
} }

View File

@ -528,7 +528,7 @@ virGetConnect(void) {
ret = (virConnectPtr) malloc(sizeof(virConnect)); ret = (virConnectPtr) malloc(sizeof(virConnect));
if (ret == NULL) { if (ret == NULL) {
virHashError(NULL, VIR_ERR_NO_MEMORY, "Allocating connection"); virHashError(NULL, VIR_ERR_NO_MEMORY, _("allocating connection"));
goto failed; goto failed;
} }
memset(ret, 0, sizeof(virConnect)); memset(ret, 0, sizeof(virConnect));
@ -625,13 +625,13 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
*/ */
ret = (virDomainPtr) malloc(sizeof(virDomain)); ret = (virDomainPtr) malloc(sizeof(virDomain));
if (ret == NULL) { if (ret == NULL) {
virHashError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); virHashError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
goto error; goto error;
} }
memset(ret, 0, sizeof(virDomain)); memset(ret, 0, sizeof(virDomain));
ret->name = strdup(name); ret->name = strdup(name);
if (ret->name == NULL) { if (ret->name == NULL) {
virHashError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); virHashError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
goto error; goto error;
} }
ret->magic = VIR_DOMAIN_MAGIC; ret->magic = VIR_DOMAIN_MAGIC;
@ -642,7 +642,7 @@ virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid) {
if (virHashAddEntry(conn->domains, name, ret) < 0) { if (virHashAddEntry(conn->domains, name, ret) < 0) {
virHashError(conn, VIR_ERR_INTERNAL_ERROR, virHashError(conn, VIR_ERR_INTERNAL_ERROR,
"Failed to add domain to connectio hash table"); _("failed to add domain to connection hash table"));
goto error; goto error;
} }
conn->uses++; conn->uses++;
@ -694,7 +694,7 @@ virFreeDomain(virConnectPtr conn, virDomainPtr domain) {
if (virHashRemoveEntry(conn->domains, domain->name, NULL) < 0) { if (virHashRemoveEntry(conn->domains, domain->name, NULL) < 0) {
virHashError(conn, VIR_ERR_INTERNAL_ERROR, virHashError(conn, VIR_ERR_INTERNAL_ERROR,
"domain missing from connection hash table"); _("domain missing from connection hash table"));
goto done; goto done;
} }
domain->magic = -1; domain->magic = -1;

View File

@ -16,11 +16,16 @@
#include "libvirt/libvirt.h" #include "libvirt/libvirt.h"
#include "libvirt/virterror.h" #include "libvirt/virterror.h"
#include "driver.h" #include "driver.h"
#include <libintl.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define _(str) dgettext(GETTEXT_PACKAGE, (str))
#define _N(str) dgettext(GETTEXT_PACKAGE, (str))
#define gettext_noop(str) (str)
/** /**
* ATTRIBUTE_UNUSED: * ATTRIBUTE_UNUSED:
* *

View File

@ -60,10 +60,13 @@ virInitialize(void)
return(0); return(0);
initialized = 1; initialized = 1;
if (!bindtextdomain(GETTEXT_PACKAGE, LOCALEBASEDIR))
return (-1);
/* /*
* should not be needed but... * should not be needed but...
*/ */
for (i = 0;i < MAX_DRIVERS;i++) for (i = 0;i < MAX_DRIVERS;i++)
virDriverTab[i] = NULL; virDriverTab[i] = NULL;
/* /*
@ -140,7 +143,8 @@ virRegisterDriver(virDriverPtr driver)
int i; int i;
if (!initialized) if (!initialized)
virInitialize(); if (virInitialize() < 0)
return -1;
if (driver == NULL) { if (driver == NULL) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__); virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
@ -182,7 +186,8 @@ virGetVersion(unsigned long *libVer, const char *type,
int i; int i;
if (!initialized) if (!initialized)
virInitialize(); if (virInitialize() < 0)
return -1;
if (libVer == NULL) if (libVer == NULL)
return (-1); return (-1);
@ -223,7 +228,8 @@ virConnectOpen(const char *name)
virConnectPtr ret = NULL; virConnectPtr ret = NULL;
if (!initialized) if (!initialized)
virInitialize(); if (virInitialize() < 0)
return NULL;
if (name == NULL) { if (name == NULL) {
name = "Xen"; name = "Xen";
@ -234,7 +240,7 @@ virConnectOpen(const char *name)
ret = virGetConnect(); ret = virGetConnect();
if (ret == NULL) { if (ret == NULL) {
virLibConnError(NULL, VIR_ERR_NO_MEMORY, "Allocating connection"); virLibConnError(NULL, VIR_ERR_NO_MEMORY, _("allocating connection"));
goto failed; goto failed;
} }
@ -290,14 +296,15 @@ virConnectOpenReadOnly(const char *name)
virConnectPtr ret = NULL; virConnectPtr ret = NULL;
if (!initialized) if (!initialized)
virInitialize(); if (virInitialize() < 0)
return NULL;
if (name == NULL) if (name == NULL)
name = "Xen"; name = "Xen";
ret = virGetConnect(); ret = virGetConnect();
if (ret == NULL) { if (ret == NULL) {
virLibConnError(NULL, VIR_ERR_NO_MEMORY, "Allocating connection"); virLibConnError(NULL, VIR_ERR_NO_MEMORY, _("allocating connection"));
goto failed; goto failed;
} }
@ -313,7 +320,7 @@ virConnectOpenReadOnly(const char *name)
if (ret->nb_drivers == 0) { if (ret->nb_drivers == 0) {
if (name == NULL) if (name == NULL)
virLibConnError(NULL, VIR_ERR_NO_CONNECT, virLibConnError(NULL, VIR_ERR_NO_CONNECT,
"could not connect to Xen Daemon nor Xen Store"); _("Xen Daemon or Xen Store"));
else else
/* we failed to find an adequate driver */ /* we failed to find an adequate driver */
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name); virLibConnError(NULL, VIR_ERR_NO_SUPPORT, name);

View File

@ -190,7 +190,7 @@ virProxyForkServer(void)
setsid(); setsid();
if (fork() == 0) { if (fork() == 0) {
execl(proxyPath, proxyPath, NULL); execl(proxyPath, proxyPath, NULL);
fprintf(stderr, "failed to exec %s\n", proxyPath); fprintf(stderr, _("failed to exec %s\n"), proxyPath);
} }
/* /*
* calling exit() generate troubles for termination handlers * calling exit() generate troubles for termination handlers
@ -284,7 +284,7 @@ virProxyCloseClientSocket(int fd) {
ret = close(fd); ret = close(fd);
if (ret != 0) if (ret != 0)
fprintf(stderr, "Failed to close socket %d\n", fd); fprintf(stderr, _("Failed to close socket %d\n"), fd);
else if (debug > 0) else if (debug > 0)
fprintf(stderr, "Closed socket %d\n", fd); fprintf(stderr, "Closed socket %d\n", fd);
return(ret); return(ret);
@ -317,7 +317,7 @@ retry:
goto retry; goto retry;
} }
if (!quiet) if (!quiet)
fprintf(stderr, "Failed to read socket %d\n", fd); fprintf(stderr, _("Failed to read socket %d\n"), fd);
return(-1); return(-1);
} }
@ -351,7 +351,7 @@ retry:
fd, len); fd, len);
goto retry; goto retry;
} }
fprintf(stderr, "Failed to write to socket %d\n", fd); fprintf(stderr, _("Failed to write to socket %d\n"), fd);
return(-1); return(-1);
} }
if (debug) if (debug)
@ -413,7 +413,7 @@ retry:
return(-1); return(-1);
if (ret != sizeof(virProxyPacket)) { if (ret != sizeof(virProxyPacket)) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: got %d bytes of %d\n", _("Communication error with proxy: got %d bytes of %d\n"),
ret, (int) sizeof(virProxyPacket)); ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
@ -421,7 +421,7 @@ retry:
res = request; res = request;
if (res->len != sizeof(virProxyPacket)) { if (res->len != sizeof(virProxyPacket)) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: expected %d bytes got %d\n", _("Communication error with proxy: expected %d bytes got %d\n"),
(int) sizeof(virProxyPacket), res->len); (int) sizeof(virProxyPacket), res->len);
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
@ -434,7 +434,7 @@ retry:
return(-1); return(-1);
if (ret != sizeof(virProxyPacket)) { if (ret != sizeof(virProxyPacket)) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: got %d bytes of %d\n", _("Communication error with proxy: got %d bytes of %d\n"),
ret, (int) sizeof(virProxyPacket)); ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
@ -443,7 +443,7 @@ retry:
if ((res->len < sizeof(virProxyPacket)) || if ((res->len < sizeof(virProxyPacket)) ||
(res->len > sizeof(virProxyFullPacket))) { (res->len > sizeof(virProxyFullPacket))) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: got %d bytes packet\n", _("Communication error with proxy: got %d bytes packet\n"),
res->len); res->len);
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
@ -454,7 +454,7 @@ retry:
res->len - ret, quiet); res->len - ret, quiet);
if (ret != (int) (res->len - sizeof(virProxyPacket))) { if (ret != (int) (res->len - sizeof(virProxyPacket))) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: got %d bytes of %d\n", _("Communication error with proxy: got %d bytes of %d\n"),
ret, (int) sizeof(virProxyPacket)); ret, (int) sizeof(virProxyPacket));
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
@ -467,13 +467,13 @@ retry:
if ((res == NULL) || (res->version != PROXY_PROTO_VERSION) || if ((res == NULL) || (res->version != PROXY_PROTO_VERSION) ||
(res->len < sizeof(virProxyPacket))) { (res->len < sizeof(virProxyPacket))) {
fprintf(stderr, fprintf(stderr,
"Communication error with proxy: malformed packet\n"); _("Communication error with proxy: malformed packet\n"));
xenProxyClose(conn); xenProxyClose(conn);
return(-1); return(-1);
} }
if (res->serial != serial) { if (res->serial != serial) {
TODO /* Asynchronous communication */ TODO /* Asynchronous communication */
fprintf(stderr, "gor asynchronous packet number %d\n", res->serial); fprintf(stderr, _("got asynchronous packet number %d\n"), res->serial);
goto retry; goto retry;
} }
return(0); return(0);
@ -787,7 +787,7 @@ xenProxyLookupByID(virConnectPtr conn, int id)
res = virGetDomain(conn, name, uuid); res = virGetDomain(conn, name, uuid);
if (res == NULL) if (res == NULL)
virProxyError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); virProxyError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
else else
res->handle = id; res->handle = id;
@ -834,7 +834,7 @@ xenProxyLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
res = virGetDomain(conn, name, uuid); res = virGetDomain(conn, name, uuid);
if (res == NULL) if (res == NULL)
virProxyError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); virProxyError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
else else
res->handle = req.data.arg; res->handle = req.data.arg;
@ -885,7 +885,7 @@ xenProxyDomainLookupByName(virConnectPtr conn, const char *name)
res = virGetDomain(conn, name, (const unsigned char *)&req.extra.str[0]); res = virGetDomain(conn, name, (const unsigned char *)&req.extra.str[0]);
if (res == NULL) if (res == NULL)
virProxyError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); virProxyError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
else else
res->handle = req.data.arg; res->handle = req.data.arg;

View File

@ -56,7 +56,7 @@ sexpr_new(void)
ret = (struct sexpr *) malloc(sizeof(*ret)); ret = (struct sexpr *) malloc(sizeof(*ret));
if (ret == NULL) { if (ret == NULL) {
virSexprError(VIR_ERR_NO_MEMORY, "failed to allocate a node"); virSexprError(VIR_ERR_NO_MEMORY, _("failed to allocate a node"));
return (NULL); return (NULL);
} }
ret->kind = SEXPR_NIL; ret->kind = SEXPR_NIL;
@ -349,7 +349,7 @@ _string2sexpr(const char *buffer, size_t * end)
ret->value = strndup(start, ptr - start); ret->value = strndup(start, ptr - start);
if (ret->value == NULL) { if (ret->value == NULL) {
virSexprError(VIR_ERR_NO_MEMORY, virSexprError(VIR_ERR_NO_MEMORY,
"failed to copy a string"); _("failed to copy a string"));
} }
if (*ptr == '\'') if (*ptr == '\'')
@ -364,7 +364,7 @@ _string2sexpr(const char *buffer, size_t * end)
ret->value = strndup(start, ptr - start); ret->value = strndup(start, ptr - start);
if (ret->value == NULL) { if (ret->value == NULL) {
virSexprError(VIR_ERR_NO_MEMORY, virSexprError(VIR_ERR_NO_MEMORY,
"failed to copy a string"); _("failed to copy a string"));
} }
} }

View File

@ -197,26 +197,26 @@ static int testLoadDomain(virConnectPtr conn,
virDomainRestart onCrash = VIR_DOMAIN_RENAME_RESTART; virDomainRestart onCrash = VIR_DOMAIN_RENAME_RESTART;
if (gettimeofday(&tv, NULL) < 0) { if (gettimeofday(&tv, NULL) < 0) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "cannot get timeofday"); testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, _("getting time of day"));
return -1; return -1;
} }
root = xmlDocGetRootElement(xml); root = xmlDocGetRootElement(xml);
if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "domain"))) { if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "domain"))) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed root element"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("domain"));
goto error; goto error;
} }
ctxt = xmlXPathNewContext(xml); ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) { if (ctxt == NULL) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "cannot create xpath context"); testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, _("creating xpath context"));
goto error; goto error;
} }
obj = xmlXPathEval(BAD_CAST "string(/domain/name[1])", ctxt); obj = xmlXPathEval(BAD_CAST "string(/domain/name[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) || if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) { (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "missing name element on domain"); testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, _("domain name"));
goto error; goto error;
} }
name = strdup((const char *)obj->stringval); name = strdup((const char *)obj->stringval);
@ -225,12 +225,12 @@ static int testLoadDomain(virConnectPtr conn,
obj = xmlXPathEval(BAD_CAST "string(/domain/uuid[1])", ctxt); obj = xmlXPathEval(BAD_CAST "string(/domain/uuid[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) || if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) { (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "missing uuid element on domain"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("domain uuid"));
goto error; goto error;
} }
dst_uuid = (char *) &rawuuid[0]; dst_uuid = (char *) &rawuuid[0];
if (!(virParseUUID((char **)&dst_uuid, (const char *)obj->stringval))) { if (!(virParseUUID((char **)&dst_uuid, (const char *)obj->stringval))) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed uuid data in domain"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("domain uuid"));
goto error; goto error;
} }
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
@ -238,12 +238,12 @@ static int testLoadDomain(virConnectPtr conn,
obj = xmlXPathEval(BAD_CAST "string(/domain/memory[1])", ctxt); obj = xmlXPathEval(BAD_CAST "string(/domain/memory[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) || if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) { (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "missing memory element on domain"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("domain memory"));
goto error; goto error;
} }
memory = strtoll((const char*)obj->stringval, &conv, 10); memory = strtoll((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) { if (conv == (const char*)obj->stringval) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed memory value for domain"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("domain memory"));
goto error; goto error;
} }
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
@ -255,7 +255,7 @@ static int testLoadDomain(virConnectPtr conn,
} else { } else {
nrVirtCpu = strtoll((const char*)obj->stringval, &conv, 10); nrVirtCpu = strtoll((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) { if (conv == (const char*)obj->stringval) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed vcpus value for domain"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("domain vcpus"));
goto error; goto error;
} }
} }
@ -266,7 +266,7 @@ static int testLoadDomain(virConnectPtr conn,
if ((obj != NULL) && (obj->type == XPATH_STRING) && if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) { (obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (!(onReboot = testRestartStringToFlag((const char *)obj->stringval))) { if (!(onReboot = testRestartStringToFlag((const char *)obj->stringval))) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed on_reboot value for domain"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("domain reboot behaviour"));
goto error; goto error;
} }
} }
@ -277,7 +277,7 @@ static int testLoadDomain(virConnectPtr conn,
if ((obj != NULL) && (obj->type == XPATH_STRING) && if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) { (obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (!(onReboot = testRestartStringToFlag((const char *)obj->stringval))) { if (!(onReboot = testRestartStringToFlag((const char *)obj->stringval))) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed on_poweroff value for domain"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("domain poweroff behaviour"));
goto error; goto error;
} }
} }
@ -288,7 +288,7 @@ static int testLoadDomain(virConnectPtr conn,
if ((obj != NULL) && (obj->type == XPATH_STRING) && if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) { (obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (!(onReboot = testRestartStringToFlag((const char *)obj->stringval))) { if (!(onReboot = testRestartStringToFlag((const char *)obj->stringval))) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed on_crash value for domain"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("domain crash behaviour"));
goto error; goto error;
} }
} }
@ -331,7 +331,7 @@ static int testLoadDomainFromDoc(virConnectPtr conn,
if (!(xml = xmlReadDoc(BAD_CAST doc, "domain.xml", NULL, if (!(xml = xmlReadDoc(BAD_CAST doc, "domain.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) { XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot parse domain definition"); testError(NULL, NULL, VIR_ERR_XML_ERROR, _("domain"));
return -1; return -1;
} }
@ -349,14 +349,14 @@ static int testLoadDomainFromFile(virConnectPtr conn,
xmlDocPtr xml; xmlDocPtr xml;
if ((fd = open(file, O_RDONLY)) < 0) { if ((fd = open(file, O_RDONLY)) < 0) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot load domain definition"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("load domain definition file"));
return -1; return -1;
} }
if (!(xml = xmlReadFd(fd, file, NULL, if (!(xml = xmlReadFd(fd, file, NULL,
XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) { XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot parse domain definition"); testError(NULL, NULL, VIR_ERR_XML_ERROR, _("domain"));
close(fd); close(fd);
return -1; return -1;
} }
@ -376,7 +376,7 @@ static int testOpenDefault(virConnectPtr conn,
struct timeval tv; struct timeval tv;
if (gettimeofday(&tv, NULL) < 0) { if (gettimeofday(&tv, NULL) < 0) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot get timeofday"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("getting time of day"));
return -1; return -1;
} }
@ -431,14 +431,14 @@ static int testOpenFromFile(virConnectPtr conn,
virNodeInfoPtr nodeInfo; virNodeInfoPtr nodeInfo;
if ((fd = open(file, O_RDONLY)) < 0) { if ((fd = open(file, O_RDONLY)) < 0) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot load host definition"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("loading host definition file"));
return -1; return -1;
} }
if (!(xml = xmlReadFd(fd, file, NULL, if (!(xml = xmlReadFd(fd, file, NULL,
XML_PARSE_NOENT | XML_PARSE_NONET | XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) { XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot parse host definition"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("host"));
goto error; goto error;
} }
close(fd); close(fd);
@ -446,13 +446,13 @@ static int testOpenFromFile(virConnectPtr conn,
root = xmlDocGetRootElement(xml); root = xmlDocGetRootElement(xml);
if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "node"))) { if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "node"))) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "malformed root element"); testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node"));
goto error; goto error;
} }
ctxt = xmlXPathNewContext(xml); ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) { if (ctxt == NULL) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot create xpath context"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("creating xpath context"));
goto error; goto error;
} }
@ -468,7 +468,7 @@ static int testOpenFromFile(virConnectPtr conn,
char *conv = NULL; char *conv = NULL;
nodeInfo->nodes = strtol((const char*)obj->stringval, &conv, 10); nodeInfo->nodes = strtol((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) { if (conv == (const char*)obj->stringval) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed nodes value for node cpu"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu numa nodes"));
goto error; goto error;
} }
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
@ -480,7 +480,7 @@ static int testOpenFromFile(virConnectPtr conn,
char *conv = NULL; char *conv = NULL;
nodeInfo->sockets = strtol((const char*)obj->stringval, &conv, 10); nodeInfo->sockets = strtol((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) { if (conv == (const char*)obj->stringval) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed sockets value for node cpu"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu sockets"));
goto error; goto error;
} }
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
@ -492,7 +492,7 @@ static int testOpenFromFile(virConnectPtr conn,
char *conv = NULL; char *conv = NULL;
nodeInfo->cores = strtol((const char*)obj->stringval, &conv, 10); nodeInfo->cores = strtol((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) { if (conv == (const char*)obj->stringval) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed cores value for node cpu"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu cores"));
goto error; goto error;
} }
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
@ -504,7 +504,7 @@ static int testOpenFromFile(virConnectPtr conn,
char *conv = NULL; char *conv = NULL;
nodeInfo->threads = strtol((const char*)obj->stringval, &conv, 10); nodeInfo->threads = strtol((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) { if (conv == (const char*)obj->stringval) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed threads value for node cpu"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu threads"));
goto error; goto error;
} }
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
@ -516,7 +516,7 @@ static int testOpenFromFile(virConnectPtr conn,
char *conv = NULL; char *conv = NULL;
unsigned int active = strtol((const char*)obj->stringval, &conv, 10); unsigned int active = strtol((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) { if (conv == (const char*)obj->stringval) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed active value for node cpu"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("node active cpu"));
goto error; goto error;
} }
if (active < nodeInfo->cpus) { if (active < nodeInfo->cpus) {
@ -530,7 +530,7 @@ static int testOpenFromFile(virConnectPtr conn,
char *conv = NULL; char *conv = NULL;
nodeInfo->mhz = strtol((const char*)obj->stringval, &conv, 10); nodeInfo->mhz = strtol((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) { if (conv == (const char*)obj->stringval) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed threads value for node cpu"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu mhz"));
goto error; goto error;
} }
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
@ -549,7 +549,7 @@ static int testOpenFromFile(virConnectPtr conn,
char *conv = NULL; char *conv = NULL;
nodeInfo->memory = strtol((const char*)obj->stringval, &conv, 10); nodeInfo->memory = strtol((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) { if (conv == (const char*)obj->stringval) {
testError(conn, NULL, VIR_ERR_INTERNAL_ERROR, "malformed memory value for node"); testError(conn, NULL, VIR_ERR_XML_ERROR, _("node memory"));
goto error; goto error;
} }
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
@ -558,7 +558,7 @@ static int testOpenFromFile(virConnectPtr conn,
obj = xmlXPathEval(BAD_CAST "/node/domain", ctxt); obj = xmlXPathEval(BAD_CAST "/node/domain", ctxt);
if ((obj == NULL) || (obj->type != XPATH_NODESET) || if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
(obj->nodesetval == NULL)) { (obj->nodesetval == NULL)) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot extract domain list"); testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node domain list"));
goto error; goto error;
} }
@ -567,7 +567,7 @@ static int testOpenFromFile(virConnectPtr conn,
char *absFile = testBuildFilename(file, (const char *)domFile); char *absFile = testBuildFilename(file, (const char *)domFile);
free(domFile); free(domFile);
if (!absFile) { if (!absFile) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot resolve filename"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("resolving domain filename"));
goto error; goto error;
} }
if (testLoadDomainFromFile(conn, i, absFile) != 0) { if (testLoadDomainFromFile(conn, i, absFile) != 0) {
@ -605,7 +605,7 @@ static int getNextConnection(void) {
if (node == NULL) { if (node == NULL) {
node = calloc(1, sizeof(testNode)); node = calloc(1, sizeof(testNode));
if (!node) { if (!node) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot allocate memory"); testError(NULL, NULL, VIR_ERR_NO_MEMORY, _("allocating node"));
return -1; return -1;
} }
} }
@ -645,7 +645,7 @@ int testOpen(virConnectPtr conn,
if ((connid = getNextConnection()) < 0) { if ((connid = getNextConnection()) < 0) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "too many connections"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("too many connections"));
return -1; return -1;
} }
@ -722,7 +722,7 @@ testDomainCreateLinux(virConnectPtr conn, const char *xmlDesc,
return NULL; return NULL;
dom = virGetDomain(conn, con->domains[i].name, con->domains[i].uuid); dom = virGetDomain(conn, con->domains[i].name, con->domains[i].uuid);
if (dom == NULL) { if (dom == NULL) {
testError(conn, NULL, VIR_ERR_NO_MEMORY, "allocating domain"); testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating domain"));
return NULL; return NULL;
} }
con->numDomains++; con->numDomains++;
@ -730,7 +730,7 @@ testDomainCreateLinux(virConnectPtr conn, const char *xmlDesc,
} }
} }
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "too many domains"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("too many domains"));
return (NULL); return (NULL);
} }
@ -747,7 +747,7 @@ virDomainPtr testLookupDomainByID(virConnectPtr conn,
dom = virGetDomain(conn, con->domains[id].name, con->domains[id].uuid); dom = virGetDomain(conn, con->domains[id].name, con->domains[id].uuid);
if (dom == NULL) { if (dom == NULL) {
testError(conn, NULL, VIR_ERR_NO_MEMORY, "Allocating domain"); testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating domain"));
return(NULL); return(NULL);
} }
dom->handle = id; dom->handle = id;
@ -770,7 +770,7 @@ virDomainPtr testLookupDomainByUUID(virConnectPtr conn,
if (id >= 0) { if (id >= 0) {
dom = virGetDomain(conn, con->domains[id].name, con->domains[id].uuid); dom = virGetDomain(conn, con->domains[id].name, con->domains[id].uuid);
if (dom == NULL) { if (dom == NULL) {
testError(conn, NULL, VIR_ERR_NO_MEMORY, "Allocating domain"); testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating domain"));
return(NULL); return(NULL);
} }
dom->handle = id; dom->handle = id;
@ -794,7 +794,7 @@ virDomainPtr testLookupDomainByName(virConnectPtr conn,
if (id >= 0) { if (id >= 0) {
dom = virGetDomain(conn, con->domains[id].name, con->domains[id].uuid); dom = virGetDomain(conn, con->domains[id].name, con->domains[id].uuid);
if (dom == NULL) { if (dom == NULL) {
testError(conn, NULL, VIR_ERR_NO_MEMORY, "Allocating domain"); testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating domain"));
return(NULL); return(NULL);
} }
dom->handle = id; dom->handle = id;
@ -892,7 +892,7 @@ int testShutdownDomain (virDomainPtr domain)
con = &node->connections[domain->conn->handle]; con = &node->connections[domain->conn->handle];
if (gettimeofday(&tv, NULL) < 0) { if (gettimeofday(&tv, NULL) < 0) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot get timeofday"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("getting time of day"));
return (-1); return (-1);
} }
@ -920,7 +920,7 @@ int testRebootDomain (virDomainPtr domain, virDomainRestart action)
con = &node->connections[domain->conn->handle]; con = &node->connections[domain->conn->handle];
if (gettimeofday(&tv, NULL) < 0) { if (gettimeofday(&tv, NULL) < 0) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot get timeofday"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("getting time of day"));
return (-1); return (-1);
} }
@ -947,7 +947,7 @@ int testGetDomainInfo (virDomainPtr domain,
con = &node->connections[domain->conn->handle]; con = &node->connections[domain->conn->handle];
if (gettimeofday(&tv, NULL) < 0) { if (gettimeofday(&tv, NULL) < 0) {
testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot get timeofday"); testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("getting time of day"));
return (-1); return (-1);
} }
@ -1038,7 +1038,7 @@ int testSetMemory (virDomainPtr domain,
con = &node->connections[domain->conn->handle]; con = &node->connections[domain->conn->handle];
if (memory > con->domains[domain->handle].info.maxMem) { if (memory > con->domains[domain->handle].info.maxMem) {
testError(domain->conn, domain, VIR_ERR_INVALID_ARG, "memory over maximum limit"); testError(domain->conn, domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1); return (-1);
} }
@ -1064,7 +1064,7 @@ int testSetVcpus(virDomainPtr domain,
/* We allow more cpus in guest than host */ /* We allow more cpus in guest than host */
if (nrCpus > 32) { if (nrCpus > 32) {
testError(domain->conn, domain, VIR_ERR_INVALID_ARG, "too many virtual cpus"); testError(domain->conn, domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
return (-1); return (-1);
} }

File diff suppressed because it is too large Load Diff

View File

@ -240,10 +240,10 @@ virDefaultErrorFunc(virErrorPtr err)
lvl = ""; lvl = "";
break; break;
case VIR_ERR_WARNING: case VIR_ERR_WARNING:
lvl = "warning"; lvl = _("warning");
break; break;
case VIR_ERR_ERROR: case VIR_ERR_ERROR:
lvl = "error"; lvl = _("error");
break; break;
} }
switch (err->domain) { switch (err->domain) {
@ -325,7 +325,7 @@ __virRaiseError(virConnectPtr conn, virDomainPtr dom,
* formats the message * formats the message
*/ */
if (msg == NULL) { if (msg == NULL) {
str = strdup("No error message provided"); str = strdup(_("No error message provided"));
} else { } else {
VIR_GET_VAR_STR(msg, str); VIR_GET_VAR_STR(msg, str);
} }
@ -379,195 +379,195 @@ __virErrorMsg(virErrorNumber error, const char *info)
return (NULL); return (NULL);
case VIR_ERR_INTERNAL_ERROR: case VIR_ERR_INTERNAL_ERROR:
if (info != NULL) if (info != NULL)
errmsg = "internal error %s"; errmsg = _("internal error %s");
else else
errmsg = "internal error"; errmsg = _("internal error");
break; break;
case VIR_ERR_NO_MEMORY: case VIR_ERR_NO_MEMORY:
errmsg = "out of memory"; errmsg = _("out of memory");
break; break;
case VIR_ERR_NO_SUPPORT: case VIR_ERR_NO_SUPPORT:
if (info != NULL) if (info != NULL)
errmsg = "no support for hypervisor"; errmsg = _("no support for hypervisor");
else else
errmsg = "no support for hypervisor %s"; errmsg = _("no support for hypervisor %s");
break; break;
case VIR_ERR_NO_CONNECT: case VIR_ERR_NO_CONNECT:
if (info == NULL) if (info == NULL)
errmsg = "could not connect to hypervisor"; errmsg = _("could not connect to hypervisor");
else else
errmsg = "could not connect to %s"; errmsg = _("could not connect to %s");
break; break;
case VIR_ERR_INVALID_CONN: case VIR_ERR_INVALID_CONN:
if (info == NULL) if (info == NULL)
errmsg = "invalid connection pointer in"; errmsg = _("invalid connection pointer in");
else else
errmsg = "invalid connection pointer in %s"; errmsg = _("invalid connection pointer in %s");
break; break;
case VIR_ERR_INVALID_DOMAIN: case VIR_ERR_INVALID_DOMAIN:
if (info == NULL) if (info == NULL)
errmsg = "invalid domain pointer in"; errmsg = _("invalid domain pointer in");
else else
errmsg = "invalid domain pointer in %s"; errmsg = _("invalid domain pointer in %s");
break; break;
case VIR_ERR_INVALID_ARG: case VIR_ERR_INVALID_ARG:
if (info == NULL) if (info == NULL)
errmsg = "invalid argument in"; errmsg = _("invalid argument in");
else else
errmsg = "invalid argument in %s"; errmsg = _("invalid argument in %s");
break; break;
case VIR_ERR_OPERATION_FAILED: case VIR_ERR_OPERATION_FAILED:
if (info != NULL) if (info != NULL)
errmsg = "operation failed: %s"; errmsg = _("operation failed: %s");
else else
errmsg = "operation failed"; errmsg = _("operation failed");
break; break;
case VIR_ERR_GET_FAILED: case VIR_ERR_GET_FAILED:
if (info != NULL) if (info != NULL)
errmsg = "GET operation failed: %s"; errmsg = _("GET operation failed: %s");
else else
errmsg = "GET operation failed"; errmsg = _("GET operation failed");
break; break;
case VIR_ERR_POST_FAILED: case VIR_ERR_POST_FAILED:
if (info != NULL) if (info != NULL)
errmsg = "POST operation failed: %s"; errmsg = _("POST operation failed: %s");
else else
errmsg = "POST operation failed"; errmsg = _("POST operation failed");
break; break;
case VIR_ERR_HTTP_ERROR: case VIR_ERR_HTTP_ERROR:
errmsg = "got unknown HTTP error code %d"; errmsg = _("got unknown HTTP error code %d");
break; break;
case VIR_ERR_UNKNOWN_HOST: case VIR_ERR_UNKNOWN_HOST:
if (info != NULL) if (info != NULL)
errmsg = "unknown host %s"; errmsg = _("unknown host %s");
else else
errmsg = "unknown host"; errmsg = _("unknown host");
break; break;
case VIR_ERR_SEXPR_SERIAL: case VIR_ERR_SEXPR_SERIAL:
if (info != NULL) if (info != NULL)
errmsg = "failed to serialize S-Expr: %s"; errmsg = _("failed to serialize S-Expr: %s");
else else
errmsg = "failed to serialize S-Expr"; errmsg = _("failed to serialize S-Expr");
break; break;
case VIR_ERR_NO_XEN: case VIR_ERR_NO_XEN:
if (info == NULL) if (info == NULL)
errmsg = "could not use Xen hypervisor entry"; errmsg = _("could not use Xen hypervisor entry");
else else
errmsg = "could not use Xen hypervisor entry %s"; errmsg = _("could not use Xen hypervisor entry %s");
break; break;
case VIR_ERR_NO_XENSTORE: case VIR_ERR_NO_XENSTORE:
if (info == NULL) if (info == NULL)
errmsg = "could not connect to Xen Store"; errmsg = _("could not connect to Xen Store");
else else
errmsg = "could not connect to Xen Store %s"; errmsg = _("could not connect to Xen Store %s");
break; break;
case VIR_ERR_XEN_CALL: case VIR_ERR_XEN_CALL:
errmsg = "failed Xen syscall %s %d"; errmsg = _("failed Xen syscall %s %d");
break; break;
case VIR_ERR_OS_TYPE: case VIR_ERR_OS_TYPE:
if (info == NULL) if (info == NULL)
errmsg = "unknown OS type"; errmsg = _("unknown OS type");
else else
errmsg = "unknown OS type %s"; errmsg = _("unknown OS type %s");
break; break;
case VIR_ERR_NO_KERNEL: case VIR_ERR_NO_KERNEL:
errmsg = "missing kernel information"; errmsg = _("missing kernel information");
break; break;
case VIR_ERR_NO_ROOT: case VIR_ERR_NO_ROOT:
if (info == NULL) if (info == NULL)
errmsg = "missing root device information"; errmsg = _("missing root device information");
else else
errmsg = "missing root device information in %s"; errmsg = _("missing root device information in %s");
break; break;
case VIR_ERR_NO_SOURCE: case VIR_ERR_NO_SOURCE:
if (info == NULL) if (info == NULL)
errmsg = "missing source information for device"; errmsg = _("missing source information for device");
else else
errmsg = "missing source information for device %s"; errmsg = _("missing source information for device %s");
break; break;
case VIR_ERR_NO_TARGET: case VIR_ERR_NO_TARGET:
if (info == NULL) if (info == NULL)
errmsg = "missing target information for device"; errmsg = _("missing target information for device");
else else
errmsg = "missing target information for device %s"; errmsg = _("missing target information for device %s");
break; break;
case VIR_ERR_NO_NAME: case VIR_ERR_NO_NAME:
if (info == NULL) if (info == NULL)
errmsg = "missing domain name information"; errmsg = _("missing domain name information");
else else
errmsg = "missing domain name information in %s"; errmsg = _("missing domain name information in %s");
break; break;
case VIR_ERR_NO_OS: case VIR_ERR_NO_OS:
if (info == NULL) if (info == NULL)
errmsg = "missing operating system information"; errmsg = _("missing operating system information");
else else
errmsg = "missing operating system information for %s"; errmsg = _("missing operating system information for %s");
break; break;
case VIR_ERR_NO_DEVICE: case VIR_ERR_NO_DEVICE:
if (info == NULL) if (info == NULL)
errmsg = "missing devices information"; errmsg = _("missing devices information");
else else
errmsg = "missing devices information for %s"; errmsg = _("missing devices information for %s");
break; break;
case VIR_ERR_DRIVER_FULL: case VIR_ERR_DRIVER_FULL:
if (info == NULL) if (info == NULL)
errmsg = "too many drivers registered"; errmsg = _("too many drivers registered");
else else
errmsg = "too many drivers registered in %s"; errmsg = _("too many drivers registered in %s");
break; break;
case VIR_ERR_CALL_FAILED: case VIR_ERR_CALL_FAILED:
if (info == NULL) if (info == NULL)
errmsg = "library call failed, possibly not supported"; errmsg = _("library call failed, possibly not supported");
else else
errmsg = "library call %s failed, possibly not supported"; errmsg = _("library call %s failed, possibly not supported");
break; break;
case VIR_ERR_XML_ERROR: case VIR_ERR_XML_ERROR:
if (info == NULL) if (info == NULL)
errmsg = "XML description not well formed or invalid"; errmsg = _("XML description not well formed or invalid");
else else
errmsg = "XML description for %s is not well formed or invalid"; errmsg = _("XML description for %s is not well formed or invalid");
break; break;
case VIR_ERR_DOM_EXIST: case VIR_ERR_DOM_EXIST:
if (info == NULL) if (info == NULL)
errmsg = "this domain exists already"; errmsg = _("this domain exists already");
else else
errmsg = "domain %s exists already"; errmsg = _("domain %s exists already");
break; break;
case VIR_ERR_OPERATION_DENIED: case VIR_ERR_OPERATION_DENIED:
if (info == NULL) if (info == NULL)
errmsg = "operation forbidden for read only access"; errmsg = _("operation forbidden for read only access");
else else
errmsg = "operation %s forbidden for read only access"; errmsg = _("operation %s forbidden for read only access");
break; break;
case VIR_ERR_OPEN_FAILED: case VIR_ERR_OPEN_FAILED:
if (info == NULL) if (info == NULL)
errmsg = "failed to open configuration file for reading"; errmsg = _("failed to open configuration file for reading");
else else
errmsg = "failed to open %s for reading"; errmsg = _("failed to open %s for reading");
break; break;
case VIR_ERR_READ_FAILED: case VIR_ERR_READ_FAILED:
if (info == NULL) if (info == NULL)
errmsg = "failed to read configuration file"; errmsg = _("failed to read configuration file");
else else
errmsg = "failed to read configuration file %s"; errmsg = _("failed to read configuration file %s");
break; break;
case VIR_ERR_PARSE_FAILED: case VIR_ERR_PARSE_FAILED:
if (info == NULL) if (info == NULL)
errmsg = "failed to parse configuration file"; errmsg = _("failed to parse configuration file");
else else
errmsg = "failed to parse configuration file %s"; errmsg = _("failed to parse configuration file %s");
break; break;
case VIR_ERR_CONF_SYNTAX: case VIR_ERR_CONF_SYNTAX:
if (info == NULL) if (info == NULL)
errmsg = "configuration file syntax error"; errmsg = _("configuration file syntax error");
else else
errmsg = "configuration file syntax error: %s"; errmsg = _("configuration file syntax error: %s");
break; break;
case VIR_ERR_WRITE_FAILED: case VIR_ERR_WRITE_FAILED:
if (info == NULL) if (info == NULL)
errmsg = "failed to write configuration file"; errmsg = _("failed to write configuration file");
else else
errmsg = "failed to write configuration file: %s"; errmsg = _("failed to write configuration file: %s");
break; break;
} }
return (errmsg); return (errmsg);

View File

@ -1238,7 +1238,7 @@ xenHypervisorNumOfDomains(virConnectPtr conn)
retry: retry:
dominfos = malloc(maxids * sizeof(xen_v0_getdomaininfo)); dominfos = malloc(maxids * sizeof(xen_v0_getdomaininfo));
if (dominfos == NULL) { if (dominfos == NULL) {
virXenError(VIR_ERR_NO_MEMORY, "failed to allocate %d domain info", virXenError(VIR_ERR_NO_MEMORY, _("allocating %d domain info"),
maxids); maxids);
return(-1); return(-1);
} }
@ -1285,7 +1285,7 @@ xenHypervisorListDomains(virConnectPtr conn, int *ids, int maxids)
dominfos = malloc(maxids * sizeof(xen_v0_getdomaininfo)); dominfos = malloc(maxids * sizeof(xen_v0_getdomaininfo));
if (dominfos == NULL) { if (dominfos == NULL) {
virXenError(VIR_ERR_NO_MEMORY, "failed to allocate %d domain info", virXenError(VIR_ERR_NO_MEMORY, "allocating %d domain info",
maxids); maxids);
return(-1); return(-1);
} }

View File

@ -261,10 +261,10 @@ wr_sync(int fd, void *buffer, size_t size, int do_read)
if (len == -1) { if (len == -1) {
if (do_read) if (do_read)
virXendError(NULL, VIR_ERR_INTERNAL_ERROR, virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
"faid to read from Xen Daemon"); _("failed to read from Xen Daemon"));
else else
virXendError(NULL, VIR_ERR_INTERNAL_ERROR, virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
"faid to read from Xen Daemon"); _("failed to read from Xen Daemon"));
return (-1); return (-1);
} }
@ -1053,7 +1053,7 @@ xenDaemonDomainCreateLinux(virConnectPtr xend, const char *sexpr)
if (ptr == NULL) { if (ptr == NULL) {
/* this should be caught at the interface but ... */ /* this should be caught at the interface but ... */
virXendError(xend, VIR_ERR_INTERNAL_ERROR, virXendError(xend, VIR_ERR_INTERNAL_ERROR,
"Failed to urlencode the create S-Expr"); _("failed to urlencode the create S-Expr"));
return (-1); return (-1);
} }
@ -1094,20 +1094,20 @@ xenDaemonDomainLookupByName_ids(virConnectPtr xend, const char *domname,
value = sexpr_node(root, "domain/domid"); value = sexpr_node(root, "domain/domid");
if (value == NULL) { if (value == NULL) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR, virXendError(xend, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, missing domid"); _("domain information incomplete, missing domid"));
goto error; goto error;
} }
ret = strtol(value, NULL, 0); ret = strtol(value, NULL, 0);
if ((ret == 0) && (value[0] != '0')) { if ((ret == 0) && (value[0] != '0')) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR, virXendError(xend, VIR_ERR_INTERNAL_ERROR,
"domain information incorrect domid not numberic"); _("domain information incorrect domid not numeric"));
ret = -1; ret = -1;
} else if (uuid != NULL) { } else if (uuid != NULL) {
char **ptr = (char **) &uuid; char **ptr = (char **) &uuid;
if (sexpr_uuid(ptr, root, "domain/uuid") == NULL) { if (sexpr_uuid(ptr, root, "domain/uuid") == NULL) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR, virXendError(xend, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, missing uuid"); _("domain information incomplete, missing uuid"));
} }
} }
@ -1147,7 +1147,7 @@ xenDaemonDomainLookupByID(virConnectPtr xend,
name = sexpr_node(root, "domain/name"); name = sexpr_node(root, "domain/name");
if (name == NULL) { if (name == NULL) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR, virXendError(xend, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, missing name"); _("domain information incomplete, missing name"));
goto error; goto error;
} }
if (domname) if (domname)
@ -1156,7 +1156,7 @@ xenDaemonDomainLookupByID(virConnectPtr xend,
dst_uuid = (char *)&uuid[0]; dst_uuid = (char *)&uuid[0];
if (sexpr_uuid(&dst_uuid, root, "domain/uuid") == NULL) { if (sexpr_uuid(&dst_uuid, root, "domain/uuid") == NULL) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR, virXendError(xend, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, missing uuid"); _("domain information incomplete, missing uuid"));
goto error; goto error;
} }
@ -1405,7 +1405,7 @@ xend_parse_sexp_desc_os(struct sexpr *node, virBufferPtr buf, int hvm)
tmp = sexpr_node(node, "domain/image/hvm/kernel"); tmp = sexpr_node(node, "domain/image/hvm/kernel");
if (tmp == NULL) { if (tmp == NULL) {
virXendError(NULL, VIR_ERR_INTERNAL_ERROR, virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, missing kernel"); _("domain information incomplete, missing kernel"));
return(-1); return(-1);
} }
virBufferVSprintf(buf, " <loader>%s</loader>\n", tmp); virBufferVSprintf(buf, " <loader>%s</loader>\n", tmp);
@ -1430,7 +1430,7 @@ xend_parse_sexp_desc_os(struct sexpr *node, virBufferPtr buf, int hvm)
tmp = sexpr_node(node, "domain/image/linux/kernel"); tmp = sexpr_node(node, "domain/image/linux/kernel");
if (tmp == NULL) { if (tmp == NULL) {
virXendError(NULL, VIR_ERR_INTERNAL_ERROR, virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, missing kernel"); _("domain information incomplete, missing kernel"));
return(-1); return(-1);
} }
virBufferVSprintf(buf, " <kernel>%s</kernel>\n", tmp); virBufferVSprintf(buf, " <kernel>%s</kernel>\n", tmp);
@ -1484,11 +1484,11 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
domid = sexpr_int(root, "domain/domid"); domid = sexpr_int(root, "domain/domid");
virBufferVSprintf(&buf, "<domain type='xen' id='%d'>\n", domid); virBufferVSprintf(&buf, "<domain type='xen' id='%d'>\n", domid);
tmp = sexpr_node(root, "domain/name"); tmp = sexpr_node(root, "domain/name");
if (tmp == NULL) { if (tmp == NULL) {
virXendError(NULL, VIR_ERR_INTERNAL_ERROR, virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, missing name"); _("domain information incomplete, missing name"));
goto error; goto error;
} }
virBufferVSprintf(&buf, " <name>%s</name>\n", tmp); virBufferVSprintf(&buf, " <name>%s</name>\n", tmp);
@ -1540,7 +1540,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
virBufferAdd(&buf, " <pae/>\n", 11); virBufferAdd(&buf, " <pae/>\n", 11);
virBufferAdd(&buf, " </features>\n", 14); virBufferAdd(&buf, " </features>\n", 14);
} }
virBufferAdd(&buf, " <devices>\n", 12); virBufferAdd(&buf, " <devices>\n", 12);
/* in case of HVM we have devices emulation */ /* in case of HVM we have devices emulation */
@ -1561,9 +1561,10 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
if (dst == NULL) { if (dst == NULL) {
virXendError(NULL, VIR_ERR_INTERNAL_ERROR, virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, vbd has no dev"); _("domain information incomplete, vbd has no dev"));
goto error; goto error;
} }
if (!strncmp(dst, "ioemu:", 6)) if (!strncmp(dst, "ioemu:", 6))
dst += 6; dst += 6;
/* New style disk config from Xen >= 3.0.3 */ /* New style disk config from Xen >= 3.0.3 */
@ -1597,9 +1598,10 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
if (dst == NULL) { if (dst == NULL) {
virXendError(NULL, VIR_ERR_INTERNAL_ERROR, virXendError(NULL, VIR_ERR_INTERNAL_ERROR,
"domain information incomplete, vbd has no dev"); _("domain information incomplete, vbd has no dev"));
goto error; goto error;
} }
if (!strncmp(dst, "ioemu:", 6)) if (!strncmp(dst, "ioemu:", 6))
dst += 6; dst += 6;
/* New style cdrom config from Xen >= 3.0.3 */ /* New style cdrom config from Xen >= 3.0.3 */
@ -1859,7 +1861,7 @@ sexpr_to_domain(virConnectPtr conn, struct sexpr *root)
ret = virGetDomain(conn, name, (const unsigned char *) &uuid[0]); ret = virGetDomain(conn, name, (const unsigned char *) &uuid[0]);
if (ret == NULL) { if (ret == NULL) {
virXendError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); virXendError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
return(NULL); return(NULL);
} }
ret->handle = sexpr_int(root, "domain/domid"); ret->handle = sexpr_int(root, "domain/domid");
@ -1870,7 +1872,7 @@ sexpr_to_domain(virConnectPtr conn, struct sexpr *root)
error: error:
virXendError(conn, VIR_ERR_INTERNAL_ERROR, virXendError(conn, VIR_ERR_INTERNAL_ERROR,
"failed to parse Xend domain information"); _("failed to parse Xend domain information"));
if (ret != NULL) if (ret != NULL)
virFreeDomain(conn, ret); virFreeDomain(conn, ret);
return(NULL); return(NULL);
@ -1949,7 +1951,7 @@ try_http:
ret = xenDaemonOpen_unix(conn, uri->path); ret = xenDaemonOpen_unix(conn, uri->path);
if (ret < 0) if (ret < 0)
goto failed; goto failed;
ret = xenDaemonGetVersion(conn, &version); ret = xenDaemonGetVersion(conn, &version);
if (ret < 0) if (ret < 0)
goto failed; goto failed;
@ -2555,7 +2557,7 @@ xenDaemonLookupByID(virConnectPtr conn, int id) {
ret = virGetDomain(conn, name, uuid); ret = virGetDomain(conn, name, uuid);
if (ret == NULL) { if (ret == NULL) {
virXendError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); virXendError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
goto error; goto error;
} }
ret->handle = id; ret->handle = id;
@ -2763,7 +2765,7 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
ret = virGetDomain(conn, name, uuid); ret = virGetDomain(conn, name, uuid);
if (ret == NULL) { if (ret == NULL) {
virXendError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); virXendError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
goto error; goto error;
} }
ret->handle = id; ret->handle = id;
@ -2826,13 +2828,13 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
ret = xenDaemonDomainCreateLinux(conn, sexpr); ret = xenDaemonDomainCreateLinux(conn, sexpr);
free(sexpr); free(sexpr);
if (ret != 0) { if (ret != 0) {
fprintf(stderr, "Failed to create domain %s\n", name); fprintf(stderr, _("Failed to create domain %s\n"), name);
goto error; goto error;
} }
ret = xend_wait_for_devices(conn, name); ret = xend_wait_for_devices(conn, name);
if (ret != 0) { if (ret != 0) {
fprintf(stderr, "Failed to get devices for domain %s\n", name); fprintf(stderr, _("Failed to get devices for domain %s\n"), name);
goto error; goto error;
} }
@ -2843,7 +2845,7 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
ret = xenDaemonDomainResume(dom); ret = xenDaemonDomainResume(dom);
if (ret != 0) { if (ret != 0) {
fprintf(stderr, "Failed to resume new domain %s\n", name); fprintf(stderr, _("Failed to resume new domain %s\n"), name);
xenDaemonDomainDestroy(dom); xenDaemonDomainDestroy(dom);
goto error; goto error;
} }

View File

@ -61,7 +61,7 @@ virBufferGrow(virBufferPtr buf, unsigned int len)
newbuf = (char *) realloc(buf->content, size); newbuf = (char *) realloc(buf->content, size);
if (newbuf == NULL) { if (newbuf == NULL) {
virXMLError(VIR_ERR_NO_MEMORY, "growing buffer", size); virXMLError(VIR_ERR_NO_MEMORY, _("growing buffer"), size);
return (-1); return (-1);
} }
buf->content = newbuf; buf->content = newbuf;
@ -113,11 +113,11 @@ virBufferNew(unsigned int size)
virBufferPtr buf; virBufferPtr buf;
if (!(buf = malloc(sizeof(*buf)))) { if (!(buf = malloc(sizeof(*buf)))) {
virXMLError(VIR_ERR_NO_MEMORY, "allocate new buffer", sizeof(*buf)); virXMLError(VIR_ERR_NO_MEMORY, _("allocate new buffer"), sizeof(*buf));
return NULL; return NULL;
} }
if (size && (buf->content = malloc(size))==NULL) { if (size && (buf->content = malloc(size))==NULL) {
virXMLError(VIR_ERR_NO_MEMORY, "allocate buffer content", size); virXMLError(VIR_ERR_NO_MEMORY, _("allocate buffer content"), size);
free(buf); free(buf);
return NULL; return NULL;
} }

View File

@ -60,8 +60,8 @@ static char *xmlGetText(xmlNodePtr node)
if (node->type == XML_TEXT_NODE) { if (node->type == XML_TEXT_NODE) {
char *x = strdup((const char *)node->content); char *x = strdup((const char *)node->content);
if (!x) if (!x)
xmlRpcError(VIR_ERR_NO_MEMORY, "copying node content", xmlRpcError(VIR_ERR_NO_MEMORY, _("copying node content"),
strlen((const char *)node->content)); strlen((const char *)node->content));
return x; return x;
} }
return NULL; return NULL;
@ -154,14 +154,14 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalArray(xmlNodePtr node)
if (!ret) if (!ret)
return NULL; return NULL;
for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur)) for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur))
n_elements += 1; n_elements += 1;
ret->value.array.elements = malloc(n_elements * sizeof(xmlRpcValue)); ret->value.array.elements = malloc(n_elements * sizeof(xmlRpcValue));
if (!ret->value.array.elements) { if (!ret->value.array.elements) {
xmlRpcError(VIR_ERR_NO_MEMORY, "allocate value array", xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value array"),
n_elements * sizeof(xmlRpcValue)); n_elements * sizeof(xmlRpcValue));
free(ret); free(ret);
return NULL; return NULL;
} }
@ -193,7 +193,7 @@ static xmlRpcValueDictElementPtr xmlRpcValueUnmarshalDictElement(xmlNodePtr node
} else if (xmlStrEqual(cur->name, BAD_CAST "value")) { } else if (xmlStrEqual(cur->name, BAD_CAST "value")) {
ret->value = xmlRpcValueUnmarshal(cur); ret->value = xmlRpcValueUnmarshal(cur);
} else { } else {
xmlRpcError(VIR_ERR_XML_ERROR, "unexpected dict node", 0); xmlRpcError(VIR_ERR_XML_ERROR, _("unexpected dict node"), 0);
if (ret->name) if (ret->name)
free(ret->name); free(ret->name);
if (ret->value) if (ret->value)
@ -265,7 +265,7 @@ xmlRpcValuePtr xmlRpcValueUnmarshal(xmlNodePtr node)
} else if (xmlStrEqual(node->name, BAD_CAST "nil")) { } else if (xmlStrEqual(node->name, BAD_CAST "nil")) {
ret = xmlRpcValueNew(XML_RPC_NIL); ret = xmlRpcValueNew(XML_RPC_NIL);
} else { } else {
xmlRpcError(VIR_ERR_XML_ERROR, "unexpected value node", 0); xmlRpcError(VIR_ERR_XML_ERROR, _("unexpected value node"), 0);
} }
return ret; return ret;
@ -426,22 +426,22 @@ static char *xmlRpcCallRaw(const char *url, const char *request)
&contentType, &contentType,
NULL, NULL,
strlen(request)); strlen(request));
if (cxt == NULL) { if (cxt == NULL) {
xmlRpcError(VIR_ERR_POST_FAILED, "send request", 0); xmlRpcError(VIR_ERR_POST_FAILED, _("send request"), 0);
goto error; goto error;
} }
if (contentType && strcmp(contentType, "text/xml") != 0) { if (contentType && strcmp(contentType, "text/xml") != 0) {
errno = EINVAL; errno = EINVAL;
xmlRpcError(VIR_ERR_POST_FAILED, "unexpected mime type", 0); xmlRpcError(VIR_ERR_POST_FAILED, _("unexpected mime type"), 0);
goto error; goto error;
} }
len = xmlNanoHTTPContentLength(cxt); len = xmlNanoHTTPContentLength(cxt);
response = malloc(len + 1); response = malloc(len + 1);
if (response == NULL) { if (response == NULL) {
xmlRpcError(VIR_ERR_NO_MEMORY, "allocate response", len); xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate response"), len);
goto error; goto error;
} }
ret = xmlNanoHTTPRead(cxt, response, len); ret = xmlNanoHTTPRead(cxt, response, len);
@ -449,7 +449,7 @@ static char *xmlRpcCallRaw(const char *url, const char *request)
errno = EINVAL; errno = EINVAL;
free(response); free(response);
response = NULL; response = NULL;
xmlRpcError(VIR_ERR_POST_FAILED, "read response", 0); xmlRpcError(VIR_ERR_POST_FAILED, _("read response"), 0);
} }
response[len] = 0; response[len] = 0;
@ -481,7 +481,7 @@ static char **xmlRpcStringArray(xmlRpcValuePtr value)
size += strlen(value->value.array.elements[i]->value.string) + 1; size += strlen(value->value.array.elements[i]->value.string) + 1;
if (!(ptr = malloc(size))) { if (!(ptr = malloc(size))) {
xmlRpcError(VIR_ERR_NO_MEMORY, "allocate string array", size); xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate string array"), size);
return NULL; return NULL;
} }
ret = (char **)ptr; ret = (char **)ptr;
@ -511,7 +511,7 @@ xmlRpcArgvNew(const char *fmt, va_list ap, int *argc)
*argc = strlen(fmt); *argc = strlen(fmt);
if (!(argv = malloc(sizeof(*argv) * *argc))) { if (!(argv = malloc(sizeof(*argv) * *argc))) {
xmlRpcError(VIR_ERR_NO_MEMORY, "read response", sizeof(*argv) * *argc); xmlRpcError(VIR_ERR_NO_MEMORY, _("read response"), sizeof(*argv) * *argc);
return NULL; return NULL;
} }
i = 0; i = 0;
@ -603,7 +603,7 @@ int xmlRpcCall(xmlRpcContextPtr context, const char *method,
if (xml == NULL) { if (xml == NULL) {
errno = EINVAL; errno = EINVAL;
xmlRpcError(VIR_ERR_XML_ERROR, "parse server response failed", 0); xmlRpcError(VIR_ERR_XML_ERROR, _("parse server response failed"), 0);
return -1; return -1;
} }
@ -667,7 +667,7 @@ xmlRpcContextPtr xmlRpcContextNew(const char *uri)
ret->uri = strdup(uri); ret->uri = strdup(uri);
ret->faultMessage = NULL; ret->faultMessage = NULL;
} else } else
xmlRpcError(VIR_ERR_NO_MEMORY, "allocate new context", sizeof(*ret)); xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate new context"), sizeof(*ret));
return ret; return ret;
} }

View File

@ -315,7 +315,7 @@ xenStoreOpen(virConnectPtr conn, const char *name, int flags)
if (conn->xshandle == NULL) { if (conn->xshandle == NULL) {
if (!(flags & VIR_DRV_OPEN_QUIET)) if (!(flags & VIR_DRV_OPEN_QUIET))
virXenStoreError(conn, VIR_ERR_NO_XEN, virXenStoreError(conn, VIR_ERR_NO_XEN,
"failed to connect to Xen Store"); _("failed to connect to Xen Store"));
return (-1); return (-1);
} }
return (0); return (0);
@ -589,7 +589,7 @@ xenStoreDomainLookupByName(virConnectPtr conn, const char *name)
ret = virGetDomain(conn, name, NULL); ret = virGetDomain(conn, name, NULL);
if (ret == NULL) { if (ret == NULL) {
virXenStoreError(conn, VIR_ERR_NO_MEMORY, "Allocating domain"); virXenStoreError(conn, VIR_ERR_NO_MEMORY, _("allocating domain"));
if (path != NULL) if (path != NULL)
free(path); free(path);
goto done; goto done;

View File

@ -10,8 +10,8 @@ INCLUDES = \
-I$(top_srcdir)/include \ -I$(top_srcdir)/include \
-I$(top_srcdir)/src \ -I$(top_srcdir)/src \
@LIBXML_CFLAGS@ \ @LIBXML_CFLAGS@ \
-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L \
-DGETTEXT_PACKAGE=\"$(PACKAGE)\"
LDADDS = \ LDADDS = \
@STATIC_BINARIES@ \ @STATIC_BINARIES@ \
@LIBXML_LIBS@ \ @LIBXML_LIBS@ \

View File

@ -2,7 +2,7 @@ Id: 1
Name: fc4 Name: fc4
UUID: ef861801-45b9-11cb-88e3-afbfe5370493 UUID: ef861801-45b9-11cb-88e3-afbfe5370493
OS Type: linux OS Type: linux
State: running State: running
CPU(s): 1 CPU(s): 1
Max memory: 131072 kB Max memory: 131072 kB
Used memory: 131072 kB Used memory: 131072 kB

View File

@ -1,2 +1,2 @@
running running

View File

@ -1,5 +1,5 @@
Id Name State Id Name State
---------------------------------- ----------------------------------
0 fv0 running 0 fv0 running
1 fc4 running 1 fc4 running

View File

@ -1,4 +1,4 @@
Id Name State Id Name State
---------------------------------- ----------------------------------
0 Domain-0 running 0 Domain-0 running