mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
Replace use of qemudLog with logging.h APIs/macros
This commit is contained in:
parent
10e3148f0a
commit
b756b005ec
@ -1,3 +1,9 @@
|
||||
Tue Mar 3 11:31:13 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
|
||||
|
||||
* src/iptables.c, src/qemu_conf.c, src/qemu_driver.c,
|
||||
src/uuid.c: Replace qemudLogging with calls to logging.h
|
||||
APIs
|
||||
|
||||
Tue Mar 3 12:22:51 +0100 2009 Jim Meyering <meyering@redhat.com>
|
||||
|
||||
avoid file descriptor leak when fd == 0
|
||||
|
@ -45,8 +45,7 @@
|
||||
#include "util.h"
|
||||
#include "memory.h"
|
||||
#include "virterror_internal.h"
|
||||
|
||||
#define qemudLog(level, msg...) fprintf(stderr, msg)
|
||||
#include "logging.h"
|
||||
|
||||
enum {
|
||||
ADD = 0,
|
||||
@ -101,7 +100,7 @@ notifyRulesUpdated(const char *table,
|
||||
|
||||
char ebuf[1024];
|
||||
if (virRun(NULL, argv, NULL) < 0)
|
||||
qemudLog(QEMUD_WARN, _("Failed to run '%s %s': %s"),
|
||||
VIR_WARN(_("Failed to run '%s %s': %s"),
|
||||
LOKKIT_PATH, arg, virStrerror(errno, ebuf, sizeof ebuf));
|
||||
}
|
||||
|
||||
@ -149,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, "%s", _("Failed to read " SYSCONF_DIR
|
||||
"/sysconfig/system-config-firewall"));
|
||||
VIR_WARN("%s", _("Failed to read " SYSCONF_DIR
|
||||
"/sysconfig/system-config-firewall"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -178,8 +177,8 @@ notifyRulesRemoved(const char *table,
|
||||
|
||||
write_error:;
|
||||
char ebuf[1024];
|
||||
qemudLog(QEMUD_WARN, _("Failed to write to " SYSCONF_DIR
|
||||
"/sysconfig/system-config-firewall : %s"),
|
||||
VIR_WARN(_("Failed to write to " SYSCONF_DIR
|
||||
"/sysconfig/system-config-firewall : %s"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
if (f)
|
||||
fclose(f);
|
||||
@ -244,13 +243,13 @@ iptRulesSave(iptRules *rules)
|
||||
|
||||
char ebuf[1024];
|
||||
if ((err = virFileMakePath(rules->dir))) {
|
||||
qemudLog(QEMUD_WARN, _("Failed to create directory %s : %s"),
|
||||
VIR_WARN(_("Failed to create directory %s : %s"),
|
||||
rules->dir, virStrerror(err, ebuf, sizeof ebuf));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((err = writeRules(rules->path, rules->rules, rules->nrules))) {
|
||||
qemudLog(QEMUD_WARN, _("Failed to saves iptables rules to %s : %s"),
|
||||
VIR_WARN(_("Failed to saves iptables rules to %s : %s"),
|
||||
rules->path, virStrerror(err, ebuf, sizeof ebuf));
|
||||
return;
|
||||
}
|
||||
@ -551,8 +550,7 @@ iptRulesReload(iptRules *rules)
|
||||
rule->argv[rule->command_idx] = (char *) "--delete";
|
||||
|
||||
if (virRun(NULL, rule->argv, NULL) < 0)
|
||||
qemudLog(QEMUD_WARN,
|
||||
_("Failed to remove iptables rule '%s'"
|
||||
VIR_WARN(_("Failed to remove iptables rule '%s'"
|
||||
" from chain '%s' in table '%s': %s"),
|
||||
rule->rule, rules->chain, rules->table,
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
@ -562,8 +560,8 @@ iptRulesReload(iptRules *rules)
|
||||
|
||||
for (i = 0; i < rules->nrules; i++)
|
||||
if (virRun(NULL, rules->rules[i].argv, NULL) < 0)
|
||||
qemudLog(QEMUD_WARN, _("Failed to add iptables rule '%s'"
|
||||
" to chain '%s' in table '%s': %s"),
|
||||
VIR_WARN(_("Failed to add iptables rule '%s'"
|
||||
" to chain '%s' in table '%s': %s"),
|
||||
rules->rules[i].rule, rules->chain, rules->table,
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "datatypes.h"
|
||||
#include "xml.h"
|
||||
#include "nodeinfo.h"
|
||||
#include "logging.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||
|
||||
@ -77,8 +78,6 @@ VIR_ENUM_IMPL(qemuDiskCacheV2, VIR_DOMAIN_DISK_CACHE_LAST,
|
||||
"writeback");
|
||||
|
||||
|
||||
#define qemudLog(level, msg...) fprintf(stderr, msg)
|
||||
|
||||
int qemudLoadDriverConfig(struct qemud_driver *driver,
|
||||
const char *filename) {
|
||||
virConfPtr conf;
|
||||
@ -469,17 +468,15 @@ rewait:
|
||||
if (errno == EINTR)
|
||||
goto rewait;
|
||||
|
||||
qemudLog(QEMUD_ERR,
|
||||
_("Unexpected exit status from qemu %d pid %lu"),
|
||||
WEXITSTATUS(status), (unsigned long)child);
|
||||
VIR_ERROR(_("Unexpected exit status from qemu %d pid %lu"),
|
||||
WEXITSTATUS(status), (unsigned long)child);
|
||||
ret = -1;
|
||||
}
|
||||
/* Check & log unexpected exit status, but don't fail,
|
||||
* as there's really no need to throw an error if we did
|
||||
* actually read a valid version number above */
|
||||
if (WEXITSTATUS(status) != 0) {
|
||||
qemudLog(QEMUD_WARN,
|
||||
_("Unexpected exit status '%d', qemu probably failed"),
|
||||
VIR_WARN(_("Unexpected exit status '%d', qemu probably failed"),
|
||||
WEXITSTATUS(status));
|
||||
}
|
||||
|
||||
|
@ -82,8 +82,6 @@
|
||||
|
||||
static int qemudShutdown(void);
|
||||
|
||||
#define qemudLog(level, msg...) fprintf(stderr, msg)
|
||||
|
||||
static void qemuDriverLock(struct qemud_driver *driver)
|
||||
{
|
||||
virMutexLock(&driver->lock);
|
||||
@ -220,9 +218,9 @@ qemudAutostartConfigs(struct qemud_driver *driver) {
|
||||
int ret = qemudStartVMDaemon(conn, driver, vm, NULL, -1);
|
||||
if (ret < 0) {
|
||||
virErrorPtr err = virGetLastError();
|
||||
qemudLog(QEMUD_ERROR, _("Failed to autostart VM '%s': %s\n"),
|
||||
vm->def->name,
|
||||
err ? err->message : NULL);
|
||||
VIR_ERROR(_("Failed to autostart VM '%s': %s\n"),
|
||||
vm->def->name,
|
||||
err ? err->message : NULL);
|
||||
} else {
|
||||
virDomainEventPtr event =
|
||||
virDomainEventNewFromObj(vm,
|
||||
@ -306,8 +304,8 @@ qemudReconnectVMs(struct qemud_driver *driver)
|
||||
if ((config = virDomainConfigFile(NULL,
|
||||
driver->stateDir,
|
||||
vm->def->name)) == NULL) {
|
||||
qemudLog(QEMUD_ERROR, _("Failed to read domain status for %s\n"),
|
||||
vm->def->name);
|
||||
VIR_ERROR(_("Failed to read domain status for %s\n"),
|
||||
vm->def->name);
|
||||
goto next_error;
|
||||
}
|
||||
|
||||
@ -316,14 +314,14 @@ qemudReconnectVMs(struct qemud_driver *driver)
|
||||
vm->newDef = vm->def;
|
||||
vm->def = status->def;
|
||||
} else {
|
||||
qemudLog(QEMUD_ERROR, _("Failed to parse domain status for %s\n"),
|
||||
vm->def->name);
|
||||
VIR_ERROR(_("Failed to parse domain status for %s\n"),
|
||||
vm->def->name);
|
||||
goto next_error;
|
||||
}
|
||||
|
||||
if ((rc = qemudOpenMonitor(NULL, driver, vm, status->monitorpath, 1)) != 0) {
|
||||
qemudLog(QEMUD_ERROR, _("Failed to reconnect monitor for %s: %d\n"),
|
||||
vm->def->name, rc);
|
||||
VIR_ERROR(_("Failed to reconnect monitor for %s: %d\n"),
|
||||
vm->def->name, rc);
|
||||
goto next_error;
|
||||
}
|
||||
|
||||
@ -369,7 +367,7 @@ qemudStartup(void) {
|
||||
return -1;
|
||||
|
||||
if (virMutexInit(&qemu_driver->lock) < 0) {
|
||||
qemudLog(QEMUD_ERROR, "%s", _("cannot initialize mutex"));
|
||||
VIR_ERROR("%s", _("cannot initialize mutex"));
|
||||
VIR_FREE(qemu_driver);
|
||||
return -1;
|
||||
}
|
||||
@ -422,8 +420,8 @@ qemudStartup(void) {
|
||||
|
||||
if (virFileMakePath(qemu_driver->stateDir) < 0) {
|
||||
char ebuf[1024];
|
||||
qemudLog(QEMUD_ERROR, _("Failed to create state dir '%s': %s\n"),
|
||||
qemu_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
|
||||
VIR_ERROR(_("Failed to create state dir '%s': %s\n"),
|
||||
qemu_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -901,7 +899,7 @@ static int qemudWaitForMonitor(virConnectPtr conn,
|
||||
"console", 3);
|
||||
if (close(logfd) < 0) {
|
||||
char ebuf[1024];
|
||||
qemudLog(QEMUD_WARN, _("Unable to close logfile: %s\n"),
|
||||
VIR_WARN(_("Unable to close logfile: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
}
|
||||
|
||||
@ -1299,29 +1297,29 @@ static int qemudStartVMDaemon(virConnectPtr conn,
|
||||
tmp = progenv;
|
||||
while (*tmp) {
|
||||
if (safewrite(vm->logfile, *tmp, strlen(*tmp)) < 0)
|
||||
qemudLog(QEMUD_WARN, _("Unable to write envv to logfile: %s\n"),
|
||||
VIR_WARN(_("Unable to write envv to logfile: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
if (safewrite(vm->logfile, " ", 1) < 0)
|
||||
qemudLog(QEMUD_WARN, _("Unable to write envv to logfile: %s\n"),
|
||||
VIR_WARN(_("Unable to write envv to logfile: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
tmp++;
|
||||
}
|
||||
tmp = argv;
|
||||
while (*tmp) {
|
||||
if (safewrite(vm->logfile, *tmp, strlen(*tmp)) < 0)
|
||||
qemudLog(QEMUD_WARN, _("Unable to write argv to logfile: %s\n"),
|
||||
VIR_WARN(_("Unable to write argv to logfile: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
if (safewrite(vm->logfile, " ", 1) < 0)
|
||||
qemudLog(QEMUD_WARN, _("Unable to write argv to logfile: %s\n"),
|
||||
VIR_WARN(_("Unable to write argv to logfile: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
tmp++;
|
||||
}
|
||||
if (safewrite(vm->logfile, "\n", 1) < 0)
|
||||
qemudLog(QEMUD_WARN, _("Unable to write argv to logfile: %s\n"),
|
||||
VIR_WARN(_("Unable to write argv to logfile: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
|
||||
if ((pos = lseek(vm->logfile, 0, SEEK_END)) < 0)
|
||||
qemudLog(QEMUD_WARN, _("Unable to seek to end of logfile: %s\n"),
|
||||
VIR_WARN(_("Unable to seek to end of logfile: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
|
||||
for (i = 0 ; i < ntapfds ; i++)
|
||||
@ -1399,7 +1397,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
if (!virDomainIsActive(vm))
|
||||
return;
|
||||
|
||||
qemudLog(QEMUD_DEBUG, _("Shutting down VM '%s'\n"), vm->def->name);
|
||||
VIR_DEBUG(_("Shutting down VM '%s'\n"), vm->def->name);
|
||||
|
||||
if (virKillProcess(vm->pid, 0) == 0 &&
|
||||
virKillProcess(vm->pid, SIGTERM) < 0)
|
||||
@ -1414,7 +1412,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
|
||||
if (close(vm->logfile) < 0) {
|
||||
char ebuf[1024];
|
||||
qemudLog(QEMUD_WARN, _("Unable to close logfile: %s\n"),
|
||||
VIR_WARN(_("Unable to close logfile: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
}
|
||||
if (vm->monitor != -1)
|
||||
@ -1426,7 +1424,7 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
virKillProcess(vm->pid, SIGKILL);
|
||||
|
||||
if (qemudRemoveDomainStatus(conn, driver, vm) < 0) {
|
||||
qemudLog(QEMUD_WARN, _("Failed to remove domain status for %s"),
|
||||
VIR_WARN(_("Failed to remove domain status for %s"),
|
||||
vm->def->name);
|
||||
}
|
||||
vm->pid = -1;
|
||||
@ -1473,8 +1471,8 @@ qemudDispatchVMEvent(int watch, int fd, int events, void *opaque) {
|
||||
if (events & (VIR_EVENT_HANDLE_HANGUP | VIR_EVENT_HANDLE_ERROR))
|
||||
quit = 1;
|
||||
else {
|
||||
qemudLog(QEMUD_ERROR, _("unhandled fd event %d for %s"),
|
||||
events, vm->def->name);
|
||||
VIR_ERROR(_("unhandled fd event %d for %s"),
|
||||
events, vm->def->name);
|
||||
failed = 1;
|
||||
}
|
||||
}
|
||||
@ -1587,7 +1585,7 @@ qemudMonitorCommandExtra(const virDomainObjPtr vm,
|
||||
/* Log, but ignore failures to write logfile for VM */
|
||||
if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
|
||||
char ebuf[1024];
|
||||
qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s\n"),
|
||||
VIR_WARN(_("Unable to log VM console data: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
}
|
||||
|
||||
@ -1599,7 +1597,7 @@ qemudMonitorCommandExtra(const virDomainObjPtr vm,
|
||||
/* Log, but ignore failures to write logfile for VM */
|
||||
if (safewrite(vm->logfile, buf, strlen(buf)) < 0) {
|
||||
char ebuf[1024];
|
||||
qemudLog(QEMUD_WARN, _("Unable to log VM console data: %s\n"),
|
||||
VIR_WARN(_("Unable to log VM console data: %s\n"),
|
||||
virStrerror(errno, ebuf, sizeof ebuf));
|
||||
}
|
||||
VIR_FREE(buf);
|
||||
@ -3380,7 +3378,7 @@ static int qemudDomainAttachPciDiskDevice(virConnectPtr conn,
|
||||
s += strlen(PCI_ATTACH_OK_MSG);
|
||||
|
||||
if (virStrToLong_i ((const char*)s, &dummy, 10, &dev->data.disk->slotnum) == -1)
|
||||
qemudLog(QEMUD_WARN, "%s", _("Unable to parse slot number\n"));
|
||||
VIR_WARN("%s", _("Unable to parse slot number\n"));
|
||||
} else {
|
||||
qemudReportError (conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
|
||||
_("adding %s disk failed"), type);
|
||||
@ -4512,8 +4510,8 @@ cleanup:
|
||||
* overwrite the previous error, though, so we just throw something
|
||||
* to the logs and hope for the best
|
||||
*/
|
||||
qemudLog(QEMUD_ERROR, _("Failed to resume guest %s after failure\n"),
|
||||
vm->def->name);
|
||||
VIR_ERROR(_("Failed to resume guest %s after failure\n"),
|
||||
vm->def->name);
|
||||
}
|
||||
else {
|
||||
DEBUG ("cont reply: %s", info);
|
||||
|
@ -37,8 +37,7 @@
|
||||
#include "internal.h"
|
||||
#include "util.h"
|
||||
#include "virterror_internal.h"
|
||||
|
||||
#define qemudLog(level, msg...) fprintf(stderr, msg)
|
||||
#include "logging.h"
|
||||
|
||||
#ifndef ENODATA
|
||||
#define ENODATA EIO
|
||||
@ -102,8 +101,7 @@ virUUIDGenerate(unsigned char *uuid)
|
||||
|
||||
if ((err = virUUIDGenerateRandomBytes(uuid, VIR_UUID_BUFLEN))) {
|
||||
char ebuf[1024];
|
||||
qemudLog(QEMUD_WARN,
|
||||
_("Falling back to pseudorandom UUID,"
|
||||
VIR_WARN(_("Falling back to pseudorandom UUID,"
|
||||
" failed to generate random bytes: %s"),
|
||||
virStrerror(err, ebuf, sizeof ebuf));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user