Booting n9000v with QEMU

I ran into an issue booting up a n9kv image with Qemu where things were looking good, and then at the last minute before getting the prompts that VDC is coming online and all that fun stuff I got booted right back to the loader prompt. My output ended up looking something like this:

WARNING: No BIOS Info found
Sysconf checksum failed. Using default values
Sysconf checksum failed. Using default values
Sysconf checksum failed. Using default values
ATE0Q1&D2&C1S0=1
Standalone chassis
check_bootmode: grub2pxe: grub failed, launch ipxe
Trying to load ipxe
Loading Application:
/Vendor(429bdb26-48a6-47bd-664c-801204061400)/UnknownMedia(6)/EndEntire
cannot load imageFailed to launch ipxe
Came back to grub, now load efi shell
Trying to load efishell
Loading Application:
/Vendor(429bdb26-48a6-47bd-664c-801204061400)/UnknownMedia(6)/EndEntire
cannot load imageFailed to launch shell
Trying to read config file /boot/grub/menu.lst.local from (hd0,4)
Filesystem type is ext2fs, partition type 0x83
Trying to read config file /boot/grub/menu.lst.local from (hd0,5)
Filesystem type is ext2fs, partition type 0x83
No autoboot or failed autoboot. falling to loader

Loader Version 5.9

loader >

Obviously not awesome. The “No BIOS Info found” thing threw me and sent me down a rabbit hole of trying out some different bios images to no avail. So I took a deeper look back at the output during boot up and noticed the following:

Installing LC netdev ... [ 53.757723] BUG: unable to handle kernel NULL pointer dereference at 0000000000000118
[ 53.761995] IP: [] dev_get_by_name_rcu+0x2f/0x90
[ 53.763113] PGD 80000001f86f6067 PUD 22c773067 PMD 0
[ 53.763113] Oops: 0000 [#1] SMP
[ 53.763113] Modules linked in: klm_lcnd(O+) klm_rni_lcnd(O) klm_fcfwd(PO) klm_if_index(PO) klm_nvram(O) klm_pfmsvcs(PO) klm_dc_sprom(O) klm_ins_igb(O) klm_cctrli(PO) klm_i2c_stub(O) klm_sdwrap(O) klm_kpss(PO) klm_tlv(PO) klm_sse(O) klm_ftrace(O) klm_rdn_pdsim(PO) klm_swover_trigger(PO) klm_procfs_init(PO) klm_cmos(PO) ata_piix klm_card_index(O)
[ 53.763113] CPU: 0 PID: 8656 Comm: insmod Tainted: P O 4.1.21-WR8.0.0.25-standard #1
[ 53.763113] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
[ 53.763113] task: ffff88022f83c7a0 ti: ffff88006a42c000 task.ti: ffff88006a42c000
[ 53.763113] RIP: 0010:[] [] dev_get_by_name_rcu+0x2f/0x90
[ 53.763113] RSP: 0018:ffff88006a42fc68 EFLAGS: 00010a03
[ 53.763113] RAX: 000000005a493a5e RBX: 0000000000000000 RCX: 0000000000000020
[ 53.763113] RDX: 9e37fffffffc0001 RSI: 0000000000000004 RDI: 0000000031687465
[ 53.763113] RBP: ffff88006a42fc78 R08: 000000000000000a R09: 0000000000000244
[ 53.763113] R10: 0000000000000030 R11: 0000000000000006 R12: ffff8801f831d150
[ 53.763113] R13: 0000000080000000 R14: ffff8801f831d2a0 R15: ffff880211d74ea0
[ 53.763113] FS: 00007f0865216700(0000) GS:ffff880239c00000(0000) knlGS:0000000000000000
[ 53.763113] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 53.763113] CR2: 0000000000000118 CR3: 00000001f833e000 CR4: 0000000000000670
[ 53.763113] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 53.763113] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 53.763113] Stack:
[ 53.763113] 0000000000000000 0000000000000000 ffff88006a42fc88 ffffffff976557ae
[ 53.763113] ffff88006a42fcc8 ffffffffb8df83c8 0000000000000000 ffffffff97c13270
[ 53.763113] ffff88006a42fcc8 00000000b8db99c3 0000000000000000 ffffffff97c13270
[ 53.763113] Call Trace:
[ 53.763113] [] dev_get_by_name+0xe/0x20
[ 53.763113] [] lcnd_platform_init+0x298/0x7f0 [klm_lcnd]
[ 53.763113] [] lcnd_init_module+0x2ac/0xa70 [klm_lcnd]
[ 53.763113] [] ? lcnd_unregister_pernet_subsys+0x20/0x20 [klm_lcnd]
[ 53.763113] [] do_one_initcall+0x105/0x1c0
[ 53.763113] [] ? kmem_cache_alloc_trace+0x12c/0x1f0
[ 53.763113] [] do_init_module+0x64/0x1e0
[ 53.763113] [] load_module+0x1486/0x1790
[ 53.763113] [] ? mod_kobject_put+0x50/0x50
[ 53.763113] [] SyS_finit_module+0x71/0x90
[ 53.763113] [] tracesys_phase2+0x90/0x95
[ 53.763113] Code: 00 55 48 89 e5 41 54 49 89 f4 be 10 00 00 00 53 48 89 fb 4c 89 e7 e8 21 c9 d6 ff 4c 89 e7 89 c6 e8 77 b4 b6 ff 69 c0 01 00 37 9e <48> 8b 93 18 01 00 00 31 db c1 e8 18 48 8d 04 c2 48 8b 00 48 8d
[ 53.763113] RIP [] dev_get_by_name_rcu+0x2f/0x90
[ 53.763113] RSP
[ 53.763113] CR2: 0000000000000118
[ 53.839781] ---[ end trace 71f904f851d077cb ]---

Obviously that doesn’t look great, but I was ignoring it because I figured “LC” == line card and of course this is just a VM instance so there was no line card… so it could make sense that there would be some angry output. At this point I need to mention that I was trying to do as little as possible to get this thing to boot — a tactic that is usually pretty handy; eliminate any superfluous stuff, and focus on the basics. Well, that kind of shot me in the foot here as the device had no interfaces; and that apparently made it very angry… adding in some e1000 devices in my qemu command cleared things up and it booted right up.

TL;DR: n9kv needs to have at least some ethernet interfaces or it gets very angry and won’t boot!

Tidbit: Arista/NAPALM Config Replace

Quick one here — if you are dorking about with NAPALM and config replace (I’ve been using Ansible, but probably same story for just pure Python) and you are getting annoying errors on whatever is AFTER your BGP stanza, make sure you “exit” out of your BGP stanza like so:

 

router bgp 1234
   router-id 1.1.1.1
   neighbor 1.1.1.1 remote-as 1234
   neighbor 1.1.1.1 update-source loopback0
!
  address-family ipv4
   neighbor 1.1.1.1 activate
   network 2.2.2.2/32
   exit 
  exit
!
router ospf 1
  router-id 1.1.1.1

Basically I was getting an annoying error saying something about an invalid token and “‘router ospf 1’ failed:”. Adding the “exit” statements out of each of the nested stanzas of BGP fixed this right away. Hopefully this saves somebody some time 🙂