Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

labs: Makefile: Add scp and ssh targets for easier module transfer on images with networking #240

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion tools/labs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ copy: $(YOCTO_IMAGE)
sudo umount $(TEMPDIR)
rmdir $(TEMPDIR)

scp:
if [ ! -e qemu.mon ]; then exit 1; fi
IP=$$(qemu/get_vm_ip.sh); \
if [ -z "$$IP" ]; then exit 1; fi; \
modules=$$(find skels -type f \( -name *.ko -or -executable \)); \
echo -n $$modules | xargs -d ' ' --no-run-if-empty dirname | xargs ssh root@$$IP mkdir -p || true; \
echo -n $$modules | xargs -d ' ' -I _ --no-run-if-empty scp _ root@$$IP:_ || true; \
checkers=$$(find skels -type d \( -name checker \)); \
echo -n $$checkers | xargs -d ' ' --no-run-if-empty dirname | xargs ssh root@$$IP mkdir -p || true; \
echo -n $$checkers | xargs -d ' ' -I _ --no-run-if-empty scp -r _ root@$$IP:_ || true

ssh:
if [ ! -e qemu.mon ]; then exit 1; fi
IP=$$(qemu/get_vm_ip.sh); \
if [ -z "$$IP" ]; then exit 1; fi; \
ssh root@$$IP

ip:
qemu/get_vm_ip.sh

docker-docs:
cd docker && docker-compose build docs-build
cd docker && UID=$(shell id -u) GID=$(shell id -g) docker-compose run docs-build bash -c "cd /linux/tools/labs && make docs"
Expand All @@ -57,4 +77,4 @@ clean::
clean_skels:
rm -rf skels

.PHONY: skels build copy docs docker-docs docker-kernel stop-docker-kernel clean clean_skels
.PHONY: skels build copy scp ssh ip docs docker-docs docker-kernel stop-docker-kernel clean clean_skels
9 changes: 9 additions & 0 deletions tools/labs/qemu/get_vm_ip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

GUEST_IP=$(arp -n -i tap0 | tail -1 | cut -d ' ' -f 1)
while [ "$GUEST_IP" = "arp:" ]; do
sleep 1
GUEST_IP=$(arp -e -n -i tap0 | tail -1 | cut -d ' ' -f 1)
done

echo $GUEST_IP