Giter Club home page Giter Club logo

cloudlab-scripts's Introduction

dev helpers

  1. copy the /boot/config-xxx from guest

    scp root@guest_ip:/boot/config-3.13-xxx .config

  2. change your guest ip and modules path in config.sh

  3. In linux src directory, yes "" | make oldconfig

  4. In linux src directory, make menuconfig, in virtualization, mark KVM and intel part to * (builtin), In Kernel Hacking - Compile time checks and options, turn on the Provide GDB scripts for kernel debugging, then save the config.

    In Device Drivers > Network device support > Ethernet driver support,

<*>     RealTek RTL-8139 C+ PCI Fast Ethernet Adapter support
<*>     RealTek RTL-8129/8130/8139 PCI Fast Ethernet Adapter support
  1. bash build.sh to compile
  2. bash update-guest.sh to install new kernel for guest os

pre setup

In guest os, modify /etc/ssh/sshd_config to allow ssh as root

#PermitRootLogin without-password
StrictModes yes
PermitRootLogin yes
PasswordAuthentication yes

then setup root password with sudo passwd root then sudo service ssh restart then use setup-sshkey.sh to setup ssh key access with guest vm.

GDB debugging

Host setup

Run sudo virsh edit guest0 to edit the xml spec.

# Modify this:
<domain type='kvm'>
# To look like this:
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <qemu:commandline>
    <qemu:arg value='-s'/> # add -S to wait for gdb before booting
  </qemu:commandline>

To enable nested virtualization vmx feature, sudo virsh edit guest0 to modify the cpu attribute to,

  <cpu mode='host-model' check='partial'>
    <model fallback='allow'>Haswell-noTSX-IBRS</model>
  </cpu>

  or add <feature policy='require' name='vmx'/> inside <cpu> section

add the following line to ~/.gdbinit to allow loading helper files:

set auto-load safe-path /

Guest setup

modify /etc/default/grub.

#GRUB_HIDDEN_TIMEOUT=-1
#GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=-1
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nokaslr"
GRUB_CMDLINE_LINUX="console=ttyS0,115200n8"

add nokaslr to cmdline_linux_default (for gdb breakpoint to work) to /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nokaslr"

Then sudo update-grub.

playing with GDB

start the guest, and then navigate to the linux source directory in host,

gdb vmlinux

In gdb:

(gdb) lx-symbols
(gdb) target remote :1234
(gdb) hb vmx_init
(gdb) c

hb = hardware breakpoint, (normal breakpoint not working).

then you can play with gdb, see https://01.org/linuxgraphics/gfx-docs/drm/dev-tools/gdb-kernel-debugging.html for info on helper commands like lx-symbols.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.