This really needs to be changed to pass through gettext, eg

   error(dom->conn, VIR_ERR_INTERNAL_ERROR,
         _("Could not exec %s"), VZCTL);

NB, we have to use a %s format string when going via gettext rather than
just allowing the preprocessor to do string concatenation for us.

Ok, it need. Thanks!

fixed patch is attached.
Index: openvz_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/openvz_conf.c,v
retrieving revision 1.25
diff -u -p -r1.25 openvz_conf.c
--- openvz_conf.c	12 Jun 2008 13:48:29 -0000	1.25
+++ openvz_conf.c	9 Jul 2008 10:08:49 -0000
@@ -57,21 +57,29 @@
 #include "memory.h"
 
 static char *openvzLocateConfDir(void);
-static void error (virConnectPtr conn, virErrorNumber code, const char *info);
 static struct openvz_vm_def *openvzParseXML(virConnectPtr conn, xmlDocPtr xml);
 static int openvzGetVPSUUID(int vpsid, char *uuidstr);
 static int openvzSetUUID(int vpsid);
 
-/* For errors internal to this library. */
-static void
-error (virConnectPtr conn, virErrorNumber code, const char *info)
+void
+error (virConnectPtr conn, virErrorNumber code, const char *fmt, ...)
 {
+    va_list args;
+    char errorMessage[OPENVZ_MAX_ERROR_LEN];
     const char *errmsg;
 
-    errmsg = __virErrorMsg (code, info);
+    if (fmt) {
+        va_start(args, fmt);
+        vsnprintf(errorMessage, OPENVZ_MAX_ERROR_LEN-1, fmt, args);
+        va_end(args);
+    } else {
+        errorMessage[0] = '\0';
+    }
+
+    errmsg = __virErrorMsg(code, (errorMessage[0] ? errorMessage : NULL));
     __virRaiseError (conn, NULL, NULL, VIR_FROM_OPENVZ,
-                     code, VIR_ERR_ERROR, errmsg, info, NULL, 0, 0,
-                     errmsg, info);
+                     code, VIR_ERR_ERROR, errmsg, errorMessage, NULL, 0, 0,
+                     errmsg, errorMessage);
 }
 
 struct openvz_vm
Index: openvz_conf.h
===================================================================
RCS file: /data/cvs/libvirt/src/openvz_conf.h,v
retrieving revision 1.6
diff -u -p -r1.6 openvz_conf.h
--- openvz_conf.h	5 Feb 2008 19:27:37 -0000	1.6
+++ openvz_conf.h	9 Jul 2008 10:08:49 -0000
@@ -110,6 +110,7 @@ openvzIsActiveVM(struct openvz_vm *vm)
     return vm->vpsid != -1;
 }
 
+void error (virConnectPtr conn, virErrorNumber code, const char *fmt, ...);
 int openvz_readline(int fd, char *ptr, int maxlen);
 struct openvz_vm *openvzFindVMByID(const struct openvz_driver *driver, int id);
 struct openvz_vm *openvzFindVMByUUID(const struct openvz_driver *driver,
Index: openvz_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/openvz_driver.c,v
retrieving revision 1.23
diff -u -p -r1.23 openvz_driver.c
--- openvz_driver.c	7 Jul 2008 11:48:40 -0000	1.23
+++ openvz_driver.c	9 Jul 2008 10:08:49 -0000
@@ -125,18 +125,6 @@ static void cmdExecFree(char *cmdExec[])
     }
 }
 
-/* For errors internal to this library. */
-static void
-error (virConnectPtr conn, virErrorNumber code, const char *info)
-{
-    const char *errmsg;
-
-    errmsg = __virErrorMsg (code, info);
-    __virRaiseError (conn, NULL, NULL, VIR_FROM_OPENVZ,
-                     code, VIR_ERR_ERROR, errmsg, info, NULL, 0, 0,
-                     errmsg, info);
-}
-
 static virDomainPtr openvzDomainLookupByID(virConnectPtr conn,
                                    int id) {
     struct openvz_driver *driver = (struct openvz_driver *)conn->privateData;
@@ -257,7 +245,8 @@ static int openvzDomainShutdown(virDomai
 
     ret = virExec(dom->conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
     if(ret == -1) {
-        error(dom->conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
+        error(dom->conn, VIR_ERR_INTERNAL_ERROR, 
+              _("Could not exec %s"), VZCTL);
         return -1;
     }
 
@@ -301,7 +290,8 @@ static int openvzDomainReboot(virDomainP
     }
     ret = virExec(dom->conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
     if(ret == -1) {
-        error(dom->conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
+        error(dom->conn, VIR_ERR_INTERNAL_ERROR, 
+               _("Could not exec %s"), VZCTL);
         return -1;
     }
 
@@ -360,7 +350,8 @@ openvzDomainDefineXML(virConnectPtr conn
     }
     ret = virExec(conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
     if(ret == -1) {
-        error(conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
+        error(conn, VIR_ERR_INTERNAL_ERROR, 
+               _("Could not exec %s"), VZCTL);
         goto bail_out2;
     }
 
@@ -428,7 +419,8 @@ openvzDomainCreateLinux(virConnectPtr co
     }
     ret = virExec(conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
     if(ret == -1) {
-        error(conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
+        error(conn, VIR_ERR_INTERNAL_ERROR, 
+               _("Could not exec %s"), VZCTL);
         return NULL;
     }
 
@@ -444,7 +436,8 @@ openvzDomainCreateLinux(virConnectPtr co
     }
     ret = virExec(conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
     if(ret == -1) {
-        error(conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
+        error(conn, VIR_ERR_INTERNAL_ERROR, 
+               _("Could not exec %s"), VZCTL);
         return NULL;
     }
 
@@ -498,7 +491,8 @@ openvzDomainCreate(virDomainPtr dom)
     }
     ret = virExec(dom->conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
     if(ret == -1) {
-        error(dom->conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
+        error(dom->conn, VIR_ERR_INTERNAL_ERROR, 
+               _("Could not exec %s"), VZCTL);
         return -1;
     }
 
@@ -541,7 +535,8 @@ openvzDomainUndefine(virDomainPtr dom)
     }
     ret = virExec(conn, (char **)cmdExec, &pid, -1, &outfd, &errfd);
     if(ret == -1) {
-        error(conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
+        error(conn, VIR_ERR_INTERNAL_ERROR, 
+               _("Could not exec %s"), VZCTL);
         return -1;
     }
 
@@ -633,7 +628,8 @@ static int openvzListDomains(virConnectP
 
     ret = virExec(conn, (char **)cmd, &pid, -1, &outfd, &errfd);
     if(ret == -1) {
-        error(conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
+        error(conn, VIR_ERR_INTERNAL_ERROR, 
+               _("Could not exec %s"), VZLIST);
         return -1;
     }
 
@@ -664,7 +660,8 @@ static int openvzListDefinedDomains(virC
     /* the -S options lists only stopped domains */
     ret = virExec(conn, (char **)cmd, &pid, -1, &outfd, &errfd);
     if(ret == -1) {
-        error(conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
+        error(conn, VIR_ERR_INTERNAL_ERROR, 
+               _("Could not exec %s"), VZLIST);
         return -1;
     }
 
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to