]> git.proxmox.com Git - qemu-server.git/commitdiff
move map_storage to PVE::JSONSchema::map_id
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 9 Feb 2022 13:07:37 +0000 (14:07 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 9 Feb 2022 17:46:20 +0000 (18:46 +0100)
since we are going to reuse the same mechanism/code for network bridge
mapping and pve-container.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/QemuMigrate.pm
PVE/QemuServer.pm

index c9bc39d2ce25331235079d387814ac0bef05783b..a00c2459e8108ae32a88d903991b36dc017a42f9 100644 (file)
@@ -342,7 +342,7 @@ sub prepare {
        my $targetsid = $sid;
        # NOTE: we currently ignore shared source storages in mappings so skip here too for now
        if (!$scfg->{shared}) {
-           $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $sid);
+           $targetsid = PVE::JSONSchema::map_id($self->{opts}->{storagemap}, $sid);
        }
 
        my $target_scfg = PVE::Storage::storage_check_enabled($storecfg, $targetsid, $self->{node});
@@ -408,7 +408,7 @@ sub scan_local_volumes {
 
            next if @{$dl->{$storeid}} == 0;
 
-           my $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $storeid);
+           my $targetsid = PVE::JSONSchema::map_id($self->{opts}->{storagemap}, $storeid);
            # check if storage is available on target node
            my $target_scfg = PVE::Storage::storage_check_enabled(
                $storecfg,
@@ -479,7 +479,7 @@ sub scan_local_volumes {
            my $targetsid = $sid;
            # NOTE: we currently ignore shared source storages in mappings so skip here too for now
            if (!$scfg->{shared}) {
-               $targetsid = PVE::QemuServer::map_storage($self->{opts}->{storagemap}, $sid);
+               $targetsid = PVE::JSONSchema::map_id($self->{opts}->{storagemap}, $sid);
            }
 
            PVE::Storage::storage_check_enabled($storecfg, $targetsid, $self->{node});
index 8aa19469303ee0e6951d646239d0031b0bab35cc..8c1aa30a0c5794ea9c0ece34ecd34ad989321bb5 100644 (file)
@@ -119,21 +119,6 @@ PVE::JSONSchema::register_standard_option('pve-qemu-machine', {
        optional => 1,
 });
 
-
-sub map_storage {
-    my ($map, $source) = @_;
-
-    return $source if !defined($map);
-
-    return $map->{entries}->{$source}
-       if $map->{entries} && defined($map->{entries}->{$source});
-
-    return $map->{default} if $map->{default};
-
-    # identity (fallback)
-    return $source;
-}
-
 PVE::JSONSchema::register_standard_option('pve-targetstorage', {
     description => "Mapping from source to target storages. Providing only a single storage ID maps all source storages to that storage. Providing the special value '1' will map each source storage to itself.",
     type => 'string',
@@ -5279,7 +5264,7 @@ sub vm_migrate_alloc_nbd_disks {
        # volume is not available there, fall back to the default format.
        # Otherwise use the same format as the original.
        if (!$storagemap->{identity}) {
-           $storeid = map_storage($storagemap, $storeid);
+           $storeid = PVE::JSONSchema::map_id($storagemap, $storeid);
            my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid);
            my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
            my $fileFormat = qemu_img_format($scfg, $volname);