From 01bb02ed48c16c0e147de03ef56ec5a860639933 Mon Sep 17 00:00:00 2001 From: Zev Weiss Date: Sat, 18 Nov 2023 16:29:05 -0800 Subject: [PATCH 1/2] virtme-init: Add guest hostname to /etc/hosts The update of the virtme_ng_init submodule pulls in a larger batch of changes; while most of them are non-behavioral code cleanups, also included is commit a1eb25c6e180 ("Add guest hostname to /etc/hosts"), which makes the corresponding change to this one so that the two inits remain behaviorally in sync with each other. Signed-off-by: Zev Weiss --- virtme/guest/virtme-init | 6 ++++++ virtme_ng_init | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/virtme/guest/virtme-init b/virtme/guest/virtme-init index 57a4690..dd90e64 100755 --- a/virtme/guest/virtme-init +++ b/virtme/guest/virtme-init @@ -68,6 +68,12 @@ fi touch /tmp/fstab mount --bind /tmp/fstab /etc/fstab +if [[ -n "$virtme_hostname" ]]; then + cp /etc/hosts /tmp/hosts + printf '\n127.0.0.1 %s\n::1 %s\n' "$virtme_hostname" "$virtme_hostname" >> /tmp/hosts + mount --bind /tmp/hosts /etc/hosts +fi + # Fix dpkg if we are on a Debian-based distro if [ -d /var/lib/dpkg ]; then lock_files=(/var/lib/dpkg/lock /var/lib/dpkg/lock-frontend /var/lib/dpkg/triggers/Lock) diff --git a/virtme_ng_init b/virtme_ng_init index f20306d..dcefa64 160000 --- a/virtme_ng_init +++ b/virtme_ng_init @@ -1 +1 @@ -Subproject commit f20306df2a97a83683db94e8427a6e0d4b6b6ddc +Subproject commit dcefa64504ce41f6da8d9d5ef31bb8d10a6ecf89 From 81e8d82ce10981bdadc5651ce2db8d8d47f05044 Mon Sep 17 00:00:00 2001 From: Zev Weiss Date: Fri, 17 Nov 2023 15:23:27 -0800 Subject: [PATCH 2/2] virtme-ng: Set a default for --name This is basically just to help make it easier to distinguish a shell prompt within the guest from one on the host (as long as your prompt incorporates the hostname). Signed-off-by: Zev Weiss --- virtme_ng/run.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/virtme_ng/run.py b/virtme_ng/run.py index 19bbd7f..7b897c5 100644 --- a/virtme_ng/run.py +++ b/virtme_ng/run.py @@ -205,7 +205,10 @@ def make_parser(): parser.add_argument("--qemu", action="store", help="Use the specified QEMU binary") parser.add_argument( - "--name", action="store", help="Set guest hostname and qemu -name flag" + "--name", + action="store", + default="virtme-ng", + help="Set guest hostname and qemu -name flag" ) parser.add_argument(