[pve-devel] [PATCH v2 storage 06/10] iscsi plugin: support volume export

Filip Schauer f.schauer at proxmox.com
Wed Dec 18 15:05:54 CET 2024


I tested exporting a volume from an iSCSI storage.
First I installed Debian in a VM on a LUN and then exported the volume:

```
$ pvesm export tgtstorage:0.0.1.scsi-360000000000000000e00000000010001 
raw+size output
3915055104 bytes (3.9 GB, 3.6 GiB) copied, 11 s, 356 MB/s
65472+0 records in
65472+0 records out
4290772992 bytes (4.3 GB, 4.0 GiB) copied, 12.0677 s, 356 MB/s
```

Then I imported the volume into a directory storage:

```
$ pvesm import local:117/vm-117-disk-0.raw raw+size output
```

Assigned the disk to a VM and it booted up just fine.

Trying to import into an iSCSI storage fails as expected:

```
$ pvesm import tgtstorage raw+size output
cannot import into volume 'tgtstorage'
```

Tested-by: Filip Schauer <f.schauer at proxmox.com>


On 17/12/2024 16:48, Fiona Ebner wrote:
> Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
>
> New in v2.
>
>   src/PVE/Storage/ISCSIPlugin.pm | 48 ++++++++++++++++++++++++++++++++++
>   1 file changed, 48 insertions(+)
>
> diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm
> index 6de7610..eb70453 100644
> --- a/src/PVE/Storage/ISCSIPlugin.pm
> +++ b/src/PVE/Storage/ISCSIPlugin.pm
> @@ -596,5 +596,53 @@ sub volume_has_feature {
>       return undef;
>   }
>   
> +sub volume_export_formats {
> +    my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_;
> +
> +    return () if defined($snapshot); # not supported
> +    return () if defined($base_snapshot); # not supported
> +    return () if $with_snapshots; # not supported
> +    return ('raw+size');
> +}
> +
> +sub volume_export {
> +    my (
> +	$class,
> +	$scfg,
> +	$storeid,
> +	$fh,
> +	$volname,
> +	$format,
> +	$snapshot,
> +	$base_snapshot,
> +	$with_snapshots,
> +    ) = @_;
> +
> +    die "volume export format $format not available for $class\n" if $format ne 'raw+size';
> +    die "cannot export volumes together with their snapshots in $class\n" if $with_snapshots;
> +    die "cannot export an incremental stream in $class\n" if defined($base_snapshot);
> +    die "cannot export a snapshot in $class\n" if defined($snapshot);
> +
> +    my $file = $class->filesystem_path($scfg, $volname, $snapshot);
> +    my $size;
> +    run_command(['/sbin/blockdev', '--getsize64', $file], outfunc => sub {
> +	my ($line) = @_;
> +	die "unexpected output from /sbin/blockdev: $line\n" if $line !~ /^(\d+)$/;
> +	$size = int($1);
> +    });
> +    PVE::Storage::Plugin::write_common_header($fh, $size);
> +    run_command(['dd', "if=$file", "bs=64k", "status=progress"], output => '>&'.fileno($fh));
> +    return;
> +}
> +
> +sub volume_import_formats {
> +    my ($class, $scfg, $storeid, $volname, $snapshot, $base_snapshot, $with_snapshots) = @_;
> +
> +    return ();
> +}
> +
> +sub volume_import {
> +    die "volume import is not possible on iscsi storage\n";
> +}
>   
>   1;




More information about the pve-devel mailing list