From: Matthias Bolte Date: Sat, 3 Apr 2010 15:31:24 +0000 (+0200) Subject: macvtap: Remove virConnectPtr from ReportError X-Git-Tag: v0.8.0~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d7d699795d82066f3aee4e6bad5e408177710e6;p=thirdparty%2Flibvirt.git macvtap: Remove virConnectPtr from ReportError Also rename ReportError to macvtapError. --- diff --git a/cfg.mk b/cfg.mk index b4fda89a69..70465c3b5a 100644 --- a/cfg.mk +++ b/cfg.mk @@ -175,7 +175,7 @@ msg_gen_function += ERROR0 msg_gen_function += ESX_ERROR msg_gen_function += ESX_VI_ERROR msg_gen_function += REMOTE_DEBUG -msg_gen_function += ReportError +msg_gen_function += macvtapError msg_gen_function += VIR_FREE msg_gen_function += VIR_INFO msg_gen_function += VIR_USE_CPU diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 592360f3c6..538784a83d 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1469,7 +1469,7 @@ qemudPhysIfaceConnect(virConnectPtr conn, net->model && STREQ(net->model, "virtio")) vnet_hdr = 1; - rc = openMacvtapTap(conn, net->ifname, net->mac, linkdev, brmode, + rc = openMacvtapTap(net->ifname, net->mac, linkdev, brmode, &res_ifname, vnet_hdr); if (rc >= 0) { VIR_FREE(net->ifname); diff --git a/src/util/macvtap.c b/src/util/macvtap.c index 999e670b4f..2a99c6bde1 100644 --- a/src/util/macvtap.c +++ b/src/util/macvtap.c @@ -49,9 +49,9 @@ # define VIR_FROM_THIS VIR_FROM_NET -# define ReportError(conn, code, ...) \ - virReportErrorHelper(conn, VIR_FROM_NET, code, __FILE__, \ - __FUNCTION__, __LINE__, __VA_ARGS__) +# define macvtapError(code, ...) \ + virReportErrorHelper(NULL, VIR_FROM_NET, code, __FILE__, \ + __FUNCTION__, __LINE__, __VA_ARGS__) # define MACVTAP_NAME_PREFIX "macvtap" # define MACVTAP_NAME_PATTERN "macvtap%d" @@ -193,7 +193,7 @@ nlAppend(struct nlmsghdr *nlm, int totlen, const void *data, int datalen) static int -getIfIndex(virConnectPtr conn, +getIfIndex(bool reportError, const char *ifname, int *idx) { @@ -206,20 +206,20 @@ getIfIndex(virConnectPtr conn, if (virStrncpy(ifreq.ifr_name, ifname, strlen(ifname), sizeof(ifreq.ifr_name)) == NULL) { - if (conn) - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("invalid interface name %s"), - ifname); + if (reportError) + macvtapError(VIR_ERR_INTERNAL_ERROR, + _("invalid interface name %s"), + ifname); rc = EINVAL; goto err_exit; } if (ioctl(fd, SIOCGIFINDEX, &ifreq) >= 0) *idx = ifreq.ifr_ifindex; else { - if (conn) - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - _("interface %s does not exist"), - ifname); + if (reportError) + macvtapError(VIR_ERR_INTERNAL_ERROR, + _("interface %s does not exist"), + ifname); rc = ENODEV; } @@ -296,8 +296,7 @@ ifUp(const char *name, int up) static int -link_add(virConnectPtr conn, - const char *type, +link_add(const char *type, const unsigned char *macaddress, int macaddrsize, const char *ifname, const char *srcdev, @@ -315,7 +314,7 @@ link_add(virConnectPtr conn, char *recvbuf = NULL; int recvbuflen; - if (getIfIndex(conn, srcdev, &ifindex) != 0) + if (getIfIndex(true, srcdev, &ifindex) != 0) return -1; *retry = 0; @@ -434,14 +433,14 @@ link_add(virConnectPtr conn, return rc; malformed_resp: - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed netlink response message")); + macvtapError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed netlink response message")); VIR_FREE(recvbuf); return -1; buffer_too_small: - ReportError(conn, VIR_ERR_INTERNAL_ERROR, - "%s", _("internal buffer is too small")); + macvtapError(VIR_ERR_INTERNAL_ERROR, "%s", + _("internal buffer is too small")); return -1; } @@ -512,21 +511,20 @@ link_del(const char *name) return rc; malformed_resp: - ReportError(NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed netlink response message")); + macvtapError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed netlink response message")); VIR_FREE(recvbuf); return -1; buffer_too_small: - ReportError(NULL, VIR_ERR_INTERNAL_ERROR, - "%s", _("internal buffer is too small")); + macvtapError(VIR_ERR_INTERNAL_ERROR, "%s", + _("internal buffer is too small")); return -1; } /* Open the macvtap's tap device. - * @conn: Pointer to virConnect object - * @name: Name of the macvtap interface + * @ifname: Name of the macvtap interface * @retries : Number of retries in case udev for example may need to be * waited for to create the tap chardev * Returns negative value in case of error, the file descriptor otherwise. @@ -677,7 +675,6 @@ configMacvtapTap(int tapfd, int vnet_hdr) * openMacvtapTap: * Create an instance of a macvtap device and open its tap character * device. - * @conn: Pointer to virConnect object * @tgifname: Interface name that the macvtap is supposed to have. May * be NULL if this function is supposed to choose a name * @macaddress: The MAC address for the macvtap device @@ -689,13 +686,11 @@ configMacvtapTap(int tapfd, int vnet_hdr) * to the caller to free the string. * * Returns file descriptor of the tap device in case of success, - * negative value otherwise with error message attached to the 'conn' - * object. + * negative value otherwise with error reported. * */ int -openMacvtapTap(virConnectPtr conn, - const char *tgifname, +openMacvtapTap(const char *tgifname, const unsigned char *macaddress, const char *linkdev, int mode, @@ -713,7 +708,7 @@ openMacvtapTap(virConnectPtr conn, *res_ifname = NULL; if (tgifname) { - if(getIfIndex(NULL, tgifname, &ifindex) == 0) { + if(getIfIndex(false, tgifname, &ifindex) == 0) { if (STRPREFIX(tgifname, MACVTAP_NAME_PREFIX)) { goto create_name; @@ -723,7 +718,7 @@ openMacvtapTap(virConnectPtr conn, return -1; } cr_ifname = tgifname; - rc = link_add(conn, type, macaddress, 6, tgifname, linkdev, + rc = link_add(type, macaddress, 6, tgifname, linkdev, macvtapMode, &do_retry); if (rc) return -1; @@ -732,8 +727,8 @@ create_name: retries = 5; for (c = 0; c < 8192; c++) { snprintf(ifname, sizeof(ifname), MACVTAP_NAME_PATTERN, c); - if (getIfIndex(NULL, ifname, &ifindex) == ENODEV) { - rc = link_add(conn, type, macaddress, 6, ifname, linkdev, + if (getIfIndex(false, ifname, &ifindex) == ENODEV) { + rc = link_add(type, macaddress, 6, ifname, linkdev, macvtapMode, &do_retry); if (rc == 0) break; diff --git a/src/util/macvtap.h b/src/util/macvtap.h index bd5f4d6282..5d4ea5e32b 100644 --- a/src/util/macvtap.h +++ b/src/util/macvtap.h @@ -28,8 +28,7 @@ # include "internal.h" -int openMacvtapTap(virConnectPtr conn, - const char *ifname, +int openMacvtapTap(const char *ifname, const unsigned char *macaddress, const char *linkdev, int mode,