Re: [pve-devel] [PATCH 1/5] add qemu_img_convert
Also, if name is not provided, maybe can we add a default name : Copy of.$orignalname ? To avoid duplicate name ? Yes. will do that. ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH 1/5] add qemu_img_convert
My plan was to get this basic functionality stable so that we can include this with 3.0? Yes, I think it could be a start, we can add features step by step. Yes (will try to do that asap). When do you plan to release 3.0 ? AFAIK Debian Wheeze is planned this weekend. We want RC1 shortly after that. ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH 1/5] add qemu_img_convert
I think it could be great to add a name parameter yes, and a 'description' For full clone, we should add a target storage and output format options. (I think that only 1 target storage/output format for all disks is enough) OK for me. ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH 1/5] add qemu_img_convert
I think it could be great to add a name parameter yes, and a 'description' Also, if name is not provided, maybe can we add a default name : Copy of.$orignalname ? To avoid duplicate name ? - Mail original - De: Dietmar Maurer diet...@proxmox.com À: Alexandre DERUMIER aderum...@odiso.com Cc: pve-devel@pve.proxmox.com Envoyé: Mardi 30 Avril 2013 07:03:21 Objet: RE: [pve-devel] [PATCH 1/5] add qemu_img_convert I think it could be great to add a name parameter yes, and a 'description' For full clone, we should add a target storage and output format options. (I think that only 1 target storage/output format for all disks is enough) OK for me. ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH 1/5] add qemu_img_convert
I'll resend an improved version monday - Mail original - De: Alexandre DERUMIER aderum...@odiso.com À: Dietmar Maurer diet...@proxmox.com Cc: pve-devel@pve.proxmox.com Envoyé: Vendredi 26 Avril 2013 13:59:42 Objet: Re: [pve-devel] [PATCH 1/5] add qemu_img_convert Why do you suppress messages to stderr, No reason, I think we can remove errfunc= sub {} and why do we need a $parser here? I' don't remember exactly, but I think that without outfunc, run_command display the full output result when finished, and not progressivly. also , currently it's only display the raw output of progression % , but maybe can we improve the display (total bytes transferred , remaining bytes) - Mail original - De: Dietmar Maurer diet...@proxmox.com À: Alexandre Derumier aderum...@odiso.com, pve-devel@pve.proxmox.com Envoyé: Vendredi 26 Avril 2013 13:36:44 Objet: RE: [pve-devel] [PATCH 1/5] add qemu_img_convert + my $parser = sub { + my $line = shift; + print $line.\n; + }; + + eval { run_command($cmd, timeout = undef, errfunc = sub {}, outfunc = $parser); }; Why do you suppress messages to stderr, and why do we need a $parser here? ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH 1/5] add qemu_img_convert
+ my $parser = sub { + my $line = shift; + print $line.\n; + }; + + eval { run_command($cmd, timeout = undef, errfunc = sub {}, outfunc = $parser); }; Why do you suppress messages to stderr, and why do we need a $parser here? ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH 1/5] add qemu_img_convert
Why do you suppress messages to stderr, No reason, I think we can remove errfunc= sub {} and why do we need a $parser here? I' don't remember exactly, but I think that without outfunc, run_command display the full output result when finished, and not progressivly. also , currently it's only display the raw output of progression % , but maybe can we improve the display (total bytes transferred , remaining bytes) - Mail original - De: Dietmar Maurer diet...@proxmox.com À: Alexandre Derumier aderum...@odiso.com, pve-devel@pve.proxmox.com Envoyé: Vendredi 26 Avril 2013 13:36:44 Objet: RE: [pve-devel] [PATCH 1/5] add qemu_img_convert + my $parser = sub { + my $line = shift; + print $line.\n; + }; + + eval { run_command($cmd, timeout = undef, errfunc = sub {}, outfunc = $parser); }; Why do you suppress messages to stderr, and why do we need a $parser here? ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
[pve-devel] [PATCH 1/5] add qemu_img_convert
also work with snapshot as source for qcow2,rbd,sheepdog. Signed-off-by: Alexandre Derumier aderum...@odiso.com --- PVE/QemuServer.pm | 54 + 1 file changed, 54 insertions(+) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 4d2710a..c7b32c3 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4465,4 +4465,58 @@ sub is_template { return 1 if defined $conf-{template} $conf-{template} == 1; } +sub qemu_img_convert { +my ($src_volid, $dst_volid, $snapname) = @_; + +my $storecfg = PVE::Storage::config(); +my ($src_storeid, $src_volname) = PVE::Storage::parse_volume_id($src_volid, 1); +my ($dst_storeid, $dst_volname) = PVE::Storage::parse_volume_id($dst_volid, 1); + +if ($src_storeid $dst_storeid) { + my $src_scfg = PVE::Storage::storage_config($storecfg, $src_storeid); + my $dst_scfg = PVE::Storage::storage_config($storecfg, $dst_storeid); + + my $src_format = qemu_img_format($src_scfg, $src_volname); + my $dst_format = qemu_img_format($dst_scfg, $dst_volname); + + my $src_path = PVE::Storage::path($storecfg, $src_volid, $snapname); + my $dst_path = PVE::Storage::path($storecfg, $dst_volid); + + my $cmd = []; + push @$cmd, '/usr/bin/qemu-img', 'convert', '-t', 'writeback', '-p', '-C'; + push @$cmd, '-s', $snapname if($snapname $src_format eq qcow2); + push @$cmd, '-f', $src_format, '-O', $dst_format, $src_path, $dst_path; + + my $parser = sub { + my $line = shift; + print $line.\n; + }; + + eval { run_command($cmd, timeout = undef, errfunc = sub {}, outfunc = $parser); }; + my $err = $@; + die copy failed: $err if $err; +} +} + +sub qemu_img_format { +my ($scfg, $volname) = @_; + +if ($scfg-{path} $volname =~ m/\.(raw|qcow2|qed|vmdk)$/){ + return $1; +} +elsif ($scfg-{type} eq 'nexenta' || $scfg-{type} eq 'iscsidirect'){ + return iscsi; +} +elsif ($scfg-{type} eq 'lvm' || $scfg-{type} eq 'iscsi'){ + return host_device; +} +elsif ($scfg-{type} eq 'rbd'){ + return raw; +} +#sheepdog,rbd,or other qemu block driver +else{ + return $scfg-{type}; +} +} + 1; -- 1.7.10.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH 1/5] add qemu_img_convert
Why is it necessary to specify source and destination format? It's more by security, from doc: fmt is the disk image format. It is guessed automatically in most cases. I don't like too much in most cases ;) OK, lets keep that code. ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
[pve-devel] [PATCH 1/5] add qemu_img_convert
also work with snapshot as source for qcow2,rbd,sheepdog. Signed-off-by: Alexandre Derumier aderum...@odiso.com --- PVE/QemuServer.pm | 51 +++ 1 file changed, 51 insertions(+) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index fb672eb..b55a68e 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4478,4 +4478,55 @@ sub is_template { return 2 if $baseimagecount $totalvolumecount; #semi-template } +sub qemu_img_convert { +my ($src_volid, $dst_volid, $snapname) = @_; + +my $storecfg = PVE::Storage::config(); +my ($src_storeid, $src_volname) = PVE::Storage::parse_volume_id($src_volid, 1); +my ($dst_storeid, $dst_volname) = PVE::Storage::parse_volume_id($dst_volid, 1); + +if ($src_storeid $dst_storeid) { + my $src_scfg = PVE::Storage::storage_config($storecfg, $src_storeid); + my $dst_scfg = PVE::Storage::storage_config($storecfg, $dst_storeid); + + my $src_format = qemu_img_format($src_scfg, $src_volname); + my $dst_format = qemu_img_format($dst_scfg, $dst_volname); + + my $src_path = PVE::Storage::path($storecfg, $src_volid, $snapname); + my $dst_path = PVE::Storage::path($storecfg, $dst_volid); + + my $cmd = []; + push @$cmd, '/usr/bin/qemu-img', 'convert', '-t', 'writeback', '-p', '-C'; + push @$cmd, '-s', $snapname if($snapname $src_format eq qcow2); + push @$cmd, '-f', $src_format, '-O', $dst_format, $src_path, $dst_path; + + my $parser = sub { + my $line = shift; + print $line.\n; + }; + + eval { run_command($cmd, timeout = undef, errfunc = sub {}, outfunc = $parser); }; + my $err = $@; + die copy failed: $err if $err; +} +} + +sub qemu_img_format { +my ($scfg, $volname) = @_; + +if ($scfg-{path} $volname =~ m/\.(raw|qcow2|qed|vmdk)$/){ + return $1; +} +elsif ($scfg-{type} eq 'nexenta' || $scfg-{type} eq 'iscsidirect'){ + return iscsi; +} +elsif ($scfg-{type} eq 'lvm' || $scfg-{type} eq 'iscsi'){ + return host_device; +} +#sheepdog,rbd,or other qemu block driver +else{ + return $scfg-{type}; +} +} + 1; -- 1.7.10.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel