On 3/10/18 12:49 PM, Gandalf Corvotempesta wrote: > Il 10/03/2018 10:28, Thomas Lamprecht ha scritto: >> It's in the qemu-server git repository, the importdisk >> command is in the qm CLI helper (PVE/CLI/qm.pm) and >> uses mostly the PVE::QemuServer::ImportDisk module >> (PVE/QemuServer/ImportDisk.pm) >> >> gitweb link to them: >> https://git.proxmox.com/?p=qemu-server.git;a=blob;f=PVE/CLI/qm.pm;h=3347612556bc3689abd783540bb9ea2d1cffeaba;hb=HEAD#l418 >> https://git.proxmox.com/?p=qemu-server.git;a=blob;f=PVE/QemuServer/ImportDisk.pm;h=db7db6343c4c0af67a094b695d0c9e329ff80ab8;hb=HEAD#l1 > > Thanks > >> If you want to skip import phase, which is, AFAIK, pretty >> much 90% this command does, maybe just write a simple CLI >> command your self doing the data import with your scripts >> and then just add the disk to the config with and helper of >> ours, just as an idea... > > It's what I'm trying to do. > As I'm outputting a raw image from XenServer, probably, I can > directly write the raw image to a zfs block volume, right ?
Yes, using the PVE stack you would do something like: my $storecfg = PVE::Storage::config(); # storage_id == the ID of the destination storage, e.g. you ZFS pool. $dst_format is 'raw' but could be also qcow2, etc. # $src_size is the size of the zo import disk (transformed to KB here) my $destination_volid = PVE::Storage::vdisk_alloc($storecfg, $storage_id, $vmid, $dst_format, undef, $src_size / 1024); # get destination path my $dst_path = PVE::Storage::path($storecfg, $dst_volid); PVE::Storage::activate_volumes($storecfg, [$dst_volid]) # Then write to it, your case DD or also qemu-img convert # dd ... PVE::Storage::deactivate_volumes($storecfg, [$dst_volid]); # add disk to vm PVE::QemuConfig->lock_config($vmid, sub { PVE::QemuConfig->add_unused_volume($vm_conf, $dst_volid); PVE::QemuConfig->write_config($vmid, $vm_conf); }); # done But, looking at the importdisk code adding an additional case where source equals '-' with a then needed source_size parameter wouldn't be too hard, and would do exactly what you need in a general way and probably useful for a few others. Basically you then could do: ./import-from-xen.sh | qm importdisk 102 - zfsstore --source_size $[512*1024] If you need this then it would be really great if you could contribute it to our whole great community :) (my backlog on work is just to big to add this on tmy TODO at the moment, sorry) cheers, Thomas _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel