[pve-devel] [PATCH v2 qemu-server] api/migration: fix autocomplete for targetstorage
Aaron Lauterer
a.lauterer at proxmox.com
Mon Nov 18 15:23:18 CET 2019
Show storages configured for the target node and not for the current one
because they can be different.
Duplicated the `complete_storage` sub and extended it to extract the
targetnode from the parameters to pass it into the storage_check_enabled
function.
Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
---
v1 -> v2: make parameters more readable @thx thomas for the hint
PVE/API2/Qemu.pm | 2 +-
PVE/QemuServer.pm | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 8e162aa..3989633 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -3299,7 +3299,7 @@ __PACKAGE__->register_method({
targetstorage => get_standard_option('pve-storage-id', {
description => "Default target storage.",
optional => 1,
- completion => \&PVE::QemuServer::complete_storage,
+ completion => \&PVE::QemuServer::complete_migration_storage,
}),
bwlimit => {
description => "Override I/O bandwidth limit (in KiB/s).",
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 54c8c88..f1d9cfd 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -7459,4 +7459,22 @@ sub complete_storage {
return $res;
}
+sub complete_migration_storage {
+ my ($cmd, $param, $current_value, $all_args) = @_;
+
+ my $targetnode = @$all_args[1];
+
+ my $cfg = PVE::Storage::config();
+ my $ids = $cfg->{ids};
+
+ my $res = [];
+ foreach my $sid (keys %$ids) {
+ next if !PVE::Storage::storage_check_enabled($cfg, $sid, $targetnode, 1);
+ next if !$ids->{$sid}->{content}->{images};
+ push @$res, $sid;
+ }
+
+ return $res;
+}
+
1;
--
2.20.1
More information about the pve-devel
mailing list