Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ci-vm-image
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas Schneider
ci-vm-image
Commits
fdbe7fe4
Commit
fdbe7fe4
authored
1 year ago
by
Thomas Schneider
Browse files
Options
Downloads
Patches
Plain Diff
Adadpt for Linux Kernel Programming lecture, some documentation
parent
65255327
Branches
lkp
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
launch.1
+57
-0
57 additions, 0 deletions
launch.1
launch.sh
+41
-7
41 additions, 7 deletions
launch.sh
make-image.sh
+3
-1
3 additions, 1 deletion
make-image.sh
with
101 additions
and
8 deletions
launch.1
0 → 100644
+
57
−
0
View file @
fdbe7fe4
.Dd November 07, 2023
.Dt LAUNCH.SH 1
.Os
.Sh NAME
.Nm launch.sh
.Nd launch a Linux Kernel development VM
.Sh SYNOPSIS
.Nm
.Op Fl k Ar kernel
.Op Fl i Ar initrd
.Op Fl a Ar append
.Op Fl s Ar share
.Op Fl -
.Op Ar "extra qemu arguments"
.Sh DESCRIPTION
.Nm
launches a prepared VM image using
.Xr qemu 1 ,
suitable for Linux Kernel development.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl k Ar kernel
Use
.Ar kernel
to boot the VM.
.It Fl i Ar initrd
Provide
.Ar initrd
as initrd/initramfs image to the kernel.
Use an empty argument to boot
.Em without
an initrd/initramfs.
.It Fl a Ar append
Append
.Ar append
to the default kernel command line.
.It Fl s Ar share
Provide the directory
.Ar share
to the VM using virtfs/9p.
.It Ar "extra qemu arguments"
Specify extra arguments to pass to
.Xr qemu 1 .
.El
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
The following invocation launches a VM with a custom kernel, no initramfs, and a
share directory:
.Dl $ ./ Ns Nm Fl k Pa ../linux/arch/x86/boot/bzImage Fl i Pa "''" Fl s Pa ../share
.Sh SEE ALSO
.Xr qemu 1
.Sh AUTHORS
.An Thomas Schneider Aq Mt thomas@fsmpi.rwth-aachen.de
.Sh BUGS
Currently, too many options that should be customisable are hard-coded.
This diff is collapsed.
Click to expand it.
launch.sh
+
41
−
7
View file @
fdbe7fe4
#!/
bin/
sh
#!/
usr/bin/env ba
sh
set
-e
H
=
$(
dirname
"
$0
"
)
kernel
=
"
$H
/vmlinuz-virt"
initrd
=
"
$H
/initramfs-virt"
append
=
""
share
=
""
optstring
=
"k:i:a:s:"
while
getopts
$optstring
opt
;
do
case
$opt
in
k
)
kernel
=
"
$OPTARG
"
;;
i
)
initrd
=
"
$OPTARG
"
;;
a
)
append
=
"
$OPTARG
"
;;
s
)
share
=
"
$OPTARG
"
;;
'?'
)
printf
"Usage: %s [-k KERNEL] [-i INITRD] [-a APPEND] [-s SHARE] [...]
\n
"
"
$0
"
1>&2
exit
1
;;
esac
done
shift
$((
OPTIND
-
1
))
qargs
=(
-kernel
"
$kernel
"
)
test
-n
"
$initrd
"
&&
qargs+
=(
-initrd
"
$initrd
"
)
qargs+
=(
-append
"root=/dev/vda overlaytmpfs console=hvc0 earlyprintk=hvc0
$append
"
)
test
-n
"
$share
"
&&
qargs+
=(
-virtfs
"local,path=
$share
,mount_tag=share,security_model=mapped-file,id=share"
)
qargs+
=(
"
$@
"
)
set
-x
exec
qemu-system-x86_64
\
-M
microvm,x-option-roms
=
off,pit
=
off,pic
=
off,rtc
=
off,isa-serial
=
off,pcie
=
on
\
...
...
@@ -14,9 +52,6 @@ exec qemu-system-x86_64 \
-device
virtio-rng-device
\
-drive
id
=
root,file
=
image.sqfs,format
=
raw,if
=
none
\
-device
virtio-blk-device,drive
=
root
\
-kernel
vmlinuz-virt
\
-initrd
initramfs-virt
\
-append
"root=/dev/vda overlaytmpfs console=hvc0 earlyprintk=hvc0"
\
-chardev
stdio,mux
=
on,id
=
stdio
\
-device
virtio-serial-device
\
-device
virtconsole,chardev
=
stdio,name
=
console.0
\
...
...
@@ -25,7 +60,6 @@ exec qemu-system-x86_64 \
-device
virtio-net-device,netdev
=
net
\
-chardev
socket,path
=
qga,server
=
on,wait
=
off,id
=
qga
\
-device
virtserialport,chardev
=
qga,name
=
org.qemu.guest_agent.0
\
-chardev
socket,id
=
virtfs,path
=
/tmp/virtfs.sock
\
-device
vhost-user-fs-pci,chardev
=
virtfs,tag
=
virtfs,queue-size
=
1024
\
-object
memory-backend-memfd,id
=
mem,size
=
1536M,share
=
on
\
-numa
node,memdev
=
mem
-numa
node,memdev
=
mem
\
"
${
qargs
[@]
}
"
This diff is collapsed.
Click to expand it.
make-image.sh
+
3
−
1
View file @
fdbe7fe4
...
...
@@ -13,10 +13,12 @@ ln -s "$PWD/apk-cache" /etc/apk/cache
ln
-s
"
$PWD
/apk-cache"
/image/etc/apk/cache
cp
-r
/etc/apk/repositories /etc/apk/keys /image/etc/apk
apk add
--root
/image
--update-cache
--initdb
alpine-base mkinitfs
\
qemu-guest-agent
git git-lfs gitlab-runner bash buildah
qemu-guest-agent
echo
'features="base squashfs virtio"'
>
/image/etc/mkinitfs/mkinitfs.conf
apk add
--root
/image linux-virt
echo
"share /mnt 9p trans=virtio,version=9p2000.L,nofail"
>>
/image/etc/fstab
oldpwd
=
"
$PWD
"
cd
/image/etc/runlevels
for
i
in
devfs dmesg mdev hwdrivers cgroups
;
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment