From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45431179AF for ; Tue, 2 Jan 2024 22:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UgTWd5MW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704234307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=36PJfL15CR3X2jt5wcxpt6IxoBzkYcgOKQ9j/gK9QDc=; b=UgTWd5MW9qt6QAgBmFl3xwu6ZVoKgxS0ugCcUznemw1ex5FpoCS6wJsvvMnIM5y/HJpEkR 6+gyrgFTMMeW4os8iQe1Z7cI4GiJUGkV0HtQcGb7eK77ncoub7noBGdgSh4qid6H8mrcdC AD+By5/byptUdM8PQZ5i5CjuNe921S0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-WZ6XTkcgO7-hbnl6FRWBOQ-1; Tue, 02 Jan 2024 17:25:05 -0500 X-MC-Unique: WZ6XTkcgO7-hbnl6FRWBOQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76810848A65 for ; Tue, 2 Jan 2024 22:25:05 +0000 (UTC) Received: from aion.redhat.com (unknown [10.22.32.219]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67BB640C6EB9 for ; Tue, 2 Jan 2024 22:25:05 +0000 (UTC) Received: from aion.redhat.com (localhost [IPv6:::1]) by aion.redhat.com (Postfix) with ESMTP id 0A8F21142D1 for ; Tue, 2 Jan 2024 17:25:05 -0500 (EST) From: Scott Mayhew To: kdevops@lists.linux.dev Subject: [PATCH] guestfs: Don't force the bringup to abort if a domain already exists Date: Tue, 2 Jan 2024 17:25:05 -0500 Message-ID: <20240102222505.34645-1-smayhew@redhat.com> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true The guestfs bringup script checks to see if a domain already exists, and aborts if it does. Vagrant would just bring up the existing domain. Add a config option to do that with guestfs (the default is still to abort, though). Signed-off-by: Scott Mayhew --- kconfigs/Kconfig.bringup | 7 +++++++ scripts/bringup_guestfs.sh | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/kconfigs/Kconfig.bringup b/kconfigs/Kconfig.bringup index 95991cc5..8e096736 100644 --- a/kconfigs/Kconfig.bringup +++ b/kconfigs/Kconfig.bringup @@ -66,6 +66,13 @@ config VIRT_BUILDER_OS_VERSION build a root image for the guest. Run "virt-builder -l" to get a list of operating systems and versions supported by guestfs. +config GUESTFS_ABORT_DUP + bool "Abort bringup if domain already defined" + default y + help + This option will abort the bringup process if the domain is + already defined. If set to "n", the bringup process try to + start the existing domain instead of aborting. endif # GUESTFS config LIBVIRT diff --git a/scripts/bringup_guestfs.sh b/scripts/bringup_guestfs.sh index e51a5b47..406a9d5e 100755 --- a/scripts/bringup_guestfs.sh +++ b/scripts/bringup_guestfs.sh @@ -22,6 +22,7 @@ BASE_IMAGE_DIR="${STORAGEDIR}/base_images" BASE_IMAGE="${BASE_IMAGE_DIR}/${OS_VERSION}.raw" mkdir -p $STORAGEDIR mkdir -p $BASE_IMAGE_DIR +ABORT_DUP=${CONFIG_GUESTFS_ABORT_DUP} cmdfile=$(mktemp) @@ -58,8 +59,14 @@ do # virsh domstate $name 1>/dev/null 2>&1 if [ $? -eq 0 ]; then - echo "Domain $name is already defined. Aborting!" - exit 1 + if [ "$ABORT_DUP" = "y" ]; then + echo "Domain $name is already defined. Aborting!" + exit 1 + else + echo "Domain $name is already defined." + virsh start $name + exit 0 + fi fi SSH_KEY_DIR="${GUESTFSDIR}/$name/ssh" -- 2.41.0