qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Blue Swirl" <blauwirbel@gmail.com>
To: qemu-devel@nongnu.org, mark@glines.org
Subject: Re: [Qemu-devel] emulated lance device crashes in debian-sparc32
Date: Sat, 19 May 2007 22:08:23 +0300	[thread overview]
Message-ID: <f43fc5580705191208k2edf616s340e28bf729788d7@mail.gmail.com> (raw)
In-Reply-To: <f43fc5580705191003m227c8f7fk1b7ae5c1bafbf5f2@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 959 bytes --]

On 5/19/07, Blue Swirl <blauwirbel@gmail.com> wrote:
> On 5/19/07, Mark Glines <mark@glines.org> wrote:
> > The weird thing is, when I add "-net nic,model=lance" to my command line
> > right before "-net user", the crash does not occur.  I kinda assumed from
> > the above backtrace that the lance driver was selected on sparc32 by
> > default...

This patch fixes the crash. But I'm not convinced it's the right one,
perhaps the default net parameter logic could be improved instead:
    /* init network clients */
    if (nb_net_clients == 0) {
        /* if no clients, we use a default config */
        pstrcpy(net_clients[0], sizeof(net_clients[0]),
                "nic");
        pstrcpy(net_clients[1], sizeof(net_clients[0]),
                "user");
        nb_net_clients = 2;
    }

Also one of the network options could be a black hole kind of device,
such that unlike the "none" type, the device exists, it just can't
send or receive anything.

[-- Attachment #2: null_netdevice.diff --]
[-- Type: text/x-diff, Size: 3199 bytes --]

Index: qemu/hw/sun4m.c
===================================================================
--- qemu.orig/hw/sun4m.c	2007-05-19 18:36:33.000000000 +0000
+++ qemu/hw/sun4m.c	2007-05-19 18:40:39.000000000 +0000
@@ -304,15 +304,13 @@
     }
     tcx_init(ds, hwdef->tcx_base, phys_ram_base + ram_size, ram_size,
              hwdef->vram_size, graphic_width, graphic_height, graphic_depth);
-    if (nd_table[0].vlan) {
-        if (nd_table[0].model == NULL
-            || strcmp(nd_table[0].model, "lance") == 0) {
-            main_lance = lance_init(&nd_table[0], hwdef->le_base, dma,
-                                    slavio_irq[hwdef->le_irq]);
-        } else {
-            fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
-            exit (1);
-        }
+    if (nd_table[0].model == NULL
+        || strcmp(nd_table[0].model, "lance") == 0) {
+        main_lance = lance_init(&nd_table[0], hwdef->le_base, dma,
+                                slavio_irq[hwdef->le_irq]);
+    } else {
+        fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd_table[0].model);
+        exit (1);
     }
     nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0,
                         hwdef->nvram_size, 8);
Index: qemu/hw/pcnet.c
===================================================================
--- qemu.orig/hw/pcnet.c	2007-05-19 18:37:57.000000000 +0000
+++ qemu/hw/pcnet.c	2007-05-19 18:50:52.000000000 +0000
@@ -1267,7 +1267,8 @@
             if (CSR_LOOP(s))
                 pcnet_receive(s, s->buffer, s->xmit_pos);
             else
-                qemu_send_packet(s->vc, s->buffer, s->xmit_pos);
+                if (s->vc)
+                    qemu_send_packet(s->vc, s->buffer, s->xmit_pos);
 
             s->csr[0] &= ~0x0008;   /* clear TDMD */
             s->csr[4] |= 0x0004;    /* set TXSTRT */
@@ -1562,7 +1563,8 @@
 
     /* Initialize the PROM */
 
-    memcpy(s->prom, s->nd->macaddr, 6);
+    if (s->nd)
+        memcpy(s->prom, s->nd->macaddr, 6);
     s->prom[12] = s->prom[13] = 0x00;
     s->prom[14] = s->prom[15] = 0x57;
 
@@ -1898,18 +1900,21 @@
 
     d->nd = nd;
 
-    d->vc = qemu_new_vlan_client(nd->vlan, pcnet_receive, 
-                                 pcnet_can_receive, d);
-    
-    snprintf(d->vc->info_str, sizeof(d->vc->info_str),
-             "pcnet 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]);
-
+    if (nd && nd->vlan) {
+        d->vc = qemu_new_vlan_client(nd->vlan, pcnet_receive,
+                                     pcnet_can_receive, d);
+
+        snprintf(d->vc->info_str, sizeof(d->vc->info_str),
+                 "pcnet 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]);
+    } else {
+        d->vc = NULL;
+    }
     pcnet_h_reset(d);
     register_savevm("pcnet", 0, 2, pcnet_save, pcnet_load, d);
 }

  reply	other threads:[~2007-05-19 19:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-19 14:16 [Qemu-devel] emulated lance device crashes in debian-sparc32 Mark Glines
2007-05-19 17:03 ` Blue Swirl
2007-05-19 19:08   ` Blue Swirl [this message]
2007-05-19 22:08     ` Mark Glines
2007-05-20  7:10       ` Blue Swirl
2007-05-20  9:11         ` Mark Glines
2007-05-20 10:25           ` Paul Brook
2007-05-20 13:15             ` Mark Glines
2007-05-20 13:51               ` Paul Brook
2007-05-20 15:45             ` Blue Swirl
2007-05-20 19:45               ` Blue Swirl

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=f43fc5580705191208k2edf616s340e28bf729788d7@mail.gmail.com \
    --to=blauwirbel@gmail.com \
    --cc=mark@glines.org \
    --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).