[Libvir] Proposal: More script hooks for <interface type='ethernet'>
by Charles Duffy
I have a few issues with <interface type='ethernet'>:
- The requirement that either
(1) the tap device already exists and has a constant name, or
(2) the tap device can be created by the current user without
privilege escalation
doesn't work for places where the user wants to
- dynamically generate tap devices
- ...but is running kvm without privileges to do so.
(this is particularly likely now that write privileges to
/dev/net/tap are not enough, and the user needs CAP_NET_ADMIN to
create a tap device).
Allowing a target script to be specified (which is responsible for
gaining any privileges necessary) which runs *before* the tap device
is opened and would resolve this.
- A qemu-ifup script can be specified, but not a qemu-ifdown
replacement.
Before looking to use libvirt, I had kvm's invocation wrapped by a
script which did appropriate privilege escalation (ifname=$(sudo tunctl
-b -u $USER), with sudo configured with the NOPASSWORD flag for this
request -- though plenty of other approaches are certainly possible). It
would be ideal if more hooks were available... for instance:
<interface type='ethernet'>
<!-- script gives device name on stdout -->
<target script='/usr/local/bin/make-me-a-tap-device'/>
<!-- preexisting argument and syntax for up scripts -->
<script path='/etc/qemu-ifup-mynet'/>
<!-- option to specify a down script, passed to qemu via
'downscript=' parameter-->
<script-down path='/etc/qemu-ifdown-mynet'/>
</interface>
Working around this means that I would need to preallocate the tap
devices and assign them to specific VMs (boo! hiss!) or that (if I
wrapped libvirt's invocation to have the tap device created just ahead
of time and its name substituted into interface/@dev) 3rd-party
libvirt-based management tools couldn't be used (which would defeat the
point of switching to libvirt from my homegrown script collection in the
first place).
So -- does the proposed syntax extension look reasonable?
16 years, 10 months
[Libvir] Libparted history contribution
by Matt Davis
Hello,
I am sending this email out to various programs that use libparted for partition
table manipulation. If you are on the libparted devel list, you probably have
caught word of this. I have implemented some functionality that allows parted
to maintain a list of disk changes, allowing for a user to undo/redo changes
before they are actually committed, or written, to disk. This "History" is a
safety feature, and a library change vs usefulness might not be wanted by you
all. I was just querying to see if such functionality, as an addition to
libparted, would be welcomed? In any case, it might be useful for me to wrap it
up into its own library, possibly something such as libparted-utilities or
extras.
While the changes I have implemented can exist outside of the library, I figured
it might be something other projects might find useful. But making any library
changes, especially when many well-known projects use such a library, is a
serious decision. If this is a worthy change I would like to hear your
feedback.
Thanks
-Matt
16 years, 10 months
[Libvir] Why QEMU?
by Anton Protopopov
Hi, all.
When I executing virsh to connect to openvz I get the following:
[root@localhost ~]# virsh -c openvz:///system
libvir: QEMU error : cannot create bridge 'virbr0' : File exists
Failed to autostart network 'default': cannot create bridge 'virbr0' :
File existsWelcome to virsh, the virtualization interactive terminal.
Type: 'help' for help with commands
'quit' to quit
virsh #
...
But I didn't want to connect to QEMU...
Anton
16 years, 10 months
[Libvir] [RFC][PATCH]: Make the iscsi storage backend mostly use sysfs
by Chris Lalancette
Hello,
The newer version of iscsi-initiator-utils (6.2.0.865-0.2),
available in the f8-updates repository, is required as part of the fix
for a hang when doing iscsi logout (the other fix is in the 2.6.25
kernel). Unfortunately, this version also changes the output of the
iscsiadm -m session -P 3 command; this output was being used to gather
the scsi devices available in a pool and present them as volumes.
Consequently, when starting an iSCSI pool on a machine with these newer
versions of the iscsi tools, the pool will be successfully created but
you won't be able to see any of the LUNs presented.
The attached patch *lessens* our dependency on the iscsiadm output by
using sysfs to gather the /dev devices. Note that this patch is not to
be applied; I'm just putting it out there so people can take a look at
it. DanB has suggested getting rid of our dependency on the iscsiadm
output altogether is the way to go, and I agree with him there; this is
mostly just a short-term solution, to possibly base future work on.
Chris Lalancette
16 years, 10 months
[Libvir] Problem using libvirtd on RHEL5.1
by Tiago Cruz
Hello 8-)
I'm using libvirt-0.4.0-1 (re)compiled from libvirt-0.4.0.tar.gz, on Red
Hat EL 5.1 x86_64.
The problem is:
# /etc/init.d/libvirtd start
Starting libvirtd daemon: libvir: QEMU error : cannot create bridge 'virbr0' : File exists
Failed to autostart network 'default': cannot create bridge[FAILED]' : File exists
And I can't destroy the 'virbr0', because I don't know how :^)
---
I've tried do compile the libvirt-cvs-snapshot.tar.gz, but I can't
too :(
In file included from libvirt.c:36:
util.h:28:22: error: util-lib.h: No such file or directory
RPM build errors:
File not found: /var/tmp/libvirt-0.4.0-root/usr/libexec/libvirt_parthelper
Maybe you have some tip/ trick for me :)
Many thanks
--
Tiago Cruz
http://everlinux.com
Linux User #282636
16 years, 10 months
[Libvir] tons of format string warnings on rawhide
by Jim Meyering
Avoid warnings like this:
file:nnn:format not a string literal and no format arguments
Easy to fix: prepend an "%s" argument.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
qemud/qemud.c | 68 +++++++++++++++-----------
qemud/remote.c | 28 ++++++-----
src/iptables.c | 4 +-
src/qemu_driver.c | 23 ++++++---
src/storage_backend.c | 22 ++++----
src/storage_backend_fs.c | 29 ++++++------
src/storage_backend_iscsi.c | 18 ++++----
src/storage_backend_logical.c | 20 ++++----
src/storage_conf.c | 77 +++++++++++++++---------------
src/storage_driver.c | 103 +++++++++++++++++++++--------------------
10 files changed, 207 insertions(+), 185 deletions(-)
diff --git a/qemud/qemud.c b/qemud/qemud.c
index a40dfcb..e01b6dc 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -245,9 +245,9 @@ static void qemudDispatchSignalEvent(int fd ATTRIBUTE_UNUSED,
switch (sigc) {
case SIGHUP:
- qemudLog(QEMUD_INFO, _("Reloading configuration on SIGHUP"));
+ qemudLog(QEMUD_INFO, "%s", _("Reloading configuration on SIGHUP"));
if (virStateReload() < 0)
- qemudLog(QEMUD_WARN, _("Error while reloading drivers"));
+ qemudLog(QEMUD_WARN, "%s", _("Error while reloading drivers"));
break;
case SIGINT:
@@ -274,7 +274,8 @@ static int qemudSetCloseExec(int fd) {
goto error;
return 0;
error:
- qemudLog(QEMUD_ERR, _("Failed to set close-on-exec file descriptor flag"));
+ qemudLog(QEMUD_ERR,
+ "%s", _("Failed to set close-on-exec file descriptor flag"));
return -1;
}
@@ -288,7 +289,8 @@ static int qemudSetNonBlock(int fd) {
goto error;
return 0;
error:
- qemudLog(QEMUD_ERR, _("Failed to set non-blocking file descriptor flag"));
+ qemudLog(QEMUD_ERR,
+ "%s", _("Failed to set non-blocking file descriptor flag"));
return -1;
}
@@ -467,7 +469,7 @@ static int qemudListenUnix(struct qemud_server *server,
if (!sock) {
qemudLog(QEMUD_ERR,
- _("Failed to allocate memory for struct qemud_socket"));
+ "%s", _("Failed to allocate memory for struct qemud_socket"));
return -1;
}
@@ -517,7 +519,7 @@ static int qemudListenUnix(struct qemud_server *server,
POLLIN| POLLERR | POLLHUP,
qemudDispatchServerEvent,
server) < 0) {
- qemudLog(QEMUD_ERR, _("Failed to add server event callback"));
+ qemudLog(QEMUD_ERR, "%s", _("Failed to add server event callback"));
goto cleanup;
}
@@ -647,7 +649,7 @@ remoteListenTCP (struct qemud_server *server,
POLLIN| POLLERR | POLLHUP,
qemudDispatchServerEvent,
server) < 0) {
- qemudLog(QEMUD_ERR, _("Failed to add server event callback"));
+ qemudLog(QEMUD_ERR, "%s", _("Failed to add server event callback"));
return -1;
}
@@ -698,7 +700,7 @@ static int qemudInitPaths(struct qemud_server *server,
snprintf_error:
qemudLog(QEMUD_ERR,
- _("Resulting path to long for buffer in qemudInitPaths()"));
+ "%s", _("Resulting path to long for buffer in qemudInitPaths()"));
return -1;
}
@@ -706,7 +708,7 @@ static struct qemud_server *qemudInitialize(int sigread) {
struct qemud_server *server;
if (!(server = calloc(1, sizeof(*server)))) {
- qemudLog(QEMUD_ERR, _("Failed to allocate struct qemud_server"));
+ qemudLog(QEMUD_ERR, "%s", _("Failed to allocate struct qemud_server"));
return NULL;
}
@@ -935,20 +937,23 @@ remoteCheckCertificate (gnutls_session_t session)
if (status != 0) {
if (status & GNUTLS_CERT_INVALID)
- qemudLog (QEMUD_ERR, _("remoteCheckCertificate: "
- "the client certificate is not trusted."));
+ qemudLog (QEMUD_ERR, "%s",
+ _("remoteCheckCertificate: "
+ "the client certificate is not trusted."));
if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
- qemudLog (QEMUD_ERR, _("remoteCheckCertificate: the client "
- "certificate has unknown issuer."));
+ qemudLog (QEMUD_ERR, "%s",
+ _("remoteCheckCertificate: the client "
+ "certificate has unknown issuer."));
if (status & GNUTLS_CERT_REVOKED)
- qemudLog (QEMUD_ERR, _("remoteCheckCertificate: "
- "the client certificate has been revoked."));
+ qemudLog (QEMUD_ERR, "%s",
+ _("remoteCheckCertificate: "
+ "the client certificate has been revoked."));
#ifndef GNUTLS_1_0_COMPAT
if (status & GNUTLS_CERT_INSECURE_ALGORITHM)
- qemudLog (QEMUD_ERR,
+ qemudLog (QEMUD_ERR, "%s",
_("remoteCheckCertificate: the client certificate"
" uses an insecure algorithm."));
#endif
@@ -957,13 +962,13 @@ remoteCheckCertificate (gnutls_session_t session)
}
if (gnutls_certificate_type_get (session) != GNUTLS_CRT_X509) {
- qemudLog (QEMUD_ERR, _("remoteCheckCertificate: "
- "certificate is not X.509"));
+ qemudLog (QEMUD_ERR,
+ "%s", _("remoteCheckCertificate: certificate is not X.509"));
return -1;
}
if (!(certs = gnutls_certificate_get_peers(session, &nCerts))) {
- qemudLog (QEMUD_ERR, _("remoteCheckCertificate: no peers"));
+ qemudLog (QEMUD_ERR, "%s", _("remoteCheckCertificate: no peers"));
return -1;
}
@@ -973,7 +978,7 @@ remoteCheckCertificate (gnutls_session_t session)
gnutls_x509_crt_t cert;
if (gnutls_x509_crt_init (&cert) < 0) {
- qemudLog (QEMUD_ERR,
+ qemudLog (QEMUD_ERR, "%s",
_("remoteCheckCertificate: gnutls_x509_crt_init failed"));
return -1;
}
@@ -984,15 +989,15 @@ remoteCheckCertificate (gnutls_session_t session)
}
if (gnutls_x509_crt_get_expiration_time (cert) < now) {
- qemudLog (QEMUD_ERR, _("remoteCheckCertificate: "
- "the client certificate has expired"));
+ qemudLog (QEMUD_ERR, "%s", _("remoteCheckCertificate: "
+ "the client certificate has expired"));
gnutls_x509_crt_deinit (cert);
return -1;
}
if (gnutls_x509_crt_get_activation_time (cert) > now) {
- qemudLog (QEMUD_ERR, _("remoteCheckCertificate: the client "
- "certificate is not yet activated"));
+ qemudLog (QEMUD_ERR, "%s", _("remoteCheckCertificate: the client "
+ "certificate is not yet activated"));
gnutls_x509_crt_deinit (cert);
return -1;
}
@@ -1000,7 +1005,7 @@ remoteCheckCertificate (gnutls_session_t session)
if (i == 0) {
if (!remoteCheckDN (cert)) {
/* This is the most common error: make it informative. */
- qemudLog (QEMUD_ERR, _("remoteCheckCertificate: client's Distinguished Name is not on the list of allowed clients (tls_allowed_dn_list). Use 'openssl x509 -in clientcert.pem -text' to view the Distinguished Name field in the client certificate, or run this daemon with --verbose option."));
+ qemudLog (QEMUD_ERR, "%s", _("remoteCheckCertificate: client's Distinguished Name is not on the list of allowed clients (tls_allowed_dn_list). Use 'openssl x509 -in clientcert.pem -text' to view the Distinguished Name field in the client certificate, or run this daemon with --verbose option."));
gnutls_x509_crt_deinit (cert);
return -1;
}
@@ -1016,9 +1021,13 @@ remoteCheckAccess (struct qemud_client *client)
{
/* Verify client certificate. */
if (remoteCheckCertificate (client->tlssession) == -1) {
- qemudLog (QEMUD_ERR, _("remoteCheckCertificate: failed to verify client's certificate"));
+ qemudLog (QEMUD_ERR, "%s",
+ _("remoteCheckCertificate: "
+ "failed to verify client's certificate"));
if (!tls_no_verify_certificate) return -1;
- else qemudLog (QEMUD_INFO, _("remoteCheckCertificate: tls_no_verify_certificate is set so the bad certificate is ignored"));
+ else qemudLog (QEMUD_INFO, "%s",
+ _("remoteCheckCertificate: tls_no_verify_certificate "
+ "is set so the bad certificate is ignored"));
}
/* Checks have succeeded. Write a '\1' byte back to the client to
@@ -1889,7 +1898,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
if (unix_sock_group) {
if (getuid() != 0) {
qemudLog (QEMUD_WARN,
- _("Cannot set group when not running as root"));
+ "%s", _("Cannot set group when not running as root"));
} else {
struct group *grp = getgrnam(unix_sock_group);
if (!grp) {
@@ -2146,7 +2155,8 @@ int main(int argc, char **argv) {
POLLIN,
qemudDispatchSignalEvent,
server) < 0) {
- qemudLog(QEMUD_ERR, _("Failed to register callback for signal pipe"));
+ qemudLog(QEMUD_ERR,
+ "%s", _("Failed to register callback for signal pipe"));
ret = 3;
goto error2;
}
diff --git a/qemud/remote.c b/qemud/remote.c
index f7c9b24..014fe65 100644
--- a/qemud/remote.c
+++ b/qemud/remote.c
@@ -2130,7 +2130,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
REMOTE_DEBUG("Initialize SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn != NULL) {
- qemudLog(QEMUD_ERR, _("client tried invalid SASL init request"));
+ qemudLog(QEMUD_ERR, "%s", _("client tried invalid SASL init request"));
remoteDispatchFailAuth(client, req);
return -2;
}
@@ -2184,7 +2184,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
cipher = gnutls_cipher_get(client->tlssession);
if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) {
- qemudLog(QEMUD_ERR, _("cannot TLS get cipher size"));
+ qemudLog(QEMUD_ERR, "%s", _("cannot TLS get cipher size"));
remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
@@ -2250,7 +2250,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
REMOTE_DEBUG("Available mechanisms for client: '%s'", mechlist);
ret->mechlist = strdup(mechlist);
if (!ret->mechlist) {
- qemudLog(QEMUD_ERR, _("cannot allocate mechlist"));
+ qemudLog(QEMUD_ERR, "%s", _("cannot allocate mechlist"));
remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
@@ -2323,7 +2323,7 @@ remoteSASLCheckAccess (struct qemud_server *server,
return -1;
}
if (val == NULL) {
- qemudLog(QEMUD_ERR, _("no client username was found"));
+ qemudLog(QEMUD_ERR, "%s", _("no client username was found"));
remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
@@ -2333,7 +2333,7 @@ remoteSASLCheckAccess (struct qemud_server *server,
client->saslUsername = strdup((const char*)val);
if (client->saslUsername == NULL) {
- qemudLog(QEMUD_ERR, _("out of memory copying username"));
+ qemudLog(QEMUD_ERR, "%s", _("out of memory copying username"));
remoteDispatchFailAuth(client, req);
sasl_dispose(&client->saslconn);
client->saslconn = NULL;
@@ -2378,7 +2378,7 @@ remoteDispatchAuthSaslStart (struct qemud_server *server,
REMOTE_DEBUG("Start SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn == NULL) {
- qemudLog(QEMUD_ERR, _("client tried invalid SASL start request"));
+ qemudLog(QEMUD_ERR, "%s", _("client tried invalid SASL start request"));
remoteDispatchFailAuth(client, req);
return -2;
}
@@ -2458,7 +2458,7 @@ remoteDispatchAuthSaslStep (struct qemud_server *server,
REMOTE_DEBUG("Step SASL auth %d", client->fd);
if (client->auth != REMOTE_AUTH_SASL ||
client->saslconn == NULL) {
- qemudLog(QEMUD_ERR, _("client tried invalid SASL start request"));
+ qemudLog(QEMUD_ERR, "%s", _("client tried invalid SASL start request"));
remoteDispatchFailAuth(client, req);
return -2;
}
@@ -2532,7 +2532,7 @@ remoteDispatchAuthSaslInit (struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, _("client tried unsupported SASL init request"));
+ qemudLog(QEMUD_ERR, "%s", _("client tried unsupported SASL init request"));
remoteDispatchFailAuth(client, req);
return -1;
}
@@ -2544,7 +2544,7 @@ remoteDispatchAuthSaslStart (struct qemud_server *server ATTRIBUTE_UNUSED,
remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, _("client tried unsupported SASL start request"));
+ qemudLog(QEMUD_ERR, "%s", _("client tried unsupported SASL start request"));
remoteDispatchFailAuth(client, req);
return -1;
}
@@ -2556,7 +2556,7 @@ remoteDispatchAuthSaslStep (struct qemud_server *server ATTRIBUTE_UNUSED,
remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, _("client tried unsupported SASL step request"));
+ qemudLog(QEMUD_ERR, "%s", _("client tried unsupported SASL step request"));
remoteDispatchFailAuth(client, req);
return -1;
}
@@ -2597,13 +2597,14 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
REMOTE_DEBUG("Start PolicyKit auth %d", client->fd);
if (client->auth != REMOTE_AUTH_POLKIT) {
- qemudLog(QEMUD_ERR, _("client tried invalid PolicyKit init request"));
+ qemudLog(QEMUD_ERR,
+ "%s", _("client tried invalid PolicyKit init request"));
remoteDispatchFailAuth(client, req);
return -2;
}
if (qemudGetSocketIdentity(client->fd, &callerUid, &callerPid) < 0) {
- qemudLog(QEMUD_ERR, _("cannot get peer socket identity"));
+ qemudLog(QEMUD_ERR, "%s", _("cannot get peer socket identity"));
remoteDispatchFailAuth(client, req);
return -2;
}
@@ -2713,7 +2714,8 @@ remoteDispatchAuthPolkit (struct qemud_server *server ATTRIBUTE_UNUSED,
void *args ATTRIBUTE_UNUSED,
remote_auth_polkit_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, _("client tried unsupported PolicyKit init request"));
+ qemudLog(QEMUD_ERR,
+ "%s", _("client tried unsupported PolicyKit init request"));
remoteDispatchFailAuth(client, req);
return -1;
}
diff --git a/src/iptables.c b/src/iptables.c
index f970701..dda1c24 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -148,8 +148,8 @@ notifyRulesRemoved(const char *table,
len = virFileReadAll(SYSCONF_DIR "/sysconfig/system-config-firewall",
MAX_FILE_LEN, &content);
if (len < 0) {
- qemudLog(QEMUD_WARN, _("Failed to read " SYSCONF_DIR
- "/sysconfig/system-config-firewall"));
+ qemudLog(QEMUD_WARN, "%s", _("Failed to read " SYSCONF_DIR
+ "/sysconfig/system-config-firewall"));
return;
}
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 15cd52c..f5fe504 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -71,7 +71,8 @@ static int qemudSetCloseExec(int fd) {
goto error;
return 0;
error:
- qemudLog(QEMUD_ERR, _("Failed to set close-on-exec file descriptor flag"));
+ qemudLog(QEMUD_ERR,
+ "%s", _("Failed to set close-on-exec file descriptor flag"));
return -1;
}
@@ -85,7 +86,8 @@ static int qemudSetNonBlock(int fd) {
goto error;
return 0;
error:
- qemudLog(QEMUD_ERR, _("Failed to set non-blocking file descriptor flag"));
+ qemudLog(QEMUD_ERR,
+ "%s", _("Failed to set non-blocking file descriptor flag"));
return -1;
}
@@ -182,7 +184,8 @@ qemudStartup(void) {
goto snprintf_error;
if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1) {
- qemudLog (QEMUD_ERR, _("out of memory in asprintf"));
+ qemudLog (QEMUD_ERR,
+ "%s", _("out of memory in asprintf"));
goto out_of_memory;
}
}
@@ -224,11 +227,12 @@ qemudStartup(void) {
snprintf_error:
qemudLog(QEMUD_ERR,
- _("Resulting path to long for buffer in qemudInitPaths()"));
+ "%s", _("Resulting path to long for buffer in qemudInitPaths()"));
return -1;
out_of_memory:
- qemudLog (QEMUD_ERR, _("qemudStartup: out of memory"));
+ qemudLog (QEMUD_ERR,
+ "%s", _("qemudStartup: out of memory"));
free (base);
free(qemu_driver);
qemu_driver = NULL;
@@ -246,7 +250,8 @@ qemudReload(void) {
qemudScanConfigs(qemu_driver);
if (qemu_driver->iptables) {
- qemudLog(QEMUD_INFO, _("Reloading iptables rules"));
+ qemudLog(QEMUD_INFO,
+ "%s", _("Reloading iptables rules"));
iptablesReloadRules(qemu_driver->iptables);
}
@@ -777,7 +782,8 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
if (waitpid(vm->pid, NULL, WNOHANG) != vm->pid) {
kill(vm->pid, SIGKILL);
if (waitpid(vm->pid, NULL, 0) != vm->pid) {
- qemudLog(QEMUD_WARN, _("Got unexpected pid, damn"));
+ qemudLog(QEMUD_WARN,
+ "%s", _("Got unexpected pid, damn"));
}
}
@@ -1265,7 +1271,8 @@ static int qemudShutdownNetworkDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
waitpid(network->dnsmasqPid, NULL, WNOHANG) != network->dnsmasqPid) {
kill(network->dnsmasqPid, SIGKILL);
if (waitpid(network->dnsmasqPid, NULL, 0) != network->dnsmasqPid)
- qemudLog(QEMUD_WARN, _("Got unexpected pid for dnsmasq\n"));
+ qemudLog(QEMUD_WARN,
+ "%s", _("Got unexpected pid for dnsmasq\n"));
}
network->bridge[0] = '\0';
diff --git a/src/storage_backend.c b/src/storage_backend.c
index 6f8940f..a13d9a4 100644
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -247,7 +247,7 @@ virStorageBackendUpdateVolInfoFD(virConnectPtr conn,
}
vol->target.perms.label = strdup(filecon);
if (vol->target.perms.label == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("context"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("context"));
return -1;
}
freecon(filecon);
@@ -306,7 +306,7 @@ virStorageBackendStablePath(virConnectPtr conn,
stablepath = malloc(strlen(pool->def->target.path) +
1 + strlen(dent->d_name) + 1);
if (stablepath == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("path"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("path"));
closedir(dh);
return NULL;
}
@@ -359,7 +359,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
/* Compile all regular expressions */
if ((reg = calloc(nregex, sizeof(*reg))) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("regex"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("regex"));
return -1;
}
@@ -385,12 +385,12 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
/* Storage for matched variables */
if ((groups = calloc(totgroups, sizeof(*groups))) == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("regex groups"));
+ "%s", _("regex groups"));
goto cleanup;
}
if ((vars = calloc(maxvars+1, sizeof(*vars))) == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("regex groups"));
+ "%s", _("regex groups"));
goto cleanup;
}
@@ -402,7 +402,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
if ((list = fdopen(fd, "r")) == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("cannot read fd"));
+ "%s", _("cannot read fd"));
goto cleanup;
}
@@ -426,7 +426,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
if ((groups[ngroup++] =
strdup(line + vars[j+1].rm_so)) == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("regex groups"));
+ "%s", _("regex groups"));
goto cleanup;
}
}
@@ -489,7 +489,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
}
} else {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("command did not exit cleanly"));
+ "%s", _("command did not exit cleanly"));
return -1;
}
}
@@ -530,7 +530,7 @@ virStorageBackendRunProgNul(virConnectPtr conn,
if (n_columns > SIZE_MAX / sizeof *v
|| (v = malloc (n_columns * sizeof *v)) == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("n_columns too large"));
+ "%s", _("n_columns too large"));
return -1;
}
for (i = 0; i < n_columns; i++)
@@ -543,7 +543,7 @@ virStorageBackendRunProgNul(virConnectPtr conn,
if ((fp = fdopen(fd, "r")) == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("cannot read fd"));
+ "%s", _("cannot read fd"));
goto cleanup;
}
@@ -611,7 +611,7 @@ virStorageBackendRunProgNul(virConnectPtr conn,
}
} else {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("command did not exit cleanly"));
+ "%s", _("command did not exit cleanly"));
return -1;
}
}
diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
index ffb4010..9425cbc 100644
--- a/src/storage_backend_fs.c
+++ b/src/storage_backend_fs.c
@@ -503,18 +503,18 @@ virStorageBackendFileSystemMount(virConnectPtr conn,
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
if (pool->def->source.host.name == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("missing source host"));
+ "%s", _("missing source host"));
return -1;
}
if (pool->def->source.dir == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("missing source path"));
+ "%s", _("missing source path"));
return -1;
}
} else {
if (pool->def->source.ndevice != 1) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("missing source device"));
+ "%s", _("missing source device"));
return -1;
}
}
@@ -537,7 +537,7 @@ virStorageBackendFileSystemMount(virConnectPtr conn,
src = strdup(pool->def->source.devices[0].path);
}
if (src == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("source"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("source"));
return -1;
}
mntargv[3] = src;
@@ -568,18 +568,18 @@ virStorageBackendFileSystemUnmount(virConnectPtr conn,
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
if (pool->def->source.host.name == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("missing source host"));
+ "%s", _("missing source host"));
return -1;
}
if (pool->def->source.dir == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("missing source dir"));
+ "%s", _("missing source dir"));
return -1;
}
} else {
if (pool->def->source.ndevice != 1) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("missing source device"));
+ "%s", _("missing source device"));
return -1;
}
}
@@ -680,7 +680,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn,
vol = calloc(1, sizeof(virStorageVolDef));
if (vol == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("volume"));
+ "%s", _("volume"));
goto cleanup;
}
@@ -688,7 +688,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn,
if (vol->name == NULL) {
free(vol);
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("volume name"));
+ "%s", _("volume name"));
goto cleanup;
}
@@ -699,7 +699,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn,
free(vol->target.path);
free(vol);
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("volume name"));
+ "%s", _("volume name"));
goto cleanup;
}
strcpy(vol->target.path, pool->def->target.path);
@@ -710,7 +710,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn,
free(vol->target.path);
free(vol);
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("volume key"));
+ "%s", _("volume key"));
goto cleanup;
}
@@ -822,7 +822,7 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn,
vol->target.path = malloc(strlen(pool->def->target.path) +
1 + strlen(vol->name) + 1);
if (vol->target.path == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("target"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("target"));
return -1;
}
strcpy(vol->target.path, pool->def->target.path);
@@ -831,7 +831,7 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn,
vol->key = strdup(vol->target.path);
if (vol->key == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("storage vol key"));
+ "%s", _("storage vol key"));
return -1;
}
@@ -963,7 +963,8 @@ virStorageBackendFileSystemVolCreate(virConnectPtr conn,
}
#else
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("creation of non-raw images is not supported without qemu-img"));
+ "%s", _("creation of non-raw images "
+ "is not supported without qemu-img"));
return -1;
#endif
}
diff --git a/src/storage_backend_iscsi.c b/src/storage_backend_iscsi.c
index 2f7d746..fc79b46 100644
--- a/src/storage_backend_iscsi.c
+++ b/src/storage_backend_iscsi.c
@@ -92,7 +92,7 @@ virStorageBackendISCSIExtractSession(virConnectPtr conn,
if (STREQ(groups[1], pool->def->source.devices[0].path)) {
if ((*session = strdup(groups[0])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("session"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("session"));
return -1;
}
}
@@ -133,7 +133,7 @@ virStorageBackendISCSISession(virConnectPtr conn,
if (session == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("cannot find session"));
+ "%s", _("cannot find session"));
return NULL;
}
@@ -174,17 +174,17 @@ virStorageBackendISCSIMakeLUN(virConnectPtr conn,
snprintf(lunid, sizeof(lunid)-1, "lun-%s", groups[3]);
if ((vol = calloc(1, sizeof(virStorageVolDef))) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("volume"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
return -1;
}
if ((vol->name = strdup(lunid)) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("name"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("name"));
goto cleanup;
}
if ((devpath = malloc(5 + strlen(dev) + 1)) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("devpath"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("devpath"));
goto cleanup;
}
strcpy(devpath, "/dev/");
@@ -230,7 +230,7 @@ virStorageBackendISCSIMakeLUN(virConnectPtr conn,
/* XXX use unique iSCSI id instead */
vol->key = strdup(vol->target.path);
if (vol->key == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("key"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("key"));
goto cleanup;
}
@@ -342,7 +342,7 @@ virStorageBackendISCSIPortal(virConnectPtr conn,
portal = malloc(strlen(ipaddr) + 1 + 4 + 2 + 1);
if (portal == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("portal"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("portal"));
return NULL;
}
@@ -361,14 +361,14 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
if (pool->def->source.host.name == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("missing source host"));
+ "%s", _("missing source host"));
return -1;
}
if (pool->def->source.ndevice != 1 ||
pool->def->source.devices[0].path == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("missing source device"));
+ "%s", _("missing source device"));
return -1;
}
diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c
index c14e788..a70c087 100644
--- a/src/storage_backend_logical.c
+++ b/src/storage_backend_logical.c
@@ -113,12 +113,12 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
/* Or a completely new volume */
if (vol == NULL) {
if ((vol = calloc(1, sizeof(*vol))) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("volume"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
return -1;
}
if ((vol->name = strdup(groups[0])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("volume"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
return -1;
}
@@ -130,7 +130,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
if (vol->target.path == NULL) {
if ((vol->target.path = malloc(strlen(pool->def->target.path) +
1 + strlen(vol->name) + 1)) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("volume"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
return -1;
}
strcpy(vol->target.path, pool->def->target.path);
@@ -140,7 +140,7 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
if (vol->key == NULL &&
(vol->key = strdup(groups[1])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("volume"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("volume"));
return -1;
}
@@ -151,30 +151,30 @@ virStorageBackendLogicalMakeVol(virConnectPtr conn,
/* Finally fill in extents information */
if ((tmp = realloc(vol->source.extents, sizeof(*tmp)
* (vol->source.nextent + 1))) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("extents"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("extents"));
return -1;
}
vol->source.extents = tmp;
if ((vol->source.extents[vol->source.nextent].path =
strdup(groups[2])) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("extents"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("extents"));
return -1;
}
if (virStrToLong_ull(groups[3], NULL, 10, &offset) < 0) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("malformed volume extent offset value"));
+ "%s", _("malformed volume extent offset value"));
return -1;
}
if (virStrToLong_ull(groups[4], NULL, 10, &length) < 0) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("malformed volume extent length value"));
+ "%s", _("malformed volume extent length value"));
return -1;
}
if (virStrToLong_ull(groups[5], NULL, 10, &size) < 0) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("malformed volume extent size value"));
+ "%s", _("malformed volume extent size value"));
return -1;
}
@@ -266,7 +266,7 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn,
/* XXX multiple pvs */
if ((vgargv = malloc(sizeof(char*) * (1))) == NULL) {
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("command line"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("command line"));
return -1;
}
diff --git a/src/storage_conf.c b/src/storage_conf.c
index 8dfcde7..76e141e 100644
--- a/src/storage_conf.c
+++ b/src/storage_conf.c
@@ -153,14 +153,14 @@ virStoragePoolDefParseAuthChap(virConnectPtr conn,
auth->login = virXPathString("string(/pool/source/auth/@login)", ctxt);
if (auth->login == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing auth host attribute"));
+ "%s", _("missing auth host attribute"));
return -1;
}
auth->passwd = virXPathString("string(/pool/source/auth/@passwd)", ctxt);
if (auth->passwd == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing auth passwd attribute"));
+ "%s", _("missing auth passwd attribute"));
return -1;
}
@@ -183,7 +183,7 @@ virStoragePoolDefParsePerms(virConnectPtr conn,
perms->mode = strtol(mode, &end, 8);
if (*end || perms->mode < 0 || perms->mode > 0777) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("malformed octal mode"));
+ "%s", _("malformed octal mode"));
return -1;
}
}
@@ -193,7 +193,7 @@ virStoragePoolDefParsePerms(virConnectPtr conn,
} else {
if (virXPathLong("number(/pool/permissions/owner)", ctxt, &v) < 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("malformed owner element"));
+ "%s", _("malformed owner element"));
return -1;
}
perms->uid = (int)v;
@@ -204,7 +204,7 @@ virStoragePoolDefParsePerms(virConnectPtr conn,
} else {
if (virXPathLong("number(/pool/permissions/group)", ctxt, &v) < 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("malformed group element"));
+ "%s", _("malformed group element"));
return -1;
}
perms->gid = (int)v;
@@ -232,7 +232,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
if (STRNEQ((const char *)root->name, "pool")) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("unknown root element"));
+ "%s", _("unknown root element"));
goto cleanup;
}
@@ -248,7 +248,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
if ((ret->name = virXPathString("string(/pool/name)", ctxt)) == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing name element"));
+ "%s", _("missing name element"));
goto cleanup;
}
@@ -256,13 +256,13 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
if (uuid == NULL) {
if (virUUIDGenerate(ret->uuid) < 0) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unable to generate uuid"));
+ "%s", _("unable to generate uuid"));
goto cleanup;
}
} else {
if (virUUIDParse(uuid, ret->uuid) < 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("malformed uuid element"));
+ "%s", _("malformed uuid element"));
goto cleanup;
}
free(uuid);
@@ -281,7 +281,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
if (options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_HOST) {
if ((ret->source.host.name = virXPathString("string(/pool/source/host/@name)", ctxt)) == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing source host name"));
+ "%s", _("missing source host name"));
goto cleanup;
}
}
@@ -291,12 +291,12 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
if ((nsource = virXPathNodeSet("/pool/source/device", ctxt, &nodeset)) <= 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("cannot extract source devices"));
+ "%s", _("cannot extract source devices"));
goto cleanup;
}
if ((ret->source.devices = calloc(nsource, sizeof(*ret->source.devices))) == NULL) {
free(nodeset);
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("device"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("device"));
goto cleanup;
}
for (i = 0 ; i < nsource ; i++) {
@@ -304,7 +304,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
if (path == NULL) {
free(nodeset);
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing source device path"));
+ "%s", _("missing source device path"));
goto cleanup;
}
ret->source.devices[i].path = (char *)path;
@@ -315,7 +315,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
if (options->flags & VIR_STORAGE_BACKEND_POOL_SOURCE_DIR) {
if ((ret->source.dir = virXPathString("string(/pool/source/dir/@path)", ctxt)) == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing source path"));
+ "%s", _("missing source path"));
goto cleanup;
}
}
@@ -346,7 +346,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
if ((ret->target.path = virXPathString("string(/pool/target/path)", ctxt)) == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing target path"));
+ "%s", _("missing target path"));
goto cleanup;
}
@@ -378,21 +378,21 @@ virStoragePoolDefParse(virConnectPtr conn,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("malformed xml document"));
+ "%s", _("malformed xml document"));
goto cleanup;
}
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("xmlXPathContext"));
+ "%s", _("xmlXPathContext"));
goto cleanup;
}
node = xmlDocGetRootElement(xml);
if (node == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing root element"));
+ "%s", _("missing root element"));
goto cleanup;
}
@@ -429,7 +429,7 @@ virStoragePoolDefFormat(virConnectPtr conn,
type = virStorageBackendToString(def->type);
if (!type) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("unexpected pool type"));
+ "%s", _("unexpected pool type"));
goto cleanup;
}
if (virBufferVSprintf(buf, "<pool type='%s'>\n", type) < 0)
@@ -540,7 +540,7 @@ virStoragePoolDefFormat(virConnectPtr conn,
return virBufferContentAndFree(buf);
no_memory:
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("xml"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("xml"));
cleanup:
virBufferFree(buf);
return NULL;
@@ -562,7 +562,7 @@ virStorageVolDefParsePerms(virConnectPtr conn,
perms->mode = strtol(mode, &end, 8);
if (*end || perms->mode < 0 || perms->mode > 0777) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("malformed octal mode"));
+ "%s", _("malformed octal mode"));
return -1;
}
}
@@ -572,7 +572,7 @@ virStorageVolDefParsePerms(virConnectPtr conn,
} else {
if (virXPathLong("number(/volume/permissions/owner)", ctxt, &v) < 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing owner element"));
+ "%s", _("missing owner element"));
return -1;
}
perms->uid = (int)v;
@@ -582,7 +582,7 @@ virStorageVolDefParsePerms(virConnectPtr conn,
} else {
if (virXPathLong("number(/volume/permissions/group)", ctxt, &v) < 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing owner element"));
+ "%s", _("missing owner element"));
return -1;
}
perms->gid = (int)v;
@@ -653,12 +653,12 @@ virStorageSize(virConnectPtr conn,
if (virStrToLong_ull (val, &end, 10, ret) < 0) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("malformed capacity element"));
+ "%s", _("malformed capacity element"));
return -1;
}
if (*ret > (ULLONG_MAX / mult)) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("capacity element value too large"));
+ "%s", _("capacity element value too large"));
return -1;
}
@@ -687,14 +687,14 @@ virStorageVolDefParseDoc(virConnectPtr conn,
if (STRNEQ((const char *)root->name, "volume")) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("unknown root element"));
+ "%s", _("unknown root element"));
goto cleanup;
}
ret->name = virXPathString("string(/volume/name)", ctxt);
if (ret->name == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing name element"));
+ "%s", _("missing name element"));
goto cleanup;
}
@@ -705,7 +705,7 @@ virStorageVolDefParseDoc(virConnectPtr conn,
unit = virXPathString("string(/volume/capacity/@unit)", ctxt);
if (capacity == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing capacity element"));
+ "%s", _("missing capacity element"));
goto cleanup;
}
if (virStorageSize(conn, unit, capacity, &ret->capacity) < 0)
@@ -766,21 +766,21 @@ virStorageVolDefParse(virConnectPtr conn,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("malformed xml document"));
+ "%s", _("malformed xml document"));
goto cleanup;
}
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("xmlXPathContext"));
+ "%s", _("xmlXPathContext"));
goto cleanup;
}
node = xmlDocGetRootElement(xml);
if (node == NULL) {
virStorageReportError(conn, VIR_ERR_XML_ERROR,
- _("missing root element"));
+ "%s", _("missing root element"));
goto cleanup;
}
@@ -903,7 +903,7 @@ virStorageVolDefFormat(virConnectPtr conn,
return virBufferContentAndFree(buf);
no_memory:
- virStorageReportError(conn, VIR_ERR_NO_MEMORY, _("xml"));
+ virStorageReportError(conn, VIR_ERR_NO_MEMORY, "%s", _("xml"));
cleanup:
virBufferFree(buf);
return NULL;
@@ -1013,7 +1013,7 @@ virStoragePoolObjAssignDef(virConnectPtr conn,
if (!(pool = calloc(1, sizeof(virStoragePoolObj)))) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("pool"));
+ "%s", _("pool"));
return NULL;
}
@@ -1150,26 +1150,27 @@ virStoragePoolObjSaveDef(virConnectPtr conn,
if (virFileBuildPath(driver->configDir, def->name, ".xml",
path, sizeof(path)) < 0) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("cannot construct config file path"));
+ "%s", _("cannot construct config file path"));
return -1;
}
if (!(pool->configFile = strdup(path))) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("configFile"));
+ "%s", _("configFile"));
return -1;
}
if (virFileBuildPath(driver->autostartDir, def->name, ".xml",
path, sizeof(path)) < 0) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("cannot construct autostart link path"));
+ "%s", _("cannot construct "
+ "autostart link path"));
free(pool->configFile);
pool->configFile = NULL;
return -1;
}
if (!(pool->autostartLink = strdup(path))) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("config file"));
+ "%s", _("config file"));
free(pool->configFile);
pool->configFile = NULL;
return -1;
@@ -1178,7 +1179,7 @@ virStoragePoolObjSaveDef(virConnectPtr conn,
if (!(xml = virStoragePoolDefFormat(conn, def))) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("failed to generate XML"));
+ "%s", _("failed to generate XML"));
return -1;
}
diff --git a/src/storage_driver.c b/src/storage_driver.c
index f97f706..2fa06af 100644
--- a/src/storage_driver.c
+++ b/src/storage_driver.c
@@ -261,7 +261,7 @@ storagePoolLookupByUUID(virConnectPtr conn,
if (!pool) {
virStorageReportError(conn, VIR_ERR_NO_STORAGE_POOL,
- _("no pool with matching uuid"));
+ "%s", _("no pool with matching uuid"));
return NULL;
}
@@ -279,7 +279,7 @@ storagePoolLookupByName(virConnectPtr conn,
if (!pool) {
virStorageReportError(conn, VIR_ERR_NO_STORAGE_POOL,
- _("no pool with matching name"));
+ "%s", _("no pool with matching name"));
return NULL;
}
@@ -329,7 +329,7 @@ storageListPools(virConnectPtr conn,
if (virStoragePoolObjIsActive(pool)) {
if (!(names[got] = strdup(pool->def->name))) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("names"));
+ "%s", _("names"));
goto cleanup;
}
got++;
@@ -366,7 +366,7 @@ storageListDefinedPools(virConnectPtr conn,
if (!virStoragePoolObjIsActive(pool)) {
if (!(names[got] = strdup(pool->def->name))) {
virStorageReportError(conn, VIR_ERR_NO_MEMORY,
- _("names"));
+ "%s", _("names"));
goto cleanup;
}
got++;
@@ -401,7 +401,7 @@ storagePoolCreate(virConnectPtr conn,
if (virStoragePoolObjFindByUUID(driver, def->uuid) ||
virStoragePoolObjFindByName(driver, def->name)) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool already exists"));
+ "%s", _("storage pool already exists"));
virStoragePoolDefFree(def);
return NULL;
}
@@ -470,13 +470,13 @@ storagePoolUndefine(virStoragePoolPtr obj) {
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
if (virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("pool is still active"));
+ "%s", _("pool is still active"));
return -1;
}
@@ -507,7 +507,7 @@ storagePoolStart(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
@@ -517,7 +517,7 @@ storagePoolStart(virStoragePoolPtr obj,
if (virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("pool already active"));
+ "%s", _("pool already active"));
return -1;
}
if (backend->startPool &&
@@ -546,7 +546,7 @@ storagePoolBuild(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
@@ -556,7 +556,7 @@ storagePoolBuild(virStoragePoolPtr obj,
if (virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is already active"));
+ "%s", _("storage pool is already active"));
return -1;
}
@@ -577,7 +577,7 @@ storagePoolDestroy(virStoragePoolPtr obj) {
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
@@ -587,7 +587,7 @@ storagePoolDestroy(virStoragePoolPtr obj) {
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return -1;
}
@@ -618,7 +618,7 @@ storagePoolDelete(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
@@ -628,13 +628,13 @@ storagePoolDelete(virStoragePoolPtr obj,
if (virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is still active"));
+ "%s", _("storage pool is still active"));
return -1;
}
if (!backend->deletePool) {
virStorageReportError(obj->conn, VIR_ERR_NO_SUPPORT,
- _("pool does not support volume delete"));
+ "%s", _("pool does not support volume delete"));
return -1;
}
if (backend->deletePool(obj->conn, pool, flags) < 0)
@@ -655,7 +655,7 @@ storagePoolRefresh(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
@@ -665,7 +665,7 @@ storagePoolRefresh(virStoragePoolPtr obj,
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return -1;
}
@@ -696,7 +696,7 @@ storagePoolGetInfo(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
@@ -725,7 +725,7 @@ storagePoolDumpXML(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return NULL;
}
@@ -741,7 +741,7 @@ storagePoolGetAutostart(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no pool with matching uuid"));
+ "%s", _("no pool with matching uuid"));
return -1;
}
@@ -763,13 +763,13 @@ storagePoolSetAutostart(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no pool with matching uuid"));
+ "%s", _("no pool with matching uuid"));
return -1;
}
if (!pool->configFile) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_ARG,
- _("pool has no config file"));
+ "%s", _("pool has no config file"));
return -1;
}
@@ -819,13 +819,13 @@ storagePoolNumVolumes(virStoragePoolPtr obj) {
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return -1;
}
@@ -844,13 +844,13 @@ storagePoolListVolumes(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return -1;
}
@@ -859,7 +859,8 @@ storagePoolListVolumes(virStoragePoolPtr obj,
while (vol && i < maxnames) {
names[i] = strdup(vol->name);
if (names[i] == NULL) {
- virStorageReportError(obj->conn, VIR_ERR_NO_MEMORY, _("name"));
+ virStorageReportError(obj->conn, VIR_ERR_NO_MEMORY,
+ "%s", _("name"));
goto cleanup;
}
vol = vol->next;
@@ -888,13 +889,13 @@ storageVolumeLookupByName(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return NULL;
}
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return NULL;
}
@@ -902,7 +903,7 @@ storageVolumeLookupByName(virStoragePoolPtr obj,
if (!vol) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage vol with matching name"));
+ "%s", _("no storage vol with matching name"));
return NULL;
}
@@ -931,7 +932,7 @@ storageVolumeLookupByKey(virConnectPtr conn,
}
virStorageReportError(conn, VIR_ERR_INVALID_STORAGE_VOL,
- _("no storage vol with matching key"));
+ "%s", _("no storage vol with matching key"));
return NULL;
}
@@ -956,7 +957,7 @@ storageVolumeLookupByPath(virConnectPtr conn,
}
virStorageReportError(conn, VIR_ERR_INVALID_STORAGE_VOL,
- _("no storage vol with matching path"));
+ "%s", _("no storage vol with matching path"));
return NULL;
}
@@ -972,13 +973,13 @@ storageVolumeCreateXML(virStoragePoolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return NULL;
}
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return NULL;
}
@@ -991,14 +992,14 @@ storageVolumeCreateXML(virStoragePoolPtr obj,
if (virStorageVolDefFindByName(pool, vol->name)) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("storage vol already exists"));
+ "%s", _("storage vol already exists"));
virStorageVolDefFree(vol);
return NULL;
}
if (!backend->createVol) {
virStorageReportError(obj->conn, VIR_ERR_NO_SUPPORT,
- _("storage pool does not support volume creation"));
+ "%s", _("storage pool does not support volume creation"));
virStorageVolDefFree(vol);
return NULL;
}
@@ -1026,13 +1027,13 @@ storageVolumeDelete(virStorageVolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return -1;
}
@@ -1043,13 +1044,13 @@ storageVolumeDelete(virStorageVolPtr obj,
if (!vol) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage vol with matching name"));
+ "%s", _("no storage vol with matching name"));
return -1;
}
if (!backend->deleteVol) {
virStorageReportError(obj->conn, VIR_ERR_NO_SUPPORT,
- _("storage pool does not support vol deletion"));
+ "%s", _("storage pool does not support vol deletion"));
virStorageVolDefFree(vol);
return -1;
}
@@ -1089,13 +1090,13 @@ storageVolumeGetInfo(virStorageVolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return -1;
}
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return -1;
}
@@ -1103,7 +1104,7 @@ storageVolumeGetInfo(virStorageVolPtr obj,
if (!vol) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage vol with matching name"));
+ "%s", _("no storage vol with matching name"));
return -1;
}
@@ -1133,13 +1134,13 @@ storageVolumeGetXMLDesc(virStorageVolPtr obj,
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return NULL;
}
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return NULL;
}
@@ -1147,7 +1148,7 @@ storageVolumeGetXMLDesc(virStorageVolPtr obj,
if (!vol) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage vol with matching name"));
+ "%s", _("no storage vol with matching name"));
return NULL;
}
@@ -1167,13 +1168,13 @@ storageVolumeGetPath(virStorageVolPtr obj) {
if (!pool) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage pool with matching uuid"));
+ "%s", _("no storage pool with matching uuid"));
return NULL;
}
if (!virStoragePoolObjIsActive(pool)) {
virStorageReportError(obj->conn, VIR_ERR_INTERNAL_ERROR,
- _("storage pool is not active"));
+ "%s", _("storage pool is not active"));
return NULL;
}
@@ -1181,13 +1182,13 @@ storageVolumeGetPath(virStorageVolPtr obj) {
if (!vol) {
virStorageReportError(obj->conn, VIR_ERR_INVALID_STORAGE_POOL,
- _("no storage vol with matching name"));
+ "%s", _("no storage vol with matching name"));
return NULL;
}
ret = strdup(vol->target.path);
if (ret == NULL) {
- virStorageReportError(obj->conn, VIR_ERR_NO_MEMORY, _("path"));
+ virStorageReportError(obj->conn, VIR_ERR_NO_MEMORY, "%s", _("path"));
return NULL;
}
return ret;
--
1.5.4.1.144.gc2249
16 years, 10 months
[Libvir] [PATCH] 2/2: Use safewrite in place of write, in many cases.
by Jim Meyering
Use safewrite in place of write, in many cases.
Also add "make syntax-check" rules to ensure no new uses sneak in.
There are many uses of write like this:
if (write (fd, xml, towrite) != towrite)
return -1;
The problem is that the syscall can succeed, yet write less than
the requested number of bytes, so the caller should retry
rather than simply failing.
This patch changes most of them to use util.c's safewrite wrapper,
which encapsulates the process. Also, there were a few cases in
which the retry loop was open-coded, and I replaced those, too.
Note: the change to libvirt_proxy.c removes a diagnostic that
would have warned about an EINTR-interrupted (and retried) write,
but that seems ok.
* Makefile.maint (sc_avoid_write): New rule, to avoid recurrence.
* .x-sc_avoid_write: New file. Record two legitimate exemptions.
* qemud/qemud.c (sig_handler, qemudClientWriteBuf): Use safewrite, not write.
* src/conf.c (__virConfWriteFile): Likewise.
* src/qemu_conf.c (qemudSaveConfig, qemudSaveNetworkConfig): Likewise.
* src/qemu_driver.c (qemudWaitForMonitor, qemudStartVMDaemon)
(qemudVMData, PROC_IP_FORWARD): Likewise.
* proxy/libvirt_proxy.c: Include "util.h".
(proxyWriteClientSocket): Use safewrite.
* src/test.c (testDomainSave, testDomainCoreDump): Likewise.
* src/proxy_internal.c (virProxyWriteClientSocket): Likewise.
* src/virsh.c: Include "util-lib.h".
(vshOutputLogFile): Use safewrite.
* src/console.c: Include "util-lib.h".
(vshRunConsole): Use safewrite.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
.x-sc_avoid_write | 2 ++
Makefile.maint | 11 +++++++++++
qemud/qemud.c | 10 ++++------
src/conf.c | 2 +-
src/console.c | 6 ++++--
src/proxy_internal.c | 14 ++++----------
src/qemu_conf.c | 4 ++--
src/qemu_driver.c | 19 +++++++------------
src/test.c | 9 +++++----
src/virsh.c | 5 +++--
10 files changed, 43 insertions(+), 39 deletions(-)
create mode 100644 .x-sc_avoid_write
diff --git a/.x-sc_avoid_write b/.x-sc_avoid_write
new file mode 100644
index 0000000..72a196d
--- /dev/null
+++ b/.x-sc_avoid_write
@@ -0,0 +1,2 @@
+^src/util\.c$
+^src/xend_internal\.c$
diff --git a/Makefile.maint b/Makefile.maint
index 39320df..fe964a5 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -46,6 +46,17 @@ sc_avoid_if_before_free:
{ echo '$(ME): found useless "if" before "free" above' 1>&2; \
exit 1; } || :
+# Avoid uses of write(2). Either switch to streams (fwrite), or use
+# the safewrite wrapper.
+sc_avoid_write:
+ @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
+ grep '\<write *(' $$($(CVS_LIST_EXCEPT) | grep '\.c$$') && \
+ { echo "$(ME): the above files use write;" \
+ " consider using the safewrite wrapper instead" \
+ 1>&2; exit 1; } || :; \
+ else :; \
+ fi
+
sc_cast_of_argument_to_free:
@grep -nE '\<free \(\(' $$($(CVS_LIST_EXCEPT)) && \
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
diff --git a/qemud/qemud.c b/qemud/qemud.c
index a40dfcb..d53a813 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -118,7 +118,7 @@ static void sig_handler(int sig) {
return;
origerrno = errno;
- r = write(sigwrite, &sigc, 1);
+ r = safewrite(sigwrite, &sigc, 1);
if (r == -1) {
sig_errors++;
sig_lasterrno = errno;
@@ -1360,11 +1360,9 @@ static int qemudClientWriteBuf(struct qemud_server *server,
const char *data, int len) {
int ret;
if (!client->tlssession) {
- if ((ret = write(client->fd, data, len)) == -1) {
- if (errno != EAGAIN) {
- qemudLog (QEMUD_ERR, _("write: %s"), strerror (errno));
- qemudDispatchClientFailure(server, client);
- }
+ if ((ret = safewrite(client->fd, data, len)) == -1) {
+ qemudLog (QEMUD_ERR, _("write: %s"), strerror (errno));
+ qemudDispatchClientFailure(server, client);
return -1;
}
} else {
diff --git a/src/conf.c b/src/conf.c
index e0ecdea..53ea993 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -904,7 +904,7 @@ __virConfWriteFile(const char *filename, virConfPtr conf)
goto error;
}
- ret = write(fd, buf->content, buf->use);
+ ret = safewrite(fd, buf->content, buf->use);
close(fd);
if (ret != (int) buf->use) {
virConfError(NULL, VIR_ERR_WRITE_FAILED, _("failed to save content"), 0);
diff --git a/src/console.c b/src/console.c
index 02a9c7f..079d4ef 100644
--- a/src/console.c
+++ b/src/console.c
@@ -1,7 +1,7 @@
/*
* console.c: A dumb serial console client
*
- * Copyright (C) 2007 Red Hat, Inc.
+ * Copyright (C) 2007, 2008 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -37,6 +37,7 @@
#include "console.h"
#include "internal.h"
+#include "util-lib.h"
/* ie Ctrl-] as per telnet */
#define CTRL_CLOSE_BRACKET '\35'
@@ -161,7 +162,8 @@ int vshRunConsole(const char *tty) {
while (sent < got) {
int done;
- if ((done = write(destfd, buf + sent, got - sent)) <= 0) {
+ if ((done = safewrite(destfd, buf + sent, got - sent))
+ <= 0) {
fprintf(stderr, _("failure writing output: %s\n"),
strerror(errno));
goto cleanup;
diff --git a/src/proxy_internal.c b/src/proxy_internal.c
index bc94763..c3e50c6 100644
--- a/src/proxy_internal.c
+++ b/src/proxy_internal.c
@@ -1,7 +1,7 @@
/*
* proxy_client.c: client side of the communication with the libvirt proxy.
*
- * Copyright (C) 2006 Red Hat, Inc.
+ * Copyright (C) 2006, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -26,6 +26,7 @@
#include "internal.h"
#include "driver.h"
#include "proxy_internal.h"
+#include "util.h"
#include "xen_unified.h"
#define STANDALONE
@@ -345,17 +346,10 @@ virProxyWriteClientSocket(int fd, const char *data, int len) {
if ((fd < 0) || (data == NULL) || (len < 0))
return(-1);
-retry:
- ret = write(fd, data, len);
+ ret = safewrite(fd, data, len);
if (ret < 0) {
- if (errno == EINTR) {
- if (debug > 0)
- fprintf(stderr, "write socket %d, %d bytes interrupted\n",
- fd, len);
- goto retry;
- }
fprintf(stderr, _("Failed to write to socket %d\n"), fd);
- return(-1);
+ return(-1);
}
if (debug)
fprintf(stderr, "wrote %d bytes to socket %d\n",
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index ac1cc1e..fc82a6d 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -1866,7 +1866,7 @@ static int qemudSaveConfig(virConnectPtr conn,
}
towrite = strlen(xml);
- if (write(fd, xml, towrite) != towrite) {
+ if (safewrite(fd, xml, towrite) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write config file %s: %s",
vm->configFile, strerror(errno));
@@ -2089,7 +2089,7 @@ static int qemudSaveNetworkConfig(virConnectPtr conn,
}
towrite = strlen(xml);
- if (write(fd, xml, towrite) != towrite) {
+ if (safewrite(fd, xml, towrite) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write config file %s: %s",
network->configFile, strerror(errno));
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 15cd52c..85d042f 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -539,11 +539,9 @@ static int qemudWaitForMonitor(virConnectPtr conn,
"console");
buf[sizeof(buf)-1] = '\0';
- retry:
- if (write(vm->logfile, buf, strlen(buf)) < 0) {
+
+ if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
/* Log, but ignore failures to write logfile for VM */
- if (errno == EINTR)
- goto retry;
qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s"),
strerror(errno));
}
@@ -656,15 +654,15 @@ static int qemudStartVMDaemon(virConnectPtr conn,
tmp = argv;
while (*tmp) {
- if (write(vm->logfile, *tmp, strlen(*tmp)) < 0)
+ if (safewrite(vm->logfile, *tmp, strlen(*tmp)) < 0)
qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
errno, strerror(errno));
- if (write(vm->logfile, " ", 1) < 0)
+ if (safewrite(vm->logfile, " ", 1) < 0)
qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
errno, strerror(errno));
tmp++;
}
- if (write(vm->logfile, "\n", 1) < 0)
+ if (safewrite(vm->logfile, "\n", 1) < 0)
qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
errno, strerror(errno));
@@ -733,11 +731,8 @@ static int qemudVMData(struct qemud_driver *driver ATTRIBUTE_UNUSED,
}
buf[ret] = '\0';
- retry:
- if (write(vm->logfile, buf, ret) < 0) {
+ if (safewrite(vm->logfile, buf, ret) < 0) {
/* Log, but ignore failures to write logfile for VM */
- if (errno == EINTR)
- goto retry;
qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s"),
strerror(errno));
}
@@ -1113,7 +1108,7 @@ qemudEnableIpForwarding(void)
if ((fd = open(PROC_IP_FORWARD, O_WRONLY|O_TRUNC)) == -1)
return 0;
- if (write(fd, "1\n", 2) < 0)
+ if (safewrite(fd, "1\n", 2) < 0)
ret = 0;
close (fd);
diff --git a/src/test.c b/src/test.c
index f860e49..1d064d3 100644
--- a/src/test.c
+++ b/src/test.c
@@ -42,6 +42,7 @@
#include "test.h"
#include "xml.h"
#include "buf.h"
+#include "util.h"
#include "uuid.h"
/* Flags that determine the action to take on a shutdown or crash of a domain
@@ -1293,19 +1294,19 @@ static int testDomainSave(virDomainPtr domain,
return (-1);
}
len = strlen(xml);
- if (write(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) != sizeof(TEST_SAVE_MAGIC)) {
+ if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write header");
close(fd);
return (-1);
}
- if (write(fd, (char*)&len, sizeof(len)) != sizeof(len)) {
+ if (safewrite(fd, (char*)&len, sizeof(len)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write metadata length");
close(fd);
return (-1);
}
- if (write(fd, xml, len) != len) {
+ if (safewrite(fd, xml, len) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write metadata");
free(xml);
@@ -1398,7 +1399,7 @@ static int testDomainCoreDump(virDomainPtr domain,
"cannot save domain core");
return (-1);
}
- if (write(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) != sizeof(TEST_SAVE_MAGIC)) {
+ if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write header");
close(fd);
diff --git a/src/virsh.c b/src/virsh.c
index 5a5f04e..356c496 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -46,9 +46,10 @@
#include <readline/history.h>
#endif
+#include "buf.h"
#include "console.h"
#include "util.h"
-#include "buf.h"
+#include "util-lib.h"
static char *progname;
@@ -6170,7 +6171,7 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format, va_list
snprintf(msg_buf + strlen(msg_buf), sizeof(msg_buf) - strlen(msg_buf), "\n");
/* write log */
- if (write(ctl->log_fd, msg_buf, strlen(msg_buf)) == -1) {
+ if (safewrite(ctl->log_fd, msg_buf, strlen(msg_buf)) < 0) {
vshCloseLogFile(ctl);
vshError(ctl, FALSE, "%s", _("failed to write the log file"));
}
--
1.5.4.2.185.gf5f8
16 years, 10 months
[Libvir] [PATCH] write(2) may write less than the total requested
by Jim Meyering
Use safewrite in place of write, in many cases.
And add "make syntax-check" rules to ensure no new uses sneak in.
There are many uses of write like this:
if (write (fd, xml, towrite) != towrite)
return -1;
The problem is that the syscall can succeed, yet write less than
the requested number of bytes, so the caller should retry
rather than simply failing.
This patch changes most of them to use util.c's safewrite wrapper,
which encapsulates the process. Also, there were a few cases in
which the retry loop was open-coded, and I replaced those, too.
However, there remain invalid uses of write in both virsh.c and
console.c. I would have replaced those, too, but util.c isn't
linked with them, so it would have made this change more involved.
xend_internal.c has one use, but it's ok, and not easily replaced.
Note: the change to libvirt_proxy.c removes a diagnostic that
would have warned about an EINTR-interrupted (and retried) write,
but that seems ok.
* qemud/qemud.c (sig_handler):
* src/conf.c (__virConfWriteFile):
* src/proxy_internal.c (virProxyWriteClientSocket):
* src/qemu_conf.c (qemudSaveConfig, qemudSaveNetworkConfig):
* src/qemu_driver.c (qemudWaitForMonitor, qemudStartVMDaemon)
(qemudVMData, PROC_IP_FORWARD):
* src/test.c (testDomainSave, testDomainCoreDump):
* proxy/libvirt_proxy.c (proxyWriteClientSocket):
* proxy/Makefile.am (libvirt_proxy_SOURCES): Add src/util.c.
* Makefile.maint (sc_avoid_write): New rule.
* .x-sc_avoid_write: New file. Record the two legitimate
exemptions, and two that are temporarily grandfathered in.
Signed-off-by: Jim Meyering <meyering(a)redhat.com>
---
.x-sc_avoid_write | 4 ++++
Makefile.maint | 11 +++++++++++
proxy/Makefile.am | 5 +++--
proxy/libvirt_proxy.c | 15 ++++-----------
qemud/qemud.c | 10 ++++------
src/conf.c | 2 +-
src/proxy_internal.c | 13 +++----------
src/qemu_conf.c | 4 ++--
src/qemu_driver.c | 19 +++++++------------
src/test.c | 8 ++++----
10 files changed, 43 insertions(+), 48 deletions(-)
create mode 100644 .x-sc_avoid_write
diff --git a/.x-sc_avoid_write b/.x-sc_avoid_write
new file mode 100644
index 0000000..0933e20
--- /dev/null
+++ b/.x-sc_avoid_write
@@ -0,0 +1,4 @@
+^src/util\.c$
+^src/xend_internal\.c$
+^src/virsh\.c$
+^src/console\.c$
diff --git a/Makefile.maint b/Makefile.maint
index 4b54baf..afddddb 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -46,6 +46,17 @@ sc_avoid_if_before_free:
{ echo '$(ME): found useless "if" before "free" above' 1>&2; \
exit 1; } || :
+# Avoid uses of write(2). Either switch to streams (fwrite), or use
+# the safewrite wrapper.
+sc_avoid_write:
+ @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
+ grep '\<write *(' $$($(CVS_LIST_EXCEPT) | grep '\.c$$') && \
+ { echo "$(ME): the above files use write;" \
+ " consider using the safewrite wrapper instead" \
+ 1>&2; exit 1; } || :; \
+ else :; \
+ fi
+
sc_cast_of_argument_to_free:
@grep -nE '\<free \(\(' $$($(CVS_LIST_EXCEPT)) && \
{ echo '$(ME): don'\''t cast free argument' 1>&2; \
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index ff9a3eb..6827f36 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -12,11 +12,12 @@ libexec_PROGRAMS = libvirt_proxy
libvirt_proxy_SOURCES = libvirt_proxy.c @top_srcdir(a)/src/xend_internal.c \
@top_srcdir(a)/src/xen_internal.c @top_srcdir(a)/src/virterror.c \
@top_srcdir(a)/src/sexpr.c @top_srcdir(a)/src/xml.c \
- @top_srcdir(a)/src/xs_internal.c @top_srcdir(a)/src/buf.c @top_srcdir(a)/src/uuid.c
+ @top_srcdir(a)/src/xs_internal.c @top_srcdir(a)/src/buf.c \
+ @top_srcdir(a)/src/util.c @top_srcdir(a)/src/uuid.c
libvirt_proxy_LDFLAGS = $(WARN_CFLAGS)
libvirt_proxy_DEPENDENCIES =
libvirt_proxy_LDADD =
install-exec-hook:
chmod u+s $(DESTDIR)$(libexecdir)/libvirt_proxy
-endif
\ No newline at end of file
+endif
diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c
index d96d3db..12d0f35 100644
--- a/proxy/libvirt_proxy.c
+++ b/proxy/libvirt_proxy.c
@@ -2,7 +2,7 @@
* proxy_svr.c: root suid proxy server for Xen access to APIs with no
* side effects from unauthenticated clients.
*
- * Copyright (C) 2006, 2007 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -317,19 +317,12 @@ proxyWriteClientSocket(int nr, virProxyPacketPtr req) {
return(-1);
}
-retry:
- ret = write(pollInfos[nr].fd, (char *) req, req->len);
+ ret = safewrite(pollInfos[nr].fd, (char *) req, req->len);
if (ret < 0) {
- if (errno == EINTR) {
- if (debug > 0)
- fprintf(stderr, "write socket %d to client %d interrupted\n",
- pollInfos[nr].fd, nr);
- goto retry;
- }
fprintf(stderr, "write %d bytes to socket %d from client %d failed\n",
req->len, pollInfos[nr].fd, nr);
- proxyCloseClientSocket(nr);
- return(-1);
+ proxyCloseClientSocket(nr);
+ return(-1);
}
if (ret == 0) {
if (debug)
diff --git a/qemud/qemud.c b/qemud/qemud.c
index 3a5e44c..269e9fe 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -118,7 +118,7 @@ static void sig_handler(int sig) {
return;
origerrno = errno;
- r = write(sigwrite, &sigc, 1);
+ r = safewrite(sigwrite, &sigc, 1);
if (r == -1) {
sig_errors++;
sig_lasterrno = errno;
@@ -1360,11 +1360,9 @@ static int qemudClientWriteBuf(struct qemud_server *server,
const char *data, int len) {
int ret;
if (!client->tlssession) {
- if ((ret = write(client->fd, data, len)) == -1) {
- if (errno != EAGAIN) {
- qemudLog (QEMUD_ERR, _("write: %s"), strerror (errno));
- qemudDispatchClientFailure(server, client);
- }
+ if ((ret = safewrite(client->fd, data, len)) == -1) {
+ qemudLog (QEMUD_ERR, _("write: %s"), strerror (errno));
+ qemudDispatchClientFailure(server, client);
return -1;
}
} else {
diff --git a/src/conf.c b/src/conf.c
index e0ecdea..53ea993 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -904,7 +904,7 @@ __virConfWriteFile(const char *filename, virConfPtr conf)
goto error;
}
- ret = write(fd, buf->content, buf->use);
+ ret = safewrite(fd, buf->content, buf->use);
close(fd);
if (ret != (int) buf->use) {
virConfError(NULL, VIR_ERR_WRITE_FAILED, _("failed to save content"), 0);
diff --git a/src/proxy_internal.c b/src/proxy_internal.c
index bc94763..5a14e54 100644
--- a/src/proxy_internal.c
+++ b/src/proxy_internal.c
@@ -1,7 +1,7 @@
/*
* proxy_client.c: client side of the communication with the libvirt proxy.
*
- * Copyright (C) 2006 Red Hat, Inc.
+ * Copyright (C) 2006, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -345,17 +345,10 @@ virProxyWriteClientSocket(int fd, const char *data, int len) {
if ((fd < 0) || (data == NULL) || (len < 0))
return(-1);
-retry:
- ret = write(fd, data, len);
+ ret = safewrite(fd, data, len);
if (ret < 0) {
- if (errno == EINTR) {
- if (debug > 0)
- fprintf(stderr, "write socket %d, %d bytes interrupted\n",
- fd, len);
- goto retry;
- }
fprintf(stderr, _("Failed to write to socket %d\n"), fd);
- return(-1);
+ return(-1);
}
if (debug)
fprintf(stderr, "wrote %d bytes to socket %d\n",
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index e39c7bc..ff6a92e 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -1866,7 +1866,7 @@ static int qemudSaveConfig(virConnectPtr conn,
}
towrite = strlen(xml);
- if (write(fd, xml, towrite) != towrite) {
+ if (safewrite(fd, xml, towrite) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write config file %s: %s",
vm->configFile, strerror(errno));
@@ -2089,7 +2089,7 @@ static int qemudSaveNetworkConfig(virConnectPtr conn,
}
towrite = strlen(xml);
- if (write(fd, xml, towrite) != towrite) {
+ if (safewrite(fd, xml, towrite) < 0) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write config file %s: %s",
network->configFile, strerror(errno));
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 15cd52c..85d042f 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -539,11 +539,9 @@ static int qemudWaitForMonitor(virConnectPtr conn,
"console");
buf[sizeof(buf)-1] = '\0';
- retry:
- if (write(vm->logfile, buf, strlen(buf)) < 0) {
+
+ if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
/* Log, but ignore failures to write logfile for VM */
- if (errno == EINTR)
- goto retry;
qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s"),
strerror(errno));
}
@@ -656,15 +654,15 @@ static int qemudStartVMDaemon(virConnectPtr conn,
tmp = argv;
while (*tmp) {
- if (write(vm->logfile, *tmp, strlen(*tmp)) < 0)
+ if (safewrite(vm->logfile, *tmp, strlen(*tmp)) < 0)
qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
errno, strerror(errno));
- if (write(vm->logfile, " ", 1) < 0)
+ if (safewrite(vm->logfile, " ", 1) < 0)
qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
errno, strerror(errno));
tmp++;
}
- if (write(vm->logfile, "\n", 1) < 0)
+ if (safewrite(vm->logfile, "\n", 1) < 0)
qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
errno, strerror(errno));
@@ -733,11 +731,8 @@ static int qemudVMData(struct qemud_driver *driver ATTRIBUTE_UNUSED,
}
buf[ret] = '\0';
- retry:
- if (write(vm->logfile, buf, ret) < 0) {
+ if (safewrite(vm->logfile, buf, ret) < 0) {
/* Log, but ignore failures to write logfile for VM */
- if (errno == EINTR)
- goto retry;
qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s"),
strerror(errno));
}
@@ -1113,7 +1108,7 @@ qemudEnableIpForwarding(void)
if ((fd = open(PROC_IP_FORWARD, O_WRONLY|O_TRUNC)) == -1)
return 0;
- if (write(fd, "1\n", 2) < 0)
+ if (safewrite(fd, "1\n", 2) < 0)
ret = 0;
close (fd);
diff --git a/src/test.c b/src/test.c
index 003d6b7..3dd1007 100644
--- a/src/test.c
+++ b/src/test.c
@@ -1293,19 +1293,19 @@ static int testDomainSave(virDomainPtr domain,
return (-1);
}
len = strlen(xml);
- if (write(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) != sizeof(TEST_SAVE_MAGIC)) {
+ if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write header");
close(fd);
return (-1);
}
- if (write(fd, (char*)&len, sizeof(len)) != sizeof(len)) {
+ if (safewrite(fd, (char*)&len, sizeof(len)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write metadata length");
close(fd);
return (-1);
}
- if (write(fd, xml, len) != len) {
+ if (safewrite(fd, xml, len) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write metadata");
free(xml);
@@ -1398,7 +1398,7 @@ static int testDomainCoreDump(virDomainPtr domain,
"cannot save domain core");
return (-1);
}
- if (write(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) != sizeof(TEST_SAVE_MAGIC)) {
+ if (safewrite(fd, TEST_SAVE_MAGIC, sizeof(TEST_SAVE_MAGIC)) < 0) {
testError(domain->conn, domain, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write header");
close(fd);
--
1.5.4.2.134.g82883
16 years, 10 months
[Libvir] avoid new warnings
by Jim Meyering
Here are two easy ones:
With --without-xen, avoid warning about unused function.
* tests/statstest.c (testQuietError) [!WITH_XEN]: Don't define.
---
tests/statstest.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/tests/statstest.c b/tests/statstest.c
index 6213da8..2d6fc1d 100644
--- a/tests/statstest.c
+++ b/tests/statstest.c
@@ -7,10 +7,13 @@
#include "stats_linux.h"
#include "internal.h"
-static void testQuietError(void *userData ATTRIBUTE_UNUSED, virErrorPtr error ATTRIBUTE_UNUSED)
+#if WITH_XEN
+static void testQuietError(void *userData ATTRIBUTE_UNUSED,
+ virErrorPtr error ATTRIBUTE_UNUSED)
{
/* nada */
}
+#endif
#if __linux__ && WITH_XEN
static int testDevice(const char *path, int expect)
--
=============================================================================
With --enable-iptables-lokkit=no, avoid warning about unused parameter.
* src/iptables.c (iptRulesSave) [!ENABLE_IPTABLES_LOKKIT]:
Mark parameter as used.
---
src/iptables.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/iptables.c b/src/iptables.c
index 04b1da6..f970701 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -256,6 +256,8 @@ iptRulesSave(iptRules *rules)
notifyRulesUpdated(rules->table, rules->path);
else
notifyRulesRemoved(rules->table, rules->path);
+#else
+ (void) rules;
#endif /* ENABLE_IPTABLES_LOKKIT */
}
--
1.5.4.2.185.gf5f8
16 years, 10 months