提交 498cc578 编写于 作者: D Daniel P. Berrange

Updated to use virError object & APIs for error reporting

上级 2dd21783
Tue Jun 26 16:41:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
Tue Jun 26 16:50:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/Makefile.am, qemud/conf.c, qemud/dispatch.c, qemud/driver.c,
qemud/driver.h, qemud/internal.h, qemud/qemud.c: Switch over to
use regular libvirt virError objects & APIs for QEMU error
reporting purposes
Tue Jun 26 16:43:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/driver.c, qemud/driver.h, qemud/qemud.c: Move code
handling global startup, shutdown & reload into driver.c
......
......@@ -17,6 +17,7 @@ libvirt_qemud_SOURCES = \
protocol.h protocol.c \
remote_protocol.h remote_protocol.c \
remote.c \
../src/virterror.c \
event.c event.h
#-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
libvirt_qemud_CFLAGS = \
......@@ -24,7 +25,9 @@ libvirt_qemud_CFLAGS = \
$(WARN_CFLAGS) -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \
-DSYSCONF_DIR="\"$(sysconfdir)\"" \
-DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\"" \
-DREMOTE_PID_FILE="\"$(REMOTE_PID_FILE)\""
-DREMOTE_PID_FILE="\"$(REMOTE_PID_FILE)\"" \
-DGETTEXT_PACKAGE=\"$(PACKAGE)\"
libvirt_qemud_LDFLAGS = $(WARN_CFLAGS) $(LIBXML_LIBS) $(SYSFS_LIBS)
libvirt_qemud_DEPENDENCIES = ../src/libvirt.la
libvirt_qemud_LDADD = ../src/libvirt.la
......
此差异已折叠。
......@@ -39,9 +39,14 @@
static int qemudDispatchFailure(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
struct qemud_packet_server_data *out) {
virErrorPtr err = virGetLastError();
out->type = QEMUD_SERVER_PKT_FAILURE;
out->qemud_packet_server_data_u.failureReply.code = server->errorCode;
strcpy(out->qemud_packet_server_data_u.failureReply.message, server->errorMessage);
out->qemud_packet_server_data_u.failureReply.code = err->code;
strncpy(out->qemud_packet_server_data_u.failureReply.message,
err->message, QEMUD_MAX_ERROR_LEN-1);
out->qemud_packet_server_data_u.failureReply.message[QEMUD_MAX_ERROR_LEN-1] = '\0';
return 0;
}
......@@ -90,7 +95,7 @@ qemudDispatchGetCapabilities (struct qemud_server *server,
char *xml = qemudGetCapabilities(server);
if (strlen(xml) > QEMUD_MAX_XML_LEN) {
qemudReportError (server, VIR_ERR_XML_ERROR, NULL);
qemudReportError(NULL, NULL, NULL, VIR_ERR_XML_ERROR, NULL);
qemudDispatchFailure (server, client, out);
free(xml);
return 0;
......@@ -784,8 +789,7 @@ int qemudDispatch(struct qemud_server *server, struct qemud_client *client,
qemudDebug("> Dispatching request type %d, readonly ? %d",
in->type, client->readonly);
server->errorCode = 0;
server->errorMessage[0] = '\0';
virResetLastError();
memset(out, 0, sizeof(*out));
......@@ -801,7 +805,7 @@ int qemudDispatch(struct qemud_server *server, struct qemud_client *client,
if (!funcs[type]) {
qemudDebug("Illegal operation requested");
qemudReportError(server, VIR_ERR_OPERATION_DENIED, NULL);
qemudReportError(NULL, NULL, NULL, VIR_ERR_OPERATION_DENIED, NULL);
qemudDispatchFailure(server, client, out);
} else {
if ((funcs[type])(server, client, in, out) < 0) {
......
此差异已折叠。
......@@ -43,9 +43,11 @@ int qemudStartup(struct qemud_server *server);
void qemudReload(struct qemud_server *server);
void qemudShutdown(struct qemud_server *server);
void qemudReportError(struct qemud_server *server,
void qemudReportError(virConnectPtr conn,
virDomainPtr dom,
virNetworkPtr net,
int code, const char *fmt, ...)
ATTRIBUTE_FORMAT(printf,3,4);
ATTRIBUTE_FORMAT(printf,5,6);
int qemudGetNodeInfo(unsigned int *memory,
char *cpuModel, int cpuModelLength,
......
......@@ -352,8 +352,6 @@ struct qemud_server {
char *networkConfigDir;
char *networkAutostartDir;
char logDir[PATH_MAX];
char errorMessage[QEMUD_MAX_ERROR_LEN];
int errorCode;
unsigned int shutdown : 1;
};
......
......@@ -1484,7 +1484,7 @@ static void qemudDispatchServerEvent(int fd, int events, void *opaque) {
}
static int qemudOneLoop(struct qemud_server *server ATTRIBUTE_UNUSED) {
static int qemudOneLoop(void) {
sig_atomic_t errors;
if (virEventRunOnce() < 0)
......@@ -1506,7 +1506,7 @@ static int qemudOneLoop(struct qemud_server *server ATTRIBUTE_UNUSED) {
static int qemudRunLoop(struct qemud_server *server) {
int ret;
while ((ret = qemudOneLoop(server)) == 0 && !server->shutdown)
while ((ret = qemudOneLoop()) == 0 && !server->shutdown)
;
return ret == -1 ? -1 : 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册