提交 cfa655f9 编写于 作者: M Mark McLoughlin

Fri Feb 16 18:28:32 IST 2007 Mark McLoughlin <markmc@redhat.com>

        * qemud/qemud.c, qemud/dispatch.c, qemud/internal.h
        qemud/conf.c, qemud/driver.c, configure.in: add a
        qemudLog() function which uses syslog() if we're in daemon
        mode, doesn't output INFO/DEBUG messages unless the
        verbose flag is set and doesn't output DEBUG messages
        unless compiled with --enable-debug. Also, make a first
        pass through fatal errors and add error messages for them.
上级 49fe2820
Fri Feb 16 18:28:32 IST 2007 Mark McLoughlin <markmc@redhat.com>
* qemud/qemud.c, qemud/dispatch.c, qemud/internal.h
qemud/conf.c, qemud/driver.c, configure.in: add a
qemudLog() function which uses syslog() if we're in daemon
mode, doesn't output INFO/DEBUG messages unless the
verbose flag is set and doesn't output DEBUG messages
unless compiled with --enable-debug. Also, make a first
pass through fatal errors and add error messages for them.
Fri Feb 16 18:26:55 IST 2007 Mark McLoughlin <markmc@redhat.com>
* qemud/internal.h, qemud/qemud.c: improve signal handling
......
......@@ -78,6 +78,14 @@ dnl
CFLAGS="-g -O -W -Wformat -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -Wall"
fi
dnl --enable-debug=(yes|no)
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug=no/yes],
[enable debugging output]))
if test x"$enable_debug" = x"yes"; then
AC_DEFINE(ENABLE_DEBUG, [], [whether debugging is enabled])
fi
dnl
dnl allow the creation of iptables rules in chains with a
dnl specific prefix rather than in the standard toplevel chains
......
......@@ -1642,6 +1642,8 @@ int qemudScanConfigDir(struct qemud_server *server,
if (!(dir = opendir(configDir))) {
if (errno == ENOENT)
return 0;
qemudLog(QEMUD_ERR, "Failed to open dir '%s': %s",
configDir, strerror(errno));
return -1;
}
......
......@@ -812,7 +812,7 @@ int qemudDispatch(struct qemud_server *server, struct qemud_client *client,
struct qemud_packet *in, struct qemud_packet *out) {
clientFunc *funcs;
unsigned int type = in->header.type;
QEMUD_DEBUG("> Dispatching request %d readonly ? %d\n", type, client->readonly);
qemudDebug("> Dispatching request %d readonly ? %d", type, client->readonly);
server->errorCode = 0;
server->errorMessage[0] = '\0';
......@@ -820,12 +820,12 @@ int qemudDispatch(struct qemud_server *server, struct qemud_client *client,
memset(out, 0, sizeof(struct qemud_packet));
if (type >= QEMUD_PKT_MAX) {
QEMUD_DEBUG("Illegal request type\n");
qemudDebug("Illegal request type");
return -1;
}
if (type == QEMUD_PKT_FAILURE) {
QEMUD_DEBUG("Illegal request type\n");
qemudDebug("Illegal request type");
return -1;
}
......@@ -835,17 +835,17 @@ int qemudDispatch(struct qemud_server *server, struct qemud_client *client,
funcs = funcsTransmitRW;
if (!funcs[type]) {
QEMUD_DEBUG("Illegal operation requested\n");
qemudDebug("Illegal operation requested");
qemudReportError(server, VIR_ERR_OPERATION_DENIED, NULL);
qemudDispatchFailure(server, client, out);
} else {
if ((funcs[type])(server, client, in, out) < 0) {
QEMUD_DEBUG("Dispatch failed\n");
qemudDebug("Dispatch failed");
return -1;
}
}
QEMUD_DEBUG("< Returning reply %d (%d bytes)\n",
qemudDebug("< Returning reply %d (%d bytes)",
out->header.type,
out->header.dataSize);
......
......@@ -90,7 +90,7 @@ int qemudMonitorCommand(struct qemud_server *server ATTRIBUTE_UNUSED,
size += got;
}
if (buf)
QEMUD_DEBUG("Mon [%s]\n", buf);
qemudDebug("Mon [%s]", buf);
/* Look for QEMU prompt to indicate completion */
if (buf && ((tmp = strstr(buf, "\n(qemu)")) != NULL)) {
tmp[0] = '\0';
......@@ -203,7 +203,7 @@ static int qemudGetProcessInfo(unsigned long long *cpuTime, int pid) {
}
if (fscanf(pidinfo, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %lu %lu", &usertime, &systime) != 2) {
QEMUD_DEBUG("not enough arg\n");
qemudDebug("not enough arg");
return -1;
}
......@@ -214,7 +214,7 @@ static int qemudGetProcessInfo(unsigned long long *cpuTime, int pid) {
*/
*cpuTime = 1000 * 1000 * 1000 * (usertime + systime) / sysconf(_SC_CLK_TCK);
QEMUD_DEBUG("Got %lu %lu %lld\n", usertime, systime, *cpuTime);
qemudDebug("Got %lu %lu %lld", usertime, systime, *cpuTime);
fclose(pidinfo);
......@@ -322,7 +322,7 @@ int qemudDomainSuspend(struct qemud_server *server, int id) {
qemudReportError(server, VIR_ERR_OPERATION_FAILED, "suspend operation failed");
return -1;
}
printf("Reply %s\n", info);
qemudDebug("Reply %s", info);
free(info);
return 0;
}
......@@ -343,7 +343,7 @@ int qemudDomainResume(struct qemud_server *server, int id) {
qemudReportError(server, VIR_ERR_OPERATION_FAILED, "resume operation failed");
return -1;
}
printf("Reply %s\n", info);
qemudDebug("Reply %s", info);
free(info);
return -1;
}
......
......@@ -43,14 +43,17 @@
#define ATTRIBUTE_UNUSED
#endif
#ifdef DEBUG
#define QEMUD_DEBUG(args...) fprintf(stderr, args)
#else
#define QEMUD_DEBUG(args...) do {} while(0)
#endif
#define UUID_LEN 16
typedef enum {
QEMUD_ERR,
QEMUD_WARN,
QEMUD_INFO,
#ifdef ENABLE_DEBUG
QEMUD_DEBUG
#endif
} qemudLogPriority;
/* Different types of QEMU acceleration possible */
enum qemud_vm_virt_type {
QEMUD_VIRT_QEMU,
......@@ -306,6 +309,13 @@ int qemudStartNetworkDaemon(struct qemud_server *server,
int qemudShutdownNetworkDaemon(struct qemud_server *server,
struct qemud_network *network);
void qemudLog(int priority, const char *fmt, ...);
#ifdef ENABLE_DEBUG
#define qemudDebug(...) qemudLog(QEMUD_DEBUG, __VA_ARGS__)
#else
#define qemudDebug(fmt, ...) do { } while(0);
#endif
#endif
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册