mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
macvtap: log an error if on failure to connect to netlink socket
A bug in libnl (see https://bugzilla.redhat.com/show_bug.cgi?id=677724 and https://bugzilla.redhat.com/show_bug.cgi?id=677725) makes it very easy to create a failure to connect to the netlink socket when trying to open a macvtap network device ("type='direct'" in domain interface XML). When that error occurred (during a call to libnl's nl_connect() from libvirt's nlComm(), there was no log message, leading virsh (for example) to report "unknown error". There were two other cases in nlComm where an error in a libnl function might return with failure but no error reported. In all three cases, this patch logs a message which will hopefully be more useful. Note that more detailed information about the failure might be available from libnl's nl_geterror() function, but it calls strerror(), which is not threadsafe, so we can't use it.
This commit is contained in:
parent
98a4e5a301
commit
12775d9491
@ -120,13 +120,18 @@ int nlComm(struct nl_msg *nl_msg,
|
||||
fd_set readfds;
|
||||
int fd;
|
||||
int n;
|
||||
struct nl_handle *nlhandle = nl_handle_alloc();
|
||||
struct nlmsghdr *nlmsg = nlmsg_hdr(nl_msg);
|
||||
struct nl_handle *nlhandle = nl_handle_alloc();
|
||||
|
||||
if (!nlhandle)
|
||||
if (!nlhandle) {
|
||||
virReportSystemError(errno,
|
||||
"%s", _("cannot allocate nlhandle for netlink"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (nl_connect(nlhandle, NETLINK_ROUTE) < 0) {
|
||||
virReportSystemError(errno,
|
||||
"%s", _("cannot connect to netlink socket"));
|
||||
rc = -1;
|
||||
goto err_exit;
|
||||
}
|
||||
@ -161,9 +166,11 @@ int nlComm(struct nl_msg *nl_msg,
|
||||
}
|
||||
|
||||
*respbuflen = nl_recv(nlhandle, &nladdr, respbuf, NULL);
|
||||
if (*respbuflen <= 0)
|
||||
if (*respbuflen <= 0) {
|
||||
virReportSystemError(errno,
|
||||
"%s", _("nl_recv failed"));
|
||||
rc = -1;
|
||||
|
||||
}
|
||||
err_exit:
|
||||
if (rc == -1) {
|
||||
VIR_FREE(*respbuf);
|
||||
|
Loading…
Reference in New Issue
Block a user