Help with Qemu

3 views
Skip to first unread message

Aijaz Baig

unread,
Apr 13, 2023, 3:16:53 AM4/13/23
to inside...@googlegroups.com
Hello folks

I'm trying to set up a qemu-kvm VM following this guide as a reference. The only change I did was install DHCP and git as additional target packages while configuring buildroot.

This is how I invoke qemu:

    sudo modprobe kvm-intel && sudo qemu-system-x86_64 -kernel /arch/x86_64/boot/bzImage -nographic -drive format=raw,file=~/buildroot/output/images/rootfs.ext4,if=virtio -append "root=/dev/vda console=ttyS0 nokaslr" -m 512M -accel kvm -cpu host -smp 1 -netdev user,id=nd0,hostfwd=tcp::8080-:80 -device virtio-net,netdev=nd0 -s

After my VM is up and running I modify my /etc/network/interfaces/ file to add the following lines:
    auto eth0
    iface eth0 inet dhcp

Now, with these two changes, I see that my VM interfaces look like this
    # ifconfig
    eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:56
              inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
              inet6 addr: fe80::fd5a:482c:3194:fa26/64 Scope:Link
              inet6 addr: fec0::28e6:7439:6d58:6246/64 Scope:Site
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:29 errors:0 dropped:0 overruns:0 frame:0
              TX packets:58 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:4401 (4.2 KiB)  TX bytes:6537 (6.3 KiB)
   
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


I have a few questions about this setup:

 1. I'd like to know if there is a way to connect to this VM without hostfwd (since it doesn't seem to work)?
 2. My SSH keys get erased on every reboot. Is there a way to persist it?
 3. Speaking of persistence, why is it that my settings in `/etc/network/interfaces` persists while my SSH keys don't?

Keen to have some clarity on this rather user-hostile qemu CLI tool. I find the Qemu documentation to be rather obtuse and seems to be written for folks who have had their feet wet elsewhere already!

--

Best Regards,
Aijaz Baig

Anil Kumar Pugalia

unread,
Apr 14, 2023, 10:58:36 PM4/14/23
to inside...@googlegroups.com

1. You need to have some IP of the VM exposed out for connectivity.

2 & 3. Check for how the two locations are mounted.

Regards
Anil
Passion: https://sysplay.in (Playing with Systems)
Aijaz Baig wrote on 13/04/23 12:46 pm:
--
You received this message because you are subscribed to the Google Groups "SysPlay's Inside Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inside_linux/CAHB2L%2BdrCx6VWHMB4ejX6Dp_rXoOxirfp5kbXWhyv4w5bUQUhg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages