pve 为虚拟机打快照的部分,暂时略过一系列错误判断逻辑,最终会调用 qemu-img 实现核心功能,相关源码如下:

sub volume_snapshot {
    my ($class, $scfg, $storeid, $volname, $snap) = @_;

    die "can't snapshot this image format\\n" if $volname !~ m/\\.(qcow2|qed)$/;

    my $path = $class->filesystem_path($scfg, $volname);

    my $cmd = ['/usr/bin/qemu-img', 'snapshot','-c', $snap, $path];

    run_command($cmd);

    return undef;
}