From: Andrew Deason <adeason@sinenomine.net>
To: "Michal Prívozník" <mprivozn@redhat.com>
Cc: Michael Roth <michael.roth@amd.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH 3/3] qga/commands-posix: Fix listing ifaces for Solaris
Date: Mon, 28 Mar 2022 12:44:30 -0500 [thread overview]
Message-ID: <20220328124430.e752e82107ded8a0abbe48c0@sinenomine.net> (raw)
In-Reply-To: <10f8e706-ae5b-6cd1-d057-110933b865ff@redhat.com>
On Mon, 21 Mar 2022 10:14:57 +0100
Michal Prívozník <mprivozn@redhat.com> wrote:
> On 3/20/22 22:38, Andrew Deason wrote:
> > 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>
> > ---
> > 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 bd0d67f674..c0b00fc488 100644
> > --- a/qga/commands-posix.c
> > +++ b/qga/commands-posix.c
> > @@ -2781,20 +2781,21 @@ guest_find_interface(GuestNetworkInterfaceList *head,
> > return head->value;
> > }
> > }
> >
> > return NULL;
> > }
> >
> > 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;
> > char *line = NULL, *colon;
> > size_t n = 0;
> > fp = fopen(devinfo, "r");
> > if (!fp) {
> > return -1;
> > }
> > name_len = strlen(name);
> > @@ -2836,20 +2837,21 @@ static int guest_get_network_stats(const char *name,
> > stats->tx_errs = tx_errs;
> > stats->tx_dropped = 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 */
>
> I wonder whether we should signal this somehow. I mean, have something
> like this:
>
> #else /* !CONFIG_LINUX */
> g_debug("Stats reporting available only for Linux");
> #endif /* !CONFIG_LINUX */
>
> > return -1;
> > }
>
> A counter argument is that if fopen() above fails then -1 is returned
> without any error/debug message reported. And stats fetching is best
> effort anyway.
Ping for this stack. Should I just go ahead and add the above? Sorry if
I was expected to respond to this; I don't disagree but I also saw the
existing silent-failure code path so it doesn't seem like it matters.
I could add debug messages for both silent-failure code paths, maybe as
a separate commit afterwards?
--
Andrew Deason
adeason@sinenomine.net
next prev parent reply other threads:[~2022-03-28 17:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-20 21:38 [PATCH 0/3] qga: Implement guest-network-get-interfaces for Solaris Andrew Deason
2022-03-20 21:38 ` [PATCH 1/3] qga/commands-posix: Use getifaddrs when available Andrew Deason
2022-03-20 21:38 ` [PATCH 2/3] qga/commands-posix: Fix iface hw address detection Andrew Deason
2022-03-20 21:38 ` [PATCH 3/3] qga/commands-posix: Fix listing ifaces for Solaris Andrew Deason
2022-03-21 9:14 ` Michal Prívozník
2022-03-28 17:44 ` Andrew Deason [this message]
2022-03-21 9:14 ` [PATCH 0/3] qga: Implement guest-network-get-interfaces " Michal Prívozník
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220328124430.e752e82107ded8a0abbe48c0@sinenomine.net \
--to=adeason@sinenomine.net \
--cc=michael.roth@amd.com \
--cc=mprivozn@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).