Hello everyone! I recently decided to reignite my passion for learning about kernel development, so I printed out the third edition of Linux Device Drivers by J. Corbet + others. In the book it is stated that they assume you have the 2.6.10 kernel. I decided to set up a virtual machine using virt-manager so that I can work through most of the book (I realise VMs dont allow for many things when developing drivers, where physical access to hardware is required, but its the best option for now until I can get a RPi or something else).

I decided to go with Ubuntu Dapper Drake, as it has a kernel version pretty close to what is used in the book, so I figured there wouldn’t be much friction when trying to install the specific 2.6.10 version (Dapper Drake is on 2.6.15, at least the one I got). However, I am encountering an issue with my networking. I have set up the NAT bridge from my regular WIFI internet connection to my virtual machines, set my dapper drake installation to use that in the NIC settings, but it doesnt connect.

Here are some commands and their output from the guest OS:

$ ifconfig -a
lo
<loopback information yada yada>

sit0
<yada yada>

$ lspci | grep -i ethernet
0000:01:00.0 Ethernet controller: Unknown device 1af4:1041 (rev 01)

The second command’s output leads me to believe that a device is detected but the OS doesnt know what to do with it because I dont have the virtio drivers for networking installed.

I’ve searched everywhere for a way to download them either as source or as a .deb package so I can transfer them to the guest OS using a disk drive I will create, but I cant find them anywhere. Everywhere I look, everyone says that for linux they are already included in the kernel (might not be true for the distribution I have as a guest).

So here is my question(s) finally: Where can I find virtio-tools either as a .deb package or as source with instruction to build on a distribution of around the age of dapper drake, or if there is another way and I am wrongly fixated on this, how can I set up networking by passing through my regular internet from the host to the guest, so that I can use stuff like github to write the driver code on my host and easily transfer it to the guest for compilation/testing?

Please be gentle. Dapper drake released around 2006 and it wasn’t until 2016 when I first used linux in any form, so I am used to a little more quality of life in my distributions xD /j

As always, many thanks in advance to everyone taking time to answer :)

  • MorphiusFaydal@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    4 days ago

    Instead of trying to backport the virtio device drivers to that version, I’d recommend editing the VM to use the emulated e1000 NIC.

    • promitheas@programming.devOP
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      4 days ago

      I’ve got it set up like that. In my NIC section, under device model, the selected option is e1000e, but still no eth0 interface or anything other than lo and sit0

      Edit: unless I misunderstood and that’s not enough to use the e1000 driver

      • MorphiusFaydal@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        4 days ago

        You may need to shut down the VM, check the device config to ensure it’s set to e1000, then boot it back up. The PCI ID on your original post belongs to the virtio-net device.

        • promitheas@programming.devOP
          link
          fedilink
          arrow-up
          1
          ·
          3 days ago

          Please could you guide me through that? How would I check that its set to e1000? I looked at the xml and and the model type is e1000, but again, I’m not sure im looking in the right place. Up to now I have been rawdogging qemu, so im not that familiar with virt-manager

          • MorphiusFaydal@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            3 days ago

            I don’t recall in virt-manager off the top of my head. But if you make changes in the XML of a domain, you do have to shutdown/restart the domain before they’re effective. And just to be safe, I would say to shutdown the domain, then check the XML, then start up again.

            You do say you’re just using qemu, so if that’s the case and you aren’t using libvirt in front of it, shutdown the VM, make sure your qemu command specifies an e1000 network device, and run again.

            I can check virt-manager when I get some free time this evening, if that’s what you want/need.

  • dkc@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    4 days ago

    I’ve done some kernel development. I’d suggest using a modern system. Most of the basic stuff in the book is still accurate and there’s great documentation available to help find newer APIs. The kernel is always refactoring so learning to find newer info is part of the skills you’ll need to develop anyway.

    • promitheas@programming.devOP
      link
      fedilink
      arrow-up
      1
      ·
      4 days ago

      I considered that, and the reason I decided to go with the method I chose was twofold:

      1. I of course need to be safe - that means I don’t want to run unsafe kernel code on my main machine, so a virtual machine makes sense. I could use one of my old laptops as both a host and target machine, but honestly I have my main machine set up just how I like it for development so I would probably end up using it for writing the actual code anyway. I suppose I could have one of my laptops be the target and pull code from github (exactly what I was planning to do with the virtual machine just with real hardware).

      2. I didn’t want to introduce more problems than would naturally occur when going through the book while learning, by adding the fact that I have a great mismatch in kernel versions, which would undoubtedly change the APIs a great deal. I learn better when I can focus on getting comfortable with one thing at the beginning, and then building from there. If its not as tragic as I imagine it though (the mountain looks larger before you start the climb) I would definitely prefer getting comfortable with the modern kernel as ultimately that’s what I plan to develop on (this all started because I want to fix some stuff with my Genesis Xenon 770 mouse that I’m unhappy with currently).

      However, I am open to the idea. Could you direct me to any resources you found helpful specifically for adapting what you read/learn in that book, to the modern kernel? Or any other helpful resources really, anything would be helpful at this point. Discords, forums, wikis, whatever you have :)