[Libvir] Patch for routed virtual networks
by Mads Chr. Olesen
Greetings!
The attached patch adds support for having routed virtual networks, in
addition to the masquerading setup possible with the "<forward />"
stanza.
I have added a <route dev="ethX" /> stanza (dev is optional), completely
equivalent to the <forward /> stanza.
Summary of changes:
* Added <route /> stanza to XML parsing/creation
* Refactored qemudAddIptablesRules to allow for the routed network type
* In iptables.c:
* Renamed iptables(.*)ForwardAllowIn to
iptables(.*)ForwardAllowRelatedIn, to better reflect their function
* Added iptables(.*)ForwardAllowIn functions, that do not require
traffic to be related
Comments are very much appreciated :-)
--
Mads Chr. Olesen <shiyee(a)shiyee.dk>
shiyee.dk
16 years, 8 months
[Libvir] PHP bindings for libvirt API?
by BrunoM
Hello,
Does anyone have information about a mean to plug libvirt into PHP?
Maybe we could just issue shell commands to "virsh", but it would be
preferable to have direct access to the API.
Thanks for any information you could give.
Regards,
Bruno
16 years, 8 months
[Libvir] [PATCH 4/9] qemudReportError: mark for translation string args to this function
by Jim Meyering
qemudReportError: mark for translation string args to this function
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 2 +-
src/qemu_conf.c | 248 +++++++++++++++++++++++++++++++++--------------------
src/qemu_driver.c | 27 ++++--
3 files changed, 174 insertions(+), 103 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index ccf6f5d..6e4868e 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -314,11 +314,11 @@ msg_gen_function += remoteDispatchError
msg_gen_function += virStorageLog
msg_gen_function += xenXMError
msg_gen_function += ReportError
+msg_gen_function += qemudReportError
# msg_gen_function += virXenError
# msg_gen_function += testError
# msg_gen_function += openvzLog
-# msg_gen_function += qemudReportError
# msg_gen_function += error
func_or := $(shell printf '$(msg_gen_function)'|tr -s '[[:space:]]' '|')
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index f6ae06b..bafea8c 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -82,7 +82,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
strcpy(driver->vncListen, "127.0.0.1");
if (!(driver->vncTLSx509certdir = strdup(SYSCONF_DIR "/pki/libvirt-vnc"))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "vncTLSx509certdir");
+ "%s", _("failed to allocate vncTLSx509certdir"));
return -1;
}
@@ -117,7 +117,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
free(driver->vncTLSx509certdir);
if (!(driver->vncTLSx509certdir = strdup(p->str))) {
qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
- "vncTLSx509certdir");
+ "%s", _("failed to allocate vncTLSx509certdir"));
virConfFree(conf);
return -1;
}
@@ -530,7 +530,7 @@ int qemudExtractVersion(virConnectPtr conn,
if (stat(binary, &sb) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Cannot find QEMU binary %s: %s", binary,
+ _("Cannot find QEMU binary %s: %s"), binary,
strerror(errno));
return -1;
}
@@ -613,14 +613,16 @@ static int qemudParseDiskXML(virConnectPtr conn,
!strcmp((const char *)device, "floppy") &&
strcmp((const char *)target, "fda") &&
strcmp((const char *)target, "fdb")) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid floppy device name: %s", target);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Invalid floppy device name: %s"), target);
goto error;
}
if (device &&
!strcmp((const char *)device, "cdrom") &&
strcmp((const char *)target, "hdc")) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid cdrom device name: %s", target);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Invalid cdrom device name: %s"), target);
goto error;
}
@@ -633,7 +635,8 @@ static int qemudParseDiskXML(virConnectPtr conn,
strcmp((const char *)target, "hdb") &&
strcmp((const char *)target, "hdc") &&
strcmp((const char *)target, "hdd")) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid harddisk device name: %s", target);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Invalid harddisk device name: %s"), target);
goto error;
}
@@ -653,7 +656,8 @@ static int qemudParseDiskXML(virConnectPtr conn,
else if (!strcmp((const char *)device, "floppy"))
disk->device = QEMUD_DISK_FLOPPY;
else {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid device type: %s", device);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Invalid device type: %s"), device);
goto error;
}
@@ -795,11 +799,11 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
if (network == NULL) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "No <source> 'network' attribute specified with <interface type='network'/>");
+ "%s", _("No <source> 'network' attribute specified with <interface type='network'/>"));
goto error;
} else if ((len = xmlStrlen(network)) >= (QEMUD_MAX_NAME_LEN-1)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Network name '%s' too long", network);
+ _("Network name '%s' too long"), network);
goto error;
} else {
strncpy(net->dst.network.name, (char *)network, len);
@@ -814,7 +818,8 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
if (ifname != NULL) {
if ((len = xmlStrlen(ifname)) >= (BR_IFNAME_MAXLEN-1)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "TAP interface name '%s' is too long", ifname);
+ _("TAP interface name '%s' is too long"),
+ ifname);
goto error;
} else {
strncpy(net->dst.network.ifname, (char *)ifname, len);
@@ -829,7 +834,7 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
if (script != NULL) {
if ((len = xmlStrlen(script)) >= (PATH_MAX-1)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "TAP script path '%s' is too long", script);
+ _("TAP script path '%s' is too long"), script);
goto error;
} else {
strncpy(net->dst.ethernet.script, (char *)script, len);
@@ -841,7 +846,8 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
if (ifname != NULL) {
if ((len = xmlStrlen(ifname)) >= (BR_IFNAME_MAXLEN-1)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "TAP interface name '%s' is too long", ifname);
+ _("TAP interface name '%s' is too long"),
+ ifname);
goto error;
} else {
strncpy(net->dst.ethernet.ifname, (char *)ifname, len);
@@ -854,11 +860,11 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
if (bridge == NULL) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "No <source> 'dev' attribute specified with <interface type='bridge'/>");
+ "%s", _("No <source> 'dev' attribute specified with <interface type='bridge'/>"));
goto error;
} else if ((len = xmlStrlen(bridge)) >= (BR_IFNAME_MAXLEN-1)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "TAP bridge path '%s' is too long", bridge);
+ _("TAP bridge path '%s' is too long"), bridge);
goto error;
} else {
strncpy(net->dst.bridge.brname, (char *)bridge, len);
@@ -871,7 +877,7 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
if (ifname != NULL) {
if ((len = xmlStrlen(ifname)) >= (BR_IFNAME_MAXLEN-1)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "TAP interface name '%s' is too long", ifname);
+ _("TAP interface name '%s' is too long"), ifname);
goto error;
} else {
strncpy(net->dst.bridge.ifname, (char *)ifname, len);
@@ -887,13 +893,13 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
if (port == NULL) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "No <source> 'port' attribute specified with socket interface");
+ "%s", _("No <source> 'port' attribute specified with socket interface"));
goto error;
}
if (!(net->dst.socket.port = strtol((char*)port, &ret, 10)) &&
ret == (char*)port) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Cannot parse <source> 'port' attribute with socket interface");
+ "%s", _("Cannot parse <source> 'port' attribute with socket interface"));
goto error;
}
xmlFree(port);
@@ -903,12 +909,12 @@ static int qemudParseInterfaceXML(virConnectPtr conn,
if (net->type == QEMUD_NET_CLIENT ||
net->type == QEMUD_NET_MCAST) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "No <source> 'address' attribute specified with socket interface");
+ "%s", _("No <source> 'address' attribute specified with socket interface"));
goto error;
}
} else if ((len = xmlStrlen(address)) >= (BR_INET_ADDR_MAXLEN)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "IP address '%s' is too long", address);
+ _("IP address '%s' is too long"), address);
goto error;
}
if (address == NULL) {
@@ -950,7 +956,8 @@ static int qemudParseInputXML(virConnectPtr conn,
bus = xmlGetProp(node, BAD_CAST "bus");
if (!type) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "no type provide for input device");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("missing input device type"));
goto error;
}
@@ -959,21 +966,26 @@ static int qemudParseInputXML(virConnectPtr conn,
} else if (!strcmp((const char *)type, "tablet")) {
input->type = QEMU_INPUT_TYPE_TABLET;
} else {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "unsupported input device type %s", (const char*)type);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("unsupported input device type %s"),
+ (const char*)type);
goto error;
}
if (bus) {
if (!strcmp((const char*)bus, "ps2")) { /* Only allow mouse */
if (input->type == QEMU_INPUT_TYPE_TABLET) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "ps2 bus does not support %s input device", (const char*)type);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("ps2 bus does not support %s input device"),
+ (const char*)type);
goto error;
}
input->bus = QEMU_INPUT_BUS_PS2;
} else if (!strcmp((const char *)bus, "usb")) { /* Allow mouse & keyboard */
input->bus = QEMU_INPUT_BUS_USB;
} else {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "unsupported input bus %s", (const char*)bus);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("unsupported input bus %s"), (const char*)bus);
goto error;
}
} else {
@@ -1016,27 +1028,31 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
struct qemud_vm_def *def;
if (!(def = calloc(1, sizeof(*def)))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xmlXPathContext");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for xmlXPathContext"));
return NULL;
}
/* Prepare parser / xpath context */
root = xmlDocGetRootElement(xml);
if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "domain"))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "incorrect root element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("incorrect root element"));
goto error;
}
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xmlXPathContext");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for xmlXPathContext"));
goto error;
}
/* Find out what type of QEMU virtualization to use */
if (!(prop = xmlGetProp(root, BAD_CAST "type"))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "missing domain type attribute");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("missing domain type attribute"));
goto error;
}
@@ -1047,7 +1063,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
else if (!strcmp((char *)prop, "kvm"))
def->virtType = QEMUD_VIRT_KVM;
else {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "invalid domain type attribute");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("invalid domain type attribute"));
goto error;
}
free(prop);
@@ -1062,7 +1079,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
goto error;
}
if (strlen((const char *)obj->stringval) >= (QEMUD_MAX_NAME_LEN-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "domain name length too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("domain name length too long"));
goto error;
}
strcpy(def->name, (const char *)obj->stringval);
@@ -1076,11 +1094,12 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
int err;
if ((err = virUUIDGenerate(def->uuid))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Failed to generate UUID: %s", strerror(err));
+ _("Failed to generate UUID: %s"), strerror(err));
goto error;
}
} else if (virUUIDParse((const char *)obj->stringval, def->uuid) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("malformed uuid element"));
goto error;
}
xmlXPathFreeObject(obj);
@@ -1090,13 +1109,15 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
obj = xmlXPathEval(BAD_CAST "string(/domain/memory[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "missing memory element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("missing memory element"));
goto error;
} else {
conv = NULL;
def->maxmem = strtoll((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed memory information");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("malformed memory information"));
goto error;
}
}
@@ -1114,7 +1135,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
if (def->memory > def->maxmem)
def->memory = def->maxmem;
if (conv == (const char*)obj->stringval) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed memory information");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("malformed memory information"));
goto error;
}
}
@@ -1129,7 +1151,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
conv = NULL;
def->vcpus = strtoll((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed vcpu information");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("malformed vcpu information"));
goto error;
}
}
@@ -1175,11 +1198,13 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
obj = xmlXPathEval(BAD_CAST "string(/domain/os/type[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_OS_TYPE, "no OS type");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_OS_TYPE,
+ "%s", _("no OS type"));
goto error;
}
if (!virCapabilitiesSupportsGuestOSType(driver->caps, (const char*)obj->stringval)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_OS_TYPE, "%s", obj->stringval);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_OS_TYPE,
+ "%s", obj->stringval);
goto error;
}
strcpy(def->os.type, (const char *)obj->stringval);
@@ -1191,17 +1216,20 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
const char *defaultArch = virCapabilitiesDefaultGuestArch(driver->caps, def->os.type);
if (defaultArch == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "unsupported architecture");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("unsupported architecture"));
goto error;
}
if (strlen(defaultArch) >= (QEMUD_OS_TYPE_MAX_LEN-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "architecture type too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("architecture type too long"));
goto error;
}
strcpy(def->os.arch, defaultArch);
} else {
if (strlen((const char *)obj->stringval) >= (QEMUD_OS_TYPE_MAX_LEN-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "architecture type too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("architecture type too long"));
goto error;
}
strcpy(def->os.arch, (const char *)obj->stringval);
@@ -1215,17 +1243,20 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
def->os.type,
def->os.arch);
if (defaultMachine == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "unsupported architecture");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("unsupported architecture"));
goto error;
}
if (strlen(defaultMachine) >= (QEMUD_OS_MACHINE_MAX_LEN-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "machine type too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("machine type too long"));
goto error;
}
strcpy(def->os.machine, defaultMachine);
} else {
if (strlen((const char *)obj->stringval) >= (QEMUD_OS_MACHINE_MAX_LEN-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "architecture type too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("architecture type too long"));
goto error;
}
strcpy(def->os.machine, (const char *)obj->stringval);
@@ -1237,7 +1268,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (strlen((const char *)obj->stringval) >= (PATH_MAX-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "kernel path too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("kernel path too long"));
goto error;
}
strcpy(def->os.kernel, (const char *)obj->stringval);
@@ -1249,7 +1281,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (strlen((const char *)obj->stringval) >= (PATH_MAX-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "initrd path too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("initrd path too long"));
goto error;
}
strcpy(def->os.initrd, (const char *)obj->stringval);
@@ -1261,7 +1294,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (strlen((const char *)obj->stringval) >= (PATH_MAX-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "cmdline arguments too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("cmdline arguments too long"));
goto error;
}
strcpy(def->os.cmdline, (const char *)obj->stringval);
@@ -1286,7 +1320,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
def->os.bootDevs[def->os.nBootDevs++] = QEMUD_BOOT_NET;
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "unknown boot dev \'%s\'", (char*)prop);
+ _("unknown boot device \'%s\'"), (char*)prop);
goto error;
}
xmlFree(prop);
@@ -1311,13 +1345,15 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
def->os.arch,
type);
if (!emulator) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "unsupported guest type");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("unsupported guest type"));
goto error;
}
strcpy(def->os.binary, emulator);
} else {
if (strlen((const char *)obj->stringval) >= (PATH_MAX-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "emulator path too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("emulator path too long"));
goto error;
}
strcpy(def->os.binary, (const char *)obj->stringval);
@@ -1351,7 +1387,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
} else if (!strcmp((char *)prop, "sdl")) {
def->graphicsType = QEMUD_GRAPHICS_SDL;
} else {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Unsupported graphics type %s", prop);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Unsupported graphics type %s"), prop);
goto error;
}
xmlFree(prop);
@@ -1367,7 +1404,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
struct qemud_vm_disk_def *disk = calloc(1, sizeof(*disk));
if (!disk) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "disk");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for disk string"));
goto error;
}
if (qemudParseDiskXML(conn, disk, obj->nodesetval->nodeTab[i]) < 0) {
@@ -1395,7 +1433,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
struct qemud_vm_net_def *net = calloc(1, sizeof(*net));
if (!net) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "net");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for net string"));
goto error;
}
if (qemudParseInterfaceXML(conn, net, obj->nodesetval->nodeTab[i]) < 0) {
@@ -1422,7 +1461,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
struct qemud_vm_input_def *input = calloc(1, sizeof(*input));
if (!input) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "input");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for input string"));
goto error;
}
if (qemudParseInputXML(conn, input, obj->nodesetval->nodeTab[i]) < 0) {
@@ -1462,7 +1502,8 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
if (!hasPS2mouse) {
input = calloc(1, sizeof(*input));
if (!input) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "input");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for input string"));
goto error;
}
input->type = QEMU_INPUT_TYPE_MOUSE;
@@ -1505,11 +1546,13 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
if (net->type == QEMUD_NET_NETWORK) {
if (!(network = qemudFindNetworkByName(driver, net->dst.network.name))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Network '%s' not found", net->dst.network.name);
+ _("Network '%s' not found"),
+ net->dst.network.name);
goto error;
} else if (network->bridge[0] == '\0') {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Network '%s' not active", net->dst.network.name);
+ _("Network '%s' not active"),
+ net->dst.network.name);
goto error;
}
brname = network->bridge;
@@ -1529,20 +1572,21 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
ifname = net->dst.bridge.ifname;
} else {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Network type %d is not supported", net->type);
+ _("Network type %d is not supported"), net->type);
goto error;
}
if (!driver->brctl && (err = brInit(&driver->brctl))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot initialize bridge support: %s", strerror(err));
+ _("cannot initialize bridge support: %s"),
+ strerror(err));
goto error;
}
if ((err = brAddTap(driver->brctl, brname,
ifname, BR_IFNAME_MAXLEN, &tapfd))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Failed to add tap interface '%s' to bridge '%s' : %s",
+ _("Failed to add tap interface '%s' to bridge '%s' : %s"),
ifname, brname, strerror(err));
goto error;
}
@@ -1564,7 +1608,8 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
return retval;
no_memory:
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "tapfds");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for tapfds string"));
error:
free(retval);
if (tapfd != -1)
@@ -1597,7 +1642,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
*/
if (stat(vm->def->os.binary, &sb) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Cannot find QEMU binary %s: %s", vm->def->os.binary,
+ _("Cannot find QEMU binary %s: %s"),
+ vm->def->os.binary,
strerror(errno));
return -1;
}
@@ -1938,7 +1984,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
return 0;
no_memory:
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "argv");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for argv string"));
error:
if (vm->tapfds) {
for (i = 0; vm->tapfds[i] != -1; i++)
@@ -1972,7 +2019,7 @@ static int qemudSaveConfig(virConnectPtr conn,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR )) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot create config file %s: %s",
+ _("cannot create config file %s: %s"),
vm->configFile, strerror(errno));
goto cleanup;
}
@@ -1980,14 +2027,14 @@ static int qemudSaveConfig(virConnectPtr conn,
towrite = strlen(xml);
if (safewrite(fd, xml, towrite) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot write config file %s: %s",
+ _("cannot write config file %s: %s"),
vm->configFile, strerror(errno));
goto cleanup;
}
if (close(fd) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot save config file %s: %s",
+ _("cannot save config file %s: %s"),
vm->configFile, strerror(errno));
goto cleanup;
}
@@ -2021,7 +2068,8 @@ qemudParseVMDeviceDef(virConnectPtr conn,
node = xmlDocGetRootElement(xml);
if (node == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_XML_ERROR, "missing root element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_XML_ERROR,
+ "%s", _("missing root element"));
goto error;
}
if (xmlStrEqual(node->name, BAD_CAST "disk")) {
@@ -2034,7 +2082,8 @@ qemudParseVMDeviceDef(virConnectPtr conn,
dev->type = QEMUD_DEVICE_DISK;
qemudParseInputXML(conn, &(dev->data.input), node);
} else {
- qemudReportError(conn, NULL, NULL, VIR_ERR_XML_ERROR, "unknown device type");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_XML_ERROR,
+ "%s", _("unknown device type"));
goto error;
}
@@ -2093,7 +2142,8 @@ qemudAssignVMDef(virConnectPtr conn,
}
if (!(vm = calloc(1, sizeof(*vm)))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "vm");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for vm string"));
return NULL;
}
@@ -2147,7 +2197,7 @@ qemudSaveVMDef(virConnectPtr conn,
if ((err = virFileMakePath(driver->configDir))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot create config directory %s: %s",
+ _("cannot create config directory %s: %s"),
driver->configDir, strerror(err));
return -1;
}
@@ -2155,14 +2205,14 @@ qemudSaveVMDef(virConnectPtr conn,
if (virFileBuildPath(driver->configDir, def->name, ".xml",
vm->configFile, PATH_MAX) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot construct config file path");
+ "%s", _("cannot construct config file path"));
return -1;
}
if (virFileBuildPath(driver->autostartDir, def->name, ".xml",
vm->autostartLink, PATH_MAX) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot construct autostart link path");
+ "%s", _("cannot construct autostart link path"));
vm->configFile[0] = '\0';
return -1;
}
@@ -2186,7 +2236,7 @@ static int qemudSaveNetworkConfig(virConnectPtr conn,
if ((err = virFileMakePath(driver->networkConfigDir))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot create config directory %s: %s",
+ _("cannot create config directory %s: %s"),
driver->networkConfigDir, strerror(err));
goto cleanup;
}
@@ -2195,7 +2245,7 @@ static int qemudSaveNetworkConfig(virConnectPtr conn,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR )) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot create config file %s: %s",
+ _("cannot create config file %s: %s"),
network->configFile, strerror(errno));
goto cleanup;
}
@@ -2203,14 +2253,14 @@ static int qemudSaveNetworkConfig(virConnectPtr conn,
towrite = strlen(xml);
if (safewrite(fd, xml, towrite) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot write config file %s: %s",
+ _("cannot write config file %s: %s"),
network->configFile, strerror(errno));
goto cleanup;
}
if (close(fd) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot save config file %s: %s",
+ _("cannot save config file %s: %s"),
network->configFile, strerror(errno));
goto cleanup;
}
@@ -2292,7 +2342,8 @@ static int qemudParseDhcpRangesXML(virConnectPtr conn,
}
if (!(range = calloc(1, sizeof(*range)))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "range");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for range string"));
return 0;
}
@@ -2384,20 +2435,23 @@ static struct qemud_network_def *qemudParseNetworkXML(virConnectPtr conn,
struct qemud_network_def *def;
if (!(def = calloc(1, sizeof(*def)))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "network_def");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for network_def string"));
return NULL;
}
/* Prepare parser / xpath context */
root = xmlDocGetRootElement(xml);
if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "network"))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "incorrect root element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("incorrect root element"));
goto error;
}
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xmlXPathContext");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for xmlXPathContext string"));
goto error;
}
@@ -2410,7 +2464,8 @@ static struct qemud_network_def *qemudParseNetworkXML(virConnectPtr conn,
goto error;
}
if (strlen((const char *)obj->stringval) >= (QEMUD_MAX_NAME_LEN-1)) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "network name length too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("network name length too long"));
goto error;
}
strcpy(def->name, (const char *)obj->stringval);
@@ -2424,11 +2479,12 @@ static struct qemud_network_def *qemudParseNetworkXML(virConnectPtr conn,
int err;
if ((err = virUUIDGenerate(def->uuid))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Failed to generate UUID: %s", strerror(err));
+ _("Failed to generate UUID: %s"), strerror(err));
goto error;
}
} else if (virUUIDParse((const char *)obj->stringval, def->uuid) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("malformed uuid element"));
goto error;
}
xmlXPathFreeObject(obj);
@@ -2460,7 +2516,7 @@ static struct qemud_network_def *qemudParseNetworkXML(virConnectPtr conn,
if (!def->ipAddress[0] ||
!def->netmask[0]) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Forwarding requested, but no IPv4 address/netmask provided");
+ "%s", _("Forwarding requested, but no IPv4 address/netmask provided"));
goto error;
}
@@ -2471,7 +2527,7 @@ static struct qemud_network_def *qemudParseNetworkXML(virConnectPtr conn,
int len;
if ((len = xmlStrlen(tmp->stringval)) >= (BR_IFNAME_MAXLEN-1)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "forward device name '%s' is too long",
+ _("forward device name '%s' is too long"),
(char*)tmp->stringval);
goto error;
}
@@ -2542,7 +2598,8 @@ qemudAssignNetworkDef(virConnectPtr conn,
}
if (!(network = calloc(1, sizeof(*network)))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "network");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for network string"));
return NULL;
}
@@ -2590,7 +2647,7 @@ qemudSaveNetworkDef(virConnectPtr conn,
if ((err = virFileMakePath(driver->networkConfigDir))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot create config directory %s: %s",
+ _("cannot create config directory %s: %s"),
driver->networkConfigDir, strerror(err));
return -1;
}
@@ -2598,14 +2655,14 @@ qemudSaveNetworkDef(virConnectPtr conn,
if (virFileBuildPath(driver->networkConfigDir, def->name, ".xml",
network->configFile, PATH_MAX) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot construct config file path");
+ "%s", _("cannot construct config file path"));
return -1;
}
if (virFileBuildPath(driver->networkAutostartDir, def->name, ".xml",
network->autostartLink, PATH_MAX) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot construct autostart link path");
+ "%s", _("cannot construct autostart link path"));
network->configFile[0] = '\0';
return -1;
}
@@ -2801,7 +2858,8 @@ char *qemudGenerateXML(virConnectPtr conn,
break;
}
if (!type) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "unexpected domain type %d", def->virtType);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("unexpected domain type %d"), def->virtType);
goto cleanup;
}
@@ -3069,7 +3127,8 @@ char *qemudGenerateXML(virConnectPtr conn,
return virBufferContentAndFree (buf);
no_memory:
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xml");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to generate XML: out of memory"));
cleanup:
if (buf) virBufferFree (buf);
return NULL;
@@ -3160,7 +3219,8 @@ char *qemudGenerateNetworkXML(virConnectPtr conn,
return virBufferContentAndFree (buf);
no_memory:
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xml");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to generate XML: out of memory"));
if (buf) virBufferFree (buf);
return NULL;
}
@@ -3171,12 +3231,14 @@ int qemudDeleteConfig(virConnectPtr conn,
const char *configFile,
const char *name) {
if (!configFile[0]) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "no config file for %s", name);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("no config file for %s"), name);
return -1;
}
if (unlink(configFile) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot remove config for %s", name);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("cannot remove config for %s"), name);
return -1;
}
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 34abe14..d68f079 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -916,7 +916,8 @@ qemudBuildDnsmasqArgv(virConnectPtr conn,
free((*argv)[i]);
free(*argv);
}
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "dnsmasq argv");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for dnsmasq argv"));
return -1;
}
@@ -954,7 +955,8 @@ qemudAddIptablesRules(virConnectPtr conn,
int err;
if (!driver->iptables && !(driver->iptables = iptablesContextNew())) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "iptables support");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for IP tables support"));
return 1;
}
@@ -1492,7 +1494,8 @@ static char *qemudGetCapabilities(virConnectPtr conn) {
char *xml;
if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "capabilities");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for capabilities support"));
return NULL;
}
@@ -1764,7 +1767,8 @@ static char *qemudDomainGetOSType(virDomainPtr dom) {
}
if (!(type = strdup(vm->def->os.type))) {
- qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_MEMORY, "ostype");
+ qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for ostype"));
return NULL;
}
return type;
@@ -2194,7 +2198,8 @@ static int qemudListDefinedDomains(virConnectPtr conn,
while (vm && got < nnames) {
if (!qemudIsActiveVM(vm)) {
if (!(names[got] = strdup(vm->def->name))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "names");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for VM name string"));
goto cleanup;
}
got++;
@@ -2706,7 +2711,8 @@ static int qemudListNetworks(virConnectPtr conn, char **const names, int nnames)
while (network && got < nnames) {
if (qemudIsActiveNetwork(network)) {
if (!(names[got] = strdup(network->def->name))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "names");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for VM name string"));
goto cleanup;
}
got++;
@@ -2733,7 +2739,8 @@ static int qemudListDefinedNetworks(virConnectPtr conn, char **const names, int
while (network && got < nnames) {
if (!qemudIsActiveNetwork(network)) {
if (!(names[got] = strdup(network->def->name))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "names");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for VM name string"));
goto cleanup;
}
got++;
@@ -2866,13 +2873,15 @@ static char *qemudNetworkGetBridgeName(virNetworkPtr net) {
struct qemud_network *network = qemudFindNetworkByUUID(driver, net->uuid);
char *bridge;
if (!network) {
- qemudReportError(net->conn, NULL, net, VIR_ERR_INVALID_NETWORK, "no network with matching id");
+ qemudReportError(net->conn, NULL, net, VIR_ERR_INVALID_NETWORK,
+ "%s", _("no network with matching id"));
return NULL;
}
bridge = strdup(network->bridge);
if (!bridge) {
- qemudReportError(net->conn, NULL, net, VIR_ERR_NO_MEMORY, "bridge");
+ qemudReportError(net->conn, NULL, net, VIR_ERR_NO_MEMORY,
+ "%s", _("failed to allocate space for network bridge string"));
return NULL;
}
return bridge;
--
1.5.5.rc0.22.g467c
16 years, 8 months
[Libvir] [PATCH 8/9] testError: mark most string arguments for translation
by Jim Meyering
testError: mark most string arguments for translation
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 5 +++--
src/test.c | 30 +++++++++++++++---------------
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 55a9677..518e59b 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -317,9 +317,10 @@ msg_gen_function += ReportError
msg_gen_function += qemudReportError
msg_gen_function += openvzLog
-# Uncomment this after adjusting remaining diagnostics to be translatable.
+# Uncomment the following and run "make syntax-check" to see diagnostics
+# that are not yet marked for translation, but that need to be rewritten
+# so that they are translatable.
# msg_gen_function += error
-
# msg_gen_function += virXenError
# msg_gen_function += testError
diff --git a/src/test.c b/src/test.c
index f401d7d..6cf3fda 100644
--- a/src/test.c
+++ b/src/test.c
@@ -1307,31 +1307,31 @@ static int testDomainSave(virDomainPtr domain,
xml = testDomainDumpXML(domain, 0);
if (xml == NULL) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot allocate space for metadata");
+ _("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,
- "cannot save domain");
+ _("cannot save domain"));
return (-1);
}
len = strlen(xml);
if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot write header");
+ _("cannot write header"));
close(fd);
return (-1);
}
if (safewrite(fd, (char*)&len, sizeof(len)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot write metadata length");
+ _("cannot write metadata length"));
close(fd);
return (-1);
}
if (safewrite(fd, xml, len) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot write metadata");
+ _("cannot write metadata"));
free(xml);
close(fd);
return (-1);
@@ -1339,7 +1339,7 @@ static int testDomainSave(virDomainPtr domain,
free(xml);
if (close(fd) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot save domain data");
+ _("cannot save domain data"));
close(fd);
return (-1);
}
@@ -1363,30 +1363,30 @@ static int testDomainRestore(virConnectPtr conn,
if ((fd = open(path, O_RDONLY)) < 0) {
testError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot read domain image");
+ _("cannot read domain image"));
return (-1);
}
if (read(fd, magic, sizeof(magic)) != sizeof(magic)) {
testError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "incomplete save header");
+ _("incomplete save header"));
close(fd);
return (-1);
}
if (memcmp(magic, TEST_SAVE_MAGIC, sizeof(magic))) {
testError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "mismatched header magic");
+ _("mismatched header magic"));
close(fd);
return (-1);
}
if (read(fd, (char*)&len, sizeof(len)) != sizeof(len)) {
testError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "failed to read metadata length");
+ _("failed to read metadata length"));
close(fd);
return (-1);
}
if (len < 1 || len > 8192) {
testError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "length of metadata out of range");
+ _("length of metadata out of range"));
close(fd);
return (-1);
}
@@ -1398,7 +1398,7 @@ static int testDomainRestore(virConnectPtr conn,
}
if (read(fd, xml, len) != len) {
testError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "incomplete metdata");
+ _("incomplete metdata"));
close(fd);
return (-1);
}
@@ -1419,18 +1419,18 @@ static int testDomainCoreDump(virDomainPtr domain,
if ((fd = open(to, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot save domain core");
+ _("cannot save domain core"));
return (-1);
}
if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot write header");
+ _("cannot write header"));
close(fd);
return (-1);
}
if (close(fd) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
- "cannot save domain data");
+ _("cannot save domain data"));
close(fd);
return (-1);
}
--
1.5.5.rc0.22.g467c
16 years, 8 months
[Libvir] [PATCH 9/9] lxcError: mark a string and add to the list of nearly-checked functions
by Jim Meyering
lxcError: mark a string and add to the list of nearly-checked functions
* Makefile.maint (msg_gen_function): Add, but commented-out.
* src/lxc_conf.c (lxcParseXML): Mark a diagnostic for translation.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 1 +
src/lxc_conf.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 518e59b..a357d74 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -323,6 +323,7 @@ msg_gen_function += openvzLog
# msg_gen_function += error
# msg_gen_function += virXenError
# msg_gen_function += testError
+# msg_gen_function += lxcError
func_or := $(shell printf '$(msg_gen_function)'|tr -s '[[:space:]]' '|')
func_re := ($(func_or))
diff --git a/src/lxc_conf.c b/src/lxc_conf.c
index e0896ec..3923807 100644
--- a/src/lxc_conf.c
+++ b/src/lxc_conf.c
@@ -398,7 +398,7 @@ static lxc_vm_def_t * lxcParseXML(virConnectPtr conn, xmlDocPtr docPtr)
if ((xmlProp = xmlGetProp(rootNodePtr, BAD_CAST "id"))) {
if (0 > virStrToLong_i((char*)xmlProp, NULL, 10, &(containerDef->id))) {
lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
- "invalid domain id");
+ _("invalid domain id"));
goto error;
}
} else {
--
1.5.5.rc0.22.g467c
16 years, 8 months
[Libvir] [PATCH 7/9] openvzLog: mark its string arguments for translation
by Jim Meyering
openvzLog: mark its string arguments for translation
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 2 +-
src/openvz_conf.c | 35 ++++++++++++++++++++++-------------
src/openvz_driver.c | 25 +++++++++++++------------
3 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index fce59b4..55a9677 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -315,13 +315,13 @@ msg_gen_function += virStorageLog
msg_gen_function += xenXMError
msg_gen_function += ReportError
msg_gen_function += qemudReportError
+msg_gen_function += openvzLog
# Uncomment this after adjusting remaining diagnostics to be translatable.
# msg_gen_function += error
# msg_gen_function += virXenError
# msg_gen_function += testError
-# msg_gen_function += openvzLog
func_or := $(shell printf '$(msg_gen_function)'|tr -s '[[:space:]]' '|')
func_re := ($(func_or))
diff --git a/src/openvz_conf.c b/src/openvz_conf.c
index 4a2b037..65344c5 100644
--- a/src/openvz_conf.c
+++ b/src/openvz_conf.c
@@ -237,8 +237,9 @@ openvzAssignVMDef(virConnectPtr conn,
}
else
{
- openvzLog(OPENVZ_ERR, "Error already an active OPENVZ VM having id '%s'",
- def->name);
+ openvzLog(OPENVZ_ERR,
+ _("Error already an active OPENVZ VM having id '%s'"),
+ def->name);
openvzFreeVMDef(def);
return NULL; /* can't redefine an active domain */
}
@@ -383,8 +384,9 @@ static struct openvz_vm_def
obj = xmlXPathEval(BAD_CAST"string(/domain/container/network/ipaddress[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL)
|| (obj->stringval[0] == 0)) {
- openvzLog(OPENVZ_WARN, "No IP address in the given xml config file '%s'",
- xml->name);
+ openvzLog(OPENVZ_WARN,
+ _("No IP address in the given xml config file '%s'"),
+ xml->name);
}
if (xmlStrlen(obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
@@ -395,7 +397,8 @@ static struct openvz_vm_def
goto bail_out;
}
if (!(ovzIp = calloc(1, sizeof(*ovzIp)))) {
- openvzLog(OPENVZ_ERR, "Failed to Create Memory for 'ovz_ip' structure");
+ openvzLog(OPENVZ_ERR,
+ _("Failed to Create Memory for 'ovz_ip' structure"));
goto bail_out;
}
strncpy(ovzIp->ip, (const char *) obj->stringval, OPENVZ_IP_MAX);
@@ -406,8 +409,9 @@ static struct openvz_vm_def
obj = xmlXPathEval(BAD_CAST "string(/domain/container/network/netmask[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING)
|| (obj->stringval == NULL) || (obj->stringval[0] == 0))
- openvzLog(OPENVZ_WARN, "No Netmask address in the given xml config file '%s'",
- xml->name);
+ openvzLog(OPENVZ_WARN,
+ _("No Netmask address in the given xml config file '%s'"),
+ xml->name);
if (strlen((const char *) obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
@@ -424,7 +428,9 @@ static struct openvz_vm_def
obj = xmlXPathEval(BAD_CAST "string(/domain/container/network/hostname[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL)
|| (obj->stringval[0] == 0))
- openvzLog(OPENVZ_WARN, "No hostname in the given xml config file '%s'", xml->name);
+ openvzLog(OPENVZ_WARN,
+ _("No hostname in the given xml config file '%s'"),
+ xml->name);
if (strlen((const char *) obj->stringval) >= (OPENVZ_HOSTNAME_MAX - 1)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
@@ -441,8 +447,9 @@ static struct openvz_vm_def
obj = xmlXPathEval(BAD_CAST"string(/domain/container/network/gateway[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL)
|| (obj->stringval[0] == 0))
- openvzLog(OPENVZ_WARN, "No Gateway address in the given xml config file '%s'",
- xml->name);
+ openvzLog(OPENVZ_WARN,
+ _("No Gateway address in the given xml config file '%s'"),
+ xml->name);
if (strlen((const char *) obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
@@ -459,8 +466,9 @@ static struct openvz_vm_def
obj = xmlXPathEval(BAD_CAST "string(/domain/container/network/nameserver[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) || (obj->stringval == NULL)
|| (obj->stringval[0] == 0))
- openvzLog(OPENVZ_WARN, "No Nameserver address inthe given xml config file '%s'",
- xml->name);
+ openvzLog(OPENVZ_WARN,
+ _("No Nameserver address inthe given xml config file '%s'"),
+ xml->name);
if (strlen((const char *) obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
@@ -471,7 +479,8 @@ static struct openvz_vm_def
goto bail_out;
}
if (!(ovzNs = calloc(1, sizeof(*ovzNs)))) {
- openvzLog(OPENVZ_ERR, "Failed to Create Memory for 'ovz_ns' structure");
+ openvzLog(OPENVZ_ERR,
+ _("Failed to Create Memory for 'ovz_ns' structure"));
goto bail_out;
}
strncpy(ovzNs->ip, (const char *) obj->stringval, OPENVZ_IP_MAX);
diff --git a/src/openvz_driver.c b/src/openvz_driver.c
index 0e94d02..1db3c60 100644
--- a/src/openvz_driver.c
+++ b/src/openvz_driver.c
@@ -253,7 +253,7 @@ static int openvzDomainShutdown(virDomainPtr dom) {
if((ret = convCmdbufExec(cmdbuf, cmdExec)) == -1)
{
- openvzLog(OPENVZ_ERR, "Error in parsing Options to OPENVZ");
+ openvzLog(OPENVZ_ERR, "%s", _("Error in parsing Options to OPENVZ"));
goto bail_out;
}
@@ -298,7 +298,7 @@ static int openvzDomainReboot(virDomainPtr dom,
if((ret = convCmdbufExec(cmdbuf, cmdExec)) == -1)
{
- openvzLog(OPENVZ_ERR, "Error in parsing Options to OPENVZ");
+ openvzLog(OPENVZ_ERR, "%s", _("Error in parsing Options to OPENVZ"));
goto bail_out1;
}
ret = virExec(dom->conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
@@ -328,13 +328,13 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
vm = openvzFindVMByID(driver, strtoI(vmdef->name));
if (vm) {
- openvzLog(OPENVZ_ERR, "Already an OPENVZ VM active with the id '%s'",
- vmdef->name);
+ openvzLog(OPENVZ_ERR, _("Already an OPENVZ VM active with the id '%s'"),
+ vmdef->name);
goto bail_out2;
}
if (!(vm = openvzAssignVMDef(conn, driver, vmdef))) {
openvzFreeVMDef(vmdef);
- openvzLog(OPENVZ_ERR, "Error creating OPENVZ VM");
+ openvzLog(OPENVZ_ERR, "%s", _("Error creating OPENVZ VM"));
}
snprintf(cmdbuf, CMDBUF_LEN - 1, VZCTL " create %s", vmdef->name);
@@ -357,7 +357,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
if((ret = convCmdbufExec(cmdbuf, cmdExec)) == -1)
{
- openvzLog(OPENVZ_ERR, "Error in parsing Options to OPENVZ");
+ openvzLog(OPENVZ_ERR, "%s", _("Error in parsing Options to OPENVZ"));
goto bail_out2;
}
ret = virExec(conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
@@ -395,12 +395,13 @@ openvzDomainCreateLinux(virConnectPtr conn, const char *xml,
vm = openvzFindVMByID(driver, strtoI(vmdef->name));
if (vm) {
openvzFreeVMDef(vmdef);
- openvzLog(OPENVZ_ERR, "Already an OPENVZ VM defined with the id '%d'",
+ openvzLog(OPENVZ_ERR,
+ _("Already an OPENVZ VM defined with the id '%d'"),
strtoI(vmdef->name));
return NULL;
}
if (!(vm = openvzAssignVMDef(conn, driver, vmdef))) {
- openvzLog(OPENVZ_ERR, "Error creating OPENVZ VM");
+ openvzLog(OPENVZ_ERR, "%s", _("Error creating OPENVZ VM"));
return NULL;
}
@@ -424,7 +425,7 @@ openvzDomainCreateLinux(virConnectPtr conn, const char *xml,
if((ret = convCmdbufExec(cmdbuf, cmdExec)) == -1)
{
- openvzLog(OPENVZ_ERR, "Error in parsing Options to OPENVZ");
+ openvzLog(OPENVZ_ERR, "%s", _("Error in parsing Options to OPENVZ"));
goto bail_out3;
}
ret = virExec(conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
@@ -440,7 +441,7 @@ openvzDomainCreateLinux(virConnectPtr conn, const char *xml,
if((ret = convCmdbufExec(cmdbuf, cmdExec)) == -1)
{
- openvzLog(OPENVZ_ERR, "Error in parsing Options to OPENVZ");
+ openvzLog(OPENVZ_ERR, "%s", _("Error in parsing Options to OPENVZ"));
goto bail_out3;
}
ret = virExec(conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
@@ -494,7 +495,7 @@ openvzDomainCreate(virDomainPtr dom)
if((ret = convCmdbufExec(cmdbuf, cmdExec)) == -1)
{
- openvzLog(OPENVZ_ERR, "Error in parsing Options to OPENVZ");
+ openvzLog(OPENVZ_ERR, "%s", _("Error in parsing Options to OPENVZ"));
goto bail_out4;
}
ret = virExec(dom->conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
@@ -537,7 +538,7 @@ openvzDomainUndefine(virDomainPtr dom)
if((ret = convCmdbufExec(cmdbuf, cmdExec)) == -1)
{
- openvzLog(OPENVZ_ERR, "Error in parsing Options to OPENVZ");
+ openvzLog(OPENVZ_ERR, "%s", _("Error in parsing Options to OPENVZ"));
goto bail_out5;
}
ret = virExec(conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
--
1.5.5.rc0.22.g467c
16 years, 8 months
[Libvir] [PATCH 6/9] error: mark most string arguments for translation
by Jim Meyering
error: mark most string arguments for translation
Also mark some arguments to __virRaiseError.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 4 +-
po/POTFILES.in | 2 +
src/openvz_conf.c | 42 +++++++++++--------
src/openvz_driver.c | 31 +++++++++-----
src/remote_internal.c | 108 ++++++++++++++++++++++++++++---------------------
5 files changed, 110 insertions(+), 77 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index 6e4868e..fce59b4 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -316,10 +316,12 @@ msg_gen_function += xenXMError
msg_gen_function += ReportError
msg_gen_function += qemudReportError
+# Uncomment this after adjusting remaining diagnostics to be translatable.
+# msg_gen_function += error
+
# msg_gen_function += virXenError
# msg_gen_function += testError
# msg_gen_function += openvzLog
-# msg_gen_function += error
func_or := $(shell printf '$(msg_gen_function)'|tr -s '[[:space:]]' '|')
func_re := ($(func_or))
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 54cb077..dfdb583 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -8,6 +8,8 @@ src/iptables.c
src/libvirt.c
src/lxc_conf.c
src/lxc_driver.c
+src/openvz_conf.c
+src/openvz_driver.c
src/proxy_internal.c
src/qemu_conf.c
src/qemu_driver.c
diff --git a/src/openvz_conf.c b/src/openvz_conf.c
index 364cb25..4a2b037 100644
--- a/src/openvz_conf.c
+++ b/src/openvz_conf.c
@@ -307,7 +307,7 @@ static struct openvz_vm_def
root = xmlDocGetRootElement(xml);
if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "domain"))) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "incorrect root element");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("incorrect root element"));
goto bail_out;
}
@@ -319,12 +319,12 @@ static struct openvz_vm_def
/* Find out what type of OPENVZ virtualization to use */
if (!(prop = xmlGetProp(root, BAD_CAST "type"))) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "missing domain type attribute");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("missing domain type attribute"));
goto bail_out;
}
if (strcmp((char *)prop, "openvz")){
- error(conn, VIR_ERR_INTERNAL_ERROR, "invalid domain type attribute");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("invalid domain type attribute"_));
goto bail_out;
}
free(prop);
@@ -334,14 +334,14 @@ static struct openvz_vm_def
obj = xmlXPathEval(BAD_CAST "string(/domain/name[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
- error(conn, VIR_ERR_INTERNAL_ERROR,"invalid domain name");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("invalid domain name"));
goto bail_out;
}
/* rejecting VPS ID <= OPENVZ_RSRV_VM_LIMIT for they are reserved */
if (strtoI((const char *) obj->stringval) <= OPENVZ_RSRV_VM_LIMIT) {
error(conn, VIR_ERR_INTERNAL_ERROR,
- "VPS ID Error (must be an integer greater than 100");
+ _("VPS ID Error (must be an integer greater than 100"));
goto bail_out;
}
strncpy(def->name, (const char *) obj->stringval, OPENVZ_NAME_MAX);
@@ -354,11 +354,11 @@ static struct openvz_vm_def
int err;
if ((err = virUUIDGenerate(def->uuid))) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "Failed to generate UUID");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to generate UUID"));
goto bail_out;
}
} else if (virUUIDParse((const char *)obj->stringval, def->uuid) < 0) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "malformed uuid element");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("malformed uuid element"));
goto bail_out;
}
xmlXPathFreeObject(obj);
@@ -389,7 +389,8 @@ static struct openvz_vm_def
if (xmlStrlen(obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
- snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s", "ipaddress length too long");
+ snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s",
+ _("ipaddress length too long"));
error(conn, VIR_ERR_INTERNAL_ERROR, errorMessage);
goto bail_out;
}
@@ -411,7 +412,8 @@ static struct openvz_vm_def
if (strlen((const char *) obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
- snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s", "netmask length too long");
+ snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s",
+ _("netmask length too long"));
error(conn, VIR_ERR_INTERNAL_ERROR, errorMessage);
goto bail_out;
}
@@ -427,7 +429,8 @@ static struct openvz_vm_def
if (strlen((const char *) obj->stringval) >= (OPENVZ_HOSTNAME_MAX - 1)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
- snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s", "hostname length too long");
+ snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1,
+ "%s", _("hostname length too long"));
error(conn, VIR_ERR_INTERNAL_ERROR, errorMessage);
goto bail_out;
}
@@ -444,7 +447,8 @@ static struct openvz_vm_def
if (strlen((const char *) obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
- snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s", "gateway length too long");
+ snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1,
+ "%s", _("gateway length too long"));
error(conn, VIR_ERR_INTERNAL_ERROR, errorMessage);
goto bail_out;
}
@@ -461,7 +465,8 @@ static struct openvz_vm_def
if (strlen((const char *) obj->stringval) >= (OPENVZ_IP_MAX)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
- snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s", "nameserver length too long");
+ snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1,
+ "%s", _("nameserver length too long"));
error(conn, VIR_ERR_INTERNAL_ERROR, errorMessage);
goto bail_out;
}
@@ -483,7 +488,8 @@ static struct openvz_vm_def
if (strlen((const char *) obj->stringval) >= (OPENVZ_PROFILE_MAX - 1)) {
char errorMessage[OPENVZ_MAX_ERROR_LEN];
- snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1, "%s", "profile length too long");
+ snprintf(errorMessage, OPENVZ_MAX_ERROR_LEN - 1,
+ "%s", _("profile length too long"));
error(conn, VIR_ERR_INTERNAL_ERROR, errorMessage);
goto bail_out;
}
@@ -519,14 +525,14 @@ openvzGetVPSInfo(virConnectPtr conn) {
driver->num_inactive = 0;
if((fp = popen(VZLIST " -a -ovpsid,status -H 2>/dev/null", "r")) == NULL) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "popen failed");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("popen failed"));
return NULL;
}
pnext = &vm;
while(!feof(fp)) {
*pnext = calloc(1, sizeof(**pnext));
if(!*pnext) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "calloc failed");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("calloc failed"));
goto error;
}
@@ -535,7 +541,7 @@ openvzGetVPSInfo(virConnectPtr conn) {
if (fscanf(fp, "%d %s\n", &veid, status) != 2) {
error(conn, VIR_ERR_INTERNAL_ERROR,
- "Failed to parse vzlist output");
+ _("Failed to parse vzlist output"));
goto error;
}
if(strcmp(status, "stopped")) {
@@ -555,7 +561,7 @@ openvzGetVPSInfo(virConnectPtr conn) {
vmdef = calloc(1, sizeof(*vmdef));
if(!vmdef) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "calloc failed");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("calloc failed"));
goto error;
}
@@ -565,7 +571,7 @@ openvzGetVPSInfo(virConnectPtr conn) {
if(ret == -1) {
error(conn, VIR_ERR_INTERNAL_ERROR,
- "UUID in config file malformed");
+ _("UUID in config file malformed"));
free(vmdef);
goto error;
}
diff --git a/src/openvz_driver.c b/src/openvz_driver.c
index 29cb244..0e94d02 100644
--- a/src/openvz_driver.c
+++ b/src/openvz_driver.c
@@ -146,7 +146,7 @@ static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
virDomainPtr dom;
if (!vm) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "no domain with matching id");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("no domain with matching id"));
return NULL;
}
@@ -174,7 +174,7 @@ static virDomainPtr openvzDomainLookupByUUID(virConnectPtr conn,
virDomainPtr dom;
if (!vm) {
- error(conn, VIR_ERR_INVALID_DOMAIN, "no domain with matching uuid");
+ error(conn, VIR_ERR_INVALID_DOMAIN, _("no domain with matching uuid"));
return NULL;
}
@@ -195,7 +195,7 @@ static virDomainPtr openvzDomainLookupByName(virConnectPtr conn,
virDomainPtr dom;
if (!vm) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "no domain with matching name");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("no domain with matching name"));
return NULL;
}
@@ -215,7 +215,8 @@ static int openvzDomainGetInfo(virDomainPtr dom,
struct openvz_vm *vm = openvzFindVMByUUID(driver, dom->uuid);
if (!vm) {
- error(dom->conn, VIR_ERR_INVALID_DOMAIN, "no domain with matching uuid");
+ error(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ _("no domain with matching uuid"));
return -1;
}
@@ -238,12 +239,14 @@ static int openvzDomainShutdown(virDomainPtr dom) {
struct openvz_vm *vm = openvzFindVMByID(driver, dom->id);
if (!vm) {
- error(dom->conn, VIR_ERR_INVALID_DOMAIN, "no domain with matching id");
+ error(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ _("no domain with matching id"));
return -1;
}
if (vm->status != VIR_DOMAIN_RUNNING) {
- error(dom->conn, VIR_ERR_OPERATION_DENIED, "domain is not in running state");
+ error(dom->conn, VIR_ERR_OPERATION_DENIED,
+ _("domain is not in running state"));
return -1;
}
snprintf(cmdbuf, CMDBUF_LEN - 1, VZCTL " stop %d ", dom->id);
@@ -281,12 +284,14 @@ static int openvzDomainReboot(virDomainPtr dom,
struct openvz_vm *vm = openvzFindVMByID(driver, dom->id);
if (!vm) {
- error(dom->conn, VIR_ERR_INVALID_DOMAIN, "no domain with matching id");
+ error(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ _("no domain with matching id"));
return -1;
}
if (vm->status != VIR_DOMAIN_RUNNING) {
- error(dom->conn, VIR_ERR_OPERATION_DENIED, "domain is not in running state");
+ error(dom->conn, VIR_ERR_OPERATION_DENIED,
+ _("domain is not in running state"));
return -1;
}
snprintf(cmdbuf, CMDBUF_LEN - 1, VZCTL " restart %d ", dom->id);
@@ -473,12 +478,14 @@ openvzDomainCreate(virDomainPtr dom)
struct openvz_vm_def *vmdef;
if (!vm) {
- error(dom->conn, VIR_ERR_INVALID_DOMAIN, "no domain with matching id");
+ error(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ _("no domain with matching id"));
return -1;
}
if (vm->status != VIR_DOMAIN_SHUTOFF) {
- error(dom->conn, VIR_ERR_OPERATION_DENIED, "domain is not in shutoff state");
+ error(dom->conn, VIR_ERR_OPERATION_DENIED,
+ _("domain is not in shutoff state"));
return -1;
}
@@ -518,12 +525,12 @@ openvzDomainUndefine(virDomainPtr dom)
struct openvz_vm *vm = openvzFindVMByUUID(driver, dom->uuid);
if (!vm) {
- error(conn, VIR_ERR_INVALID_DOMAIN, "no domain with matching uuid");
+ error(conn, VIR_ERR_INVALID_DOMAIN, _("no domain with matching uuid"));
return -1;
}
if (openvzIsActiveVM(vm)) {
- error(conn, VIR_ERR_INTERNAL_ERROR, "cannot delete active domain");
+ error(conn, VIR_ERR_INTERNAL_ERROR, _("cannot delete active domain"));
return -1;
}
snprintf(cmdbuf, CMDBUF_LEN - 1, VZCTL " destroy %s ", vm->vmdef->name);
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 8d2d9e5..be4c573 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -879,7 +879,7 @@ check_cert_file (virConnectPtr conn, const char *type, const char *file)
if (stat(file, &sb) < 0) {
__virRaiseError (conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC,
VIR_ERR_ERROR, LIBVIRT_CACERT, NULL, NULL, 0, 0,
- "Cannot access %s '%s': %s (%d)",
+ _("Cannot access %s '%s': %s (%d)"),
type, file, strerror(errno), errno);
return -1;
}
@@ -1018,7 +1018,7 @@ negotiate_gnutls_on_connection (virConnectPtr conn,
}
if (len != 1 || buf[0] != '\1') {
error (conn, VIR_ERR_RPC,
- "server verification (of our certificate or IP address) failed\n");
+ _("server verification (of our certificate or IP address) failed\n"));
return NULL;
}
@@ -1117,7 +1117,7 @@ verify_certificate (virConnectPtr conn ATTRIBUTE_UNUSED,
VIR_FROM_REMOTE, VIR_ERR_RPC,
VIR_ERR_ERROR, priv->hostname, NULL, NULL,
0, 0,
- "Certificate's owner does not match the hostname (%s)",
+ _("Certificate's owner does not match the hostname (%s)"),
priv->hostname);
gnutls_x509_crt_deinit (cert);
return -1;
@@ -3473,8 +3473,9 @@ remoteAuthenticate (virConnectPtr conn, struct private_data *priv, int in_open,
want = REMOTE_AUTH_POLKIT;
} else {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
- VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "unknown authentication type %s", authtype);
+ VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR,
+ NULL, NULL, NULL, 0, 0,
+ _("unknown authentication type %s"), authtype);
return -1;
}
for (i = 0 ; i < ret.types.types_len ; i++) {
@@ -3484,7 +3485,8 @@ remoteAuthenticate (virConnectPtr conn, struct private_data *priv, int in_open,
if (type == REMOTE_AUTH_NONE) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "requested authentication type %s rejected", authtype);
+ _("requested authentication type %s rejected"),
+ authtype);
return -1;
}
} else {
@@ -3522,8 +3524,10 @@ remoteAuthenticate (virConnectPtr conn, struct private_data *priv, int in_open,
default:
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
- VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "unsupported authentication type %d", ret.types.types_val[0]);
+ VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR,
+ NULL, NULL, NULL, 0, 0,
+ _("unsupported authentication type %d"),
+ ret.types.types_val[0]);
free(ret.types.types_val);
return -1;
}
@@ -3550,15 +3554,18 @@ static char *addrToString(struct sockaddr_storage *sa, socklen_t salen)
port, sizeof(port),
NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
__virRaiseError (NULL, NULL, NULL, VIR_FROM_REMOTE,
- VIR_ERR_NO_MEMORY, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "Cannot resolve address %d: %s", err, gai_strerror(err));
+ VIR_ERR_NO_MEMORY, VIR_ERR_ERROR,
+ NULL, NULL, NULL, 0, 0,
+ _("Cannot resolve address %d: %s"),
+ err, gai_strerror(err));
return NULL;
}
addr = malloc(strlen(host) + 1 + strlen(port) + 1);
if (!addr) {
__virRaiseError (NULL, NULL, NULL, VIR_FROM_REMOTE,
- VIR_ERR_NO_MEMORY, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
+ VIR_ERR_NO_MEMORY, VIR_ERR_ERROR,
+ NULL, NULL, NULL, 0, 0,
"address");
return NULL;
}
@@ -3769,7 +3776,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (err != SASL_OK) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "failed to initialize SASL library: %d (%s)",
+ _("failed to initialize SASL library: %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
@@ -3779,7 +3786,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (getsockname(priv->sock, (struct sockaddr*)&sa, &salen) < 0) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "failed to get sock address %d (%s)",
+ _("failed to get sock address %d (%s)"),
socket_errno (), strerror(socket_errno ()));
goto cleanup;
}
@@ -3791,7 +3798,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (getpeername(priv->sock, (struct sockaddr*)&sa, &salen) < 0) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "failed to get peer address %d (%s)",
+ _("failed to get peer address %d (%s)"),
socket_errno (), strerror(socket_errno ()));
goto cleanup;
}
@@ -3817,7 +3824,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (err != SASL_OK) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "Failed to create SASL client context: %d (%s)",
+ _("Failed to create SASL client context: %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
@@ -3830,7 +3837,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "invalid cipher size for TLS session");
+ "%s", _("invalid cipher size for TLS session"));
goto cleanup;
}
ssf *= 8; /* key size is bytes, sasl wants bits */
@@ -3840,7 +3847,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (err != SASL_OK) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "cannot set external SSF %d (%s)",
+ _("cannot set external SSF %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
@@ -3859,7 +3866,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (err != SASL_OK) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "cannot set security props %d (%s)",
+ _("cannot set security props %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
@@ -3876,8 +3883,10 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (wantmech) {
if (strstr(mechlist, wantmech) == NULL) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
- VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "SASL mechanism %s not supported by server", wantmech);
+ VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR,
+ NULL, NULL, NULL, 0, 0,
+ _("SASL mechanism %s not supported by server"),
+ wantmech);
free(iret.mechlist);
goto cleanup;
}
@@ -3895,7 +3904,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "Failed to start SASL negotiation: %d (%s)",
+ _("Failed to start SASL negotiation: %d (%s)"),
err, sasl_errdetail(saslconn));
free(iret.mechlist);
goto cleanup;
@@ -3911,8 +3920,9 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if ((ncred =
remoteAuthMakeCredentials(interact, &cred)) < 0) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
- VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "Failed to make auth credentials");
+ VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR,
+ NULL, NULL, NULL, 0, 0,
+ "%s", _("Failed to make auth credentials"));
free(iret.mechlist);
goto cleanup;
}
@@ -3936,7 +3946,8 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (clientoutlen > REMOTE_AUTH_SASL_DATA_MAX) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "SASL negotiation data too long: %d bytes", clientoutlen);
+ _("SASL negotiation data too long: %d bytes"),
+ clientoutlen);
goto cleanup;
}
/* NB, distinction of NULL vs "" is *critical* in SASL */
@@ -3975,7 +3986,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "Failed SASL step: %d (%s)",
+ _("Failed SASL step: %d (%s)"),
err, sasl_errdetail(saslconn));
goto cleanup;
}
@@ -3989,7 +4000,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if ((ncred = remoteAuthMakeCredentials(interact, &cred)) < 0) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "Failed to make auth credentials");
+ "%s", _("Failed to make auth credentials"));
goto cleanup;
}
/* Run the authentication callback */
@@ -4053,7 +4064,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (err != SASL_OK) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "cannot query SASL ssf on connection %d (%s)",
+ _("cannot query SASL ssf on connection %d (%s)"),
err, sasl_errstring(err, NULL, NULL));
goto cleanup;
}
@@ -4062,7 +4073,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
if (ssf < 56) { /* 56 == DES level, good for Kerberos */
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "negotiation SSF %d was not strong enough", ssf);
+ _("negotiation SSF %d was not strong enough"), ssf);
goto cleanup;
}
}
@@ -4116,7 +4127,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
__virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "Failed to collect auth credentials");
+ _("Failed to collect auth credentials"));
return -1;
}
} else {
@@ -4183,7 +4194,7 @@ call (virConnectPtr conn, struct private_data *priv,
xdrmem_create (&xdr, buffer, sizeof buffer, XDR_ENCODE);
if (!xdr_remote_message_header (&xdr, &hdr)) {
error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
- VIR_ERR_RPC, "xdr_remote_message_header");
+ VIR_ERR_RPC, _("xdr_remote_message_header failed"));
return -1;
}
@@ -4205,7 +4216,8 @@ 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);
@@ -4222,7 +4234,7 @@ call (virConnectPtr conn, struct private_data *priv,
xdrmem_create (&xdr, buffer2, sizeof buffer2, XDR_DECODE);
if (!xdr_int (&xdr, &len)) {
error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
- VIR_ERR_RPC, "xdr_int (length word, reply)");
+ VIR_ERR_RPC, _("xdr_int (length word, reply)"));
return -1;
}
xdr_destroy (&xdr);
@@ -4232,7 +4244,7 @@ call (virConnectPtr conn, struct private_data *priv,
if (len < 0 || len > REMOTE_MESSAGE_MAX) {
error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
- VIR_ERR_RPC, "packet received from server too large");
+ VIR_ERR_RPC, _("packet received from server too large"));
return -1;
}
@@ -4244,22 +4256,24 @@ call (virConnectPtr conn, struct private_data *priv,
xdrmem_create (&xdr, buffer, len, XDR_DECODE);
if (!xdr_remote_message_header (&xdr, &hdr)) {
error (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
- VIR_ERR_RPC, "xdr_remote_message_header (reply)");
+ VIR_ERR_RPC, _("invalid header in reply"));
return -1;
}
/* Check program, version, etc. are what we expect. */
if (hdr.prog != REMOTE_PROGRAM) {
- __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
+ __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
+ NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "unknown program (received %x, expected %x)",
+ _("unknown program (received %x, expected %x)"),
hdr.prog, REMOTE_PROGRAM);
return -1;
}
if (hdr.vers != REMOTE_PROTOCOL_VERSION) {
- __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
+ __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
+ NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "unknown protocol version (received %x, expected %x)",
+ _("unknown protocol version (received %x, expected %x)"),
hdr.vers, REMOTE_PROTOCOL_VERSION);
return -1;
}
@@ -4269,23 +4283,25 @@ call (virConnectPtr conn, struct private_data *priv,
* message being received at this point.
*/
if (hdr.proc != proc_nr) {
- __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
+ __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
+ NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "unknown procedure (received %x, expected %x)",
+ _("unknown procedure (received %x, expected %x)"),
hdr.proc, proc_nr);
return -1;
}
if (hdr.direction != REMOTE_REPLY) {
- __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
+ __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn,
+ NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "unknown direction (received %x, expected %x)",
+ _("unknown direction (received %x, expected %x)"),
hdr.direction, REMOTE_REPLY);
return -1;
}
if (hdr.serial != serial) {
__virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "unknown serial (received %x, expected %x)",
+ _("unknown serial (received %x, expected %x)"),
hdr.serial, serial);
return -1;
}
@@ -4328,7 +4344,7 @@ call (virConnectPtr conn, struct private_data *priv,
default:
__virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE,
VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
- "unknown status (received %x)",
+ _("unknown status (received %x)"),
hdr.status);
xdr_destroy (&xdr);
return -1;
@@ -4437,7 +4453,7 @@ really_read_buf (virConnectPtr conn, struct private_data *priv,
}
if (err == 0) {
error (in_open ? NULL : conn,
- VIR_ERR_RPC, "socket closed unexpectedly");
+ VIR_ERR_RPC, _("socket closed unexpectedly"));
return -1;
}
return err;
@@ -4454,7 +4470,7 @@ really_read_buf (virConnectPtr conn, struct private_data *priv,
}
if (err == 0) {
error (in_open ? NULL : conn,
- VIR_ERR_RPC, "socket closed unexpectedly");
+ VIR_ERR_RPC, _("socket closed unexpectedly"));
return -1;
}
return err;
--
1.5.5.rc0.22.g467c
16 years, 8 months
[Libvir] [PATCH 5/9] Convert diagnostics like "VAR > MAX_VAR" to translatable messages.
by Jim Meyering
Convert diagnostics like "VAR > MAX_VAR" to translatable messages.
* src/remote_internal.c (errorf): New function.
(remoteListDomains, remoteDomainPinVcpu, remoteDomainGetVcpus):
(remoteListDefinedDomains, remoteListNetworks):
(remoteListDefinedNetworks):
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
src/remote_internal.c | 79 +++++++++++++++++++++++++++++++++++++++---------
1 files changed, 64 insertions(+), 15 deletions(-)
diff --git a/src/remote_internal.c b/src/remote_internal.c
index 0909481..8d2d9e5 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -146,6 +146,8 @@ static int remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int
virConnectAuthPtr auth);
#endif /* HAVE_POLKIT */
static void error (virConnectPtr conn, virErrorNumber code, const char *info);
+static void errorf (virConnectPtr conn, virErrorNumber code,
+ const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 3, 4);
static void server_error (virConnectPtr conn, remote_error *err);
static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain);
static virNetworkPtr get_nonnull_network (virConnectPtr conn, remote_nonnull_network network);
@@ -1330,7 +1332,9 @@ 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"));
+ errorf (conn, VIR_ERR_RPC,
+ _("too many remote domain IDs: %d > %d"),
+ maxids, REMOTE_DOMAIN_ID_LIST_MAX);
return -1;
}
args.maxids = maxids;
@@ -1342,7 +1346,9 @@ 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"));
+ errorf (conn, VIR_ERR_RPC,
+ _("too many remote domain IDs: %d > %d"),
+ ret.ids.ids_len, maxids);
xdr_free ((xdrproc_t) xdr_remote_list_domains_ret, (char *) &ret);
return -1;
}
@@ -1714,7 +1720,9 @@ remoteDomainPinVcpu (virDomainPtr domain,
GET_PRIVATE (domain->conn, -1);
if (maplen > REMOTE_CPUMAP_MAX) {
- error (domain->conn, VIR_ERR_RPC, _("maplen > REMOTE_CPUMAP_MAX"));
+ errorf (domain->conn, VIR_ERR_RPC,
+ _("map length greater than maximum: %d > %d"),
+ maplen, REMOTE_CPUMAP_MAX);
return -1;
}
@@ -1744,12 +1752,15 @@ remoteDomainGetVcpus (virDomainPtr domain,
GET_PRIVATE (domain->conn, -1);
if (maxinfo > REMOTE_VCPUINFO_MAX) {
- error (domain->conn, VIR_ERR_RPC, _("maxinfo > REMOTE_VCPUINFO_MAX"));
+ errorf (domain->conn, VIR_ERR_RPC,
+ _("vCPU count exceeds maximum: %d > %d"),
+ maxinfo, REMOTE_VCPUINFO_MAX);
return -1;
}
if (maxinfo * maplen > REMOTE_CPUMAPS_MAX) {
- error (domain->conn, VIR_ERR_RPC,
- _("maxinfo * maplen > REMOTE_CPUMAPS_MAX"));
+ errorf (domain->conn, VIR_ERR_RPC,
+ _("vCPU map buffer length exceeds maximum: %d > %d"),
+ maxinfo * maplen, REMOTE_CPUMAPS_MAX);
return -1;
}
@@ -1764,13 +1775,16 @@ remoteDomainGetVcpus (virDomainPtr domain,
return -1;
if (ret.info.info_len > maxinfo) {
- error (domain->conn, VIR_ERR_RPC, _("ret.info.info_len > maxinfo"));
+ errorf (domain->conn, VIR_ERR_RPC,
+ _("host reports too many vCPUs: %d > %d"),
+ 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"));
+ errorf (domain->conn, VIR_ERR_RPC,
+ _("host reports map buffer length exceeds maximum: %d > %d"),
+ ret.cpumaps.cpumaps_len, maxinfo * maplen);
xdr_free ((xdrproc_t) xdr_remote_domain_get_vcpus_ret, (char *) &ret);
return -1;
}
@@ -1930,7 +1944,9 @@ 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"));
+ errorf (conn, VIR_ERR_RPC,
+ _("too many remote domain names: %d > %d"),
+ maxnames, REMOTE_DOMAIN_NAME_LIST_MAX);
return -1;
}
args.maxnames = maxnames;
@@ -1942,7 +1958,9 @@ 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"));
+ errorf (conn, VIR_ERR_RPC,
+ _("too many remote domain names: %d > %d"),
+ ret.names.names_len, maxnames);
xdr_free ((xdrproc_t) xdr_remote_list_defined_domains_ret, (char *) &ret);
return -1;
}
@@ -2390,7 +2408,9 @@ 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"));
+ errorf (conn, VIR_ERR_RPC,
+ _("too many remote networks: %d > %d"),
+ maxnames, REMOTE_NETWORK_NAME_LIST_MAX);
return -1;
}
args.maxnames = maxnames;
@@ -2402,7 +2422,9 @@ 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"));
+ errorf (conn, VIR_ERR_RPC,
+ _("too many remote networks: %d > %d"),
+ ret.names.names_len, maxnames);
xdr_free ((xdrproc_t) xdr_remote_list_networks_ret, (char *) &ret);
return -1;
}
@@ -2445,7 +2467,9 @@ 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"));
+ errorf (conn, VIR_ERR_RPC,
+ _("too many remote networks: %d > %d"),
+ maxnames, REMOTE_NETWORK_NAME_LIST_MAX);
return -1;
}
args.maxnames = maxnames;
@@ -2457,7 +2481,9 @@ remoteListDefinedNetworks (virConnectPtr conn,
return -1;
if (ret.names.names_len > maxnames) {
- error (conn, VIR_ERR_RPC, _("ret.names.names_len > maxnames"));
+ errorf (conn, VIR_ERR_RPC,
+ _("too many remote networks: %d > %d"),
+ ret.names.names_len, maxnames);
xdr_free ((xdrproc_t) xdr_remote_list_defined_networks_ret, (char *) &ret);
return -1;
}
@@ -4518,6 +4544,29 @@ error (virConnectPtr conn, virErrorNumber code, const char *info)
errmsg, info);
}
+/* For errors internal to this library.
+ Identical to the above, but with a format string and optional params. */
+static void
+errorf (virConnectPtr conn, virErrorNumber code, const char *fmt, ...)
+{
+ const char *errmsg;
+ va_list args;
+ char errorMessage[256];
+
+ if (fmt) {
+ va_start(args, fmt);
+ vsnprintf(errorMessage, sizeof errorMessage - 1, fmt, args);
+ va_end(args);
+ } else {
+ errorMessage[0] = '\0';
+ }
+
+ errmsg = __virErrorMsg (code, errorMessage);
+ __virRaiseError (conn, NULL, NULL, VIR_FROM_REMOTE,
+ code, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0,
+ "%s", errmsg);
+}
+
/* For errors generated on the server side and sent back to us. */
static void
server_error (virConnectPtr conn, remote_error *err)
--
1.5.5.rc0.22.g467c
16 years, 8 months
[Libvir] [PATCH 3/9] ReportError: mark for translation string args to this function
by Jim Meyering
ReportError: mark for translation string args to this function
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 2 +-
src/util.c | 21 +++++++++++----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index ff09660..ccf6f5d 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -313,9 +313,9 @@ msg_gen_function += qemudLog
msg_gen_function += remoteDispatchError
msg_gen_function += virStorageLog
msg_gen_function += xenXMError
+msg_gen_function += ReportError
# msg_gen_function += virXenError
-# msg_gen_function += ReportError
# msg_gen_function += testError
# msg_gen_function += openvzLog
# msg_gen_function += qemudReportError
diff --git a/src/util.c b/src/util.c
index 188b7a8..0667780 100644
--- a/src/util.c
+++ b/src/util.c
@@ -106,21 +106,22 @@ _virExec(virConnectPtr conn,
int pipeerr[2] = {-1,-1};
if ((null = open(_PATH_DEVNULL, O_RDONLY)) < 0) {
- ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot open %s : %s",
- _PATH_DEVNULL, strerror(errno));
+ ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("cannot open %s: %s"),
+ _PATH_DEVNULL, strerror(errno));
goto cleanup;
}
if ((outfd != NULL && pipe(pipeout) < 0) ||
(errfd != NULL && pipe(pipeerr) < 0)) {
- ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot create pipe : %s",
- strerror(errno));
+ ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("cannot create pipe: %s"), strerror(errno));
goto cleanup;
}
if ((pid = fork()) < 0) {
- ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot fork child process : %s",
- strerror(errno));
+ ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("cannot fork child process: %s"), strerror(errno));
goto cleanup;
}
@@ -131,11 +132,11 @@ _virExec(virConnectPtr conn,
if(non_block)
if(virSetNonBlock(pipeout[0]) == -1)
ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Failed to set non-blocking file descriptor flag");
+ _("Failed to set non-blocking file descriptor flag"));
if(virSetCloseExec(pipeout[0]) == -1)
ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Failed to set close-on-exec file descriptor flag");
+ _("Failed to set close-on-exec file descriptor flag"));
*outfd = pipeout[0];
}
if (errfd) {
@@ -143,11 +144,11 @@ _virExec(virConnectPtr conn,
if(non_block)
if(virSetNonBlock(pipeerr[0]) == -1)
ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Failed to set non-blocking file descriptor flag");
+ _("Failed to set non-blocking file descriptor flag"));
if(virSetCloseExec(pipeerr[0]) == -1)
ReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "Failed to set close-on-exec file descriptor flag");
+ _("Failed to set close-on-exec file descriptor flag"));
*errfd = pipeerr[0];
}
*retpid = pid;
--
1.5.5.rc0.22.g467c
16 years, 8 months
[Libvir] [PATCH 2/9] xenXMError: mark for translation string args to this function
by Jim Meyering
xenXMError: mark for translation string args to this function
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
Makefile.maint | 2 +-
src/xm_internal.c | 81 +++++++++++++++++++++++++++++++++-------------------
2 files changed, 52 insertions(+), 31 deletions(-)
diff --git a/Makefile.maint b/Makefile.maint
index d870bfd..ff09660 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -312,8 +312,8 @@ msg_gen_function += virLog
msg_gen_function += qemudLog
msg_gen_function += remoteDispatchError
msg_gen_function += virStorageLog
+msg_gen_function += xenXMError
-# msg_gen_function += xenXMError
# msg_gen_function += virXenError
# msg_gen_function += ReportError
# msg_gen_function += testError
diff --git a/src/xm_internal.c b/src/xm_internal.c
index 55684e7..f609029 100644
--- a/src/xm_internal.c
+++ b/src/xm_internal.c
@@ -1904,26 +1904,30 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
if (doc == NULL) {
- xenXMError(conn, VIR_ERR_XML_ERROR, "cannot read XML domain definition");
+ xenXMError(conn, VIR_ERR_XML_ERROR,
+ _("cannot read XML domain definition"));
return (NULL);
}
node = xmlDocGetRootElement(doc);
if ((node == NULL) || (!xmlStrEqual(node->name, BAD_CAST "domain"))) {
- xenXMError(conn, VIR_ERR_XML_ERROR, "missing top level domain element");
+ xenXMError(conn, VIR_ERR_XML_ERROR,
+ _("missing top level domain element"));
goto error;
}
prop = xmlGetProp(node, BAD_CAST "type");
if (prop != NULL) {
if (!xmlStrEqual(prop, BAD_CAST "xen")) {
- xenXMError(conn, VIR_ERR_XML_ERROR, "domain type is invalid");
+ xenXMError(conn, VIR_ERR_XML_ERROR,
+ _("domain type is invalid"));
goto error;
}
xmlFree(prop);
prop = NULL;
}
if (!(ctxt = xmlXPathNewContext(doc))) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "cannot create XPath context");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("cannot create XPath context"));
goto error;
}
if (!(conf = virConfNew()))
@@ -2117,7 +2121,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr >= 0)) {
if (!(vfb = malloc(sizeof(*vfb)))) {
- xenXMError(conn, VIR_ERR_NO_MEMORY, "config");
+ xenXMError(conn, VIR_ERR_NO_MEMORY, _("config"));
goto error;
}
vfb->type = VIR_CONF_LIST;
@@ -2183,7 +2187,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
virConfValuePtr disp;
if (!(disp = malloc(sizeof(*disp)))) {
free(val);
- xenXMError(conn, VIR_ERR_NO_MEMORY, "config");
+ xenXMError(conn, VIR_ERR_NO_MEMORY, _("config"));
goto error;
}
disp->type = VIR_CONF_STRING;
@@ -2204,7 +2208,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr >= 0)) {
virConfValuePtr disks;
if (!(disks = malloc(sizeof(*disks)))) {
- xenXMError(conn, VIR_ERR_NO_MEMORY, "config");
+ xenXMError(conn, VIR_ERR_NO_MEMORY, _("config"));
goto error;
}
disks->type = VIR_CONF_LIST;
@@ -2217,7 +2221,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
if (disk) {
if (!(thisDisk = malloc(sizeof(*thisDisk)))) {
free(disk);
- xenXMError(conn, VIR_ERR_NO_MEMORY, "config");
+ xenXMError(conn, VIR_ERR_NO_MEMORY, _("config"));
goto error;
}
thisDisk->type = VIR_CONF_STRING;
@@ -2236,7 +2240,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr >= 0)) {
virConfValuePtr vifs;
if (!(vifs = malloc(sizeof(*vifs)))) {
- xenXMError(conn, VIR_ERR_NO_MEMORY, "config");
+ xenXMError(conn, VIR_ERR_NO_MEMORY, _("config"));
goto error;
}
vifs->type = VIR_CONF_LIST;
@@ -2248,7 +2252,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
goto error;
if (!(thisVif = malloc(sizeof(*thisVif)))) {
free(vif);
- xenXMError(conn, VIR_ERR_NO_MEMORY, "config");
+ xenXMError(conn, VIR_ERR_NO_MEMORY, _("config"));
goto error;
}
thisVif->type = VIR_CONF_STRING;
@@ -2324,7 +2328,8 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
if (!(value = virConfGetValue(conf, "name")) ||
value->type != VIR_CONF_STRING ||
value->str == NULL) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "name config parameter is missing");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("name config parameter is missing"));
goto error;
}
@@ -2332,17 +2337,20 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
/* domain exists, we will overwrite it */
if (!(oldfilename = (char *)virHashLookup(nameConfigMap, value->str))) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "can't retrieve config filename for domain to overwrite");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("can't retrieve config filename for domain to overwrite"));
goto error;
}
if (!(entry = virHashLookup(configCache, oldfilename))) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "can't retrieve config entry for domain to overwrite");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("can't retrieve config entry for domain to overwrite"));
goto error;
}
if (xenXMConfigGetUUID(entry->conf, "uuid", uuid) < 0) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "uuid config parameter is missing");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("uuid config parameter is missing"));
goto error;
}
@@ -2351,13 +2359,15 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
/* Remove the name -> filename mapping */
if (virHashRemoveEntry(nameConfigMap, value->str, NULL) < 0) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "failed to remove old domain from config map");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("failed to remove old domain from config map"));
goto error;
}
/* Remove the config record itself */
if (virHashRemoveEntry(configCache, oldfilename, xenXMConfigFree) < 0) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "failed to remove old domain from config map");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("failed to remove old domain from config map"));
goto error;
}
@@ -2365,7 +2375,8 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
}
if ((strlen(configDir) + 1 + strlen(value->str) + 1) > PATH_MAX) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "config file name is too long");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("config file name is too long"));
goto error;
}
@@ -2374,17 +2385,19 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
strcat(filename, value->str);
if (virConfWriteFile(filename, conf) < 0) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "unable to write config file");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unable to write config file"));
goto error;
}
if (!(entry = calloc(1, sizeof(*entry)))) {
- xenXMError(conn, VIR_ERR_NO_MEMORY, "config");
+ xenXMError(conn, VIR_ERR_NO_MEMORY, _("config"));
goto error;
}
if ((entry->refreshedAt = time(NULL)) == ((time_t)-1)) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "unable to get current time");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unable to get current time"));
goto error;
}
@@ -2392,18 +2405,21 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
entry->conf = conf;
if (xenXMConfigGetUUID(conf, "uuid", uuid) < 0) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "uuid config parameter is missing");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("uuid config parameter is missing"));
goto error;
}
if (virHashAddEntry(configCache, filename, entry) < 0) {
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "unable to store config file handle");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unable to store config file handle"));
goto error;
}
if (virHashAddEntry(nameConfigMap, value->str, entry->filename) < 0) {
virHashRemoveEntry(configCache, filename, NULL);
- xenXMError(conn, VIR_ERR_INTERNAL_ERROR, "unable to store config file handle");
+ xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unable to store config file handle"));
goto error;
}
@@ -2570,11 +2586,13 @@ xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) {
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
if (!doc) {
- xenXMError(domain->conn, VIR_ERR_XML_ERROR, "cannot read XML domain definition");
+ xenXMError(domain->conn, VIR_ERR_XML_ERROR,
+ _("cannot read XML domain definition"));
goto cleanup;
}
if (!(ctxt = xmlXPathNewContext(doc))) {
- xenXMError(domain->conn, VIR_ERR_INTERNAL_ERROR, "cannot create XPath context");
+ xenXMError(domain->conn, VIR_ERR_INTERNAL_ERROR,
+ _("cannot create XPath context"));
goto cleanup;
}
obj = xmlXPathEval(BAD_CAST "string(/domain/os/type)", ctxt);
@@ -2591,12 +2609,12 @@ xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) {
XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
if (!doc) {
xenXMError(domain->conn, VIR_ERR_XML_ERROR,
- "cannot read XML domain definition");
+ _("cannot read XML domain definition"));
goto cleanup;
}
if (!(ctxt = xmlXPathNewContext(doc))) {
xenXMError(domain->conn, VIR_ERR_INTERNAL_ERROR,
- "cannot create XPath context");
+ _("cannot create XPath context"));
goto cleanup;
}
@@ -2607,7 +2625,8 @@ xenXMDomainAttachDevice(virDomainPtr domain, const char *xml) {
if (xenXMAttachInterface(domain, ctxt, hvm, node, entry))
goto cleanup;
} else {
- xenXMError(domain->conn, VIR_ERR_XML_ERROR, "unknown device");
+ xenXMError(domain->conn, VIR_ERR_XML_ERROR,
+ _("unknown device"));
goto cleanup;
}
@@ -2989,11 +3008,13 @@ xenXMDomainDetachDevice(virDomainPtr domain, const char *xml) {
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
if (!doc) {
- xenXMError(domain->conn, VIR_ERR_XML_ERROR, "cannot read XML domain definition");
+ xenXMError(domain->conn, VIR_ERR_XML_ERROR,
+ _("cannot read XML domain definition"));
goto cleanup;
}
if (!(ctxt = xmlXPathNewContext(doc))) {
- xenXMError(domain->conn, VIR_ERR_INTERNAL_ERROR, "cannot create XPath context");
+ xenXMError(domain->conn, VIR_ERR_INTERNAL_ERROR,
+ _("cannot create XPath context"));
goto cleanup;
}
--
1.5.5.rc0.22.g467c
16 years, 8 months