From nobody Tue Feb 10 04:16:51 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1651003049218333.76819539147914; Tue, 26 Apr 2022 12:57:29 -0700 (PDT) Received: from localhost ([::1]:57052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1njRJP-0006fM-VH for importer@patchew.org; Tue, 26 Apr 2022 15:57:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njRIA-0004bU-S2 for qemu-devel@nongnu.org; Tue, 26 Apr 2022 15:56:10 -0400 Received: from smtp117.iad3a.emailsrvr.com ([173.203.187.117]:40072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1njRI9-0004c2-Aq for qemu-devel@nongnu.org; Tue, 26 Apr 2022 15:56:10 -0400 Received: by smtp31.relay.iad3a.emailsrvr.com (Authenticated sender: adeason-AT-sinenomine.net) with ESMTPSA id 10AE2248B3; Tue, 26 Apr 2022 15:55:45 -0400 (EDT) X-Auth-ID: adeason@sinenomine.net From: Andrew Deason To: qemu-devel@nongnu.org Subject: [PATCH v3 3/5] qga/commands-posix: Fix listing ifaces for Solaris Date: Tue, 26 Apr 2022 14:55:24 -0500 Message-Id: <20220426195526.7699-4-adeason@sinenomine.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220426195526.7699-1-adeason@sinenomine.net> References: <20220426195526.7699-1-adeason@sinenomine.net> X-Classification-ID: cc5ef99f-0605-4056-825c-a202bb8c6ff8-4-1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=173.203.187.117; envelope-from=adeason@sinenomine.net; helo=smtp117.iad3a.emailsrvr.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Roth , Andrew Deason , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Michal Privoznik Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1651003049995100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Michal Privoznik --- 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 dbfbb14152..b91fdba2c1 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -2756,20 +2756,21 @@ guest_find_interface(GuestNetworkInterfaceList *hea= d, return head->value; } } =20 return NULL; } =20 static int guest_get_network_stats(const char *name, GuestNetworkInterfaceStat *stats) { +#ifdef CONFIG_LINUX int name_len; char const *devinfo =3D "/proc/net/dev"; FILE *fp; char *line =3D NULL, *colon; size_t n =3D 0; fp =3D fopen(devinfo, "r"); if (!fp) { return -1; } name_len =3D strlen(name); @@ -2811,20 +2812,21 @@ static int guest_get_network_stats(const char *name, stats->tx_errs =3D tx_errs; stats->tx_dropped =3D tx_dropped; fclose(fp); g_free(line); return 0; } } fclose(fp); g_free(line); g_debug("/proc/net/dev: Interface '%s' not found", name); +#endif /* CONFIG_LINUX */ return -1; } =20 /* * Build information about guest interfaces */ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) { GuestNetworkInterfaceList *head =3D NULL, **tail =3D &head; struct ifaddrs *ifap, *ifa; @@ -2876,22 +2878,25 @@ GuestNetworkInterfaceList *qmp_guest_network_get_in= terfaces(Error **errp) if (errno =3D=3D EADDRNOTAVAIL) { /* The interface doesn't have a hw addr (e.g. loopback= ). */ g_debug("failed to get MAC address of %s: %s", ifa->ifa_name, strerror(errno)); } else{ g_warning("failed to get MAC address of %s: %s", ifa->ifa_name, strerror(errno)); } =20 } else { +#ifdef CONFIG_SOLARIS + mac_addr =3D (unsigned char *) &ifr.ifr_addr.sa_data; +#else mac_addr =3D (unsigned char *) &ifr.ifr_hwaddr.sa_data; - +#endif info->hardware_address =3D g_strdup_printf("%02x:%02x:%02x:%02x:%02x:%02x", (int) mac_addr[0], (int) mac_addr[1], (int) mac_addr[2], (int) mac_addr[3], (int) mac_addr[4], (int) mac_addr[5]); =20 info->has_hardware_address =3D true; } close(sock); } --=20 2.11.0