提交 13c881dc 编写于 作者: D Daniel P. Berrange

Improve error reporting when libvirtd is not installed

Currently if you try to connect to a local libvirtd when
libvirtd is not in $PATH, you'll get an error

  error: internal error invalid use of command API

This is because remoteFindDaemonPath() returns NULL, which
causes us to pass NULL into virNetSocketConnectUNIX which
in turn causes us to pass NULL into virCommandNewArgList.

Adding missing error checks improves this to

  error: internal error Unable to locate libvirtd daemon in $PATH

* src/remote/remote_driver.c: Report error if libvirtd
  cannot be found
* src/rpc/virnetsocket.c: Report error if caller requested
  spawning of daemon, but provided no binary path
上级 d336dbdb
......@@ -321,6 +321,7 @@ doRemoteOpen (virConnectPtr conn,
trans_ext,
trans_tcp,
} transport;
const char *daemonPath;
/* We handle *ALL* URIs here. The caller has rejected any
* URIs we don't care about */
......@@ -588,9 +589,14 @@ doRemoteOpen (virConnectPtr conn,
VIR_DEBUG("Proceeding with sockname %s", sockname);
}
if (!(daemonPath = remoteFindDaemonPath())) {
remoteError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to locate libvirtd daemon in $PATH"));
goto failed;
}
if (!(priv->client = virNetClientNewUNIX(sockname,
flags & VIR_DRV_OPEN_REMOTE_AUTOSTART,
remoteFindDaemonPath())))
daemonPath)))
goto failed;
priv->is_secure = 1;
......
......@@ -481,6 +481,12 @@ int virNetSocketNewConnectUNIX(const char *path,
remoteAddr.len = sizeof(remoteAddr.data.un);
if (spawnDaemon && !binary) {
virNetError(VIR_ERR_INTERNAL_ERROR,
_("Auto-spawn of daemon requested, but no binary specified"));
return -1;
}
if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
virReportSystemError(errno, "%s", _("Failed to create socket"));
goto error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册