[pve-devel] [PATCH qemu-server 01/13] blockdev: cmdline: add blockdev syntax support
Fiona Ebner
f.ebner at proxmox.com
Wed Jun 11 09:24:09 CEST 2025
Am 11.06.25 um 08:37 schrieb DERUMIER, Alexandre:
>>> Also, while the use case here shouldn't be cryptographically
>>> sensitive,
>>> you never know, so I'll just use a different hash function than sha1.
>>> I'll cut off the result from that hash to 30 hex digits. Then we
>>> still
>>> have one letter for the prefix of the node name.
>
> so, maybe something like :
>
> $digest = substr(sha256_hex("${volname}+${snap}"),0,30);
>
> ?
>
>
> I still unsure how to handle same volume multiple time (if we really
> want it). I was thinking to use the deviceid in the name (virtio0,..),
> but it don't work when you unplug/replug to a deviceid.
Why wouldn't it work?
> Maybe some kind of slot number like fabian have suggested, but I think
> it'll need some kind of lookup.
>
> or maybe, if we want same volume multiple volume, we just keep
> autogenerated qemu blockdev for this specific case, as anyway, we can't
> do snapshot, unplug, or other dynamic features.
My proposal is:
my sub get_node_name {
my ($type, $drive_id, $volid, $snap) = @_;
my $info = "drive=$drive_id,";
$info .= "snap=$snap," if defined($snap);
$info .= "volid=$volid";
my $encoded = substr(Digest::SHA::sha256_hex($info), 0, 30);
my $prefix = "";
if ($type eq 'fmt') {
$prefix = 'f';
} elsif ($type eq 'file') {
$prefix = 'e';
} else {
die "unknown node type '$type'";
}
# node-name must start with an alphabetical character
return "${prefix}${encoded}";
}
More information about the pve-devel
mailing list