[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 3/7] qga/commands-posix: Fix listing ifaces for Solaris
From: |
marcandre . lureau |
Subject: |
[PULL 3/7] qga/commands-posix: Fix listing ifaces for Solaris |
Date: |
Wed, 4 May 2022 14:00:57 +0400 |
From: Andrew Deason <adeason@sinenomine.net>
The code for guest-network-get-interfaces needs a couple of small
adjustments for Solaris:
- The results from SIOCGIFHWADDR are documented as being in ifr_addr,
not ifr_hwaddr (ifr_hwaddr doesn't exist on Solaris).
- The implementation of guest_get_network_stats is Linux-specific, so
hide it under #ifdef CONFIG_LINUX. On non-Linux, we just won't
provide network interface stats.
Signed-off-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <20220426195526.7699-4-adeason@sinenomine.net>
---
qga/commands-posix.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index febb2ef0ffd6..c1e994f3e6ab 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -2767,6 +2767,7 @@ guest_find_interface(GuestNetworkInterfaceList *head,
static int guest_get_network_stats(const char *name,
GuestNetworkInterfaceStat *stats)
{
+#ifdef CONFIG_LINUX
int name_len;
char const *devinfo = "/proc/net/dev";
FILE *fp;
@@ -2822,6 +2823,7 @@ static int guest_get_network_stats(const char *name,
fclose(fp);
g_free(line);
g_debug("/proc/net/dev: Interface '%s' not found", name);
+#endif /* CONFIG_LINUX */
return -1;
}
@@ -2887,8 +2889,11 @@ GuestNetworkInterfaceList
*qmp_guest_network_get_interfaces(Error **errp)
}
} else {
+#ifdef CONFIG_SOLARIS
+ mac_addr = (unsigned char *) &ifr.ifr_addr.sa_data;
+#else
mac_addr = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
-
+#endif
info->hardware_address =
g_strdup_printf("%02x:%02x:%02x:%02x:%02x:%02x",
(int) mac_addr[0], (int) mac_addr[1],
--
2.36.0.44.g0f828332d5ac
- [PULL 0/7] QGA patches, marcandre . lureau, 2022/05/04
- [PULL 1/7] qga/commands-posix: Use getifaddrs when available, marcandre . lureau, 2022/05/04
- [PULL 2/7] qga/commands-posix: Fix iface hw address detection, marcandre . lureau, 2022/05/04
- [PULL 4/7] qga/commands-posix: Log all net stats failures, marcandre . lureau, 2022/05/04
- [PULL 3/7] qga/commands-posix: Fix listing ifaces for Solaris,
marcandre . lureau <=
- [PULL 5/7] qga/commands-posix: 'guest-shutdown' for Solaris, marcandre . lureau, 2022/05/04
- [PULL 6/7] qga: Introduce NVMe disk bus type, marcandre . lureau, 2022/05/04
- [PULL 7/7] qga: Introduce disk smart, marcandre . lureau, 2022/05/04
- Re: [PULL 0/7] QGA patches, Richard Henderson, 2022/05/04