kdevops.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Scott Mayhew <smayhew@redhat.com>, kdevops@lists.linux.dev
Subject: Re: [PATCH] guestfs: Don't force the bringup to abort if a domain already exists
Date: Wed, 03 Jan 2024 07:09:46 -0500	[thread overview]
Message-ID: <cc1af8916caffe44ef781a0f754e37ec4e40e12f.camel@kernel.org> (raw)
In-Reply-To: <20240102222505.34645-1-smayhew@redhat.com>

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>

      reply	other threads:[~2024-01-03 12:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc1af8916caffe44ef781a0f754e37ec4e40e12f.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=kdevops@lists.linux.dev \
    --cc=smayhew@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).