Wed May 2 18:38:00 BST 2007 Richard Jones <rjones@redhat.com>

* src/proxy_internal.c, src/qemu_internal.c, src/test.c,
	  src/xen_unified.c, src/xend_internal.c, src/xs_internal.c:
	  During virConnectOpen, be careful to call __virRaiseError
	  with conn = NULL so that the error message is not
	  discarded.
This commit is contained in:
Richard W.M. Jones 2007-05-02 17:36:25 +00:00
parent f8fa07c107
commit b15d511db4
7 changed files with 46 additions and 24 deletions

View File

@ -1,3 +1,11 @@
Wed May 2 18:38:00 BST 2007 Richard Jones <rjones@redhat.com>
* src/proxy_internal.c, src/qemu_internal.c, src/test.c,
src/xen_unified.c, src/xend_internal.c, src/xs_internal.c:
During virConnectOpen, be careful to call __virRaiseError
with conn = NULL so that the error message is not
discarded.
Wed May 2 17:55:12 IST 2007 Mark McLoughlin <markmc@redhat.com>
* qemud/libvirtd.in: synchronously restart the daemon in

View File

@ -544,7 +544,7 @@ xenProxyOpen(virConnectPtr conn, const char *name ATTRIBUTE_UNUSED, int flags)
fd = virProxyOpenClientSocket(PROXY_SOCKET_PATH);
if (fd < 0) {
virProxyError(conn, VIR_ERR_NO_XEN, PROXY_SOCKET_PATH);
virProxyError(NULL, VIR_ERR_NO_XEN, PROXY_SOCKET_PATH);
return(-1);
}
priv->proxy = fd;
@ -554,7 +554,7 @@ xenProxyOpen(virConnectPtr conn, const char *name ATTRIBUTE_UNUSED, int flags)
req.len = sizeof(req);
ret = xenProxyCommand(conn, &req, NULL, 1);
if ((ret < 0) || (req.command != VIR_PROXY_NONE)) {
virProxyError(conn, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
virProxyError(NULL, VIR_ERR_OPERATION_FAILED, __FUNCTION__);
xenProxyClose(conn);
return(-1);
}

View File

@ -146,7 +146,7 @@ qemuForkServer(void)
int ret, pid, status;
if (!proxyPath) {
fprintf(stderr, "failed to find qemu\n");
qemuError (NULL, NULL, VIR_ERR_INVALID_ARG, "no proxyPath");
return(-1);
}
@ -231,6 +231,7 @@ qemuOpenClientUNIX(virConnectPtr conn ATTRIBUTE_UNUSED,
retry:
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
qemuError (NULL, NULL, VIR_ERR_SYSTEM_ERROR, "socket");
return VIR_DRV_OPEN_ERROR;
}
@ -256,6 +257,10 @@ qemuOpenClientUNIX(virConnectPtr conn ATTRIBUTE_UNUSED,
usleep(5000 * trials * trials);
goto retry;
}
__virRaiseError (NULL, NULL, NULL,
VIR_FROM_QEMU, VIR_ERR_SYSTEM_ERROR, VIR_ERR_ERROR,
"connect", NULL, NULL, errno, 0,
"connect: %s: %s", path, strerror (errno));
return VIR_DRV_OPEN_ERROR;
}
@ -346,34 +351,43 @@ static int qemuOpenConnection(virConnectPtr conn, xmlURIPtr uri, int readonly) {
int autostart = 0;
if (uri->server != NULL) {
qemuError (NULL, NULL, VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
return VIR_DRV_OPEN_ERROR;
}
if (!strcmp(uri->path, "/system")) {
if (strcmp(uri->path, "/system") == 0) {
if (readonly) {
if (snprintf(path, sizeof(path), "%s/run/libvirt/qemud-sock-ro", LOCAL_STATE_DIR) >= (int)sizeof(path)) {
qemuError (NULL, NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return VIR_DRV_OPEN_ERROR;
}
} else {
if (snprintf(path, sizeof(path), "%s/run/libvirt/qemud-sock", LOCAL_STATE_DIR) >= (int)sizeof(path)) {
qemuError (NULL, NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return VIR_DRV_OPEN_ERROR;
}
}
} else if (!strcmp(uri->path, "/session")) {
} else if (strcmp(uri->path, "/session") == 0) {
struct passwd *pw;
int uid;
if ((uid = geteuid()) < 0) {
qemuError (NULL, NULL, VIR_ERR_SYSTEM_ERROR, "geteuid");
return VIR_DRV_OPEN_ERROR;
}
if (!(pw = getpwuid(uid)))
if (!(pw = getpwuid(uid))) {
qemuError (NULL, NULL, VIR_ERR_SYSTEM_ERROR, "getpwuid");
return VIR_DRV_OPEN_ERROR;
}
if (snprintf(path, sizeof(path), "@%s/.libvirt/qemud-sock", pw->pw_dir) == sizeof(path)) {
return VIR_DRV_OPEN_ERROR;
}
autostart = 1;
} else {
qemuError (NULL, NULL, VIR_ERR_INVALID_ARG, "path should be /system or /session - for example, qemu:///session");
return VIR_DRV_OPEN_ERROR;
}
return qemuOpenClientUNIX(conn, path, autostart);
}
@ -395,7 +409,7 @@ static int qemuOpen(virConnectPtr conn,
uri = xmlParseURI(name);
if (uri == NULL) {
qemuError(conn, NULL, VIR_ERR_NO_SUPPORT, name);
qemuError(NULL, NULL, VIR_ERR_NO_SUPPORT, name);
return VIR_DRV_OPEN_DECLINED;
}
@ -409,7 +423,7 @@ static int qemuOpen(virConnectPtr conn,
/* Create per-connection private data. */
priv = conn->privateData = malloc (sizeof *priv);
if (!priv) {
qemuError (conn, NULL, VIR_ERR_NO_MEMORY, __FUNCTION__);
qemuError (NULL, NULL, VIR_ERR_NO_MEMORY, __FUNCTION__);
return VIR_DRV_OPEN_ERROR;
}

View File

@ -562,7 +562,7 @@ static int testOpenFromFile(virConnectPtr conn,
if (ret == 0) {
nodeInfo->nodes = l;
} else if (ret == -2) {
testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu numa nodes"));
testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu numa nodes"));
goto error;
}
@ -570,7 +570,7 @@ static int testOpenFromFile(virConnectPtr conn,
if (ret == 0) {
nodeInfo->sockets = l;
} else if (ret == -2) {
testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu sockets"));
testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu sockets"));
goto error;
}
@ -578,7 +578,7 @@ static int testOpenFromFile(virConnectPtr conn,
if (ret == 0) {
nodeInfo->cores = l;
} else if (ret == -2) {
testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu cores"));
testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu cores"));
goto error;
}
@ -586,7 +586,7 @@ static int testOpenFromFile(virConnectPtr conn,
if (ret == 0) {
nodeInfo->threads = l;
} else if (ret == -2) {
testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu threads"));
testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu threads"));
goto error;
}
@ -597,14 +597,14 @@ static int testOpenFromFile(virConnectPtr conn,
nodeInfo->cpus = l;
}
} else if (ret == -2) {
testError(conn, NULL, VIR_ERR_XML_ERROR, _("node active cpu"));
testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node active cpu"));
goto error;
}
ret = virXPathLong("string(/node/cpu/mhz[1])", ctxt, &l);
if (ret == 0) {
nodeInfo->mhz = l;
} else if (ret == -2) {
testError(conn, NULL, VIR_ERR_XML_ERROR, _("node cpu mhz"));
testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node cpu mhz"));
goto error;
}
@ -619,7 +619,7 @@ static int testOpenFromFile(virConnectPtr conn,
if (ret == 0) {
nodeInfo->memory = l;
} else if (ret == -2) {
testError(conn, NULL, VIR_ERR_XML_ERROR, _("node memory"));
testError(NULL, NULL, VIR_ERR_XML_ERROR, _("node memory"));
goto error;
}
@ -717,7 +717,7 @@ int testOpen(virConnectPtr conn,
uri = xmlParseURI(name);
if (uri == NULL) {
testError(conn, NULL, VIR_ERR_NO_SUPPORT, name);
testError(NULL, NULL, VIR_ERR_NO_SUPPORT, name);
return VIR_DRV_OPEN_DECLINED;
}
@ -730,7 +730,7 @@ int testOpen(virConnectPtr conn,
if (!uri->path
|| uri->path[0] == '\0'
|| (uri->path[0] == '/' && uri->path[1] == '\0')) {
testError (conn, NULL, VIR_ERR_INVALID_ARG,
testError (NULL, NULL, VIR_ERR_INVALID_ARG,
_("testOpen: supply a path or use test:///default"));
return VIR_DRV_OPEN_ERROR;
}
@ -743,7 +743,7 @@ int testOpen(virConnectPtr conn,
/* Allocate per-connection private data. */
priv = conn->privateData = malloc (sizeof (struct _testPrivate));
if (!priv) {
testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating private data"));
testError(NULL, NULL, VIR_ERR_NO_MEMORY, _("allocating private data"));
return VIR_DRV_OPEN_ERROR;
}
priv->handle = -1;

View File

@ -95,7 +95,7 @@ xenUnifiedOpen (virConnectPtr conn, const char *name, int flags)
/* Allocate per-connection private data. */
priv = malloc (sizeof *priv);
if (!priv) {
xenUnifiedError (conn, VIR_ERR_NO_MEMORY, "allocating private data");
xenUnifiedError (NULL, VIR_ERR_NO_MEMORY, "allocating private data");
return VIR_DRV_OPEN_ERROR;
}
conn->privateData = priv;

View File

@ -894,7 +894,7 @@ xenDaemonOpen_tcp(virConnectPtr conn, const char *host, int port)
pent = gethostbyname(host);
if (pent == NULL) {
if (inet_aton(host, &ip) == 0) {
virXendError(conn, VIR_ERR_UNKNOWN_HOST, host);
virXendError(NULL, VIR_ERR_UNKNOWN_HOST, host);
errno = ESRCH;
return (-1);
}
@ -1960,14 +1960,14 @@ xenDaemonOpen(virConnectPtr conn, const char *name,
*/
uri = xmlParseURI(name);
if (uri == NULL) {
virXendError(conn, VIR_ERR_NO_SUPPORT, name);
virXendError(NULL, VIR_ERR_NO_SUPPORT, name);
goto failed;
}
if (uri->scheme == NULL) {
/* It should be a file access */
if (uri->path == NULL) {
virXendError(conn, VIR_ERR_NO_SUPPORT, name);
virXendError(NULL, VIR_ERR_NO_SUPPORT, name);
goto failed;
}
ret = xenDaemonOpen_unix(conn, uri->path);
@ -1985,7 +1985,7 @@ xenDaemonOpen(virConnectPtr conn, const char *name,
if (ret == -1)
goto failed;
} else {
virXendError(conn, VIR_ERR_NO_SUPPORT, name);
virXendError(NULL, VIR_ERR_NO_SUPPORT, name);
goto failed;
}
}

View File

@ -340,7 +340,7 @@ xenStoreOpen(virConnectPtr conn,
#endif /* ! PROXY */
if (priv->xshandle == NULL) {
virXenStoreError(conn, VIR_ERR_NO_XEN,
virXenStoreError(NULL, VIR_ERR_NO_XEN,
_("failed to connect to Xen Store"));
return (-1);
}