locking: Update format strings in translated messages

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Jiri Denemark 2023-03-09 12:15:50 +01:00
parent 8875aee4eb
commit 3d61757c3b
6 changed files with 77 additions and 79 deletions

View File

@ -187,7 +187,7 @@ virLockDaemonNewServerPostExecRestart(virNetDaemon *dmn G_GNUC_UNUSED,
dmn); dmn);
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected server name '%s' during restart"), _("Unexpected server name '%1$s' during restart"),
name); name);
return NULL; return NULL;
} }
@ -461,14 +461,14 @@ virLockDaemonClientNew(virNetServerClient *client,
if (!privileged) { if (!privileged) {
if (geteuid() != clientuid) { if (geteuid() != clientuid) {
virReportRestrictedError(_("Disallowing client %llu with uid %llu"), virReportRestrictedError(_("Disallowing client %1$llu with uid %2$llu"),
(unsigned long long)priv->clientPid, (unsigned long long)priv->clientPid,
(unsigned long long)clientuid); (unsigned long long)clientuid);
goto error; goto error;
} }
} else { } else {
if (clientuid != 0) { if (clientuid != 0) {
virReportRestrictedError(_("Disallowing client %llu with uid %llu"), virReportRestrictedError(_("Disallowing client %1$llu with uid %2$llu"),
(unsigned long long)priv->clientPid, (unsigned long long)priv->clientPid,
(unsigned long long)clientuid); (unsigned long long)clientuid);
goto error; goto error;
@ -716,7 +716,7 @@ virLockDaemonPreExecRestart(const char *state_file,
if (virFileWriteStr(state_file, state, 0700) < 0) { if (virFileWriteStr(state_file, state, 0700) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to save state file %s"), state_file); _("Unable to save state file %1$s"), state_file);
return -1; return -1;
} }
@ -738,7 +738,7 @@ virLockDaemonUsage(const char *argv0, bool privileged)
fprintf(stderr, fprintf(stderr,
_("\n" _("\n"
"Usage:\n" "Usage:\n"
" %s [options]\n" " %1$s [options]\n"
"\n" "\n"
"Options:\n" "Options:\n"
" -h | --help Display program help:\n" " -h | --help Display program help:\n"
@ -757,13 +757,13 @@ virLockDaemonUsage(const char *argv0, bool privileged)
" Default paths:\n" " Default paths:\n"
"\n" "\n"
" Configuration file (unless overridden by -f):\n" " Configuration file (unless overridden by -f):\n"
" %s/libvirt/virtlockd.conf\n" " %1$s/libvirt/virtlockd.conf\n"
"\n" "\n"
" Sockets:\n" " Sockets:\n"
" %s/libvirt/virtlockd-sock\n" " %2$s/libvirt/virtlockd-sock\n"
"\n" "\n"
" PID file (unless overridden by -p):\n" " PID file (unless overridden by -p):\n"
" %s/virtlockd.pid\n" " %3$s/virtlockd.pid\n"
"\n"), "\n"),
SYSCONFDIR, SYSCONFDIR,
RUNSTATEDIR, RUNSTATEDIR,
@ -823,7 +823,7 @@ int main(int argc, char **argv) {
if (virGettextInitialize() < 0 || if (virGettextInitialize() < 0 ||
virErrorInitialize() < 0) { virErrorInitialize() < 0) {
fprintf(stderr, _("%s: initialization failed\n"), argv[0]); fprintf(stderr, _("%1$s: initialization failed\n"), argv[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -903,7 +903,7 @@ int main(int argc, char **argv) {
/* Read the config file if it exists */ /* Read the config file if it exists */
if (remote_config_file && if (remote_config_file &&
virLockDaemonConfigLoadFile(config, remote_config_file, implicit_conf) < 0) { virLockDaemonConfigLoadFile(config, remote_config_file, implicit_conf) < 0) {
VIR_ERROR(_("Can't load config file: %s: %s"), VIR_ERROR(_("Can't load config file: %1$s: %2$s"),
virGetLastErrorMessage(), remote_config_file); virGetLastErrorMessage(), remote_config_file);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -963,7 +963,7 @@ int main(int argc, char **argv) {
old_umask = umask(077); old_umask = umask(077);
VIR_DEBUG("Ensuring run dir '%s' exists", run_dir); VIR_DEBUG("Ensuring run dir '%s' exists", run_dir);
if (g_mkdir_with_parents(run_dir, 0777) < 0) { if (g_mkdir_with_parents(run_dir, 0777) < 0) {
VIR_ERROR(_("unable to create rundir %s: %s"), run_dir, VIR_ERROR(_("unable to create rundir %1$s: %2$s"), run_dir,
g_strerror(errno)); g_strerror(errno));
ret = VIR_DAEMON_ERR_RUNDIR; ret = VIR_DAEMON_ERR_RUNDIR;
umask(old_umask); umask(old_umask);
@ -987,13 +987,13 @@ int main(int argc, char **argv) {
if (godaemon) { if (godaemon) {
if (chdir("/") < 0) { if (chdir("/") < 0) {
VIR_ERROR(_("cannot change to root directory: %s"), VIR_ERROR(_("cannot change to root directory: %1$s"),
g_strerror(errno)); g_strerror(errno));
goto cleanup; goto cleanup;
} }
if ((statuswrite = virDaemonForkIntoBackground(argv[0])) < 0) { if ((statuswrite = virDaemonForkIntoBackground(argv[0])) < 0) {
VIR_ERROR(_("Failed to fork as daemon: %s"), VIR_ERROR(_("Failed to fork as daemon: %1$s"),
g_strerror(errno)); g_strerror(errno));
goto cleanup; goto cleanup;
} }

View File

@ -67,7 +67,7 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServer *server G_GNUC_UNUSED,
if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) { if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Lockspace for path %s does not exist"), _("Lockspace for path %1$s does not exist"),
args->path); args->path);
goto cleanup; goto cleanup;
} }
@ -125,7 +125,7 @@ virLockSpaceProtocolDispatchCreateResource(virNetServer *server G_GNUC_UNUSED,
if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) { if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Lockspace for path %s does not exist"), _("Lockspace for path %1$s does not exist"),
args->path); args->path);
goto cleanup; goto cleanup;
} }
@ -174,7 +174,7 @@ virLockSpaceProtocolDispatchDeleteResource(virNetServer *server G_GNUC_UNUSED,
if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) { if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Lockspace for path %s does not exist"), _("Lockspace for path %1$s does not exist"),
args->path); args->path);
goto cleanup; goto cleanup;
} }
@ -229,7 +229,7 @@ virLockSpaceProtocolDispatchNew(virNetServer *server G_GNUC_UNUSED,
if (virLockDaemonFindLockSpace(lockDaemon, args->path) != NULL) { if (virLockDaemonFindLockSpace(lockDaemon, args->path) != NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Lockspace for path %s already exists"), _("Lockspace for path %1$s already exists"),
args->path); args->path);
goto cleanup; goto cleanup;
} }
@ -324,7 +324,7 @@ virLockSpaceProtocolDispatchReleaseResource(virNetServer *server G_GNUC_UNUSED,
if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) { if (!(lockspace = virLockDaemonFindLockSpace(lockDaemon, args->path))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Lockspace for path %s does not exist"), _("Lockspace for path %1$s does not exist"),
args->path); args->path);
goto cleanup; goto cleanup;
} }

View File

@ -85,7 +85,7 @@ static int virLockManagerLockDaemonLoadConfig(const char *configFile)
if (access(configFile, R_OK) == -1) { if (access(configFile, R_OK) == -1) {
if (errno != ENOENT) { if (errno != ENOENT) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to access config file %s"), _("Unable to access config file %1$s"),
configFile); configFile);
return -1; return -1;
} }
@ -400,7 +400,7 @@ static int virLockManagerLockDaemonNew(virLockManager *lock,
/* ignored */ /* ignored */
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected parameter %s for object"), _("Unexpected parameter %1$s for object"),
params[i].key); params[i].key);
goto cleanup; goto cleanup;
} }
@ -426,7 +426,7 @@ static int virLockManagerLockDaemonNew(virLockManager *lock,
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown lock manager object type %d"), _("Unknown lock manager object type %1$d"),
type); type);
goto cleanup; goto cleanup;
} }
@ -498,7 +498,7 @@ static int
virLockManagerGetLVMKey(const char *path, virLockManagerGetLVMKey(const char *path,
char **key G_GNUC_UNUSED) char **key G_GNUC_UNUSED)
{ {
virReportSystemError(ENOSYS, _("Unable to get LVM key for %s"), path); virReportSystemError(ENOSYS, _("Unable to get LVM key for %1$s"), path);
return -1; return -1;
} }
#endif #endif
@ -601,7 +601,7 @@ static int virLockManagerLockDaemonAddResource(virLockManager *lock,
path = params[i].value.str; path = params[i].value.str;
} else { } else {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected parameter %s for lease resource"), _("Unexpected parameter %1$s for lease resource"),
params[i].key); params[i].key);
return -1; return -1;
} }
@ -617,7 +617,7 @@ static int virLockManagerLockDaemonAddResource(virLockManager *lock,
} break; } break;
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown lock manager object type %d"), _("Unknown lock manager object type %1$d"),
type); type);
return -1; return -1;
} }

View File

@ -101,7 +101,7 @@ virLockManagerSanlockError(int err,
#if WITH_SANLOCK_STRERROR #if WITH_SANLOCK_STRERROR
*message = g_strdup(sanlock_strerror(err)); *message = g_strdup(sanlock_strerror(err));
#else #else
*message = g_strdup_printf(_("sanlock error %d"), err); *message = g_strdup_printf(_("sanlock error %1$d"), err);
#endif #endif
return true; return true;
} else { } else {
@ -124,7 +124,7 @@ virLockManagerSanlockLoadConfig(virLockManagerSanlockDriver *driver,
if (access(configFile, R_OK) == -1) { if (access(configFile, R_OK) == -1) {
if (errno != ENOENT) { if (errno != ENOENT) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to access config file %s"), _("Unable to access config file %1$s"),
configFile); configFile);
return -1; return -1;
} }
@ -196,7 +196,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
if (virStrcpyStatic(ls.name, if (virStrcpyStatic(ls.name,
VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE) < 0) { VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Lockspace path '%s' exceeded %d characters"), _("Lockspace path '%1$s' exceeded %2$d characters"),
VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE, VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE,
SANLK_PATH_LEN); SANLK_PATH_LEN);
goto error; goto error;
@ -205,7 +205,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
ls.flags = 0; ls.flags = 0;
if (virStrcpy(ls.host_id_disk.path, path, SANLK_PATH_LEN) < 0) { if (virStrcpy(ls.host_id_disk.path, path, SANLK_PATH_LEN) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Lockspace path '%s' exceeded %d characters"), _("Lockspace path '%1$s' exceeded %2$d characters"),
path, SANLK_PATH_LEN); path, SANLK_PATH_LEN);
goto error; goto error;
} }
@ -221,8 +221,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
dir = g_path_get_dirname(path); dir = g_path_get_dirname(path);
if (stat(dir, &st) < 0 || !S_ISDIR(st.st_mode)) { if (stat(dir, &st) < 0 || !S_ISDIR(st.st_mode)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to create lockspace %s: parent directory" _("Unable to create lockspace %1$s: parent directory does not exist or is not a directory"),
" does not exist or is not a directory"),
path); path);
goto error; goto error;
} }
@ -233,7 +232,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
if ((fd = open(path, O_WRONLY|O_CREAT|O_EXCL, perms)) < 0) { if ((fd = open(path, O_WRONLY|O_CREAT|O_EXCL, perms)) < 0) {
if (errno != EEXIST) { if (errno != EEXIST) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to create lockspace %s"), _("Unable to create lockspace %1$s"),
path); path);
goto error; goto error;
} }
@ -243,7 +242,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
if ((driver->user != (uid_t) -1 || driver->group != (gid_t) -1) && if ((driver->user != (uid_t) -1 || driver->group != (gid_t) -1) &&
(fchown(fd, driver->user, driver->group) < 0)) { (fchown(fd, driver->user, driver->group) < 0)) {
virReportSystemError(errno, virReportSystemError(errno,
_("cannot chown '%s' to (%u, %u)"), _("cannot chown '%1$s' to (%2$u, %3$u)"),
path, path,
(unsigned int) driver->user, (unsigned int) driver->user,
(unsigned int) driver->group); (unsigned int) driver->group);
@ -254,12 +253,12 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to query sector size %s: %s"), _("Unable to query sector size %1$s: %2$s"),
path, NULLSTR(err)); path, NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
virReportSystemError(-rv, virReportSystemError(-rv,
_("Unable to query sector size %s"), _("Unable to query sector size %1$s"),
path); path);
} }
goto error_unlink; goto error_unlink;
@ -270,14 +269,14 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
*/ */
if (safezero(fd, 0, rv) < 0) { if (safezero(fd, 0, rv) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to allocate lockspace %s"), _("Unable to allocate lockspace %1$s"),
path); path);
goto error_unlink; goto error_unlink;
} }
if (VIR_CLOSE(fd) < 0) { if (VIR_CLOSE(fd) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to save lockspace %s"), _("Unable to save lockspace %1$s"),
path); path);
goto error_unlink; goto error_unlink;
} }
@ -286,12 +285,12 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to initialize lockspace %s: %s"), _("Unable to initialize lockspace %1$s: %2$s"),
path, NULLSTR(err)); path, NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
virReportSystemError(-rv, virReportSystemError(-rv,
_("Unable to initialize lockspace %s"), _("Unable to initialize lockspace %1$s"),
path); path);
} }
goto error_unlink; goto error_unlink;
@ -304,7 +303,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
(driver->group != (gid_t) -1 && driver->group != st.st_gid)) && (driver->group != (gid_t) -1 && driver->group != st.st_gid)) &&
(chown(path, driver->user, driver->group) < 0)) { (chown(path, driver->user, driver->group) < 0)) {
virReportSystemError(errno, virReportSystemError(errno,
_("cannot chown '%s' to (%u, %u)"), _("cannot chown '%1$s' to (%2$u, %3$u)"),
path, path,
(unsigned int) driver->user, (unsigned int) driver->user,
(unsigned int) driver->group); (unsigned int) driver->group);
@ -314,7 +313,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
if ((driver->group != (gid_t) -1 && (st.st_mode & 0060) != 0060) && if ((driver->group != (gid_t) -1 && (st.st_mode & 0060) != 0060) &&
chmod(path, 0660) < 0) { chmod(path, 0660) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("cannot chmod '%s' to 0660"), _("cannot chmod '%1$s' to 0660"),
path); path);
goto error; goto error;
} }
@ -344,12 +343,12 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriver *driver)
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to add lockspace %s: %s"), _("Unable to add lockspace %1$s: %2$s"),
path, NULLSTR(err)); path, NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
virReportSystemError(-rv, virReportSystemError(-rv,
_("Unable to add lockspace %s"), _("Unable to add lockspace %1$s"),
path); path);
} }
goto error; goto error;
@ -454,7 +453,7 @@ static int virLockManagerSanlockNew(virLockManager *lock,
if (type != VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN) { if (type != VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unsupported object type %d"), type); _("Unsupported object type %1$d"), type);
return -1; return -1;
} }
@ -528,7 +527,7 @@ static int virLockManagerSanlockAddLease(virLockManager *lock,
res->num_disks = 1; res->num_disks = 1;
if (virStrcpy(res->name, name, SANLK_NAME_LEN) < 0) { if (virStrcpy(res->name, name, SANLK_NAME_LEN) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Resource name '%s' exceeds %d characters"), _("Resource name '%1$s' exceeds %2$d characters"),
name, SANLK_NAME_LEN); name, SANLK_NAME_LEN);
return -1; return -1;
} }
@ -537,7 +536,7 @@ static int virLockManagerSanlockAddLease(virLockManager *lock,
if (STREQ(params[i].key, "path")) { if (STREQ(params[i].key, "path")) {
if (virStrcpy(res->disks[0].path, params[i].value.str, SANLK_PATH_LEN) < 0) { if (virStrcpy(res->disks[0].path, params[i].value.str, SANLK_PATH_LEN) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Lease path '%s' exceeds %d characters"), _("Lease path '%1$s' exceeds %2$d characters"),
params[i].value.str, SANLK_PATH_LEN); params[i].value.str, SANLK_PATH_LEN);
return -1; return -1;
} }
@ -546,7 +545,7 @@ static int virLockManagerSanlockAddLease(virLockManager *lock,
} else if (STREQ(params[i].key, "lockspace")) { } else if (STREQ(params[i].key, "lockspace")) {
if (virStrcpy(res->lockspace_name, params[i].value.str, SANLK_NAME_LEN) < 0) { if (virStrcpy(res->lockspace_name, params[i].value.str, SANLK_NAME_LEN) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Resource lockspace '%s' exceeds %d characters"), _("Resource lockspace '%1$s' exceeds %2$d characters"),
params[i].value.str, SANLK_NAME_LEN); params[i].value.str, SANLK_NAME_LEN);
return -1; return -1;
} }
@ -589,7 +588,7 @@ virLockManagerSanlockAddDisk(virLockManagerSanlockDriver *driver,
return -1; return -1;
if (virStrcpy(res->name, hash, SANLK_NAME_LEN) < 0) { if (virStrcpy(res->name, hash, SANLK_NAME_LEN) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("MD5 hash '%s' unexpectedly larger than %d characters"), _("MD5 hash '%1$s' unexpectedly larger than %2$d characters"),
hash, (SANLK_NAME_LEN - 1)); hash, (SANLK_NAME_LEN - 1));
return -1; return -1;
} }
@ -597,7 +596,7 @@ virLockManagerSanlockAddDisk(virLockManagerSanlockDriver *driver,
path = g_strdup_printf("%s/%s", driver->autoDiskLeasePath, res->name); path = g_strdup_printf("%s/%s", driver->autoDiskLeasePath, res->name);
if (virStrcpy(res->disks[0].path, path, SANLK_PATH_LEN) < 0) { if (virStrcpy(res->disks[0].path, path, SANLK_PATH_LEN) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Lease path '%s' exceeds %d characters"), _("Lease path '%1$s' exceeds %2$d characters"),
path, SANLK_PATH_LEN); path, SANLK_PATH_LEN);
return -1; return -1;
} }
@ -606,7 +605,7 @@ virLockManagerSanlockAddDisk(virLockManagerSanlockDriver *driver,
VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE, VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE,
SANLK_NAME_LEN) < 0) { SANLK_NAME_LEN) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Resource lockspace '%s' exceeds %d characters"), _("Resource lockspace '%1$s' exceeds %2$d characters"),
VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE, SANLK_NAME_LEN); VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE, SANLK_NAME_LEN);
return -1; return -1;
} }
@ -631,7 +630,7 @@ virLockManagerSanlockCreateLease(virLockManagerSanlockDriver *driver,
if ((fd = open(res->disks[0].path, O_WRONLY|O_CREAT|O_EXCL, 0600)) < 0) { if ((fd = open(res->disks[0].path, O_WRONLY|O_CREAT|O_EXCL, 0600)) < 0) {
if (errno != EEXIST) { if (errno != EEXIST) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to create lockspace %s"), _("Unable to create lockspace %1$s"),
res->disks[0].path); res->disks[0].path);
return -1; return -1;
} }
@ -641,7 +640,7 @@ virLockManagerSanlockCreateLease(virLockManagerSanlockDriver *driver,
if ((driver->user != (uid_t) -1 || driver->group != (gid_t) -1) && if ((driver->user != (uid_t) -1 || driver->group != (gid_t) -1) &&
(fchown(fd, driver->user, driver->group) < 0)) { (fchown(fd, driver->user, driver->group) < 0)) {
virReportSystemError(errno, virReportSystemError(errno,
_("cannot chown '%s' to (%u, %u)"), _("cannot chown '%1$s' to (%2$u, %3$u)"),
res->disks[0].path, res->disks[0].path,
(unsigned int) driver->user, (unsigned int) driver->user,
(unsigned int) driver->group); (unsigned int) driver->group);
@ -652,12 +651,12 @@ virLockManagerSanlockCreateLease(virLockManagerSanlockDriver *driver,
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to query sector size %s: %s"), _("Unable to query sector size %1$s: %2$s"),
res->disks[0].path, NULLSTR(err)); res->disks[0].path, NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
virReportSystemError(-rv, virReportSystemError(-rv,
_("Unable to query sector size %s"), _("Unable to query sector size %1$s"),
res->disks[0].path); res->disks[0].path);
} }
goto error_unlink; goto error_unlink;
@ -668,14 +667,14 @@ virLockManagerSanlockCreateLease(virLockManagerSanlockDriver *driver,
*/ */
if (safezero(fd, 0, rv) < 0) { if (safezero(fd, 0, rv) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to allocate lease %s"), _("Unable to allocate lease %1$s"),
res->disks[0].path); res->disks[0].path);
goto error_unlink; goto error_unlink;
} }
if (VIR_CLOSE(fd) < 0) { if (VIR_CLOSE(fd) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to save lease %s"), _("Unable to save lease %1$s"),
res->disks[0].path); res->disks[0].path);
goto error_unlink; goto error_unlink;
} }
@ -684,12 +683,12 @@ virLockManagerSanlockCreateLease(virLockManagerSanlockDriver *driver,
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to initialize lease %s: %s"), _("Unable to initialize lease %1$s: %2$s"),
res->disks[0].path, NULLSTR(err)); res->disks[0].path, NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
virReportSystemError(-rv, virReportSystemError(-rv,
_("Unable to initialize lease %s"), _("Unable to initialize lease %1$s"),
res->disks[0].path); res->disks[0].path);
} }
goto error_unlink; goto error_unlink;
@ -722,7 +721,7 @@ static int virLockManagerSanlockAddResource(virLockManager *lock,
if (priv->res_count == SANLK_MAX_RESOURCES) { if (priv->res_count == SANLK_MAX_RESOURCES) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Too many resources %d for object"), _("Too many resources %1$d for object"),
SANLK_MAX_RESOURCES); SANLK_MAX_RESOURCES);
return -1; return -1;
} }
@ -757,7 +756,7 @@ static int virLockManagerSanlockAddResource(virLockManager *lock,
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown lock manager object type %d for domain lock object"), _("Unknown lock manager object type %1$d for domain lock object"),
type); type);
return -1; return -1;
} }
@ -788,7 +787,7 @@ virLockManagerSanlockRegisterKillscript(int sock,
case VIR_DOMAIN_LOCK_FAILURE_IGNORE: case VIR_DOMAIN_LOCK_FAILURE_IGNORE:
case VIR_DOMAIN_LOCK_FAILURE_LAST: case VIR_DOMAIN_LOCK_FAILURE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Failure action %s is not supported by sanlock"), _("Failure action %1$s is not supported by sanlock"),
virDomainLockFailureTypeToString(action)); virDomainLockFailureTypeToString(action));
return -1; return -1;
} }
@ -812,14 +811,13 @@ virLockManagerSanlockRegisterKillscript(int sock,
/* sanlock_killpath() would just crop the strings */ /* sanlock_killpath() would just crop the strings */
if (strlen(path) >= SANLK_HELPER_PATH_LEN) { if (strlen(path) >= SANLK_HELPER_PATH_LEN) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Sanlock helper path is longer than %d: '%s'"), _("Sanlock helper path is longer than %1$d: '%2$s'"),
SANLK_HELPER_PATH_LEN - 1, path); SANLK_HELPER_PATH_LEN - 1, path);
return -1; return -1;
} }
if (strlen(args) >= SANLK_HELPER_ARGS_LEN) { if (strlen(args) >= SANLK_HELPER_ARGS_LEN) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Sanlock helper arguments are longer than %d:" _("Sanlock helper arguments are longer than %1$d: '%2$s'"),
" '%s'"),
SANLK_HELPER_ARGS_LEN - 1, args); SANLK_HELPER_ARGS_LEN - 1, args);
return -1; return -1;
} }
@ -828,7 +826,7 @@ virLockManagerSanlockRegisterKillscript(int sock,
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to register lock failure action: %s"), _("Failed to register lock failure action: %1$s"),
NULLSTR(err)); NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
@ -881,7 +879,7 @@ static int virLockManagerSanlockAcquire(virLockManager *lock,
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(sock, &err)) { if (virLockManagerSanlockError(sock, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open socket to sanlock daemon: %s"), _("Failed to open socket to sanlock daemon: %1$s"),
NULLSTR(err)); NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
@ -919,12 +917,12 @@ static int virLockManagerSanlockAcquire(virLockManager *lock,
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to parse lock state %s: %s"), _("Unable to parse lock state %1$s: %2$s"),
state, NULLSTR(err)); state, NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
virReportSystemError(-rv, virReportSystemError(-rv,
_("Unable to parse lock state %s"), _("Unable to parse lock state %1$s"),
state); state);
} }
goto error; goto error;
@ -943,7 +941,7 @@ static int virLockManagerSanlockAcquire(virLockManager *lock,
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_RESOURCE_BUSY, virReportError(VIR_ERR_RESOURCE_BUSY,
_("Failed to acquire lock: %s"), _("Failed to acquire lock: %1$s"),
NULLSTR(err)); NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
@ -971,7 +969,7 @@ static int virLockManagerSanlockAcquire(virLockManager *lock,
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to restrict process: %s"), _("Failed to restrict process: %1$s"),
NULLSTR(err)); NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
@ -1027,7 +1025,7 @@ static int virLockManagerSanlockRelease(virLockManager *lock,
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to inquire lock: %s"), _("Failed to inquire lock: %1$s"),
NULLSTR(err)); NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
@ -1046,7 +1044,7 @@ static int virLockManagerSanlockRelease(virLockManager *lock,
char *err = NULL; char *err = NULL;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to release lock: %s"), _("Failed to release lock: %1$s"),
NULLSTR(err)); NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {
@ -1085,7 +1083,7 @@ static int virLockManagerSanlockInquire(virLockManager *lock,
char *err; char *err;
if (virLockManagerSanlockError(rv, &err)) { if (virLockManagerSanlockError(rv, &err)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to inquire lock: %s"), _("Failed to inquire lock: %1$s"),
NULLSTR(err)); NULLSTR(err));
VIR_FREE(err); VIR_FREE(err);
} else { } else {

View File

@ -43,7 +43,7 @@ VIR_LOG_INIT("locking.lock_manager");
#define CHECK_DRIVER(field, errret) \ #define CHECK_DRIVER(field, errret) \
if (!driver->field) { \ if (!driver->field) { \
virReportError(VIR_ERR_INTERNAL_ERROR, \ virReportError(VIR_ERR_INTERNAL_ERROR, \
_("Missing '%s' field in lock manager driver"), \ _("Missing '%1$s' field in lock manager driver"), \
#field); \ #field); \
return errret; \ return errret; \
} }
@ -51,7 +51,7 @@ VIR_LOG_INIT("locking.lock_manager");
#define CHECK_MANAGER(field, errret) \ #define CHECK_MANAGER(field, errret) \
if (!lock->driver->field) { \ if (!lock->driver->field) { \
virReportError(VIR_ERR_INTERNAL_ERROR, \ virReportError(VIR_ERR_INTERNAL_ERROR, \
_("Missing '%s' field in lock manager driver"), \ _("Missing '%1$s' field in lock manager driver"), \
#field); \ #field); \
return errret; \ return errret; \
} }
@ -147,7 +147,7 @@ virLockManagerPlugin *virLockManagerPluginNew(const char *name,
if (access(modfile, R_OK) < 0) { if (access(modfile, R_OK) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Plugin %s not accessible"), _("Plugin %1$s not accessible"),
modfile); modfile);
goto cleanup; goto cleanup;
} }
@ -155,7 +155,7 @@ virLockManagerPlugin *virLockManagerPluginNew(const char *name,
handle = dlopen(modfile, RTLD_NOW | RTLD_LOCAL); handle = dlopen(modfile, RTLD_NOW | RTLD_LOCAL);
if (!handle) { if (!handle) {
virReportError(VIR_ERR_SYSTEM_ERROR, virReportError(VIR_ERR_SYSTEM_ERROR,
_("Failed to load plugin %s: %s"), _("Failed to load plugin %1$s: %2$s"),
modfile, dlerror()); modfile, dlerror());
goto cleanup; goto cleanup;
} }

View File

@ -15,7 +15,7 @@ getArgs(int argc,
int act; int act;
if (argc != 4) { if (argc != 4) {
fprintf(stderr, _("%s uri uuid action\n"), argv[0]); fprintf(stderr, _("%1$s uri uuid action\n"), argv[0]);
return -1; return -1;
} }
@ -24,7 +24,7 @@ getArgs(int argc,
act = virDomainLockFailureTypeFromString(argv[3]); act = virDomainLockFailureTypeFromString(argv[3]);
if (act < 0) { if (act < 0) {
fprintf(stderr, _("invalid failure action: '%s'\n"), argv[3]); fprintf(stderr, _("invalid failure action: '%1$s'\n"), argv[3]);
return -1; return -1;
} }
*action = act; *action = act;
@ -90,7 +90,7 @@ main(int argc, char **argv)
case VIR_DOMAIN_LOCK_FAILURE_RESTART: case VIR_DOMAIN_LOCK_FAILURE_RESTART:
case VIR_DOMAIN_LOCK_FAILURE_IGNORE: case VIR_DOMAIN_LOCK_FAILURE_IGNORE:
case VIR_DOMAIN_LOCK_FAILURE_LAST: case VIR_DOMAIN_LOCK_FAILURE_LAST:
fprintf(stderr, _("unsupported failure action: '%s'\n"), fprintf(stderr, _("unsupported failure action: '%1$s'\n"),
virDomainLockFailureTypeToString(action)); virDomainLockFailureTypeToString(action));
break; break;
} }