* [PATCH] guestfs: Don't force the bringup to abort if a domain already exists
@ 2024-01-02 22:25 Scott Mayhew
2024-01-03 12:09 ` Jeff Layton
0 siblings, 1 reply; 2+ messages in thread
From: Scott Mayhew @ 2024-01-02 22:25 UTC (permalink / raw)
To: kdevops
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 <smayhew@redhat.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] guestfs: Don't force the bringup to abort if a domain already exists
2024-01-02 22:25 [PATCH] guestfs: Don't force the bringup to abort if a domain already exists Scott Mayhew
@ 2024-01-03 12:09 ` Jeff Layton
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2024-01-03 12:09 UTC (permalink / raw)
To: Scott Mayhew, kdevops
On Tue, 2024-01-02 at 17:25 -0500, Scott Mayhew wrote:
> 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).
>
If the old behavior was to just bring up the domain, then we should
probably just follow suit here. Maybe drop the config option and just
change this to work like Vagrant does?
> Signed-off-by: Scott Mayhew <smayhew@redhat.com>
> ---
> 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"
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-03 12:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-02 22:25 [PATCH] guestfs: Don't force the bringup to abort if a domain already exists Scott Mayhew
2024-01-03 12:09 ` Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox