Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit ac1ceb1

Browse files
committed
Skip virt-clone file existence check if --preserve-data (Tomas Hoger)
1 parent 1fa99d9 commit ac1ceb1

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Patches also received from
3535
Alan Pevec <apevec-at-redhat-dot-com>
3636
Andreas Schneider <anschneider-at-suse-dot-de>
3737
Michael Marineau <marineam-at-gentoo-dot-org>
38+
Tomas Hoger <thoger-at-redhat-dot-com>
3839

3940
...send patches and get your name here...
4041

virt-clone

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_clone_uuid(new_uuid, design):
7171
if new_uuid is not None:
7272
design.set_clone_uuid(new_uuid)
7373

74-
def get_clone_diskfile(new_diskfiles, design, conn):
74+
def get_clone_diskfile(new_diskfiles, design, conn, preserve=False):
7575
if new_diskfiles is None:
7676
new_diskfiles = [None]
7777

@@ -88,7 +88,8 @@ def get_clone_diskfile(new_diskfiles, design, conn):
8888
disk = None
8989
continue
9090

91-
if os.path.exists(d.path):
91+
# Prompt if disk file already exists and preserve mode is not used
92+
if not preserve and os.path.exists(d.path):
9293
warnmsg = _("This will overwrite the existing path "
9394
"'%s'!\n") % d.path
9495
if not cli.prompt_for_yes_or_no(warnmsg + _("Do you really want to use this disk (yes or no)?")):
@@ -201,7 +202,7 @@ def main():
201202
design = clmgr.CloneDesign(connection=conn)
202203

203204
try:
204-
get_clone_diskfile(options.new_diskfile, design, conn)
205+
get_clone_diskfile(options.new_diskfile, design, conn, not options.preserve)
205206
get_clone_macaddr(options.new_mac, design)
206207
get_original_guest(options.original_guest, design)
207208
get_clone_name(options.new_name, design)

0 commit comments

Comments
 (0)