diff --git a/man/virt-clone.pod b/man/virt-clone.pod index 0cd79a42c..a4c518d12 100644 --- a/man/virt-clone.pod +++ b/man/virt-clone.pod @@ -100,6 +100,13 @@ Force cloning the passed disk target ('hdc', 'sda', etc.). By default, C will skip certain disks, such as those marked 'readonly' or 'shareable'. +=item B<--skip-copy> TARGET + +Skip cloning the passed disk target ('hdc', 'sda', etc.). By default, +C will clone certain disk images, typically read/write +devices. Use this to skip copying of a specific device, so the new +VM uses the same storage path as the original VM. + =item B<--nonsparse> Fully allocate the new storage if the path being cloned is a sparse file. diff --git a/tests/clitest.py b/tests/clitest.py index d77eacf8a..6b61e357e 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -1273,6 +1273,7 @@ c.add_valid("-o test --auto-clone") # Auto flag, no storage c.add_valid("-o test --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s") # Nodisk, but with spurious files passed c.add_valid("-o test --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --prompt") # Working scenario w/ prompt shouldn't ask anything c.add_valid("--original-xml " + _CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s") # XML File with 2 disks +c.add_valid("--original-xml " + _CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --skip-copy=hda") # XML w/ disks, skipping one disk target c.add_valid("--original-xml " + _CLONE_UNMANAGED + " --file virt-install --file %(EXISTIMG1)s --preserve") # XML w/ disks, overwriting existing files with --preserve c.add_valid("--original-xml " + _CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --file %(NEWCLONEIMG3)s --force-copy=hdc") # XML w/ disks, force copy a readonly target c.add_valid("--original-xml " + _CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --force-copy=fda") # XML w/ disks, force copy a target with no media diff --git a/virt-clone b/virt-clone index 14fba2c90..096f651fa 100755 --- a/virt-clone +++ b/virt-clone @@ -113,6 +113,10 @@ def parse_args(): stog.add_argument("--force-copy", dest="target", action="append", help=_("Force to copy devices (eg, if 'hdc' is a " "readonly cdrom device, --force-copy=hdc)")) + stog.add_argument("--skip-copy", action="append", + help=_("Skip copy of the device target. (eg, if 'vda' is a " + "disk you don't want to copy and use the same path " + "in the new VM, use --skip-copy=vda)")) stog.add_argument("--nonsparse", action="store_false", dest="sparse", default=True, help=_("Do not use a sparse file for the clone's " @@ -176,6 +180,8 @@ def main(conn=None): design.reflink = True for i in options.target or []: design.force_target = i + for i in options.skip_copy or []: + design.skip_target = i design.clone_sparse = options.sparse design.preserve = options.preserve