qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [6217] Assign a name to each VLAN client (Mark McLoughlin)
Date: Wed, 07 Jan 2009 17:43:45 +0000	[thread overview]
Message-ID: <E1LKcRV-0007Jk-Cy@cvs.savannah.gnu.org> (raw)

Revision: 6217
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6217
Author:   aliguori
Date:     2009-01-07 17:43:44 +0000 (Wed, 07 Jan 2009)

Log Message:
-----------
Assign a name to each VLAN client (Mark McLoughlin)

Automatically assign a name to each vlan client based on its model,
e.g. e1000.0, tap.3 or vde.1.

This name is intended to be used by the forthcoming 'set_link'
monitor command.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Modified Paths:
--------------
    trunk/net.c
    trunk/net.h

Modified: trunk/net.c
===================================================================
--- trunk/net.c	2009-01-07 17:42:25 UTC (rev 6216)
+++ trunk/net.c	2009-01-07 17:43:44 UTC (rev 6217)
@@ -296,6 +296,25 @@
 }
 #endif
 
+static char *assign_name(VLANClientState *vc1, const char *model)
+{
+    VLANState *vlan;
+    char buf[256];
+    int id = 0;
+
+    for (vlan = first_vlan; vlan; vlan = vlan->next) {
+        VLANClientState *vc;
+
+        for (vc = vlan->first_client; vc; vc = vc->next)
+            if (vc != vc1 && strcmp(vc->model, model) == 0)
+                id++;
+    }
+
+    snprintf(buf, sizeof(buf), "%s.%d", model, id);
+
+    return strdup(buf);
+}
+
 VLANClientState *qemu_new_vlan_client(VLANState *vlan,
                                       const char *model,
                                       IOReadHandler *fd_read,
@@ -307,6 +326,7 @@
     if (!vc)
         return NULL;
     vc->model = strdup(model);
+    vc->name = assign_name(vc, model);
     vc->fd_read = fd_read;
     vc->fd_can_read = fd_can_read;
     vc->opaque = opaque;
@@ -327,6 +347,7 @@
     while (*pvc != NULL)
         if (*pvc == vc) {
             *pvc = vc->next;
+            free(vc->name);
             free(vc->model);
             free(vc);
             break;

Modified: trunk/net.h
===================================================================
--- trunk/net.h	2009-01-07 17:42:25 UTC (rev 6216)
+++ trunk/net.h	2009-01-07 17:43:44 UTC (rev 6217)
@@ -19,6 +19,7 @@
     struct VLANClientState *next;
     struct VLANState *vlan;
     char *model;
+    char *name;
     char info_str[256];
 };
 

                 reply	other threads:[~2009-01-07 17:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=E1LKcRV-0007Jk-Cy@cvs.savannah.gnu.org \
    --to=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).