diff --git a/client-cli/pvc/cli/cli.py b/client-cli/pvc/cli/cli.py index f36435b3..45efb7c2 100644 --- a/client-cli/pvc/cli/cli.py +++ b/client-cli/pvc/cli/cli.py @@ -1970,7 +1970,7 @@ def cli_vm_snapshot_import( The import will include the VM configuration, metainfo, and the point-in-time snapshot of all attached RBD volumes. Incremental imports will be automatically handled. - A VM named DOMAIN or with the same UUID must not exist; if a VM with the same name or UUID already exists, it must be removed, or renamed and then undefined (to preserve volumes), before importing. + A VM named DOMAIN or with the same UUID must not exist; if a VM with the same name or UUID already exists, it must be removed (or renamed and then undefined, to preserve volumes while freeing the UUID) before importing. If the "-r"/"--retain-snapshot" option is specified (the default), for incremental imports, only the parent snapshot is kept; for full imports, the imported snapshot is kept. If the "-R"/"--remove-snapshot" option is specified, the imported snapshot is removed. @@ -2082,7 +2082,7 @@ def cli_vm_backup_restore(domain, backup_datestring, backup_path, retain_snapsho The restore will import the VM configuration, metainfo, and the point-in-time snapshot of all attached RBD volumes. Incremental backups will be automatically handled. - A VM named DOMAIN or with the same UUID must not exist; if a VM with the same name or UUID already exists, it must be removed, or renamed and then undefined (to preserve volumes), before restoring. + A VM named DOMAIN or with the same UUID must not exist; if a VM with the same name or UUID already exists, it must be removed (or renamed and then undefined, to preserve volumes while freeing the UUID) before importing. If the "-r"/"--retain-snapshot" option is specified (the default), for incremental restores, only the parent snapshot is kept; for full restores, the restored snapshot is kept. If the "-R"/"--remove-snapshot" option is specified, the imported snapshot is removed. diff --git a/daemon-common/vm.py b/daemon-common/vm.py index fbf24546..5127b23d 100644 --- a/daemon-common/vm.py +++ b/daemon-common/vm.py @@ -2627,7 +2627,7 @@ def vm_worker_import_snapshot( if dom_uuid: fail( celery, - f'VM "{domain}" already exists in the cluster; remove or rename it before importing a snapshot', + f"VM '{domain}' (UUID '{dom_uuid}') already exists in the cluster; remove it before importing a snapshot", ) return @@ -2672,6 +2672,15 @@ def vm_worker_import_snapshot( ) return + # Check that another VM with the same UUID doesn't already exist (rename is not enough!) + dom_name = getDomainName(zkhandler, export_source_details["vm_detail"]["uuid"]) + if dom_name: + fail( + celery, + f"VM UUID '{export_source_details['vm_detail']['uuid']}' (Name '{dom_name}') already exists in the cluster; remove it before importing a snapshot", + ) + return + # Handle incrementals incremental_parent = export_source_details.get("incremental_parent", None) if incremental_parent is not None: