From 2a004f0081e15163155762fe2ce5b845daca29a0 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Mon, 21 Jul 2014 16:43:48 -0700 Subject: [PATCH] qemu: set DHCP hostname based on image name and version Provides an easy way to test this setting hostname from DHCP, most other systems rely on it. --- build_library/qemu_template.sh | 2 +- build_library/vm_image_util.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build_library/qemu_template.sh b/build_library/qemu_template.sh index 6f1108b33f..a4c107e366 100755 --- a/build_library/qemu_template.sh +++ b/build_library/qemu_template.sh @@ -175,6 +175,6 @@ qemu-system-x86_64 \ -m ${VM_MEMORY} \ -machine accel=kvm:tcg \ -net nic,vlan=0,model=virtio \ - -net user,vlan=0,hostfwd=tcp::"${SSH_PORT}"-:22 \ + -net user,vlan=0,hostfwd=tcp::"${SSH_PORT}"-:22,hostname="${VM_NAME}" \ "$@" exit $? diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 9e17fc3574..6fb3378921 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -196,6 +196,10 @@ set_vm_paths() { VM_TMP_ROOT="${VM_TMP_DIR}/rootfs" VM_NAME="$(_src_to_dst_name "${src_name}" "")-${COREOS_VERSION_STRING}" VM_README="${dst_dir}/$(_src_to_dst_name "${src_name}" ".README")" + + # Make VM_NAME safe for use as a hostname + VM_NAME="${VM_NAME//./-}" + VM_NAME="${VM_NAME//+/-}" } _get_vm_opt() {