]> git.proxmox.com Git - qemu-server.git/commitdiff
fix #1569: add shared flag to disks
authorChris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Thu, 15 Feb 2018 13:22:24 +0000 (14:22 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 15 Feb 2018 14:19:29 +0000 (15:19 +0100)
With shared=1, (live) migration ignores the disk and assumes it is
present on all target nodes. This works similar to shared=1 on LXC
mountpoints.

Signed-off-by: Chris Hofstaedtler <chris.hofstaedtler@deduktiva.com>
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/QemuMigrate.pm
PVE/QemuServer.pm

index 937a85529049b4073227fe6f1c6fa796f0f4a21c..cf1edefbd26d5806ea2962936a2d2af26f041934 100644 (file)
@@ -318,6 +318,7 @@ sub sync_disks {
            my ($volid, $attr) = @_;
 
            if ($volid =~ m|^/|) {
+               return if $attr->{shared};
                $local_volumes->{$volid}->{ref} = 'config';
                die "local file/device\n";
            }
index 20d668274677794e91ff27e41235955a037d4b4d..ffbb436951b24dfc0a211c2438668361861094a4 100644 (file)
@@ -819,6 +819,13 @@ my %drivedesc_base = (
        maxLength => 20*3, # *3 since it's %xx url enoded
        description => "The drive's reported serial number, url-encoded, up to 20 bytes long.",
        optional => 1,
+    },
+    shared => {
+       type => 'boolean',
+       description => 'Mark this locally-managed volume as available on all nodes',
+       verbose_description => "Mark this locally-managed volume as available on all nodes.\n\nWARNING: This option does not share the volume automatically, it assumes it is shared already!",
+       optional => 1,
+       default => 0,
     }
 );
 
@@ -2837,7 +2844,7 @@ sub foreach_volid {
     my $volhash = {};
 
     my $test_volid = sub {
-       my ($volid, $is_cdrom, $replicate, $snapname) = @_;
+       my ($volid, $is_cdrom, $replicate, $shared, $snapname) = @_;
 
        return if !$volid;
 
@@ -2847,6 +2854,9 @@ sub foreach_volid {
        $volhash->{$volid}->{replicate} //= 0;
        $volhash->{$volid}->{replicate} = 1 if $replicate;
 
+       $volhash->{$volid}->{shared} //= 0;
+       $volhash->{$volid}->{shared} = 1 if $shared;
+
        $volhash->{$volid}->{referenced_in_config} //= 0;
        $volhash->{$volid}->{referenced_in_config} = 1 if !defined($snapname);
 
@@ -2856,7 +2866,7 @@ sub foreach_volid {
 
     foreach_drive($conf, sub {
        my ($ds, $drive) = @_;
-       $test_volid->($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1, undef);
+       $test_volid->($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1, $drive->{shared}, undef);
     });
 
     foreach my $snapname (keys %{$conf->{snapshots}}) {
@@ -2864,7 +2874,7 @@ sub foreach_volid {
        $test_volid->($snap->{vmstate}, 0, 1, $snapname);
        foreach_drive($snap, sub {
            my ($ds, $drive) = @_;
-           $test_volid->($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1, $snapname);
+           $test_volid->($drive->{file}, drive_is_cdrom($drive), $drive->{replicate} // 1, $drive->{shared}, $snapname);
         });
     }