mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-29 18:45:29 +00:00
config: add fleecing section
Will be used for improved cleanup of fleecing images. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Link: https://lore.proxmox.com/20250127112923.31703-14-f.ebner@proxmox.com
This commit is contained in:
parent
6eb92d31ba
commit
a82c4555e3
@ -5955,6 +5955,9 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
my $special_sections = delete $new_conf->{'special-sections'} // {};
|
my $special_sections = delete $new_conf->{'special-sections'} // {};
|
||||||
|
|
||||||
|
# fleecing state is specific to source side
|
||||||
|
delete $special_sections->{fleecing};
|
||||||
|
|
||||||
$new_conf->{skip_cloud_init} = 1; # re-use image from source side
|
$new_conf->{skip_cloud_init} = 1; # re-use image from source side
|
||||||
|
|
||||||
# TODO PVE 10 - remove backwards-compat handling?
|
# TODO PVE 10 - remove backwards-compat handling?
|
||||||
|
@ -2195,6 +2195,16 @@ sub destroy_vm {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $fleecing_section_schema = {
|
||||||
|
'fleecing-images' => {
|
||||||
|
type => 'string',
|
||||||
|
format => 'pve-volume-id-list',
|
||||||
|
description => "For internal use only. List of fleecing images allocated during backup."
|
||||||
|
." If no backup is running, these are left-overs that failed to be removed.",
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
sub parse_vm_config {
|
sub parse_vm_config {
|
||||||
my ($filename, $raw, $strict) = @_;
|
my ($filename, $raw, $strict) = @_;
|
||||||
|
|
||||||
@ -2233,23 +2243,28 @@ sub parse_vm_config {
|
|||||||
$descr = undef;
|
$descr = undef;
|
||||||
};
|
};
|
||||||
|
|
||||||
my $special_sections_re_1 = qr/(cloudinit)/;
|
my $special_schemas = {
|
||||||
|
cloudinit => $confdesc, # not actually used right now, see below
|
||||||
|
fleecing => $fleecing_section_schema,
|
||||||
|
};
|
||||||
|
my $special_sections_re_string = join('|', keys $special_schemas->%*);
|
||||||
|
my $special_sections_re_1 = qr/($special_sections_re_string)/;
|
||||||
|
|
||||||
my $section = { name => '', type => 'main' };
|
my $section = { name => '', type => 'main', schema => $confdesc };
|
||||||
|
|
||||||
my @lines = split(/\n/, $raw);
|
my @lines = split(/\n/, $raw);
|
||||||
foreach my $line (@lines) {
|
foreach my $line (@lines) {
|
||||||
next if $line =~ m/^\s*$/;
|
next if $line =~ m/^\s*$/;
|
||||||
|
|
||||||
if ($line =~ m/^\[PENDING\]\s*$/i) {
|
if ($line =~ m/^\[PENDING\]\s*$/i) {
|
||||||
$section = { name => 'pending', type => 'pending' };
|
$section = { name => 'pending', type => 'pending', schema => $confdesc };
|
||||||
$finish_description->();
|
$finish_description->();
|
||||||
$handle_error->("vm $vmid - duplicate section: $section->{name}\n")
|
$handle_error->("vm $vmid - duplicate section: $section->{name}\n")
|
||||||
if defined($res->{$section->{name}});
|
if defined($res->{$section->{name}});
|
||||||
$conf = $res->{$section->{name}} = {};
|
$conf = $res->{$section->{name}} = {};
|
||||||
next;
|
next;
|
||||||
} elsif ($line =~ m/^\[special:$special_sections_re_1\]\s*$/i) {
|
} elsif ($line =~ m/^\[special:$special_sections_re_1\]\s*$/i) {
|
||||||
$section = { name => $1, type => 'special' };
|
$section = { name => $1, type => 'special', schema => $special_schemas->{$1} };
|
||||||
$finish_description->();
|
$finish_description->();
|
||||||
$handle_error->("vm $vmid - duplicate special section: $section->{name}\n")
|
$handle_error->("vm $vmid - duplicate special section: $section->{name}\n")
|
||||||
if defined($res->{'special-sections'}->{$section->{name}});
|
if defined($res->{'special-sections'}->{$section->{name}});
|
||||||
@ -2257,7 +2272,7 @@ sub parse_vm_config {
|
|||||||
next;
|
next;
|
||||||
|
|
||||||
} elsif ($line =~ m/^\[([a-z][a-z0-9_\-]+)\]\s*$/i) {
|
} elsif ($line =~ m/^\[([a-z][a-z0-9_\-]+)\]\s*$/i) {
|
||||||
$section = { name => $1, type => 'snapshot' };
|
$section = { name => $1, type => 'snapshot', schema => $confdesc };
|
||||||
$finish_description->();
|
$finish_description->();
|
||||||
$handle_error->("vm $vmid - duplicate snapshot section: $section->{name}\n")
|
$handle_error->("vm $vmid - duplicate snapshot section: $section->{name}\n")
|
||||||
if defined($res->{snapshots}->{$section->{name}});
|
if defined($res->{snapshots}->{$section->{name}});
|
||||||
@ -2303,12 +2318,12 @@ sub parse_vm_config {
|
|||||||
$conf->{$key} = $value;
|
$conf->{$key} = $value;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
eval { $value = check_type($key, $value, $confdesc); };
|
eval { $value = check_type($key, $value, $section->{schema}); };
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$handle_error->("vm $vmid - unable to parse value of '$key' - $@");
|
$handle_error->("vm $vmid - unable to parse value of '$key' - $@");
|
||||||
} else {
|
} else {
|
||||||
$key = 'ide2' if $key eq 'cdrom';
|
$key = 'ide2' if $key eq 'cdrom';
|
||||||
my $fmt = $confdesc->{$key}->{format};
|
my $fmt = $section->{schema}->{$key}->{format};
|
||||||
if ($fmt && $fmt =~ /^pve-qm-(?:ide|scsi|virtio|sata)$/) {
|
if ($fmt && $fmt =~ /^pve-qm-(?:ide|scsi|virtio|sata)$/) {
|
||||||
my $v = parse_drive($key, $value);
|
my $v = parse_drive($key, $value);
|
||||||
if (my $volid = filename_to_volume_id($vmid, $v->{file}, $v->{media})) {
|
if (my $volid = filename_to_volume_id($vmid, $v->{file}, $v->{media})) {
|
||||||
|
20
test/parse-config-input/fleecing-section.conf
Normal file
20
test/parse-config-input/fleecing-section.conf
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
boot: order=scsi0
|
||||||
|
cores: 2
|
||||||
|
cpu: x86-64-v2-AES
|
||||||
|
ide2: lvm:vm-120-cloudinit,media=cdrom
|
||||||
|
ipconfig0: ip6=dhcp
|
||||||
|
memory: 4096
|
||||||
|
meta: creation-qemu=9.0.2,ctime=1725975013
|
||||||
|
name: deb1223
|
||||||
|
net0: vmxnet3=BC:24:11:2C:69:EC,bridge=vnet0,firewall=1
|
||||||
|
numa: 0
|
||||||
|
ostype: l26
|
||||||
|
scsi0: nfs:120/vm-120-disk-0.qcow2,iothread=1,size=4G
|
||||||
|
scsihw: virtio-scsi-single
|
||||||
|
smbios1: uuid=b3247ab1-1fe6-428e-965b-08a1b64a8746
|
||||||
|
sockets: 1
|
||||||
|
unused0: rbd:vm-120-disk-0
|
||||||
|
vmgenid: 7079e97c-50e3-4079-afe7-23e67566b946
|
||||||
|
|
||||||
|
[special:fleecing]
|
||||||
|
fleecing-images: zfs:vm-120-fleece-0
|
@ -26,7 +26,7 @@ my $OUTPUT_DIR = './parse-config-output';
|
|||||||
my $EXPECTED_DIR = './parse-config-expected';
|
my $EXPECTED_DIR = './parse-config-expected';
|
||||||
|
|
||||||
# NOTE update when you add/remove tests
|
# NOTE update when you add/remove tests
|
||||||
plan tests => 2 * 9;
|
plan tests => 2 * 10;
|
||||||
|
|
||||||
sub run_tests {
|
sub run_tests {
|
||||||
my ($strict) = @_;
|
my ($strict) = @_;
|
||||||
|
Loading…
Reference in New Issue
Block a user