+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
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;
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);
}
int ret, pid, status;
if (!proxyPath) {
- fprintf(stderr, "failed to find qemu\n");
+ qemuError (NULL, NULL, VIR_ERR_INVALID_ARG, "no proxyPath");
return(-1);
}
retry:
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
+ qemuError (NULL, NULL, VIR_ERR_SYSTEM_ERROR, "socket");
return VIR_DRV_OPEN_ERROR;
}
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;
}
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);
}
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;
}
/* 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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
/* 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;
/* 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;
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);
}
*/
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);
if (ret == -1)
goto failed;
} else {
- virXendError(conn, VIR_ERR_NO_SUPPORT, name);
+ virXendError(NULL, VIR_ERR_NO_SUPPORT, name);
goto failed;
}
}
#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);
}