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.
This commit is contained in:
Michael Marineau 2014-07-21 16:43:48 -07:00
parent 946797f5d9
commit 2a004f0081
2 changed files with 5 additions and 1 deletions

View File

@ -175,6 +175,6 @@ qemu-system-x86_64 \
-m ${VM_MEMORY} \ -m ${VM_MEMORY} \
-machine accel=kvm:tcg \ -machine accel=kvm:tcg \
-net nic,vlan=0,model=virtio \ -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 $? exit $?

View File

@ -196,6 +196,10 @@ set_vm_paths() {
VM_TMP_ROOT="${VM_TMP_DIR}/rootfs" VM_TMP_ROOT="${VM_TMP_DIR}/rootfs"
VM_NAME="$(_src_to_dst_name "${src_name}" "")-${COREOS_VERSION_STRING}" VM_NAME="$(_src_to_dst_name "${src_name}" "")-${COREOS_VERSION_STRING}"
VM_README="${dst_dir}/$(_src_to_dst_name "${src_name}" ".README")" 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() { _get_vm_opt() {