From e130d95518bd1be7a1c24438bec60643119e5754 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 17 Jun 2017 17:06:29 +0200 Subject: vm/gce: accept un-tar-ed image vm/gce differs from other VM types in that it accepts image in a weird, GCE-specific format (namely, image named disk.raw is put into .tar.gz file). This makes it impossible to write generic code that creates images for any VM types. Make vm/gce accept just image like e.g. vm/qemu and handle own specifics internally. --- tools/create-gce-image.sh | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'tools/create-gce-image.sh') diff --git a/tools/create-gce-image.sh b/tools/create-gce-image.sh index 29ed2cb0d..3329fcfe0 100755 --- a/tools/create-gce-image.sh +++ b/tools/create-gce-image.sh @@ -15,34 +15,35 @@ # note: kernel modules are not supported # # Usage: -# ./create-gce-image.sh /dir/with/user/space/system /path/to/bzImage /path/to/vmlinux 'image tag' +# ./create-gce-image.sh /dir/with/user/space/system /path/to/bzImage # -# The image can then be uploaded to GCS with: -# gsutil cp disk.tar.gz gs://my-images -# and then my-images/disk.tar.gz can be used to create new GCE bootable image. -# image.tar.gz can be used with syz-gce. +# Outputs are (in the current dir): +# - disk.raw: the image +# - key: root ssh key +# The script can also create/delete temp files in the current dir. +# +# The image then needs to be compressed with: +# tar -Sczf disk.tar.gz disk.raw +# and uploaded to GCS with: +# gsutil cp disk.tar.gz gs://my-images/image.tar.gz +# finally, my-images/image.tar.gz can be used to create a new GCE image. # # The image can be tested locally with e.g.: -# qemu-system-x86_64 -hda disk.raw -net user,host=10.0.2.10,hostfwd=tcp::10022-:22 -net nic -enable-kvm -m 2G -display none -serial stdio +# qemu-system-x86_64 -hda disk.raw -net user,host=10.0.2.10,hostfwd=tcp::10022-:22 \ +# -net nic -enable-kvm -m 2G -display none -serial stdio # once the kernel boots, you can ssh into it with: -# ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -p 10022 -i key root@localhost -# -# Note: the script creates and deletes some failes in cwd. +# ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentitiesOnly=yes \ +# -p 10022 -i key root@localhost set -eux if [ ! -e $1/sbin/init ]; then - echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage /path/to/vmlinux 'image tag'" + echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage" exit 1 fi if [ "$(basename $2)" != "bzImage" ]; then - echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage /path/to/vmlinux 'image tag'" - exit 1 -fi - -if [ "$(basename $3)" != "vmlinux" ]; then - echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage /path/to/vmlinux 'image tag'" + echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage" exit 1 fi @@ -104,9 +105,3 @@ sudo grub-install --boot-directory=disk.mnt/boot --no-floppy /dev/nbd0 sudo umount disk.mnt rm -rf disk.mnt sudo qemu-nbd -d /dev/nbd0 -tar -Sczf disk.tar.gz disk.raw -mkdir -p obj -cp $3 obj/ -echo -n "$4" > tag -tar -czf image.tar.gz disk.tar.gz key tag obj/vmlinux -rm -rf tag obj -- cgit mrf-deployment