qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mark McLoughlin <markmc@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Mark McLoughlin <markmc@redhat.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/6] Fixup info_str formatting
Date: Tue,  6 Jan 2009 15:00:33 +0000	[thread overview]
Message-ID: <1231254036-29060-3-git-send-email-markmc@redhat.com> (raw)
In-Reply-To: <1231254036-29060-2-git-send-email-markmc@redhat.com>

The VLANClientState::info_str format isn't terribly consistent and
this patch moves towards it just containing the param strings
separated by a comma.

The type/model string is removed from info_str, and 'info network'
instead displays the vlan client name with the info_str.

There's a horrible little hack in net_cleanup() to parse a tap
client's info_str which I've also fixed up. The hack probably
shouldn't exist at all, though.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 hw/e1000.c    |    2 +-
 hw/eepro100.c |    2 +-
 hw/mipsnet.c  |    2 +-
 hw/ne2000.c   |    4 ++--
 hw/pcnet.c    |    2 +-
 hw/rtl8139.c  |    2 +-
 hw/usb-net.c  |    2 +-
 net.c         |   14 ++++++++------
 8 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index 03c573b..996260c 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1075,7 +1075,7 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
                                  e1000_receive, e1000_can_receive, d);
 
     snprintf(d->vc->info_str, sizeof(d->vc->info_str),
-             "%s macaddr=%02x:%02x:%02x:%02x:%02x:%02x", info_str,
+             "macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
              d->nd->macaddr[0], d->nd->macaddr[1], d->nd->macaddr[2],
              d->nd->macaddr[3], d->nd->macaddr[4], d->nd->macaddr[5]);
 
diff --git a/hw/eepro100.c b/hw/eepro100.c
index a7861ca..8ea283c 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1780,7 +1780,7 @@ static void nic_init(PCIBus * bus, NICInfo * nd,
                                  nic_receive, nic_can_receive, s);
 
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
-             "eepro100 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
+             "macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
              s->macaddr[0],
              s->macaddr[1],
              s->macaddr[2], s->macaddr[3], s->macaddr[4], s->macaddr[5]);
diff --git a/hw/mipsnet.c b/hw/mipsnet.c
index 549e6f3..8190738 100644
--- a/hw/mipsnet.c
+++ b/hw/mipsnet.c
@@ -257,7 +257,7 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)
     }
 
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
-             "mipsnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
+             "macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
               s->nd->macaddr[0],
               s->nd->macaddr[1],
               s->nd->macaddr[2],
diff --git a/hw/ne2000.c b/hw/ne2000.c
index dc97989..600cdc3 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -745,7 +745,7 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
                                  ne2000_receive, ne2000_can_receive, s);
 
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
-             "ne2000 macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
+             "macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
              s->macaddr[0],
              s->macaddr[1],
              s->macaddr[2],
@@ -815,7 +815,7 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
                                  ne2000_receive, ne2000_can_receive, s);
 
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
-             "ne2000 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
+             "macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
              s->macaddr[0],
              s->macaddr[1],
              s->macaddr[2],
diff --git a/hw/pcnet.c b/hw/pcnet.c
index e961a06..90bf7fd 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -1940,7 +1940,7 @@ static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str)
                                      pcnet_receive, pcnet_can_receive, d);
 
         snprintf(d->vc->info_str, sizeof(d->vc->info_str),
-                 "pcnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
+                 "macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
                  d->nd->macaddr[0],
                  d->nd->macaddr[1],
                  d->nd->macaddr[2],
diff --git a/hw/rtl8139.c b/hw/rtl8139.c
index 39f3209..1853ab3 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3442,7 +3442,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
                                  rtl8139_receive, rtl8139_can_receive, s);
 
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
-             "rtl8139 pci macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
+             "macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
              s->macaddr[0],
              s->macaddr[1],
              s->macaddr[2],
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 40ee41b..1622ef8 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1461,7 +1461,7 @@ USBDevice *usb_net_init(NICInfo *nd)
                     0x40, s->mac[1], s->mac[2],
                     s->mac[3], s->mac[4], s->mac[5]);
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
-                    "usbnet macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
+                    "macaddr=%02x:%02x:%02x:%02x:%02x:%02x",
                     s->mac[0], s->mac[1], s->mac[2],
                     s->mac[3], s->mac[4], s->mac[5]);
     fprintf(stderr, "usbnet: initialized mac %02x:%02x:%02x:%02x:%02x:%02x\n",
diff --git a/net.c b/net.c
index c268233..db69c7f 100644
--- a/net.c
+++ b/net.c
@@ -474,7 +474,7 @@ static int net_slirp_init(VLANState *vlan, const char *model)
     }
     slirp_vc = qemu_new_vlan_client(vlan, model,
                                     slirp_receive, NULL, NULL);
-    snprintf(slirp_vc->info_str, sizeof(slirp_vc->info_str), "user redirector");
+    slirp_vc->info_str[0] = '\0';
     return 0;
 }
 
@@ -699,7 +699,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan, const char *model, int fd)
     s->vc->fd_readv = tap_receive_iov;
 #endif
     qemu_set_fd_handler(s->fd, tap_send, NULL, s);
-    snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", fd);
+    snprintf(s->vc->info_str, sizeof(s->vc->info_str), "fd=%d", fd);
     return s;
 }
 
@@ -954,7 +954,8 @@ static int net_tap_init(VLANState *vlan, const char *model, const char *ifname1,
     if (!s)
         return -1;
     snprintf(s->vc->info_str, sizeof(s->vc->info_str),
-             "tap: ifname=%s setup_script=%s", ifname, setup_script);
+             "ifname=%s,script=%s,downscript=%s",
+             ifname, setup_script, down_script);
     if (down_script && strcmp(down_script, "no"))
         snprintf(s->down_script, sizeof(s->down_script), "%s", down_script);
     return 0;
@@ -1016,7 +1017,7 @@ static int net_vde_init(VLANState *vlan, const char *model, const char *sock,
     }
     s->vc = qemu_new_vlan_client(vlan, model, vde_from_qemu, NULL, s);
     qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);
-    snprintf(s->vc->info_str, sizeof(s->vc->info_str), "vde: sock=%s fd=%d",
+    snprintf(s->vc->info_str, sizeof(s->vc->info_str), "sock=%s,fd=%d",
              sock, vde_datafd(s->vde));
     return 0;
 }
@@ -1639,7 +1640,7 @@ void do_info_network(void)
     for(vlan = first_vlan; vlan != NULL; vlan = vlan->next) {
         term_printf("VLAN %d devices:\n", vlan->id);
         for(vc = vlan->first_client; vc != NULL; vc = vc->next)
-            term_printf("  %s\n", vc->info_str);
+            term_printf("  %s: %s\n", vc->name, vc->info_str);
     }
 }
 
@@ -1657,7 +1658,8 @@ void net_cleanup(void)
                 char ifname[64];
                 TAPState *s = vc->opaque;
 
-                if (sscanf(vc->info_str, "tap: ifname=%63s ", ifname) == 1 &&
+                if (strcmp(vc->model, "tap") == 0 &&
+                    sscanf(vc->info_str, "ifname=%63s ", ifname) == 1 &&
                     s->down_script[0])
                     launch_script(s->down_script, ifname, s->fd);
             }
-- 
1.6.0.6

  reply	other threads:[~2009-01-06 15:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-09 10:55 [Qemu-devel] [PATCH 0/4] Add nic link up/down emulation to e1000 Mark McLoughlin
2008-12-09 10:55 ` [Qemu-devel] [PATCH 1/4] Add 'set_link' monitor command Mark McLoughlin
2008-12-09 10:55   ` [Qemu-devel] [PATCH 2/4] Add device index to 'info network' output Mark McLoughlin
2008-12-09 10:55     ` [Qemu-devel] [PATCH 3/4] Allow devices be notified of link status change Mark McLoughlin
2008-12-09 10:55       ` [Qemu-devel] [PATCH 4/4] Implement e1000 link status Mark McLoughlin
2008-12-09 15:04     ` [Qemu-devel] Re: [PATCH 2/4] Add device index to 'info network' output Anthony Liguori
2008-12-09 15:01   ` [Qemu-devel] Re: [PATCH 1/4] Add 'set_link' monitor command Anthony Liguori
2008-12-12 14:45     ` Mark McLoughlin
2008-12-12 14:46       ` [Qemu-devel] [PATCH 1/5] Add a model string to VLANClientState Mark McLoughlin
2008-12-12 14:46         ` [Qemu-devel] [PATCH 2/5] Assign a name to each VLAN client Mark McLoughlin
2008-12-12 14:46           ` [Qemu-devel] [PATCH 3/5] Fixup info_str formatting Mark McLoughlin
2008-12-12 14:46             ` [Qemu-devel] [PATCH 4/5] Add qemu_format_nic_info_str() Mark McLoughlin
2008-12-12 14:46               ` [Qemu-devel] [PATCH 5/5] Add a -net name=foo parameter Mark McLoughlin
2008-12-14 23:48                 ` Aurelien Jarno
2009-01-06 14:59       ` [Qemu-devel] Re: [PATCH 1/4] Add 'set_link' monitor command Mark McLoughlin
2009-01-06 15:00         ` [Qemu-devel] [PATCH 1/6] Add a model string to VLANClientState Mark McLoughlin
2009-01-06 15:00           ` [Qemu-devel] [PATCH 2/6] Assign a name to each VLAN client Mark McLoughlin
2009-01-06 15:00             ` Mark McLoughlin [this message]
2009-01-06 15:00               ` [Qemu-devel] [PATCH 4/6] Add qemu_format_nic_info_str() Mark McLoughlin
2009-01-06 15:00                 ` [Qemu-devel] [PATCH 5/6] add missing MAC address to info_str for some NICs Mark McLoughlin
2009-01-06 15:00                   ` [Qemu-devel] [PATCH 6/6] Add a -net name=foo parameter Mark McLoughlin
2009-01-07 17:49           ` [Qemu-devel] Re: [PATCH 1/6] Add a model string to VLANClientState Anthony Liguori
2008-12-09 11:23 ` [Qemu-devel] [PATCH 0/4] Add nic link up/down emulation to e1000 Daniel P. Berrange
2008-12-09 13:57   ` Dor Laor
2008-12-09 15:06 ` [Qemu-devel] " Anthony Liguori
2008-12-10  8:53   ` Avi Kivity

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=1231254036-29060-3-git-send-email-markmc@redhat.com \
    --to=markmc@redhat.com \
    --cc=anthony@codemonkey.ws \
    --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).